:root {
  color-scheme: dark;
  --bg: #171126;
  --panel: #241a38;
  --panel-2: #302347;
  --cream: #fff7e8;
  --muted: #b9aec9;
  --orange: #ff7b54;
  --yellow: #ffd166;
  --purple: #9b7bff;
  --green: #52d6a6;
  --red: #ff5f7a;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: #0d0916; }
body { display: grid; place-items: center; color: var(--cream); }
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  position: relative;
  width: min(100%, 460px);
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 80% 10%, rgba(155,123,255,.18), transparent 28%),
    radial-gradient(circle at 10% 90%, rgba(255,123,84,.15), transparent 30%),
    var(--bg);
}

.screen {
  display: none;
  min-height: 100dvh;
  padding: max(32px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  flex-direction: column;
  animation: enter .26s ease-out;
}
.screen.active { display: flex; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

.brand-mark {
  width: 62px; height: 62px; display: grid; place-items: center;
  margin: 7vh 0 28px; border-radius: 21px;
  background: var(--yellow); color: var(--bg); font-size: 35px; font-weight: 900;
  transform: rotate(-6deg); box-shadow: 0 12px 35px rgba(255,209,102,.22);
}
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 26px; }
.mode-tabs > a, .mode-tabs > span { display: flex; align-items: center; gap: 8px; min-height: 62px; padding: 9px 10px; border: 1px solid #59496d; border-radius: 16px; color: var(--cream); background: var(--panel); text-decoration: none; font-size: 19px; }
.mode-tabs > .active { border-color: var(--yellow); background: rgba(255,209,102,.12); }
.mode-tabs span span, .mode-tabs a span { display: grid; gap: 2px; }
.mode-tabs b { font-size: 11px; }
.mode-tabs small { color: var(--muted); font-size: 8px; }
.eyebrow { margin: 0 0 10px; color: var(--yellow); font-size: 12px; font-weight: 900; letter-spacing: .17em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 18px; font-size: clamp(64px, 19vw, 88px); line-height: .82; letter-spacing: -.07em; }
h1 span { color: var(--orange); }
h2 { margin-bottom: 16px; font-size: 42px; line-height: .98; letter-spacing: -.045em; }
.intro { color: var(--muted); font-size: 18px; line-height: 1.45; }

.primary, .secondary, dialog button {
  width: 100%; border: 0; border-radius: 18px; padding: 17px 20px;
  font-weight: 850; color: var(--bg); background: var(--orange);
  box-shadow: 0 8px 0 #bd4d34; transition: transform .08s, box-shadow .08s;
}
.primary:active, .secondary:active, dialog button:active { transform: translateY(5px); box-shadow: 0 3px 0 #bd4d34; }
.primary.big { margin-top: auto; font-size: 21px; padding: 20px; }
.secondary { margin: 8px 0 18px; background: var(--panel-2); color: var(--cream); box-shadow: none; border: 1px dashed #6e5b8a; }
.text-button, .back-button, .icon-button { border: 0; color: var(--cream); background: transparent; }
.text-button { padding: 19px; font-weight: 750; }
.back-button { width: 44px; margin: -4px 0 26px -10px; padding: 8px; font-size: 28px; text-align: left; }
.icon-button { width: 44px; height: 44px; border-radius: 50%; background: var(--panel); font-size: 20px; }
.safety-note { margin: 18px 0 0; color: #897c9e; text-align: center; font-size: 12px; line-height: 1.45; }
.badge-shelf { margin: 0 0 15px; padding: 12px; border: 1px solid rgba(255,209,102,.22); border-radius: 17px; background: rgba(36,26,56,.82); }
.badge-shelf header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; }
.badge-shelf header span { color: var(--yellow); font-size: 10px; font-weight: 950; letter-spacing: .1em; }
.badge-shelf header b { color: var(--muted); font-size: 10px; }
.badge-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.badge-row > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 4px; padding: 5px; border-radius: 10px; filter: grayscale(1); opacity: .42; }
.badge-row > div.earned { background: rgba(255,209,102,.09); filter: none; opacity: 1; }
.badge-row i { grid-row: 1 / 3; font-size: 20px; font-style: normal; }
.badge-row small { color: var(--muted); font-size: 8px; }
.badge-row b { font-size: 8px; }
.badge-meter { height: 5px; margin-top: 8px; border-radius: 9px; background: #493a5d; overflow: hidden; }
.badge-meter span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg,var(--orange),var(--yellow)); transition: width .4s; }
.badge-shelf p { margin: 6px 0 0; color: var(--muted); font-size: 9px; text-align: center; }
[data-badge-theme="gold"] { --yellow: #ffe08a; --orange: #ff9a55; }
.replay-ad-screen { text-align: center; }
.replay-ad-icon { margin: 6vh 0 18px; font-size: 62px; }
.replay-ad-slot { display: grid; place-items: center; min-height: 190px; margin: 12px 0 25px; border-color: rgba(255,209,102,.35); color: var(--muted); background: var(--panel); }
.replay-ad-screen .primary.big { margin-top: auto; }

.rule-list { display: grid; gap: 12px; margin: 20px 0; }
.rule-list article { display: flex; align-items: center; gap: 15px; padding: 16px; background: var(--panel); border-radius: 18px; }
.rule-list b { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 12px; background: var(--purple); }
.info-card { margin: 0 0 25px; padding: 16px; border-radius: 16px; color: #332907; background: var(--yellow); line-height: 1.4; font-size: 14px; }

.setup-heading, .top-row { display: flex; align-items: center; justify-content: space-between; }
.count-pill { display: inline-flex; padding: 8px 12px; border-radius: 99px; color: var(--cream); background: var(--panel); font-size: 13px; font-weight: 800; }
.player-list { display: grid; gap: 10px; max-height: 36vh; overflow-y: auto; padding: 3px 2px 10px; }
.duo-hint { margin: 10px 0 4px; padding: 11px 13px; border-radius: 13px; color: #dcd2ff; background: rgba(155,123,255,.13); font-size: 13px; line-height: 1.35; }
.mode-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 20px; padding: 0; border: 0; }
.mode-picker legend { margin-bottom: 9px; color: var(--muted); font-size: 13px; font-weight: 800; }
.mode-picker label { min-width: 0; }
.mode-picker input { position: absolute; opacity: 0; pointer-events: none; }
.mode-picker span { display: grid; gap: 4px; height: 100%; padding: 12px 8px; border: 2px solid transparent; border-radius: 15px; background: var(--panel); text-align: center; }
.mode-picker small { color: var(--muted); font-size: 10px; line-height: 1.25; }
.mode-picker input:checked + span { border-color: var(--yellow); background: rgba(255,209,102,.12); }
.player-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 17px; background: var(--panel); }
.player-dot { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 12px; }
.player-row input { width: 100%; border: 0; outline: 0; color: var(--cream); background: transparent; font-size: 17px; font-weight: 750; }
.remove-player { border: 0; background: transparent; color: var(--muted); font-size: 22px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 24px; }
.toggle-row span { display: grid; gap: 3px; }
.toggle-row small { color: var(--muted); }
.toggle-row input { display: none; }
.toggle-row i { position: relative; width: 54px; height: 32px; flex: 0 0 54px; border-radius: 20px; background: #59496d; }
.toggle-row i::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: white; transition: .2s; }
.toggle-row input:checked + i { background: var(--green); }
.toggle-row input:checked + i::after { transform: translateX(22px); }

.lobby-art { display: grid; place-items: center; width: 154px; height: 154px; margin: 8vh auto 32px; border-radius: 48px; background: linear-gradient(145deg, var(--purple), #6c4be7); box-shadow: 0 25px 55px rgba(108,75,231,.28); transform: rotate(5deg); }
.lobby-art span { font-size: 68px; transform: rotate(-5deg); }
.ad-slot { margin-top: 22px; padding: 10px; border-radius: 10px; color: #756887; background: rgba(255,255,255,.035); text-align: center; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }

.game-screen { background: var(--bg); }
.game-stage { display: flex; flex: 1; flex-direction: column; justify-content: center; padding-top: 20px; text-align: center; }
.game-stage h2 { font-size: 46px; }
.game-stage .instruction { color: var(--muted); font-size: 17px; line-height: 1.4; }
.player-turn { display: inline-flex; align-self: center; padding: 10px 15px; margin-bottom: 18px; border-radius: 99px; background: var(--panel); font-weight: 850; }
.score-display { margin: 18px 0; font-size: 74px; line-height: 1; font-weight: 950; letter-spacing: -.06em; }
.tap-area { display: grid; place-items: center; min-height: 220px; border: 0; border-radius: 36px; color: var(--bg); background: var(--yellow); box-shadow: 0 10px 0 #bd912c; font-size: 30px; font-weight: 950; user-select: none; touch-action: manipulation; }
.tap-area:active { transform: translateY(6px); box-shadow: 0 4px 0 #bd912c; }
.tap-area.waiting { background: var(--orange); box-shadow: 0 10px 0 #bd4d34; }
.tap-area.ready { background: var(--green); box-shadow: 0 10px 0 #278e69; }
.timer-ring { display: grid; place-items: center; width: 230px; height: 230px; margin: 20px auto; border: 12px solid var(--purple); border-radius: 50%; font-size: 50px; font-weight: 950; }
.pass-button { min-height: 180px; font-size: 28px; }
.vote-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vote-player { border: 0; padding: 18px 8px; border-radius: 18px; color: var(--cream); background: var(--panel-2); font-weight: 850; }
.duel-board { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 24px; }
.duel-board button { min-height: 300px; padding: 14px; border: 0; border-radius: 30px; color: var(--bg); background: var(--duel-color); font-weight: 950; font-size: 20px; writing-mode: vertical-rl; transform: rotate(180deg); touch-action: none; user-select: none; }
.duel-ready .duel-board button { box-shadow: 0 0 0 5px var(--cream), 0 0 42px rgba(82,214,166,.5); }
.puzzle-prompt, .color-word { margin: 26px 0; font-size: clamp(58px, 19vw, 86px); line-height: 1; font-weight: 950; letter-spacing: -.05em; }
.color-word { font-size: clamp(48px, 16vw, 72px); }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-grid button, .memory-choices button, .rps-grid button { min-height: 78px; border: 0; border-radius: 20px; color: var(--cream); background: var(--panel-2); font-size: 20px; font-weight: 900; }
.emoji-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; margin-top: 20px; }
.emoji-grid button { aspect-ratio: 1; border: 0; border-radius: 14px; background: var(--panel); font-size: clamp(23px, 8vw, 34px); }
.memory-sequence { padding: 32px 10px; border-radius: 25px; background: var(--panel); font-size: clamp(42px, 13vw, 60px); letter-spacing: .08em; }
.memory-choices { display: grid; gap: 12px; }
.memory-choices button { font-size: clamp(23px, 7vw, 31px); }
.playing-card { display: grid; place-items: center; width: 190px; height: 250px; margin: 20px auto 30px; border: 8px solid var(--cream); border-radius: 25px; color: var(--red); background: white; font-size: 46px; font-weight: 950; box-shadow: 0 16px 35px rgba(0,0,0,.3); transform: rotate(3deg); }
.challenge-card, .fact-card { margin: 18px 0; padding: 25px 18px; border-radius: 25px; color: var(--bg); background: var(--yellow); }
.challenge-card small { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.challenge-card b { display: block; font-size: 35px; }
.challenge-card p { margin: 14px 0 0; font-weight: 750; }
.challenge-timer { margin: 10px 0 18px; font-size: 58px; font-weight: 950; }
.challenge-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.challenge-actions button { min-height: 70px; border: 0; border-radius: 18px; color: white; background: var(--red); font-weight: 900; }
.challenge-actions button:last-child { color: var(--bg); background: var(--green); }
.fact-card { display: grid; place-items: center; min-height: 210px; font-size: 27px; line-height: 1.2; font-weight: 900; }
.rps-grid { display: grid; gap: 12px; }
.mini-results { display: grid; gap: 8px; margin: 18px 0; text-align: left; }
.mini-results div { display: flex; justify-content: space-between; padding: 12px 14px; border-radius: 13px; background: var(--panel); }

.result-screen { text-align: center; background: radial-gradient(circle at 50% 30%, rgba(255,123,84,.28), transparent 35%), var(--bg); }
.result-screen .eyebrow { margin-top: 8vh; }
.loser-avatar { display: grid; place-items: center; width: 125px; height: 125px; margin: 25px auto 18px; border: 8px solid rgba(255,255,255,.2); border-radius: 42px; background: var(--orange); color: var(--bg); font-size: 54px; font-weight: 950; transform: rotate(-4deg); }
.result-screen h2 { margin-bottom: 28px; font-size: 52px; }
.sip-line { color: var(--muted); font-size: 26px; line-height: 1.15; font-weight: 800; }
.sip-line span { color: var(--yellow); }
.water-screen { justify-content: center; text-align: center; }
.water-drop { margin-bottom: 20px; font-size: 86px; }
.water-screen .primary { margin-top: 22px; }
.end-screen { justify-content: center; text-align: center; background: radial-gradient(circle at 50% 25%, rgba(255,209,102,.18), transparent 35%), var(--bg); }
.end-icon { margin-bottom: 20px; font-size: 90px; }
.end-screen h2 span { color: var(--yellow); }

dialog { width: min(calc(100% - 40px), 400px); padding: 22px; border: 1px solid #46365e; border-radius: 24px; color: var(--cream); background: var(--panel); }
dialog::backdrop { background: rgba(4,2,8,.75); backdrop-filter: blur(4px); }
dialog h3 { font-size: 25px; }
dialog button { margin-top: 10px; box-shadow: none; }
dialog button:not(.danger) { color: var(--cream); background: var(--panel-2); }
dialog .danger { color: white; background: var(--red); }

@media (min-width: 700px) {
  .app-shell { min-height: min(900px, 100dvh); border-radius: 30px; box-shadow: 0 30px 100px #000; }
  .screen { min-height: min(900px, 100dvh); }
}
