@font-face {
  font-family: "Readex Pro";
  src: url("fonts/ReadexPro.ttf") format("truetype");
  font-weight: 160 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Lalezar";
  src: url("fonts/Lalezar-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #0e1237;
  --deep: #050714;
  --navy: #26307f;
  --cyan: #41d7f1;
  --cyan-deep: #0e8aa3;
  --gold: #c4a36a;
  --paper: #f4f7fb;
  --white: #fff;
  --tap: 72px;
  --line: rgba(65, 215, 241, .28);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--deep);
  color: var(--paper);
  font-family: "Readex Pro", "Geeza Pro", sans-serif;
  touch-action: manipulation;
  user-select: none;
  overscroll-behavior: none;
}
button, img, a { user-select: none; -webkit-user-drag: none; }
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }

body {
  background:
    radial-gradient(90vw 55vh at 50% 42%, rgba(65, 215, 241, .12), transparent 58%),
    radial-gradient(70vw 50vh at 100% 110%, rgba(38, 48, 127, .55), transparent 52%),
    var(--deep);
}

.app {
  position: relative;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding:
    calc(12px + env(safe-area-inset-top))
    calc(28px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(28px + env(safe-area-inset-left));
}
.glow {
  position: absolute;
  inset: 28% 10% 22% 10%;
  pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(65, 215, 241, .1), transparent 70%);
}

.top {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 96px;
  pointer-events: none;
}
.logo {
  display: block;
  height: 88px;
  width: auto;
  object-fit: contain;
}

.back {
  appearance: none;
  border: 0;
  background: none;
  min-height: 44px;
  padding: 0 2px;
  color: var(--cyan);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  justify-self: start;
}
.back::before { content: "←  "; }
[dir="rtl"] .back::before { content: none; }
[dir="rtl"] .back::after { content: "  →"; }
.back:active { opacity: .7; }

.stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 840px);
  justify-content: center;
  align-content: center;
  gap: 12px;
}
.screen {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
[hidden] { display: none !important; }
.screen:not([hidden]) { animation: rise .35s cubic-bezier(.16, .84, .32, 1); }

.board {
  position: relative;
  width: 100%;
  padding: 36px 36px 32px;
  text-align: center;
  background: linear-gradient(180deg, rgba(16, 22, 58, .78), rgba(8, 12, 32, .62));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.board.wide { text-align: start; }
.board.media { padding: 22px 22px 24px; }
.board::before,
.board::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--cyan);
  pointer-events: none;
}
.board::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.board::after { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.meter { display: flex; gap: 7px; align-items: center; }
.meter span {
  width: 9px;
  height: 9px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .2);
}
.meter span.is-on { background: var(--cyan); }
.meter span.is-done { background: var(--gold); }

.eyebrow, .kicker {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.kicker { letter-spacing: .12em; margin-bottom: 0; }

h1 {
  font-family: "Lalezar", "Readex Pro", sans-serif;
  font-size: clamp(28px, 3.8vh, 46px);
  font-weight: 400;
  line-height: 1.18;
}
.board h2 {
  font-family: "Lalezar", "Readex Pro", sans-serif;
  font-size: clamp(22px, 3vh, 32px);
  font-weight: 400;
  line-height: 1.4;
}
.lede {
  margin-top: 10px;
  font-size: clamp(16px, 1.7vh, 19px);
  line-height: 1.5;
  color: rgba(244, 247, 251, .74);
}
.rule {
  display: block;
  width: 72px;
  height: 1px;
  margin: 18px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 999px;
  min-height: var(--tap);
  height: var(--tap);
  padding: 0 28px;
  font-size: 20px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
}
.btn-primary {
  margin-top: 22px;
  background: var(--cyan);
  color: var(--ink);
  box-shadow: 0 0 0 6px rgba(65, 215, 241, .12);
}
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: transparent;
  color: var(--paper);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .22);
  margin-top: 22px;
}
.btn:disabled { opacity: .45; cursor: default; transform: none; }
#welcome .btn, #loading .btn { min-width: 240px; }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 24px;
}
.choice {
  appearance: none;
  border: 0;
  height: 104px;
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  font-family: "Lalezar", "Readex Pro", sans-serif;
  font-size: clamp(26px, 3.4vh, 36px);
  cursor: pointer;
}
.choice:active { transform: scale(.985); }
.choice.is-on { background: var(--cyan); }

