/* Hewis Electricity IQ Challenge — kiosk game (portrait first). */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(../fonts/montserrat-latin.woff2) format('woff2');
}

:root {
  --navy: #04224f;
  --blue: #0a4f86;
  --teal: #2fb4bd;
  --yellow: #ffc20e;
  --red: #bd1212;
  --red-hi: #d81e1e;
  --white: #fff;
  --card: rgba(70, 200, 205, .55);
  --pad: clamp(18px, 5.5vw, 48px);
  --fs-hero: clamp(38px, 10.5vw, 84px);
  --fs-title: clamp(28px, 7.4vw, 58px);
  --fs-q: clamp(22px, 5.4vw, 42px);
  --fs-body: clamp(16px, 3.7vw, 28px);
  --fs-btn: clamp(18px, 4.4vw, 34px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--white);
  background: var(--navy);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.app {
  position: relative;
  height: 100dvh;
  max-width: 900px;
  margin: 0 auto;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 100% 10%, rgba(64, 205, 210, .75), transparent 60%),
    radial-gradient(90% 60% at 0% 100%, rgba(2, 16, 64, .9), transparent 70%),
    linear-gradient(160deg, #0a3f78 0%, #136f98 45%, #2aa9b6 100%);
}
/* Soft pixel grid like the mockups. */
.app::before {
  content: '';
  position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 18px 18px;
  pointer-events: none;
}

.top {
  position: absolute; z-index: 3; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: calc(var(--pad) * .9) var(--pad) 0;
  pointer-events: none;
}
.tagline { font-size: clamp(13px, 2.6vw, 20px); padding-top: 1.2em; opacity: .95; }
.logo { width: clamp(90px, 20vw, 170px); height: auto; }

.screen {
  position: absolute; inset: 0; z-index: 2;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--pad) + clamp(110px, 24vw, 200px)) var(--pad) var(--pad);
  overflow-y: auto; scrollbar-width: none;
  opacity: 0; visibility: hidden;
  transform: translateY(16px);
  transition: opacity .28s ease, transform .28s ease, visibility 0s .28s;
}
.screen.is-active { opacity: 1; visibility: visible; transform: none; transition: opacity .28s ease, transform .28s ease; }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; gap: clamp(14px, 2.6vh, 28px); }

