@font-face { font-family: Vazirmatn; src: url(/fonts/Vazirmatn-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/fonts/Vazirmatn-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/fonts/Vazirmatn-Black.woff2) format('woff2'); font-weight: 900; font-display: swap; }

:root {
  --bg: #1b1340;
  --bg2: #2b1b63;
  --card: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff8ee;
  --muted: #c8bfe6;
  --accent: #ffd23f;
  --accent-ink: #2a1a00;
  --pink: #ff4f8b;
  --ok: #19c37d;
  --no: #ff8a1f;
  --radius: 18px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  font-family: Vazirmatn, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: manipulation;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-weight: 900; font-size: 1.6rem; }
h2 { font-weight: 700; font-size: 1rem; color: var(--muted); margin: 0 0 10px; }
h2 + .seg, .seg + h2 { margin-top: 0; }
.seg + h2 { margin-top: 18px; }

.screen {
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: calc(16px + var(--safe-t)) calc(16px + var(--safe-r)) calc(20px + var(--safe-b)) calc(16px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.top h1 { font-size: 1.25rem; flex: 1; text-align: center; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 10px 0 0; }
.hint.strong { color: var(--accent); font-weight: 700; }
.notice { background: rgba(255, 138, 31, 0.15); border: 1px solid rgba(255, 138, 31, 0.45); border-radius: 12px; padding: 10px 12px; font-size: 0.9rem; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; min-height: 56px; border: 0; border-radius: 999px;
  font-weight: 900; font-size: 1.15rem; padding: 12px 20px;
  transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 0 #c99a00, 0 10px 30px rgba(255, 210, 63, 0.25); }
.btn.primary:active { box-shadow: 0 2px 0 #c99a00; transform: translateY(4px); }
.btn.primary:disabled { filter: grayscale(1) brightness(0.7); box-shadow: none; cursor: default; }
.btn.ghost { background: transparent; border: 2px solid var(--line); color: var(--text); }
.btn.big { min-height: 68px; font-size: 1.3rem; }
.link { background: none; border: 0; color: var(--muted); padding: 8px 4px; font-weight: 700; min-height: 44px; }
.link.add { color: var(--accent); }
.link.danger { color: #ff9aa9; display: block; margin: 4px auto 0; }
.lang { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 700; min-height: 40px; }
.icon { background: none; border: 0; color: var(--muted); width: 44px; height: 44px; border-radius: 50%; font-size: 1rem; }
.icon:active { background: var(--card); }
.actions { display: flex; flex-direction: column; gap: 12px; }
.actions.sticky {
  position: sticky; bottom: 0; margin: auto -16px calc(-20px - var(--safe-b));
  padding: 14px 16px calc(16px + var(--safe-b));
  background: linear-gradient(transparent, var(--bg) 35%);
}

/* ---------- home ---------- */
.home .top { justify-content: flex-end; }
.hero { text-align: center; padding: 8px 0 4px; }
.logo {
  width: 108px; height: 108px; margin: 0 auto 14px; border-radius: 30px;
  background: linear-gradient(135deg, var(--pink), #ff9a3c);
  display: grid; place-items: center; font-size: 58px;
  box-shadow: 0 14px 40px rgba(255, 79, 139, 0.35);
  animation: wobble 3.2s ease-in-out infinite;
}
@keyframes wobble { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
.hero h1 { font-size: 3rem; letter-spacing: -0.02em; display: flex; justify-content: center; align-items: baseline; gap: 12px; }
.fa-name { font-size: 1.6rem; color: var(--accent); }
.tagline { color: var(--muted); margin: 6px 0 0; }
.how ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.how li { display: flex; gap: 12px; align-items: flex-start; }
.how li span { font-size: 1.4rem; line-height: 1.2; flex: none; }

/* ---------- setup ---------- */
.team-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.team-list li { display: flex; align-items: center; gap: 10px; }
.team-list input {
  flex: 1; min-width: 0; min-height: 48px; padding: 8px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.2); font-size: 16px;
}
.team-list input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.team-list input::placeholder { color: var(--muted); opacity: 0.8; }
.dot { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.c0 { --c: #ff4f8b; } .c1 { --c: #3cc8ff; } .c2 { --c: #19c37d; } .c3 { --c: #ffd23f; }
.c4 { --c: #b07cff; } .c5 { --c: #ff8a1f; } .c6 { --c: #7ee0c3; } .c7 { --c: #ff6b6b; }
.dot, .team-badge { background: var(--c); }
.row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.row-head h2 { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; font-weight: 700;
}
.chip.small { min-height: 34px; padding: 2px 12px; font-size: 0.9rem; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg { display: flex; background: rgba(0, 0, 0, 0.25); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

/* ---------- hand-off ---------- */
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 12px; }
.center p { margin: 0; max-width: 34ch; }
.pill { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 0.85rem; color: var(--muted); }
.team-badge { color: #1b1340; font-weight: 900; border-radius: 999px; padding: 4px 16px; }
.handoff h1 { font-size: 2rem; }
.forehead { position: relative; width: 120px; height: 120px; display: grid; place-items: center; }
.forehead .head { font-size: 92px; line-height: 1; }
.forehead .mini-phone {
  position: absolute; top: 2px; width: 62px; height: 32px; border-radius: 7px;
  background: linear-gradient(135deg, var(--pink), #ff9a3c); border: 3px solid #0d0824;
  animation: nod 2.4s ease-in-out infinite; transform-origin: 50% 100%;
}
@keyframes nod { 0%, 30%, 100% { transform: rotateX(0); } 45% { transform: rotateX(55deg); } 70% { transform: rotateX(-55deg); } }

/* ---------- countdown / time up ---------- */
.countdown, .timeup { justify-content: center; align-items: center; text-align: center; max-width: none; }
.place { font-size: 1.4rem; font-weight: 700; color: var(--muted); margin: 0; }
.count { font-size: min(45vmin, 260px); font-weight: 900; line-height: 1; color: var(--accent); animation: pop 1s ease-out infinite; }
@keyframes pop { 0% { transform: scale(1.25); opacity: 0.4; } 25% { transform: scale(1); opacity: 1; } }
.timeup { background: var(--pink); }
.timeup h1 { font-size: min(14vmin, 5rem); animation: pop 1.4s ease-out; }

/* ---------- play ---------- */
body[data-screen="play"], body[data-screen="countdown"], body[data-screen="timeup"] { overflow: hidden; }
.play {
  position: fixed; inset: 0; max-width: none; min-height: 0; gap: 0;
  padding: calc(8px + var(--safe-t)) calc(12px + var(--safe-r)) calc(10px + var(--safe-b)) calc(12px + var(--safe-l));
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.bar { display: flex; align-items: center; gap: 12px; direction: ltr; }
.timer {
  font-weight: 900; font-size: 1.6rem; min-width: 64px; text-align: center; padding: 2px 12px;
  background: rgba(0, 0, 0, 0.3); border-radius: 999px; font-variant-numeric: tabular-nums;
}
.timer.low { background: var(--pink); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.tally { color: var(--ok); font-weight: 900; font-size: 1.2rem; flex: 1; }
.pause { font-size: 0.9rem; background: rgba(0, 0, 0, 0.3); }
.word-box { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 0 2vw; }
.word {
  font-weight: 900; line-height: 1.1; text-align: center; max-width: 100%;
  overflow-wrap: normal; word-break: keep-all; text-wrap: balance;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.play > .hint { text-align: center; margin: 0; }
.zones { position: absolute; inset: 0; display: flex; pointer-events: none; z-index: -1; }
.zones span { flex: 1; display: flex; gap: 8px; align-items: flex-end; padding: 0 20px calc(18px + var(--safe-b)); font-weight: 900; font-size: 1.1rem; }
.z-skip { background: linear-gradient(90deg, rgba(255, 138, 31, 0.22), transparent); color: var(--no); }
.z-ok { background: linear-gradient(270deg, rgba(25, 195, 125, 0.22), transparent); color: var(--ok); justify-content: flex-end; }
.play .notice { margin-top: 8px; text-align: center; font-size: 0.85rem; padding: 6px 12px; }
.overlay { position: absolute; inset: 0; background: rgba(13, 8, 36, 0.8); display: grid; place-items: center; padding: 20px; z-index: 5; }
.overlay .card { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; background: var(--bg2); }
.overlay h2 { color: var(--text); font-size: 1.4rem; }

#flash {
  position: fixed; inset: 0; display: none; place-items: center; z-index: 10;
  font-weight: 900; font-size: min(18vmin, 7rem); color: #fff; pointer-events: none;
}
#flash.ok { background: var(--ok); }
#flash.no { background: var(--no); }
#flash.show { display: grid; animation: flash 0.55s ease-out forwards; }
@keyframes flash { 0% { opacity: 0; transform: scale(1.1); } 15% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- summary / scores ---------- */
.summary .top h1 { text-align: start; }
.summary > .hint { margin: 0; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.results button {
  width: 100%; display: flex; align-items: center; gap: 12px; text-align: start;
  min-height: 52px; padding: 8px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
}
.results .mark { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; flex: none; }
.results .ok .mark { background: var(--ok); }
.results .no .mark { background: rgba(255, 255, 255, 0.12); color: var(--muted); }
.results .no .w { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.3); }
.results .w { flex: 1; font-weight: 700; font-size: 1.1rem; }
.results .tag { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }

.scoreboard h1, .final h1 { text-align: center; font-size: 2rem; }
.scores { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.scores li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.scores li.lead { background: rgba(255, 210, 63, 0.14); border-color: var(--accent); }
.scores .rank { width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, 0.3); display: grid; place-items: center; font-weight: 900; flex: none; }
.scores .lead .rank { background: var(--accent); color: var(--accent-ink); }
.scores .name { flex: 1; font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; }
.scores .pts { font-weight: 900; color: var(--accent); white-space: nowrap; }
.next { text-align: center; color: var(--muted); font-weight: 700; margin: auto 0 0; }

.final { justify-content: center; position: relative; overflow: hidden; }
.final h1 { font-size: 2.4rem; color: var(--accent); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.final > :not(.confetti) { position: relative; z-index: 1; }
.confetti span {
  position: absolute; top: -10vh; left: calc(var(--i) * 6.6%); font-size: 28px;
  animation: fall calc(3s + var(--i) * 0.17s) linear calc(var(--i) * -0.4s) infinite;
}
@keyframes fall { to { transform: translateY(120vh) rotate(360deg); } }

.noscript { padding: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
  .confetti { display: none; }
}

/* landscape phones: the setup/home screens get short, so tighten */
@media (max-height: 480px) {
  .logo { width: 72px; height: 72px; font-size: 38px; border-radius: 20px; margin-bottom: 8px; }
  .hero h1 { font-size: 2.2rem; }
  .forehead { display: none; }
  .handoff h1 { font-size: 1.5rem; }
}