.portraits { align-items: stretch; }
.portrait {
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, .04);
  border-radius: 24px;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(65, 215, 241, .16);
}
.portrait:active { transform: scale(.985); }
.portrait.is-on { background: rgba(65, 215, 241, .14); box-shadow: inset 0 0 0 2px var(--cyan); }
.face {
  width: min(100%, 220px);
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #0b1024;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .28);
}
.portrait.is-on .face { box-shadow: 0 0 0 4px var(--cyan), 0 12px 28px rgba(65, 215, 241, .2); }
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}
.caption {
  font-family: "Lalezar", "Readex Pro", sans-serif;
  font-size: clamp(24px, 3vh, 32px);
  color: var(--paper);
}

#question h1 {
  font-family: "Readex Pro", sans-serif;
  font-weight: 650;
  font-size: clamp(20px, 2.6vh, 30px);
  line-height: 1.3;
  margin: 10px 0 16px;
}
.answers { display: flex; flex-direction: column; gap: 10px; }
.option {
  appearance: none;
  border: 0;
  height: 72px;
  border-radius: 16px;
  background: rgba(255, 255, 255, .96);
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  text-align: start;
  cursor: pointer;
  font-size: clamp(16px, 1.8vh, 20px);
  font-weight: 600;
  line-height: 1.25;
}
.option:active { transform: scale(.992); }
.option.is-on { background: var(--cyan); }
.key {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: var(--cyan);
  font-family: "Lalezar", sans-serif;
  font-size: 20px;
}
.option.is-on .key { background: var(--ink); }

.panel { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.panel .btn { width: min(100%, 340px); }
#career-image, #result, .camera-wrap {
  display: block;
  width: 100%;
  height: min(38vh, 420px);
  object-fit: contain;
  border-radius: 18px;
  background: rgba(5, 8, 20, .45);
  margin-bottom: 14px;
}
.camera-wrap {
  position: relative;
  overflow: hidden;
  object-fit: unset;
  height: min(40vh, 440px);
  border: 1px solid var(--line);
}
video, #capture { width: 100%; height: 100%; object-fit: cover; }
video, #capture { transform: scaleX(-1); }
#guide {
  position: absolute;
  left: 50%;
  top: 46%;
  width: min(52%, 260px);
  aspect-ratio: 3 / 4;
  transform: translate(-50%, -50%);
  border: 2px dashed rgba(65, 215, 241, .7);
  border-radius: 50%;
  pointer-events: none;
}
#countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Lalezar", sans-serif;
  font-size: clamp(72px, 10vh, 120px);
  color: var(--white);
  text-shadow: 0 10px 30px rgba(0, 0, 0, .55);
  pointer-events: none;
}
.actions { display: flex; gap: 10px; justify-content: center; width: 100%; }
.actions:not(:has(button:not([hidden]))) { display: none; }
.actions .btn { flex: 1; max-width: 240px; margin-top: 16px; }

.loader { width: 84px; height: 84px; margin: 8px auto 12px; }
.spinner {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, .1);
  border-top-color: var(--cyan);
  animation: spin .85s linear infinite;
}

#qr {
  width: 148px;
  margin: 10px auto 4px;
  background: var(--white);
  border-radius: 16px;
  padding: 10px;
}
#qr:empty { display: none; }
#qr svg { width: 100%; height: auto; display: block; }
#qr svg rect { fill: #fff; }
#qr svg path { fill: var(--navy); }
#reset-note { min-height: 1.3em; color: rgba(244, 247, 251, .68); font-size: 15px; }

#error {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  z-index: 7;
  width: min(560px, calc(100% - 48px));
  margin: 0;
  text-align: center;
  background: #931035;
  color: #fceae8;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 17px;
}
#error:empty { display: none; }

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 4px; }

@media (orientation: landscape) {
  .top { min-height: 76px; }
  .logo { height: 68px; }
  h1 { font-size: clamp(24px, 4.2vh, 38px); }
  .board { padding: 24px 28px; }
  .stage { grid-template-columns: minmax(0, 1080px); }
  .board.media {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 20px;
    align-items: center;
    text-align: start;
  }
  .board.media .panel { align-items: flex-start; }
  #career-image, #result, .camera-wrap {
    height: min(62vh, 520px);
    margin: 0;
  }
  .choice { height: 88px; }
  .option { height: 60px; }
  .face { width: min(100%, 180px); }
}

@media (prefers-reduced-motion: reduce) {
  .screen:not([hidden]), .spinner { animation: none; }
  .btn-primary:active, .choice:active, .portrait:active, .option:active, .back:active { transform: none; }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes spin { to { transform: rotate(360deg); } }
