/* Player phones. Mobile-first, chunky tactile controls, living green landscape behind the quiet screens. */
:root {
  --sky-top: color-mix(in srgb, var(--accent) 24%, #04120b);
  --sky-low: color-mix(in srgb, var(--accent) 52%, #0a2a1c);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-ui); color: #fff;
  background: radial-gradient(70% 40% at 80% 78%, rgba(191,245,92,.16), transparent 70%), linear-gradient(180deg, var(--sky-top) 0%, var(--sky-low) 80%, #123f2c 100%);
  background-attachment: fixed; overscroll-behavior-y: contain;
}
body[data-screen="q"] .scene, body[data-screen="res"] .scene { display: none; }
.app { min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); gap: 14px; max-width: 560px; width: 100%; margin: 0 auto; }
.screen.center { justify-content: center; align-items: center; text-align: center; }

.brand { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 18px 0 6px; }
.brand .logo { height: 40px; width: auto; max-width: 140px; object-fit: contain; border-radius: 6px; }
.brand .brandmark { width: 38px; height: 38px; }
.brand .title { font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em; }

/* ---------- chunky white card ---------- */
.card { background: #fff; color: var(--sage-900); border-radius: 26px; padding: 22px; box-shadow: 0 8px 0 rgba(0,0,0,.16), 0 24px 48px rgba(0,0,0,.32); }
.card.join { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.card.join .event { margin: 2px 0 6px; font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; text-align: center; color: var(--sage-900); }
.card.join label { font-weight: 700; font-size: .9rem; margin-top: 8px; }
.card.big { width: 100%; padding: 26px 22px; }
.card.big h1 { margin: 6px 0 4px; font-size: 1.8rem; letter-spacing: -.02em; }
.card.big h2 { font-size: .95rem; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: 1px; color: var(--sage-500); }
.card small { color: var(--sage-500); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: .75rem; }

.inp { font: inherit; font-size: 1.35rem; font-weight: 700; padding: 14px; border-radius: 16px; border: 2px solid var(--sage-300); width: 100%; background: var(--sage-50); color: var(--sage-900); box-shadow: inset 0 3px 0 rgba(10,60,35,.05); }
#pin { letter-spacing: .3em; text-align: center; font-size: 1.8rem; }
.inp:focus { outline: 3px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
.err { min-height: 1.3em; color: var(--bad); font-weight: 700; font-size: .95rem; }

.btn-main { font: inherit; font-size: 1.2rem; font-weight: 800; border: 0; border-radius: 18px; padding: 16px; cursor: pointer; color: #fff;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 78%, #fff), var(--accent) 60%, var(--accent-600));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 52%, #000), 0 14px 24px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.35); transition: transform .12s, box-shadow .12s; }
.btn-main:active { transform: translateY(5px); box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 52%, #000), 0 4px 8px rgba(0,0,0,.25); }
.btn-main:disabled { opacity: .6; }
.btn-main.ghost { background: transparent; color: var(--accent-600); border: 2px solid var(--accent); box-shadow: none; margin-top: 18px; width: 100%; }

.langs { display: flex; gap: 8px; }
.lang { flex: 1; font: inherit; font-weight: 800; padding: 11px; border-radius: 14px; border: 2px solid var(--sage-300); background: var(--sage-50); color: var(--sage-900); cursor: pointer; box-shadow: 0 3px 0 var(--sage-200); }
.lang.on { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 52%, #000); }

.net { position: fixed; top: 0; left: 0; right: 0; z-index: 20; background: #b45309; color: #fff; text-align: center; padding: 6px; font-weight: 700; font-size: .9rem; }
.net[hidden] { display: none; }
.player-snd { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; z-index: 20; width: 38px; height: 38px; }
.player-snd.off { background: rgba(255,255,255,.06); }

/* ---------- waiting room ---------- */
.card.wait { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.card.wait .av { --s: 5.2em; font-size: 1.4em; margin-bottom: 10px; animation: bob 3.2s ease-in-out infinite; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 0 0 5px #fff, 0 0 0 9px color-mix(in srgb, var(--c) 40%, #fff), 0 12px 24px rgba(0,0,0,.25); }
@keyframes bob { 50% { transform: translateY(-8px); } }
.nick { font-size: 1.6rem; font-weight: 800; color: var(--accent-600); word-break: break-word; margin-bottom: 6px; }
.wait .dots { display: flex; gap: 6px; margin-top: 8px; }
.wait .dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); opacity: .3; animation: dot 1.4s infinite; }
.wait .dots i:nth-child(2) { animation-delay: .2s; } .wait .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 40% { opacity: 1; transform: translateY(-4px); } }

/* ---------- question ---------- */
.qscreen { padding-top: max(12px, env(safe-area-inset-top)); }
.qtop { display: flex; justify-content: space-between; align-items: center; font-weight: 800; padding-right: 46px; }
.qtop .qn { background: rgba(255,255,255,.14); border-radius: 99px; padding: 4px 14px; font-size: .9rem; }
.qtop .time { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.bar { height: 12px; background: rgba(255,255,255,.18); border-radius: 99px; overflow: hidden; box-shadow: inset 0 2px 4px rgba(0,0,0,.3); }
.bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #d6ff8a, var(--lime)); border-radius: 99px; }
.qtext { font-size: 1.15rem; font-weight: 800; line-height: 1.3; background: #fff; color: var(--sage-900); border-radius: 20px; padding: 14px 16px; box-shadow: 0 5px 0 rgba(0,0,0,.16); }
.qimg { max-width: 100%; max-height: 26vh; object-fit: contain; border-radius: 16px; align-self: center; background: rgba(0,0,0,.2); }

.answers { flex: 1; display: grid; gap: 14px; grid-template-columns: 1fr 1fr; align-content: stretch; min-height: 240px; padding-bottom: 8px; }
.answers.n2 { grid-template-columns: 1fr; }
.answers.n3 .ans:nth-child(3) { grid-column: 1 / -1; }
.ans { --tc: var(--clay); position: relative; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 10px; border: 0; border-radius: 22px; padding: 14px 10px; min-height: 110px; color: #fff; font: inherit; font-weight: 800; font-size: 1.1rem; line-height: 1.2; cursor: pointer; text-align: center; word-break: break-word;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tc) 86%, #fff), var(--tc));
  box-shadow: 0 8px 0 color-mix(in srgb, var(--tc) 52%, #000), 0 16px 26px rgba(0,0,0,.26), inset 0 3px 0 rgba(255,255,255,.3); text-shadow: 0 2px 0 rgba(0,0,0,.18); transition: transform .1s, box-shadow .1s, opacity .25s; }
.ans.c0 { --tc: var(--clay); } .ans.c1 { --tc: var(--ocean); } .ans.c2 { --tc: var(--sun); } .ans.c3 { --tc: var(--leaf); }
.ans:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 2px 0 color-mix(in srgb, var(--tc) 52%, #000), 0 6px 12px rgba(0,0,0,.26); }
.ans .shape { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,.24); display: grid; place-items: center; box-shadow: inset 0 2px 0 rgba(255,255,255,.25); }
.ans .shape svg { width: 26px; height: 26px; display: block; }
.ans:disabled { cursor: default; }
.ans.dim { opacity: .3; box-shadow: none; transform: translateY(5px); }
.ans.picked { outline: 5px solid #fff; outline-offset: 2px; }
.sent { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; padding: 6px; }
.sent strong { font-size: 1.15rem; }
.sent span { opacity: .85; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 99px; font-weight: 700; z-index: 30; max-width: 90vw; text-align: center; }

/* ---------- result ---------- */
.screen.result { max-width: none; gap: 10px; position: relative; overflow: hidden; }
.result.ok { background: radial-gradient(80% 50% at 50% 30%, #2fb56a, transparent 70%), linear-gradient(165deg, #1f9a58, #0b5233); }
.result.bad { background: radial-gradient(80% 50% at 50% 30%, #e0604f, transparent 70%), linear-gradient(165deg, #c4432f, #6d1d16); }
.result.none { background: linear-gradient(165deg, var(--ink-800), var(--ink-950)); }
.ricon { width: 118px; height: 118px; border-radius: 50%; background: rgba(255,255,255,.2); display: grid; place-items: center; box-shadow: 0 0 0 10px rgba(255,255,255,.1), inset 0 -5px 0 rgba(0,0,0,.14), 0 14px 28px rgba(0,0,0,.25); animation: pop-in .6s var(--ease-out) both; }
.ricon svg { width: 58px; height: 58px; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.result h1 { margin: 10px 0 0; font-size: 2.4rem; letter-spacing: -.02em; }
.pts { font-size: 1.3rem; }
.pts .plus { font-size: 3.2rem; font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 3px 0 rgba(0,0,0,.2); }
.rankbox { display: flex; gap: 14px; margin-top: 12px; }
.rankbox > div { background: rgba(0,0,0,.24); border-radius: 18px; padding: 12px 20px; min-width: 130px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 4px 0 rgba(0,0,0,.14); }
.rankbox small { opacity: .8; font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; }
.rankbox b { font-size: 1.5rem; }
.next { opacity: .9; margin-top: 14px; min-height: 1.3em; }
.burst { position: absolute; left: 50%; top: 150px; width: 0; height: 0; pointer-events: none; }
.burst i { position: absolute; width: 10px; height: 16px; border-radius: 2px; animation: burst 1.3s var(--ease-out) forwards; }
@keyframes burst { from { transform: translate(0, 0) rotate(0); opacity: 1; } to { transform: translate(var(--x), var(--y)) rotate(var(--r)); opacity: 0; } }

/* ---------- final ---------- */
.card.final > .av { --s: 4.6em; font-size: 1.3em; margin: 0 auto 8px; display: grid; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 0 0 5px #fff, 0 0 0 9px color-mix(in srgb, var(--c) 40%, #fff), 0 10px 22px rgba(0,0,0,.25); }
.bigrank { font-size: 4.4rem; font-weight: 900; color: var(--accent-600); line-height: 1.1; letter-spacing: -.03em; }
.top3 { list-style: none; padding: 0; margin: 0; text-align: left; display: flex; flex-direction: column; gap: 6px; }
.top3 li { display: flex; align-items: center; gap: 10px; background: var(--sage-100); border-radius: 14px; padding: 8px 12px; font-weight: 800; }
.card.final .top3 .av { --s: 1.9em; font-size: .85em; margin: 0; box-shadow: inset 0 -2px 0 rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.2); }
.top3 .n { flex: 1; word-break: break-word; } .top3 .s { color: var(--accent-600); }
.medal { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .85rem; color: #2a1d00; flex: 0 0 auto; }
.medal.m0 { background: #f1c84b; } .medal.m1 { background: #cfd6d2; } .medal.m2 { background: #d9a272; }

/* ---------- avatar builder (join step 2) ---------- */
.card.avb { gap: 6px; padding: 16px 18px 18px; }
.avb-sub { margin: 0 0 2px; text-align: center; color: var(--sage-500); font-size: .9rem; }
.avb-stage { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.avb-preview .av { --s: 118px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.7), 0 0 0 4px var(--sage-100), 0 8px 18px rgba(10,36,22,.22); animation: bob 3.2s ease-in-out infinite; }
.avb-nick { font-weight: 800; font-size: 1.1rem; max-width: 100%; overflow-wrap: anywhere; text-align: center; }
.avb-shuffle { align-self: center; display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--sage-200); background: #fff; border-radius: 99px; padding: 6px 14px; font: inherit; font-weight: 700; font-size: .88rem; color: var(--sage-900); cursor: pointer; }
.avb-shuffle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.avb-group { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.avb-group small { font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sage-500); }
.avb-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 3px 6px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.avb-row::-webkit-scrollbar { display: none; }
.avb-opt { flex: 0 0 auto; width: 46px; height: 46px; padding: 0; border: 2px solid var(--sage-200); border-radius: 50%; background: #fff; cursor: pointer; display: grid; place-items: center; transition: transform .12s, border-color .12s; }
.avb-opt .av { --s: 38px; box-shadow: none; }
.avb-opt.swatch { background: var(--sw); }
.avb-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent); transform: scale(1.08); }
.avb-opt:active { transform: scale(.94); }
.avb-back { align-self: center; background: none; border: 0; color: var(--sage-500); font: inherit; font-weight: 700; padding: 8px 12px; cursor: pointer; }
.avb .btn-main { margin-top: 6px; }
@media (max-height: 640px) and (orientation: portrait) { .avb-preview .av { --s: 84px; } .avb-sub { display: none; } .avb-opt { width: 40px; height: 40px; } .avb-opt .av { --s: 32px; } }
@media (max-height: 480px) and (orientation: landscape) {
  .card.join.avb { display: flex; max-height: none; }
  .avb-preview .av { --s: 64px; } .avb-sub, .avb-nick { display: none; } .avb-stage { flex-direction: row; justify-content: center; }
}

/* ---------- final screen: top-three treatment ---------- */
.top3 li.p1 { background: linear-gradient(90deg, #fff3c4, var(--sage-100) 70%); box-shadow: inset 0 0 0 2px #f1c84b; }
.top3 li.p2 { background: linear-gradient(90deg, #eef1f4, var(--sage-100) 70%); box-shadow: inset 0 0 0 2px #cfd6d2; }
.top3 li.p3 { background: linear-gradient(90deg, #f7e4d2, var(--sage-100) 70%); box-shadow: inset 0 0 0 2px #d9a272; }
.top3 li.me .n::after { content: " ★"; color: var(--accent-600); }
.top3 li.p1 .av { animation: bob 3.2s ease-in-out infinite; }
.card.final.r1 > .av { box-shadow: 0 0 0 5px #fff, 0 0 0 9px #f1c84b, 0 0 28px rgba(241,200,75,.7), 0 10px 22px rgba(0,0,0,.25); }
.card.final.r2 > .av { box-shadow: 0 0 0 5px #fff, 0 0 0 9px #cfd6d2, 0 10px 22px rgba(0,0,0,.25); }
.card.final.r3 > .av { box-shadow: 0 0 0 5px #fff, 0 0 0 9px #d9a272, 0 10px 22px rgba(0,0,0,.25); }
.card.final.r1 .bigrank { color: #b8860b; }
@media (prefers-reduced-motion: reduce) { .avb-preview .av, .top3 li.p1 .av { animation: none; } }

.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid rgba(255,255,255,.25); border-top-color: var(--lime); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-height: 700px) { .ans { min-height: 140px; } }
@media (prefers-reduced-motion: reduce) { .ricon, .card.wait .av, .wait .dots i, .burst i { animation: none; } .spinner { animation-duration: 3s; } }

/* ---------- landscape phones (short viewports): keep everything reachable without scrolling ---------- */
@media (max-height: 480px) and (orientation: landscape) {
  .screen { padding: 8px 14px; gap: 8px; max-width: 760px; }
  .brand { padding: 6px 0 0; } .brand .brandmark { width: 28px; height: 28px; } .brand .title { font-size: 1.05rem; }
  .card { padding: 14px 18px; border-radius: 20px; }
  .card.join { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, auto); grid-auto-flow: column; column-gap: 18px; row-gap: 4px; margin-top: 4px; }
  .card.join .event { margin: 0; font-size: 1rem; } .card.join label { margin-top: 0; }
  .inp { padding: 9px 12px; font-size: 1.1rem; border-radius: 12px; } #pin { font-size: 1.3rem; }
  .btn-main { padding: 11px; font-size: 1.05rem; } .lang { padding: 8px; }
  .err { min-height: 0; }
  .card.big { padding: 14px 18px; } .card.big h1 { font-size: 1.4rem; margin: 2px 0; }
  .card.wait .av { --s: 3.4em; margin-bottom: 4px; } .nick { font-size: 1.2rem; margin-bottom: 2px; }
  .card.final > .av { --s: 3em; margin-bottom: 4px; } .bigrank { font-size: 2.6rem; } .card.big h2 { margin: 8px 0 4px; }
  .btn-main.ghost { margin-top: 10px; }

  .qscreen { padding-top: 6px; gap: 6px; }
  .qtext { font-size: .98rem; padding: 8px 12px; border-radius: 14px; }
  .qimg { max-height: 14vh; }
  .answers { grid-template-columns: repeat(4, 1fr); min-height: 0; gap: 10px; padding-bottom: 4px; }
  .answers.n2 { grid-template-columns: repeat(2, 1fr); } .answers.n3 { grid-template-columns: repeat(3, 1fr); }
  .answers.n3 .ans:nth-child(3) { grid-column: auto; }
  .ans { min-height: 0; height: 100%; padding: 8px 6px; font-size: .95rem; border-radius: 16px; gap: 6px; box-shadow: 0 5px 0 color-mix(in srgb, var(--tc) 52%, #000), 0 10px 16px rgba(0,0,0,.24), inset 0 2px 0 rgba(255,255,255,.3); }
  .ans .shape { width: 32px; height: 32px; border-radius: 10px; } .ans .shape svg { width: 18px; height: 18px; }
  .sent { padding: 0; flex-direction: row; gap: 10px; justify-content: center; } .sent strong { font-size: 1rem; }

  .screen.result { gap: 4px; }
  .ricon { width: 64px; height: 64px; box-shadow: 0 0 0 6px rgba(255,255,255,.1), inset 0 -3px 0 rgba(0,0,0,.14); } .ricon svg { width: 32px; height: 32px; }
  .result h1 { font-size: 1.6rem; margin: 4px 0 0; } .pts { font-size: 1rem; } .pts .plus { font-size: 2.2rem; }
  .rankbox { margin-top: 4px; gap: 10px; } .rankbox > div { padding: 6px 14px; min-width: 110px; } .rankbox b { font-size: 1.15rem; }
  .next { margin-top: 4px; }
}
@media (max-width: 340px) {
  .screen { padding: 12px; } .card { padding: 18px 16px; } .card.join label { font-size: .85rem; }
  #pin { letter-spacing: .22em; font-size: 1.6rem; } .qtext { font-size: 1.02rem; } .ans { font-size: 1rem; }
}