h1, h2, p { margin: 0; }
.headline { font-size: var(--fs-hero); font-weight: 800; line-height: 1.05; letter-spacing: -.01em; }
.title { font-size: var(--fs-title); font-weight: 800; line-height: 1.1; }
.title.sm { font-size: clamp(22px, 5.6vw, 44px); }
.title.left { text-align: left; }
.sub { font-size: var(--fs-body); line-height: 1.45; max-width: 30ch; }
.lead { font-size: var(--fs-body); line-height: 1.5; margin-top: 1em; max-width: 32ch; }
.hl { color: var(--yellow); }
.brand { color: var(--yellow); font-weight: 900; letter-spacing: .02em; -webkit-text-stroke: 1px #c98f00; }

.ico { width: 1em; height: 1em; color: var(--yellow); flex: none; }
.chev { width: 1.6em; height: .9em; color: #fff; margin-left: .3em; }

/* Buttons */
.btn {
  font: inherit; font-weight: 800; font-size: var(--fs-btn);
  border: 0; border-radius: 999px; cursor: pointer; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: .3em;
  padding: .7em 1.4em;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
}
.btn:active { transform: scale(.96); }
.btn-red { background: var(--red); box-shadow: 0 10px 30px rgba(120, 0, 0, .35); }
.btn-red:hover { background: var(--red-hi); }
.btn-xl { font-size: clamp(18px, 4.4vw, 36px); white-space: nowrap; padding: .85em 1.3em; width: 100%; max-width: 640px; align-self: center; }
.btn-lg { min-width: min(70vw, 340px); }
.btn-ghost { background: transparent; border: 3px solid #fff; }
.btn-ghost .ico { color: #fff; width: 1.4em; height: 1.4em; }
.pulse { animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255, 194, 14, .45); } 50% { box-shadow: 0 0 0 18px rgba(255, 194, 14, 0); } }

/* Attract */
#s-attract { justify-content: center; gap: clamp(28px, 6vh, 70px); }
.facts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.facts li { display: flex; flex-direction: column; align-items: center; gap: .6em; font-size: clamp(13px, 2.8vw, 22px); padding: 0 .4em; }
.facts li + li { border-left: 2px solid rgba(255,255,255,.4); }
.facts .ico { width: clamp(44px, 10vw, 80px); height: clamp(44px, 10vw, 80px); }
.headline .hl { display: inline-block; animation: flicker 4s infinite; }
@keyframes flicker { 0%, 92%, 100% { opacity: 1; } 93% { opacity: .4; } 94% { opacity: 1; } 96% { opacity: .6; } }
.mini-board { background: rgba(0, 25, 70, .35); border-radius: 22px; padding: 1em 1.4em; font-size: clamp(14px, 3vw, 22px); }
.mini-board h2 { font-size: 1em; color: var(--yellow); margin-bottom: .4em; }
.mini-board ol { margin: 0; padding-left: 1.4em; columns: 1; }
.mini-board li { padding: .15em 0; }
.mini-board li span { float: right; font-weight: 700; }

/* Name */
#name-form { display: flex; flex-direction: column; align-items: center; gap: clamp(30px, 6vh, 70px); width: 100%; margin-top: 2vh; }
.name-field {
  display: flex; align-items: center; gap: .6em; width: 100%; max-width: 640px;
  border: 3px solid #fff; border-radius: 999px; padding: .55em 1em; font-size: var(--fs-btn);
}
.name-field .ico { color: #fff; width: 1.5em; height: 1.5em; }
.name-field input {
  flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #fff;
  font: inherit; font-weight: 600; -webkit-user-select: text; user-select: text;
}
.name-field input::placeholder { color: rgba(255,255,255,.55); font-weight: 400; }
.deco-bulb { position: absolute; left: -9%; bottom: -6%; width: 34%; height: 40%; color: var(--yellow); opacity: .9; pointer-events: none; }

/* Question */
#s-question { justify-content: flex-start; gap: clamp(16px, 3vh, 34px); }
.q-head { display: flex; justify-content: space-between; align-items: baseline; font-size: clamp(14px, 3vw, 22px); letter-spacing: .06em; }
.q-head b { color: var(--yellow); }
.q-round { opacity: .8; text-align: right; }
.timer { position: relative; height: 14px; border-radius: 99px; background: rgba(255,255,255,.18); overflow: visible; }
.timer-bar { height: 100%; width: 100%; border-radius: inherit; background: var(--yellow); transform-origin: left; }
.timer-bar.run { animation: drain linear forwards; }
.timer-bar.warn { background: #ff5a3c; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.timer-num { position: absolute; right: 0; top: 18px; font-weight: 800; font-size: clamp(16px, 3.4vw, 26px); color: var(--yellow); }
.q-text { font-size: var(--fs-q); font-weight: 800; line-height: 1.2; margin-top: 1.2vh; }
.answers { display: flex; flex-direction: column; gap: clamp(14px, 2.4vh, 26px); margin-top: 1vh; position: relative; z-index: 2; }
.answer {
  font: inherit; font-weight: 700; font-size: clamp(18px, 4.3vw, 32px); text-align: left; color: #fff;
  background: var(--red); border: 3px solid transparent; border-radius: 999px;
  padding: .7em 1.2em; width: min(100%, 680px); min-height: 2.8em;
  display: flex; gap: .5em; align-items: center; cursor: pointer;
  transition: transform .12s ease, background .2s ease, border-color .2s, opacity .2s;
  animation: slideIn .35s ease backwards;
}
.answer:nth-child(2) { animation-delay: .06s; } .answer:nth-child(3) { animation-delay: .12s; } .answer:nth-child(4) { animation-delay: .18s; }
@keyframes slideIn { from { opacity: 0; transform: translateX(-24px); } }
.answer .letter { flex: none; }
.answer:active { transform: scale(.97); }
.answers.tf { flex-direction: row; }
.answers.tf .answer { justify-content: center; text-align: center; font-size: clamp(22px, 5.4vw, 40px); }
.answers.locked .answer { pointer-events: none; }
.answers.locked .answer:not(.picked):not(.right) { opacity: .45; }
.answer.picked { border-color: #fff; }
.answer.right { background: #13a05a; border-color: #fff; }
.answer.wrong { background: #6d0b0b; }
.q-illu { position: absolute; right: var(--pad); bottom: var(--pad); width: clamp(120px, 34vw, 300px); height: clamp(120px, 34vw, 300px); color: var(--yellow); opacity: .95; pointer-events: none; z-index: 1; }

/* Feedback */
.fb-icon { width: clamp(84px, 18vw, 140px); height: clamp(84px, 18vw, 140px); animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(0); } }
.tip { display: flex; gap: 1em; align-items: center; text-align: left; background: var(--card); border-radius: 18px; padding: 1.1em 1.3em; font-size: var(--fs-body); line-height: 1.45; width: 100%; max-width: 680px; margin: 2vh 0; }
.tip .ico { width: 2.4em; height: 2.4em; }
.autobar { width: min(60vw, 300px); height: 4px; background: rgba(255,255,255,.18); border-radius: 9px; overflow: hidden; }
.autobar div { height: 100%; background: rgba(255,255,255,.7); transform-origin: left; transform: scaleX(0); }
.autobar div.run { animation: fill linear forwards; }
@keyframes fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Result */
.bulbs { display: flex; gap: clamp(10px, 3.5vw, 30px); justify-content: center; }
.bulbs svg { width: clamp(50px, 12vw, 96px); height: clamp(50px, 12vw, 96px); color: rgba(255, 194, 14, .35); transition: color .3s, filter .3s, transform .3s; }
.bulbs svg.on { color: var(--yellow); filter: drop-shadow(0 0 14px rgba(255, 194, 14, .9)); transform: scale(1.08); }
.score { font-size: clamp(64px, 18vw, 150px); font-weight: 900; color: var(--yellow); text-shadow: 0 0 30px rgba(255, 194, 14, .7); animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
.tier { display: inline-flex; align-items: center; gap: .5em; background: var(--red); border-radius: 999px; padding: .5em 1.4em; font-weight: 800; font-size: clamp(20px, 5vw, 40px); text-transform: uppercase; animation: pop .5s .1s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.tier-emoji { font-size: 1.3em; }
.round-msg { font-style: italic; opacity: .85; font-size: clamp(14px, 3vw, 22px); max-width: 34ch; }
.punch { font-weight: 700; font-size: clamp(18px, 4.4vw, 34px); line-height: 1.35; }

/* Master */
.trophy-wrap img { width: clamp(180px, 45vw, 360px); height: auto; animation: pop .7s cubic-bezier(.2, 1.6, .4, 1); filter: drop-shadow(0 20px 40px rgba(255, 194, 14, .45)); }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 1; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* Leaderboard */
#s-board { justify-content: flex-start; gap: clamp(14px, 2.4vh, 26px); }
#s-board .btn { align-self: center; }
.glow-line { height: 8px; border-radius: 50%; background: radial-gradient(closest-side, var(--yellow), transparent); margin: 1vh 0; }
.board { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }
.board li {
  display: grid; grid-template-columns: 2.2em 2.4em 1fr auto; align-items: center; gap: .6em;
  font-size: clamp(18px, 4.4vw, 34px); font-weight: 800; padding: .55em .4em;
  background: radial-gradient(60% 4px at 50% 100%, rgba(255,255,255,.85), transparent) no-repeat bottom / 100% 4px;
  animation: slideIn .35s ease backwards;
}
.board li .rank { color: var(--yellow); text-shadow: 0 0 12px rgba(255, 194, 14, .8); font-size: 1.2em; }
.board li .badge { width: 1.8em; height: 1.4em; color: var(--yellow); display: flex; align-items: center; justify-content: center; }
.board li .badge img { width: 1.4em; height: auto; }
.board li .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .pts { text-align: right; white-space: nowrap; }
.board li .pts small { display: block; font-size: .5em; font-weight: 500; opacity: .75; }
.board li.me { background-color: rgba(255, 194, 14, .18); border-radius: 14px; }
.board .empty { display: block; font-weight: 500; text-align: center; opacity: .8; }

/* Hewis */
.screen::-webkit-scrollbar { display: none; }
#s-hewis { justify-content: flex-start; }
#s-hewis > :not(.phone) { position: relative; z-index: 1; }
/* Buttons sit bottom-left in the flow; the phone is decoration pinned bottom-right and
   sized from the remaining height, so it can never push the buttons off screen. */
.hewis-actions { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: clamp(12px, 2vh, 20px); padding-top: 3vh; }
.hewis-actions .btn { min-width: min(46vw, 340px); }
.phone { position: absolute; z-index: 0; right: 0; bottom: 0; width: auto; height: min(46%, 64vw); max-width: 50%; object-fit: contain; object-position: right bottom; pointer-events: none; }

/* QR */
.qr { background: #fff; padding: 16px; border-radius: 18px; width: clamp(180px, 46vw, 340px); aspect-ratio: 1; }
.qr svg, .qr img { width: 100%; height: 100%; display: block; }
.closing { font-weight: 700; color: var(--yellow); font-size: clamp(16px, 3.6vw, 26px); max-width: 30ch; line-height: 1.4; }

.toast { position: absolute; z-index: 10; left: 50%; bottom: 4vh; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: .8em 1.4em; border-radius: 12px; font-size: var(--fs-body); }

/* Landscape / wide screens: keep the portrait composition centered. */
@media (min-aspect-ratio: 4/5) {
  :root {
    --fs-hero: clamp(36px, 7.5vh, 84px);
    --fs-title: clamp(26px, 5.4vh, 58px);
    --fs-q: clamp(20px, 4vh, 42px);
    --fs-body: clamp(15px, 2.5vh, 28px);
    --fs-btn: clamp(17px, 3.2vh, 34px);
  }
  .app { max-width: min(900px, 78vh); }
  .screen { padding-top: calc(var(--pad) + clamp(100px, 17vh, 200px)); }
  .logo { width: clamp(80px, 13vh, 170px); }
}
@media (min-aspect-ratio: 4/5) and (max-height: 900px) {
  .mini-board { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  /* Countdown bars carry meaning, keep them running. */
  .timer-bar.run, .autobar div.run { animation-duration: var(--dur) !important; }
}
