:root {
  --bg: #16112e; --bg2: #231a4a; --card: #2c2260; --card2: #3a2d7a; --ink: #fff; --dim: #b9b0e6; --line: #4b3d93;
  --pink: #ff5d8f; --yellow: #ffd23f; --green: #3ddc97; --blue: #4cc9f0; --purple: #b388ff; --red: #ff5d5d; --orange: #ff9f43;
  --t0: #ff5d5d; --t1: #4c9bf0; --t2: #3ddc97;
  --r: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #3a2585 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink); font: 500 17px/1.35 Fredoka, system-ui, sans-serif;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; overscroll-behavior: none;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
#app { max-width: 520px; margin: 0 auto; padding: 12px 16px 40px; }

/* top bar */
#top { position: sticky; top: 0; z-index: 5; background: rgba(22,17,46,.88); backdrop-filter: blur(8px); }
#top:empty { display: none; }
.bar { max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 16px; }
.bar .code { font-weight: 700; letter-spacing: 2px; background: var(--card); padding: 4px 10px; border-radius: 10px; }
.bar .round { color: var(--dim); font-size: 15px; }
.bar .sp { flex: 1; }
.bar .clock { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 44px; text-align: right; }
.bar .clock.low { color: var(--yellow); animation: pulse .6s infinite alternate; }
.bar .me { font-size: 22px; }
.iconbtn { background: var(--card); border-radius: 12px; padding: 6px 10px; font-size: 16px; }

h1, h2, h3 { margin: 0; line-height: 1.15; }
.center { text-align: center; }
.dim { color: var(--dim); }
.small { font-size: 14px; }
.big { font-size: 28px; font-weight: 700; }
.huge { font-size: 64px; line-height: 1; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > .grow { flex: 1; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; }
.card.soft { background: rgba(255,255,255,.06); }

.btn { display: block; width: 100%; padding: 16px; border-radius: 18px; font-size: 20px; font-weight: 700; background: var(--pink);
  box-shadow: 0 5px 0 rgba(0,0,0,.28); transition: transform .06s; }
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.28); }
.btn.alt { background: var(--card2); }
.btn.go { background: var(--green); color: #0b2a1d; }
.btn.warn { background: var(--yellow); color: #3b2a00; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.field { width: 100%; padding: 16px; font: 600 22px Fredoka, sans-serif; border-radius: 16px; border: 2px solid var(--line); background: var(--bg2); color: var(--ink); text-align: center; outline: none; }
.field:focus { border-color: var(--purple); }
.field.code { letter-spacing: 10px; text-transform: uppercase; font-size: 30px; }

.logo { font-size: 56px; font-weight: 700; letter-spacing: -1px; text-align: center; margin-top: 18px;
  background: linear-gradient(90deg, var(--yellow), var(--pink), var(--purple), var(--blue)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { text-align: center; color: var(--dim); margin-top: -4px; }
.cards-deco { text-align: center; font-size: 34px; letter-spacing: 6px; }
.or { text-align: center; color: var(--dim); font-size: 14px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--card2); font-weight: 600; }
.chip.off { opacity: .45; }
.chip.kind { font-size: 13px; padding: 5px 10px; letter-spacing: .5px; text-transform: uppercase; }
.k-LOUD { background: var(--orange); color: #3a1c00; } .k-SKILL { background: var(--blue); color: #002a38; }
.k-MIND { background: var(--purple); color: #1d0b44; } .k-HEART { background: var(--pink); color: #3d0017; }
.k-STRATEGY { background: var(--yellow); color: #3b2a00; }
.chip.mode { background: rgba(255,255,255,.12); }

.roomcode { font-size: 64px; font-weight: 700; letter-spacing: 12px; text-align: center; color: var(--yellow); line-height: 1; }
.qr { width: 150px; height: 150px; margin: 0 auto; display: block; background: #fff; border-radius: 14px; padding: 6px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 12px; border-radius: 14px; background: var(--card2); font-weight: 700; }
.seg button.on { background: var(--yellow); color: #3b2a00; }
.seg.wrap button { padding: 10px 4px; font-size: 14px; }
.chip.pick { font-size: 15px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.chip.pick.on { background: var(--pink); color: #3d0017; }
.chip.pick[disabled] { opacity: .35; pointer-events: none; }
.card.picked { outline: 2px solid var(--pink); }

/* reveal */
.reel { height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.reel .e { font-size: 96px; line-height: 1; }
.reel .n { font-size: 26px; font-weight: 700; margin-top: 10px; }
.reel.land .e { animation: pop .5s cubic-bezier(.2,1.6,.4,1); }
.mystery { font-size: 22px; color: var(--dim); text-align: center; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 8px 0 8px 44px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 6px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--card2); display: grid; place-items: center; font-weight: 700; }
.goal { font-size: 19px; font-weight: 600; }
.teamban { border-radius: var(--r); padding: 14px; text-align: center; font-weight: 700; font-size: 22px; }
.t0 { background: var(--t0); } .t1 { background: var(--t1); } .t2 { background: var(--t2); color: #06301f; }
.tb0 { border-color: var(--t0) !important; } .tb1 { border-color: var(--t1) !important; } .tb2 { border-color: var(--t2) !important; }
.teamstrip { border-radius: 12px; padding: 6px 12px; font-weight: 700; text-align: center; font-size: 15px; }

/* choice grids */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid.one { grid-template-columns: 1fr; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.opt { background: var(--card2); border-radius: 18px; padding: 16px 10px; font-size: 19px; font-weight: 600; min-height: 64px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.opt:active { transform: translateY(2px); }
.opt.on { background: var(--yellow); color: #3b2a00; }
.opt.good { background: var(--green); color: #06301f; }
.opt.bad { background: var(--red); }
.opt.gone { opacity: .3; pointer-events: none; }
.opt[disabled] { pointer-events: none; }
.opt .av { font-size: 30px; display: block; }
.q { font-size: 24px; font-weight: 700; text-align: center; }
.wait { text-align: center; color: var(--dim); padding: 18px; }
.wait .huge { display: block; margin-bottom: 10px; animation: bob 1.2s ease-in-out infinite; }

/* big pads */
.pad { height: 52vh; min-height: 260px; border-radius: 28px; display: grid; place-items: center; text-align: center; font-size: 34px; font-weight: 700; user-select: none; touch-action: none; }
.pad.red { background: var(--red); } .pad.green { background: var(--green); color: #06301f; } .pad.grey { background: var(--card); }
.pad.purple { background: linear-gradient(160deg, var(--purple), var(--pink)); }
.pad.held { transform: scale(.97); filter: brightness(1.15); }
.count { font-size: 80px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.stroop-word { font-size: 64px; font-weight: 700; text-align: center; height: 90px; letter-spacing: 2px; }
.swatch { height: 80px; border-radius: 18px; box-shadow: 0 4px 0 rgba(0,0,0,.25); }

.bomb { font-size: 140px; text-align: center; animation: shake .15s infinite; }
.flash { text-align: center; font-weight: 600; padding: 10px; border-radius: 14px; background: rgba(255,255,255,.08); }
.secret { background: linear-gradient(160deg, #4a2fb0, #2a1d6b); border: 2px dashed var(--purple); border-radius: var(--r); padding: 20px; text-align: center; }
.secret .w { font-size: 38px; font-weight: 700; color: var(--yellow); }

/* bars */
.hpbar { height: 26px; border-radius: 13px; background: rgba(255,255,255,.1); overflow: hidden; position: relative; border: 3px solid transparent; }
.hpbar > i { position: absolute; inset: 0 auto 0 0; transition: width .2s; }
.hpbar > b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; }
.hpbar.target { border-color: var(--yellow); }
.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.move { position: relative; overflow: hidden; height: 96px; border-radius: 20px; font-size: 22px; font-weight: 700; background: var(--card2); box-shadow: 0 4px 0 rgba(0,0,0,.25); }
.move .cd { position: absolute; inset: 0; background: rgba(0,0,0,.55); transform-origin: left; pointer-events: none; }
.move.atk { background: var(--red); } .move.ult { background: linear-gradient(135deg, var(--yellow), var(--orange)); color: #3b1c00; }
.move.shield { background: var(--blue); color: #002a38; } .move.heal { background: var(--green); color: #06301f; }
.rope { position: relative; height: 60px; border-radius: 30px; background: linear-gradient(90deg, var(--t0) 0 50%, var(--t1) 50% 100%); }
.rope > i { position: absolute; top: -8px; width: 20px; height: 76px; margin-left: -10px; border-radius: 10px; background: #fff; transition: left .15s; box-shadow: 0 0 12px #fff; }

.feed { font-size: 14px; color: var(--dim); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; font-weight: 600; }
.tcard { border-radius: 16px; padding: 10px 12px; background: var(--card); border: 3px solid transparent; }
.tcard.mine { background: var(--card2); }

.spots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.spot { aspect-ratio: 1; border-radius: 16px; background: var(--card2); font-size: 34px; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.spot.me { background: var(--yellow); }
.spot.done { opacity: .28; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad button { padding: 16px; border-radius: 16px; background: var(--card2); font-size: 26px; font-weight: 700; }
.display { font-size: 40px; font-weight: 700; letter-spacing: 12px; text-align: center; min-height: 56px; background: var(--bg2); border-radius: 16px; padding: 6px; }
.locks { text-align: center; font-size: 40px; letter-spacing: 8px; }
.dice { font-size: 90px; text-align: center; }
.hearts { font-size: 18px; }
input[type=range] { width: 100%; accent-color: var(--yellow); height: 36px; }

/* results / board */
.banner { border-radius: var(--r); padding: 18px; text-align: center; }
.banner.win { background: linear-gradient(135deg, var(--yellow), var(--orange)); color: #3b1c00; }
.banner.lose { background: var(--card); }
.banner .big { font-size: 30px; }
.lines { list-style: none; padding: 0; margin: 0; }
.lines li { padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.06); margin-top: 6px; }
.lb { list-style: none; padding: 0; margin: 0; }
.lb li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--card); margin-top: 8px; }
.lb li.me { outline: 2px solid var(--yellow); }
.lb .pos { width: 26px; font-weight: 700; color: var(--dim); }
.lb .av { font-size: 26px; }
.lb .nm { flex: 1; font-weight: 600; }
.lb .sc { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plus { color: #06301f; background: var(--green); border-radius: 8px; padding: 1px 7px; font-size: 14px; font-weight: 700; animation: pop .5s; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin-top: 10px; }
.podium div { flex: 1; max-width: 120px; text-align: center; border-radius: 16px 16px 0 0; padding: 10px 4px; background: var(--card2); }
.podium .p1 { height: 170px; background: linear-gradient(var(--yellow), var(--orange)); color: #3b1c00; }
.podium .p2 { height: 130px; } .podium .p3 { height: 100px; }
.podium .av { font-size: 38px; display: block; }
.profile { border-radius: var(--r); padding: 14px; background: var(--card); }
.profile .badge { display: inline-block; margin: 6px 6px 0 0; padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: 14px; }

#sheet { position: fixed; inset: 0; z-index: 10; background: rgba(10,6,28,.8); display: flex; align-items: flex-end; }
#sheet[hidden] { display: none; }
#sheet .in { width: 100%; max-width: 520px; margin: 0 auto; max-height: 80vh; overflow: auto; background: var(--bg2); border-radius: 24px 24px 0 0; padding: 18px 16px 28px; }
#toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 20; background: var(--red); padding: 12px 18px; border-radius: 14px; font-weight: 600; max-width: 90vw; }
.away { position: fixed; top: 0; left: 0; right: 0; z-index: 30; background: var(--yellow); color: #3b2a00; text-align: center; padding: 6px; font-weight: 600; }
.confetti { position: fixed; top: -20px; z-index: 40; pointer-events: none; font-size: 22px; animation: fall linear forwards; }

@keyframes pop { 0% { transform: scale(.3); } 100% { transform: scale(1); } }
@keyframes pulse { to { opacity: .5; } }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes shake { 0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) scale(1.05); } 100% { transform: rotate(-8deg); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

.avimg { border-radius: 50%; object-fit: cover; vertical-align: middle; background: var(--card2); }
.podium .avimg, .opt .avimg { display: inline-block; }
.btn.discord { background: #5865f2; color: #fff; text-align: center; text-decoration: none; }
a { color: var(--yellow); }
