/* ---------- themes ---------- */
:root, body[data-theme="classic"] {
  --bg: #f4f5fb; --surface: #ffffff; --surface-2: #eceef6; --ink: #1b2134; --muted: #6b7390;
  --line: #d9dcea; --accent: #5b5bf0; --accent-ink: #fff;
  --correct: #22b35e; --present: #eeb11b; --absent: #7d859c; --danger: #e5484d; --gold: #f6b400;
  --opp: #ef5da8;
}
body[data-theme="midnight"] {
  --bg: #0e1222; --surface: #171c33; --surface-2: #20274a; --ink: #eef0ff; --muted: #8e96c2;
  --line: #2c3460; --accent: #7c7cff; --accent-ink: #fff;
  --correct: #2fcf73; --present: #f2b632; --absent: #3d4570; --danger: #ff5a62; --gold: #ffc62e;
  --opp: #ff6fb7;
}
body[data-theme="sunset"] {
  --bg: #fff1ea; --surface: #ffffff; --surface-2: #ffe1d3; --ink: #3a1f2b; --muted: #9a6b78;
  --line: #f4cbbb; --accent: #ff6a3d; --accent-ink: #fff;
  --correct: #e2446c; --present: #ffb238; --absent: #b79aa3; --danger: #c81d4e; --gold: #ff9f1c;
  --opp: #7b3fe4;
}
body[data-theme="mint"] {
  --bg: #e9faf4; --surface: #ffffff; --surface-2: #d3f3e7; --ink: #10352c; --muted: #5d8a7e;
  --line: #bfe8d8; --accent: #0fa37f; --accent-ink: #fff;
  --correct: #0fa37f; --present: #f4b942; --absent: #93b3a9; --danger: #e04f5f; --gold: #f4b942;
  --opp: #6a5cff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  transition: background .3s, color .3s;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; } .xs { font-size: 11px; }
.center { text-align: center; }
.right { text-align: right; }

#app { max-width: 480px; margin: 0 auto; height: 100dvh; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scroll { flex: 1; overflow-y: auto; padding: 0 16px 16px; }

/* ---------- buttons ---------- */
.btn {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 12px 16px; font-weight: 600; transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.gold { background: var(--gold); color: #2b1d00; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; border-radius: 16px; }
.btn.wide { width: 100%; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .45; pointer-events: none; }

/* ---------- home ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; gap: 8px; }
.logo { font-weight: 800; letter-spacing: .5px; font-size: 20px; }
.logo span { color: var(--accent); margin-left: 3px; }
.wallet { display: flex; gap: 6px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; font-size: 13px; white-space: nowrap; }

.name-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 8px 0 14px; }
.record { margin-left: auto; text-align: right; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: var(--accent); color: var(--accent-ink); flex: none; font-size: 18px;
}
.avatar.sm { width: 32px; height: 32px; font-size: 14px; }
.avatar.opp-av { background: var(--opp); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin-bottom: 12px; }
.daily { background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--opp))); color: #fff; border: 0; }
.daily .muted { color: rgba(255,255,255,.82); }
.daily .btn.primary { background: #fff; color: var(--accent); }
.daily-head { display: flex; justify-content: space-between; align-items: flex-start; }
.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; opacity: .85; font-weight: 600; }
.daily-title { font-size: 22px; font-weight: 800; margin-top: 2px; }
.flame { font-size: 30px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(6deg); } }
.daily-result { font-size: 16px; font-weight: 600; margin: 10px 0 6px; }
.daily-result .mini-board { margin-top: 8px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.tile-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 14px; border-radius: 18px; }
.tile-btn .ico { font-size: 24px; margin-bottom: 4px; }

.section-title { font-size: 15px; margin: 22px 0 10px; }
.quests { display: grid; gap: 8px; }
.quest { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.quest .bar { height: 6px; background: var(--surface-2); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.quest .bar i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .4s; }
.quest.done { opacity: .6; }
.quest.done .bar i { background: var(--correct); }
.quest .q-body { flex: 1; }
.quest .q-reward { font-weight: 600; font-size: 13px; white-space: nowrap; }

.leaderboard { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.leaderboard li { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.leaderboard li.me { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.leaderboard .rank { width: 26px; font-weight: 800; color: var(--muted); }
.leaderboard .lb-name { flex: 1; font-weight: 600; }
.leaderboard .lb-rating { font-weight: 800; }

.shop { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-item { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.shop-item .swatch { height: 46px; border-radius: 10px; display: flex; gap: 4px; padding: 8px; }
.shop-item .swatch i { flex: 1; border-radius: 5px; }
.premium { margin-top: 16px; }

.bottomnav { display: flex; border-top: 1px solid var(--line); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav button { flex: 1; padding: 8px 0 10px; font-size: 12px; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.bottomnav button span { font-size: 20px; filter: grayscale(1); opacity: .6; }
.bottomnav button.active { color: var(--accent); }
.bottomnav button.active span { filter: none; opacity: 1; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- search ---------- */
.center-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 8px; }
.center-wrap h2 { margin: 18px 0 0; }
.radar { width: 140px; height: 140px; position: relative; display: grid; place-items: center; }
.radar b { font-size: 30px; font-weight: 800; color: var(--accent); z-index: 1; }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: ping 2.4s ease-out infinite; opacity: 0; }
.radar span:nth-child(2) { animation-delay: .8s; } .radar span:nth-child(3) { animation-delay: 1.6s; }
@keyframes ping { from { transform: scale(.3); opacity: .9; } to { transform: scale(1.1); opacity: 0; } }
.invite { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; width: 100%; display: grid; gap: 8px; margin: 10px 0; }
.invite .code { font-size: 34px; font-weight: 800; letter-spacing: 6px; }
.invite #invite-link { word-break: break-all; }

/* ---------- match ---------- */
.match-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 6px; gap: 8px; }
.match-head .side { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.match-head .side b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; font-size: 14px; }
.match-head .opp { justify-content: flex-end; }
.clock { font-weight: 800; font-variant-numeric: tabular-nums; font-size: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; }
.clock.low { color: var(--danger); border-color: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

.opp-strip { display: flex; align-items: center; gap: 12px; margin: 2px 12px 4px; padding: 8px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.opp-status { flex: 1; font-size: 13px; font-weight: 600; color: var(--muted); text-align: right; }
.opp-status.win { color: var(--correct); }
.opp-status.bad { color: var(--danger); }

.mini-board { display: grid; gap: 2px; }
.mini-row { display: flex; gap: 2px; }
.mini-tile { width: 11px; height: 11px; border-radius: 2px; background: var(--surface-2); transition: background .25s; }
.mini-tile.correct { background: var(--correct); } .mini-tile.present { background: var(--present); } .mini-tile.absent { background: var(--absent); }
.mini-tile.typing { background: var(--opp); opacity: .55; animation: blink .9s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.mini-board.lg .mini-tile { width: 16px; height: 16px; border-radius: 3px; }

.board-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 0; padding: 4px 0; }
.board {
  display: grid; gap: 5px; --reserve: 470px;
  --tile: min(58px, calc((100dvh - var(--reserve)) / var(--rows, 6) - 5px), calc(min(100vw, 480px) / var(--cols, 5) - 14px));
}
.solo .board { --reserve: 360px; }
.hearts .board { --reserve: 560px; }
.open .board { --reserve: 560px; }
.row { display: flex; gap: 5px; }
.row.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.tile {
  width: var(--tile); height: var(--tile); min-width: 34px; min-height: 34px;
  border: 2px solid var(--line); border-radius: 8px; display: grid; place-items: center;
  font-weight: 800; font-size: calc(var(--tile) * .5); text-transform: uppercase; background: var(--surface);
  user-select: none;
}
.tile.filled { border-color: var(--muted); animation: pop .1s; }
.tile.hinted { border-style: dashed; border-color: var(--present); color: var(--muted); }
@keyframes pop { 50% { transform: scale(1.1); } }
.tile.correct, .tile.present, .tile.absent { color: #fff; border-color: transparent; }
.tile.correct { background: var(--correct); } .tile.present { background: var(--present); } .tile.absent { background: var(--absent); }
.tile.flip { animation: flip .5s ease both; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.row.win .tile { animation: jump .5s ease both; }
@keyframes jump { 40% { transform: translateY(-14px); } 70% { transform: translateY(2px); } }

.hint-banner { font-size: 13px; font-weight: 600; background: color-mix(in srgb, var(--present) 20%, transparent); border-radius: 999px; padding: 4px 12px; margin-bottom: 6px; }

.match-tools { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; }
.mode-tag:empty { display: none; }
#btn-forfeit { white-space: nowrap; }
.mode-tag { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.keyboard { padding: 4px 6px calc(8px + env(safe-area-inset-bottom)); display: grid; gap: 6px; }
.kb-row { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1; max-width: 44px; height: 54px; border-radius: 8px; background: var(--surface-2);
  font-weight: 700; font-size: 15px; text-transform: uppercase; user-select: none; transition: background .3s;
}
.key.wide { max-width: 68px; flex: 1.5; font-size: 12px; }
.key:active { filter: brightness(.9); }
.key.correct, .key.present, .key.absent { color: #fff; }
.key.correct { background: var(--correct); } .key.present { background: var(--present); } .key.absent { background: var(--absent); opacity: .7; }

.countdown { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 5; }
.countdown b { font-size: 110px; font-weight: 800; color: var(--accent); animation: zoom 1s ease infinite; }
@keyframes zoom { from { transform: scale(1.5); opacity: 0; } 30% { opacity: 1; transform: scale(1); } }

/* ---------- result ---------- */
.result { padding-top: 16px; }
.result-banner { text-align: center; padding: 22px 12px; border-radius: 22px; color: #fff; background: var(--absent); }
.result-banner.win { background: linear-gradient(135deg, var(--correct), color-mix(in srgb, var(--correct) 60%, var(--accent))); }
.result-banner.loss { background: linear-gradient(135deg, var(--danger), color-mix(in srgb, var(--danger) 60%, var(--opp))); }
.r-title { font-size: 34px; font-weight: 800; animation: pop .4s; }
.r-sub { opacity: .9; margin-top: 4px; }
.r-word { text-align: center; margin: 14px 0; font-size: 15px; }
.r-word b { text-transform: uppercase; letter-spacing: 3px; font-size: 20px; }
.versus { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.versus .col { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.versus .col.winner { border-color: var(--correct); box-shadow: 0 0 0 1px var(--correct) inset; }
.versus .who { font-weight: 700; font-size: 14px; text-align: center; }
.versus .stat { font-size: 13px; color: var(--muted); }
.words-list { display: grid; gap: 3px; }
.words-list .w { display: flex; gap: 2px; }
.words-list .w i { width: 20px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 800; color: #fff; text-transform: uppercase; }
.words-list .w i.correct { background: var(--correct); } .words-list .w i.present { background: var(--present); } .words-list .w i.absent { background: var(--absent); }
.rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0; }
.reward { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 14px; animation: pop .4s both; }
.reward.up { color: var(--correct); } .reward.down { color: var(--danger); }
.r-actions { display: grid; gap: 10px; }
.r-actions .grid2 { margin: 0; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 25, .6); display: grid; place-items: center; z-index: 20; }
.ad-box { background: var(--surface); border-radius: 20px; padding: 24px 32px; text-align: center; display: grid; gap: 10px; min-width: 220px; }
.ad-art { font-size: 60px; animation: bob 1s infinite; }
.toast {
  position: fixed; left: 50%; top: 70px; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px;
  transition: all .25s; z-index: 30; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 25; width: 100%; height: 100%; }

@media (max-height: 640px) {
  .key { height: 46px; }
  .opp-strip { padding: 6px 10px; }
  .mini-tile { width: 9px; height: 9px; }
}

/* ---------- home: daily puzzles & duel ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; }
.section-head .section-title { margin-top: 6px; }
.puzzle-card { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; position: relative; overflow: hidden; transition: transform .1s; }
.puzzle-card:active { transform: scale(.98); }
.puzzle-card .eyebrow { color: inherit; }
.pc-top { display: flex; justify-content: space-between; align-items: center; }
.pc-title { font-size: 20px; font-weight: 800; }
.pc-title.sm { font-size: 15px; }
.pc-status { margin-top: 6px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pc-go { font-weight: 800; }
.pc-done { font-weight: 700; }
.wotd { background: linear-gradient(135deg, var(--correct), color-mix(in srgb, var(--correct) 55%, var(--accent))); color: #fff; border: 0; }
.wotd .muted { color: rgba(255, 255, 255, .85); }
.wotd .mini-tile { background: rgba(255, 255, 255, .3); }
.wotd .mini-tile.correct { background: #fff; } .wotd .mini-tile.present { background: var(--present); } .wotd .mini-tile.absent { background: rgba(0, 0, 0, .25); }
.wotd .pc-go { background: #fff; color: var(--correct); padding: 6px 14px; border-radius: 999px; }
.streak-chip { background: rgba(255, 255, 255, .22); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 700; }
.wotw { background: linear-gradient(135deg, #6b4de6, #a34fe4); color: #fff; border: 0; margin: 0; }
.wotw .muted { color: rgba(255, 255, 255, .8); }
.dduel { margin: 0; }
.dduel .pc-go { color: var(--accent); }
.dduel.played { opacity: .75; }
.duel-card { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; }
.duel-card .duel-text { display: flex; flex-direction: column; gap: 3px; }
.duel-card .duel-actions { grid-column: 1 / -1; display: grid; gap: 8px; }
.mini-slot { display: flex; gap: 3px; background: var(--ink); padding: 5px; border-radius: 12px; }
.mini-slot span { width: 30px; height: 36px; display: grid; place-items: center; background: var(--surface); border-radius: 7px; font-weight: 800; font-size: 16px; animation: slotTease 3s ease-in-out infinite; }
.mini-slot span:nth-child(2) { animation-delay: .25s; } .mini-slot span:nth-child(3) { animation-delay: .5s; }
@keyframes slotTease { 0%, 80%, 100% { transform: none; } 85% { transform: translateY(-4px); } 90% { transform: translateY(2px); } }

/* ---------- reels ---------- */
.reels-wrap { gap: 18px; }
.vs-row { display: flex; align-items: center; gap: 18px; }
.vs-p { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 110px; }
.vs-p b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.vs-row .vs { font-size: 26px; color: var(--accent); font-weight: 800; animation: pulse 1s infinite; }
.slot { display: flex; gap: 10px; background: var(--ink); padding: 12px; border-radius: 22px; box-shadow: 0 10px 30px rgba(20, 25, 50, .25); transition: box-shadow .4s; }
.slot.gold { box-shadow: 0 0 0 4px var(--gold), 0 0 40px color-mix(in srgb, var(--gold) 70%, transparent); animation: goldPulse 1s ease-in-out infinite; }
@keyframes goldPulse { 50% { box-shadow: 0 0 0 4px var(--gold), 0 0 70px var(--gold); } }
.reel { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.reel-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: rgba(255, 255, 255, .6); font-weight: 700; }
.reel-window { width: 92px; height: 78px; overflow: hidden; background: var(--surface); border-radius: 12px; position: relative;
  -webkit-mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent); mask-image: linear-gradient(transparent, #000 22%, #000 78%, transparent); }
.reel.stopped .reel-window { animation: thunk .3s ease; -webkit-mask-image: none; mask-image: none; box-shadow: 0 0 0 3px var(--accent) inset; }
@keyframes thunk { 30% { transform: translateY(4px); } }
.reel-item { height: 78px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.reel-item b { font-size: 30px; line-height: 1; font-weight: 800; }
.reel-item span { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; max-width: 88px; overflow: hidden; text-overflow: ellipsis; }
.golden-banner { font-weight: 800; color: #2b1d00; background: linear-gradient(90deg, var(--gold), #ffe58a, var(--gold)); background-size: 200% 100%; padding: 8px 16px; border-radius: 999px; animation: shimmer 1.2s linear infinite, pop .4s; }
@keyframes shimmer { to { background-position: -200% 0; } }
.mode-desc { max-width: 320px; opacity: 0; transform: translateY(8px); transition: all .35s; font-size: 15px; }
.mode-desc.show { opacity: 1; transform: none; }

/* ---------- match additions ---------- */
.match-info { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 0 12px 4px; }
.match-info .chip { font-size: 12px; font-weight: 600; padding: 3px 9px; }
.chip.gold { background: var(--gold); color: #2b1d00; border-color: transparent; }
.solo .opp-strip, .solo .emotes, .solo .side.opp, .solo .clock:empty { display: none; }
.solo .match-head .side.me b { max-width: 220px; }
.opp-strip { position: relative; }
.opp-hearts { font-size: 12px; letter-spacing: 1px; }
.emote-pop { position: absolute; right: 12px; top: -6px; pointer-events: none; }
.emote-bubble { position: absolute; right: 0; top: 0; font-size: 34px; animation: emoteUp 1.8s ease-out forwards; }
@keyframes emoteUp { 0% { transform: scale(.3) translateY(10px); opacity: 0; } 15% { transform: scale(1.2); opacity: 1; } 30% { transform: scale(1); } 100% { transform: translateY(-46px); opacity: 0; } }
.emotes { display: flex; gap: 2px; }
.emote { font-size: 20px; width: 34px; height: 34px; border-radius: 10px; transition: transform .1s; }
.emote:active { transform: scale(.85); }
.emote.sent { animation: emoteSent .5s; }
@keyframes emoteSent { 40% { transform: scale(1.4) rotate(-10deg); } }

.clue-box { margin: 4px 12px 0; padding: 8px 12px; border-radius: 14px; background: color-mix(in srgb, var(--present) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--present) 40%, transparent); }
.clue-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.clue { font-size: 16px; font-weight: 700; margin-top: 2px; }
.hearts { font-size: 15px; letter-spacing: 1px; }
.hearts.hit { animation: heartHit .5s; }
@keyframes heartHit { 20%, 60% { transform: translateX(-5px) scale(1.15); } 40%, 80% { transform: translateX(5px); } }
.board-wrap { position: relative; }
.board-msg { position: absolute; inset: auto 12px; top: 50%; transform: translateY(-50%); text-align: center; padding: 14px; border-radius: 16px; font-size: 18px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(20, 25, 50, .18); animation: pop .3s; z-index: 2; }
.board-msg.good { color: var(--correct); }
.board-msg.bad { color: var(--danger); }
.open-board { display: grid; gap: 2px; }
.ob-row { display: flex; gap: 2px; }
.ob-tile { width: 17px; height: 17px; border-radius: 3px; background: var(--surface-2); font-style: normal; font-size: 10px; font-weight: 800; text-transform: uppercase; display: grid; place-items: center; color: #fff; }
.ob-tile.correct { background: var(--correct); } .ob-tile.present { background: var(--present); } .ob-tile.absent { background: var(--absent); }
.ob-tile.typing { background: color-mix(in srgb, var(--opp) 25%, var(--surface)); color: var(--opp); border: 1px solid var(--opp); }

/* ---------- results additions ---------- */
.result-banner.golden { box-shadow: 0 0 0 3px var(--gold); }
.reward.gold { background: var(--gold); color: #2b1d00; border-color: transparent; }
.hw { font-weight: 700; font-size: 13px; align-self: flex-start; }
.hw.ok { color: var(--correct); } .hw.miss { color: var(--danger); }
.puzzle-stats { display: grid; gap: 10px; justify-items: center; margin-top: 4px; }
.dist-head { font-size: 14px; }
.dist { width: 100%; display: grid; gap: 4px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.dist-row span { width: 14px; text-align: right; color: var(--muted); }
.dist-row i { font-style: normal; background: var(--absent); color: #fff; border-radius: 4px; padding: 2px 6px; text-align: right; min-width: 22px; transition: width .6s; }
.dist-row.mine i { background: var(--correct); }
.dist-row.fail i { background: color-mix(in srgb, var(--danger) 70%, var(--absent)); }
.better { font-size: 15px; }

/* ---------- rival cards (1 in a duel, up to 9 in a party) ---------- */
.opp-card { display: flex; align-items: center; gap: 12px; flex: 1; position: relative; min-width: 0; }
.opp-card .oc-name { display: none; }
.opp-card .opp-status { flex: 1; }
.opp-card.left { opacity: .45; }
#opp-list.multi { overflow-x: auto; gap: 8px; padding: 6px; scrollbar-width: none; align-items: stretch; }
#opp-list.multi .opp-card { flex: none; flex-direction: column; align-items: flex-start; gap: 4px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); min-width: 92px; }
#opp-list.multi .opp-card.solved { box-shadow: 0 0 0 2px var(--correct) inset; }
#opp-list.multi .oc-name { display: block; font-size: 12px; font-weight: 700; max-width: 100px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#opp-list.multi .opp-status { font-size: 11px; text-align: left; }
#opp-list.multi .mini-tile { width: 8px; height: 8px; }
#opp-list.multi .ob-tile { width: 13px; height: 13px; font-size: 8px; }
#opp-list.multi .emote-bubble { font-size: 26px; }
.opp-card .emote-pop { position: absolute; right: 4px; top: -4px; pointer-events: none; }

/* ---------- party room ---------- */
.room-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px 6px; gap: 8px; font-size: 17px; }
.room-invite { text-align: center; display: grid; gap: 8px; }
.room-invite .code { font-size: 34px; font-weight: 800; letter-spacing: 6px; }
.room-invite #room-link { word-break: break-all; }
.room-members { display: grid; gap: 6px; }
.room-member { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.room-member .rm-name { flex: 1; line-height: 1.2; }
.room-member.me { border-color: var(--accent); }
.room-member.empty { border-style: dashed; background: transparent; }
.room-member.empty .avatar { background: var(--surface-2); color: var(--muted); }
.chip.host { background: color-mix(in srgb, var(--gold) 25%, var(--surface)); }
.room-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); display: grid; gap: 8px; border-top: 1px solid var(--line); background: var(--surface); }
.room-foot #room-wait:empty { display: none; }

/* ---------- party standings ---------- */
.standings { width: 100%; display: grid; gap: 4px; }
.standing { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px; background: var(--surface-2); }
.standing.me { box-shadow: 0 0 0 2px var(--accent) inset; }
.standing.left { opacity: .5; }
.st-place { width: 26px; text-align: center; font-weight: 800; font-size: 18px; }
.st-name { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- account ---------- */
.guest-banner { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-bottom: 12px;
  background: color-mix(in srgb, var(--present) 14%, var(--surface)); border-color: color-mix(in srgb, var(--present) 45%, transparent); }
.guest-banner .gb-ico { font-size: 28px; }
.guest-banner .gb-text { flex: 1; }
.guest-banner .gb-go { font-weight: 800; color: var(--accent); white-space: nowrap; }
.account-box { position: relative; width: min(360px, 100%); }
.modal-x { position: absolute; right: 10px; top: 8px; font-size: 18px; color: var(--muted); padding: 6px; }
.acc-form { display: grid; gap: 8px; margin: 6px 0; }
.acc-form input { border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; font-size: 16px; background: var(--bg); color: var(--ink); }
.acc-form input:focus { outline: none; border-color: var(--accent); }
.acc-error { color: var(--danger); font-size: 13px; font-weight: 600; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px; }
.link.danger { color: var(--danger); font-size: 13px; }
.modal-box a { color: var(--accent); }
.shop-ico { font-size: 28px; }
.foot { text-align: center; padding: 18px 0 6px; }
.foot a { color: inherit; }

.legal { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; line-height: 1.55; }
.legal h1 { margin-top: 0; }
.legal a { color: var(--accent); }

/* ---------- popup ---------- */
.modal { opacity: 0; transition: opacity .18s; backdrop-filter: blur(3px); padding: 16px; }
.modal.open { opacity: 1; }
.modal-box { background: var(--surface); color: var(--ink); border-radius: 22px; padding: 22px 20px 16px; width: min(340px, 100%); display: grid; gap: 8px; text-align: center;
  box-shadow: 0 20px 60px rgba(10, 12, 25, .35); transform: scale(.92) translateY(10px); transition: transform .2s cubic-bezier(.2, .9, .3, 1.3); }
.modal.open .modal-box { transform: none; }
.modal-box h3 { margin: 0; font-size: 19px; }
.modal-box p { margin: 0; font-size: 14px; }
.modal-icon { font-size: 38px; line-height: 1; }
.modal-box input { border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 12px; font: inherit; font-size: 16px; background: var(--bg); color: var(--ink); text-align: center; }
.modal-box input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.modal-actions .btn[hidden] + .btn { grid-column: 1 / -1; }
.btn.danger-fill { background: var(--danger); color: #fff; border-color: transparent; }

/* ---------- Draw & Guess ---------- */
.draw-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; margin-top: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--opp) 14%, var(--surface)), var(--surface)); }
.draw-card .draw-ico { font-size: 30px; }
.draw-card .draw-text { flex: 1; }
.draw-card .draw-go { font-weight: 700; color: var(--opp); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

body.wide #app { max-width: 1240px; }
#screen-draw { background: var(--bg); }
.dg-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px 6px; }
.dg-word { flex: 1; text-align: center; min-width: 0; }
.dg-mask { font-weight: 800; font-size: 22px; letter-spacing: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 28px; font-variant-numeric: tabular-nums; }
.dg-mask.known { color: var(--accent); }
.dg-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.dg-timebar { height: 3px; background: var(--surface-2); margin: 0 12px; border-radius: 3px; overflow: hidden; }
.dg-timebar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s linear; }

.dg-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
.dg-players { display: flex; gap: 6px; overflow-x: auto; flex: none; scrollbar-width: none; }
.dg-player { display: flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 5px 8px; flex: none; font-size: 13px; transition: background .3s, border-color .3s; }
.dg-player .rank { display: none; font-weight: 800; color: var(--muted); font-size: 12px; width: 22px; }
.dg-player .pname { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.dg-player .pname b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.dg-player .gain { color: var(--correct); font-weight: 800; }
.dg-player.me { border-color: var(--accent); }
.dg-player.guessed { background: color-mix(in srgb, var(--correct) 16%, var(--surface)); border-color: var(--correct); }
.dg-player.drawing { background: color-mix(in srgb, var(--present) 18%, var(--surface)); }
.dg-player .avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.dg-stage { display: flex; flex-direction: column; gap: 8px; flex: none; }
.dg-canvas { position: relative; width: 100%; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: #fff;
  border: 1px solid var(--line); box-shadow: 0 2px 10px rgba(20, 25, 50, .06); touch-action: none; user-select: none; -webkit-user-select: none; margin: 0 auto; }
.dg-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.dg-canvas.can-draw { cursor: none; }
.dg-canvas.can-draw.picking { cursor: crosshair; }
.dg-cursor { position: absolute; left: 0; top: 0; border-radius: 50%; border: 1.5px solid rgba(0, 0, 0, .55); box-shadow: 0 0 0 1px rgba(255, 255, 255, .8); pointer-events: none; display: none; z-index: 2; will-change: transform; }
.dg-overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; padding: 12px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(4px); animation: fadeIn .25s; }
.ov-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px 20px; text-align: center; max-width: 92%; display: grid; gap: 6px; justify-items: center; box-shadow: 0 8px 30px rgba(20, 25, 50, .12); }
.ov-card h2, .ov-card h3, .ov-card p { margin: 0; }
.ov-emoji { font-size: 38px; }
.ov-emoji.pulse { animation: bob 1.2s infinite; }
.choices { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 6px; }
.choices .btn { text-transform: capitalize; font-size: 17px; padding: 10px 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff; border: 0; }
.choices .btn span { font-size: 11px; font-weight: 700; text-transform: none; opacity: .85; }
.choices .lvl-easy { background: var(--correct); }
.choices .lvl-medium { background: var(--accent); }
.choices .lvl-hard { background: var(--danger); }
.reveal-word { letter-spacing: 4px; color: var(--accent); animation: pop .4s; }
.gains { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 3px; min-width: 180px; }
.gains li { display: flex; justify-content: space-between; gap: 16px; font-size: 14px; }
.gains b { color: var(--correct); }
.podium { display: flex; align-items: flex-end; gap: 8px; margin: 8px 0; }
.pod { display: flex; flex-direction: column; align-items: center; width: 88px; font-size: 13px; }
.pod b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 88px; }
.pod i { display: block; width: 100%; border-radius: 8px 8px 0 0; background: var(--accent); margin-top: 4px; }
.pod.p1 { order: 2; } .pod.p1 i { height: 56px; background: var(--gold); }
.pod.p2 { order: 1; } .pod.p2 i { height: 38px; background: #b8bfcc; }
.pod.p3 { order: 3; } .pod.p3 i { height: 26px; background: #d69a5c; }
.medal { font-size: 26px; }

.dg-tools { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; display: grid; gap: 8px; }
.dg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.palette { display: flex; flex-wrap: wrap; gap: 5px; flex: 1; align-items: center; min-height: 26px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; padding: 0; transition: transform .1s; }
.swatch:active { transform: scale(.9); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.swatch.custom { position: relative; overflow: hidden; cursor: pointer; background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); }
.swatch.custom input { position: absolute; inset: -8px; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.recent .swatch { width: 22px; height: 22px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 2px; }
.seg button { padding: 6px 10px; border-radius: 8px; font-size: 16px; line-height: 1; }
.seg button.active { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.dg-preview { width: 40px; height: 40px; display: grid; place-items: center; background: repeating-conic-gradient(#e7e9f0 0 25%, #fff 0 50%) 0 0 / 10px 10px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.dg-preview i { display: block; border-radius: 50%; }
.slider { display: grid; gap: 2px; flex: 1; min-width: 90px; }
.slider input { width: 100%; accent-color: var(--accent); }
.dg-actions { display: flex; justify-content: space-between; gap: 8px; }

.dg-chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; flex: 1; min-height: 170px; }
.dg-log { flex: 1; overflow-y: auto; padding: 8px 10px; font-size: 14px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.dg-log .line { word-break: break-word; line-height: 1.3; }
.dg-log .system { color: var(--muted); font-size: 13px; }
.dg-log .guessed { color: var(--correct); }
.dg-log .private { color: var(--accent); }
.dg-log .close { color: var(--present); }
.dg-log .guessedChat { color: color-mix(in srgb, var(--correct) 70%, var(--ink)); }
.dg-form { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--line); }
.dg-form input { flex: 1; min-width: 0; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; font: inherit; font-size: 16px; background: var(--bg); color: var(--ink); }
.dg-form input:focus { outline: none; border-color: var(--accent); }
.dg-form input:disabled { opacity: .6; }

@media (min-width: 900px) {
  .dg-body { display: grid; grid-template-columns: 210px minmax(0, 1fr) 290px; align-items: start; overflow: hidden; height: 100%; }
  .dg-players { flex-direction: column; overflow-y: auto; max-height: 100%; }
  .dg-player { width: 100%; }
  .dg-player .rank { display: block; }
  .dg-player .pbadge { margin-left: auto; }
  .dg-canvas { width: min(100%, calc((100dvh - 250px) * 4 / 3)); }
  .dg-chat { height: 100%; min-height: 0; }
}
