:root {
  --bg: #1d2238;
  --bg2: #262c47;
  --panel: #2f365a;
  --panel2: #3a4270;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f1e7;
  --muted: #d3d1e4;
  --accent: #ffb347;
  --accent2: #ff7a59;
  --good: #5fd38d;
  --bad: #ff6b6b;
  --felt: #1f6b4a;
  --felt2: #17573c;
  --card: #fffdf8;
  --red: #d6303a;
  --black: #1c1c24;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { height: 100dvh; } /* follows Safari's toolbars on iPhone/iPad */
body {
  font-family: 'Nunito', system-ui, sans-serif;
  background: radial-gradient(circle at 20% 0%, #2c3360 0%, var(--bg) 55%) fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
}
h1, h2, h3, .brand, .btn, .room-code { font-family: 'Fredoka', 'Nunito', sans-serif; }
h1, h2, h3 { margin: 0 0 0.5em; font-weight: 600; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 1.35rem; font-weight: 700; letter-spacing: 0.2px; }
.brand-dice { font-size: 1.6rem; }
.top-room { display: flex; align-items: center; gap: 8px; }
.top-room .label { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; }
.room-code {
  background: var(--panel); border: 1px dashed var(--accent); color: var(--accent);
  border-radius: 10px; padding: 4px 12px; font-size: 1.15rem; font-weight: 700; letter-spacing: 3px; cursor: pointer;
}
.top-voice { display: flex; gap: 6px; align-items: center; }
.sidebar-toggle { position: relative; display: none; }
.badge { position: absolute; top: -4px; right: -4px; background: var(--accent2); color: #fff; border-radius: 99px; font-size: 0.7rem; padding: 1px 6px; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer;
  background: var(--panel2); color: var(--text); font-weight: 600; font-size: 1rem;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #2a1606; }
.btn.good { background: var(--good); color: #0d2a19; }
.btn.danger { background: #5b2b3a; }
.btn.big { padding: 14px 26px; font-size: 1.2rem; border-radius: 14px; }
.icon-btn { padding: 8px 11px; }
.voice-btn.on { background: var(--good); color: #0d2a19; }

/* ---------- Layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
main { flex: 1; padding: 22px; overflow: auto; min-width: 0; }
.sidebar {
  width: 320px; border-left: 1px solid var(--line); background: rgba(0, 0, 0, 0.15);
  display: flex; flex-direction: column; min-height: 0;
}
.panel { padding: 14px 16px; }
.panel h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.players-panel { border-bottom: 1px solid var(--line); }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.player-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); }
.player-list li.turn { background: rgba(255, 179, 71, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 179, 71, 0.5); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.player-list .name { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-list .offline .name { opacity: 0.5; }
.tag { font-size: 0.78rem; padding: 2px 6px; border-radius: 6px; background: var(--panel2); color: var(--muted); }
.tag.host { background: rgba(255, 179, 71, 0.2); color: var(--accent); }
.mic { font-size: 0.9rem; opacity: 0.9; }
.mic.speaking { filter: drop-shadow(0 0 6px var(--good)); }
.kick { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0 4px; }

.chat-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; min-height: 120px; }
.msg { font-size: 0.95rem; line-height: 1.35; overflow-wrap: anywhere; }
.msg .who { font-weight: 800; margin-right: 6px; }
.msg.system { color: var(--muted); font-style: italic; font-size: 0.85rem; }
.reactions { display: flex; gap: 4px; margin: 8px 0; flex-wrap: wrap; }
.reactions button { background: rgba(255, 255, 255, 0.06); border: 0; border-radius: 8px; padding: 4px 7px; cursor: pointer; font-size: 1.1rem; }
.chat-form { display: flex; gap: 6px; }
.chat-form input, .field input, .field select {
  flex: 1; min-width: 0; background: var(--bg2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font: inherit;
}

/* ---------- Home ---------- */
.home { max-width: 860px; margin: 3vh auto; text-align: center; }
.home h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin-bottom: 0.15em; }
.home .tagline { color: var(--muted); margin-bottom: 26px; font-size: 1.1rem; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; text-align: left; }
.home-card { background: var(--panel); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.code-input { text-transform: uppercase; letter-spacing: 6px; font-size: 1.4rem !important; text-align: center; font-weight: 800; }
.btn.quiet { background: transparent; border: 1px solid var(--line); }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }

/* ---------- Saved games ---------- */
.saved-games { margin-top: 22px; text-align: left; background: var(--panel); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); }
.saved-games h2 { margin: 0 0 4px; font-size: 1.25rem; }
.saved-hint { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.saved-row.mine { border-color: rgba(255, 179, 71, 0.45); }
.saved-emoji { font-size: 2rem; flex: none; }
.saved-info { flex: 1; min-width: 0; }
.saved-title { font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }
.saved-code { font-size: 0.8rem; letter-spacing: 2px; color: var(--muted); font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.saved-players { margin-top: 3px; }
.saved-players .dot { display: inline-block; width: 10px; height: 10px; margin-right: 4px; vertical-align: middle; }
.saved-when { margin-top: 3px; color: var(--muted); font-size: 0.88rem; }
.saved-actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex: none; }
.saved-busy { font-size: 0.8rem; color: var(--muted); max-width: 140px; text-align: center; }
@media (max-width: 520px) {
  .saved-row { flex-wrap: wrap; }
  .saved-actions { flex-direction: row; width: 100%; }
  .saved-actions .btn { flex: 1; }
}
.seat-notices { display: flex; flex-direction: column; gap: 10px; max-width: 1150px; margin: 0 auto; }
.seat-notices:not(:empty) { margin-bottom: 14px; }
.seat-notices.offer ~ .spectator-note, .seat-notices.offer ~ * .spectator-note { display: none; }
.seat-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; background: rgba(46, 134, 171, 0.18); border: 1px solid rgba(46, 134, 171, 0.55); padding: 12px 16px; border-radius: 12px; text-align: center; font-weight: 600; }
.seat-banner.ask { background: rgba(255, 179, 71, 0.16); border-color: rgba(255, 179, 71, 0.5); }
.seat-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.seat-buttons .dot { display: inline-block; margin-right: 6px; vertical-align: middle; }

.game-chips { display: flex; justify-content: center; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.chip { background: rgba(255, 255, 255, 0.06); border-radius: 99px; padding: 8px 16px; color: var(--muted); }

/* ---------- Lobby ---------- */
.lobby { max-width: 900px; margin: 0 auto; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.invite { background: var(--panel); border-radius: var(--radius); padding: 16px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.invite .big-code { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 2.4rem; letter-spacing: 8px; color: var(--accent); font-weight: 700; }
.game-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.game-option {
  background: var(--panel); border-radius: var(--radius); padding: 20px; cursor: pointer; text-align: left;
  border: 2px solid transparent; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px;
}
.game-option.selected { border-color: var(--accent); background: var(--panel2); }
.game-option:disabled { cursor: default; }
.game-option .emoji { font-size: 2.2rem; }
.game-option .title { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.4rem; font-weight: 600; }
.game-option .desc { color: var(--muted); font-size: 0.95rem; }
.options-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; background: var(--panel); padding: 14px 18px; border-radius: var(--radius); align-items: flex-end; }
.options-row .field { min-width: 180px; }
.wait-note { color: var(--muted); }

/* ---------- Yahtzee ---------- */
.yz { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.15fr); gap: 22px; max-width: 1150px; margin: 0 auto; align-items: start; }
.tray {
  background: radial-gradient(circle at 50% 30%, #2f7d57, var(--felt2));
  border-radius: 22px; padding: 24px; box-shadow: inset 0 0 0 6px #6b4226, inset 0 0 0 9px #8a5a36, var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 18px; position: sticky; top: 0;
}
.turn-banner { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.35rem; text-align: center; }
.turn-banner .sub { display: block; font-family: 'Nunito', system-ui, sans-serif; font-size: 0.95rem; color: #d7f0e0; }
.dice-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; min-height: 82px; }
.die {
  width: 70px; height: 70px; border-radius: 14px; background: #fffef9; border: 0; padding: 9px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  box-shadow: 0 4px 0 #c9c3b4, 0 8px 14px rgba(0, 0, 0, 0.35); cursor: pointer; position: relative;
  transition: transform 0.15s;
}
.die.blank { background: rgba(255, 255, 255, 0.18); box-shadow: none; cursor: default; }
.die.held { transform: translateY(-8px); box-shadow: 0 0 0 4px var(--accent), 0 10px 16px rgba(0, 0, 0, 0.4); }
.die.held::after { content: 'HELD'; position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 0.7rem; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
.die:disabled { cursor: default; }
.pip { width: 13px; height: 13px; border-radius: 50%; background: #23232d; place-self: center; visibility: hidden; }
.pip.on { visibility: visible; }
.die.rolling { animation: tumble 0.55s ease-out; }
@keyframes tumble {
  0% { transform: rotate(0) scale(0.7); }
  40% { transform: rotate(200deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}
.roll-area { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 6px; }
.rolls-left { display: flex; gap: 6px; }
.rolls-left span { width: 12px; height: 12px; border-radius: 50%; background: rgba(255, 255, 255, 0.25); }
.rolls-left span.on { background: var(--accent); }
.hint { color: #d7f0e0; font-size: 0.9rem; text-align: center; min-height: 1.2em; }
.log { width: 100%; font-size: 0.85rem; color: #d7f0e0; display: flex; flex-direction: column; gap: 2px; max-height: 120px; overflow: auto; }

.scorecard-wrap { background: var(--card); color: var(--black); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.scorecard { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.scorecard th, .scorecard td { padding: 6px 8px; border-bottom: 1px solid #e7e1d2; text-align: center; white-space: nowrap; }
.scorecard th:first-child, .scorecard td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.scorecard thead th { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-weight: 600; padding-top: 12px; }
.scorecard thead th.cur { background: #fff1d6; }
.scorecard td.cur { background: #fff8e9; }
.scorecard .cat-name { font-weight: 700; }
.scorecard .cat-hint { display: block; font-size: 0.72rem; color: #8a8576; font-weight: 600; }
.scorecard tr.sub td { background: #f3eee2; font-weight: 800; }
.scorecard tr.sub td:first-child { background: #f3eee2; }
.scorecard tr.total td { background: #2f365a; color: #fff; font-weight: 800; font-size: 1.05rem; }
.scorecard tr.total td:first-child { background: #2f365a; }
.pick {
  border: 2px dashed #e0a23c; background: #fff7e6; border-radius: 8px; padding: 2px 10px; cursor: pointer;
  font-weight: 800; color: #9a5a00; min-width: 42px;
}
.pick.zero { color: #a59f91; border-color: #d8d2c3; background: #faf8f2; }
.pick:hover { background: #ffe2a8; }
.ghost { color: #c0b9a8; font-style: italic; }
.scored { font-weight: 800; }

/* ---------- Cards / Oh Hell ---------- */
.oh { max-width: 1150px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.oh-info { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.info-pill { background: var(--panel); border-radius: 12px; padding: 8px 14px; display: flex; align-items: center; gap: 8px; }
.info-pill b { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.1rem; }
.table {
  background: radial-gradient(ellipse at 50% 40%, #2a8a5f, var(--felt) 60%, var(--felt2));
  border-radius: 30px; padding: 18px; box-shadow: inset 0 0 0 7px #6b4226, inset 0 0 0 10px #8a5a36, var(--shadow);
  display: flex; flex-direction: column; gap: 16px; min-height: 420px;
}
.seats { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.seat {
  background: rgba(0, 0, 0, 0.25); border-radius: 14px; padding: 10px 14px; min-width: 140px; text-align: center;
  border: 2px solid transparent; position: relative;
}
.seat.turn { border-color: var(--accent); box-shadow: 0 0 18px rgba(255, 179, 71, 0.45); }
.seat .seat-name { font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.seat .seat-stats { font-size: 0.85rem; color: #d7f0e0; margin-top: 2px; }
.seat .made { color: var(--good); font-weight: 800; }
.seat .over { color: var(--bad); font-weight: 800; }
.dealer-chip { background: #fff; color: #222; border-radius: 50%; width: 20px; height: 20px; font-size: 0.7rem; font-weight: 900; display: inline-grid; place-items: center; }
.mini-backs { display: flex; justify-content: center; margin-top: 6px; height: 22px; }
.mini-back { width: 14px; height: 20px; border-radius: 3px; background: repeating-linear-gradient(45deg, #7a2732, #7a2732 3px, #9a3542 3px, #9a3542 6px); border: 1px solid #fff; margin-left: -6px; }
.mini-back:first-child { margin-left: 0; }

.trick-area { flex: 1; display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; min-height: 170px; position: relative; }
.played { display: flex; flex-direction: column; align-items: center; gap: 6px; animation: drop 0.25s ease-out; }
.played .by { font-size: 0.85rem; font-weight: 700; }
.played.winner .card { box-shadow: 0 0 0 4px var(--accent), 0 0 24px rgba(255, 179, 71, 0.8); }
@keyframes drop { from { transform: translateY(-14px) scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
.table-msg { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.3rem; text-align: center; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }

.card {
  width: 74px; height: 106px; border-radius: 9px; background: var(--card); color: var(--black);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35); position: relative; flex: none; user-select: none; border: 0; padding: 0;
}
.card.red { color: var(--red); }
.card .corner { position: absolute; top: 5px; left: 7px; line-height: 1; text-align: center; font-weight: 800; font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; }
.card .corner .r { font-size: 1.15rem; display: block; }
.card .corner .s { font-size: 1rem; }
.card .corner.br { top: auto; left: auto; bottom: 5px; right: 7px; transform: rotate(180deg); }
.card .center { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.3rem; }
.card.small { width: 54px; height: 77px; }
.card.small .center { font-size: 1.6rem; }
.card.small .corner .r { font-size: 0.95rem; }

.hand-zone { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.my-stats { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.15rem; display: flex; gap: 14px; align-items: center; }
.hand { display: flex; justify-content: center; padding: 18px 10px 6px; flex-wrap: wrap; row-gap: 10px; }
.hand .card { margin-left: -18px; transition: transform 0.12s, opacity 0.12s; }
.hand .card:first-child { margin-left: 0; }
.hand.active .card.ok { cursor: pointer; transform: translateY(-10px); box-shadow: 0 0 0 3px var(--accent), 0 8px 14px rgba(0, 0, 0, 0.4); }
.hand.active .card.ok:hover { transform: translateY(-20px); }
.hand.active .card.no { filter: brightness(0.55) saturate(0.7); }

.bid-panel { background: rgba(0, 0, 0, 0.3); border-radius: 16px; padding: 14px 18px; text-align: center; }
.bid-panel h3 { margin-bottom: 10px; }
.bid-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.bid-buttons .btn { min-width: 48px; font-size: 1.2rem; }
.bid-note { color: #d7f0e0; font-size: 0.9rem; margin-top: 8px; }

.overlay { position: fixed; inset: 0; background: rgba(10, 12, 25, 0.7); display: grid; place-items: center; z-index: 45; padding: 16px; }
.modal { background: var(--panel); border-radius: 18px; padding: 24px; max-width: 760px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal h2 { display: flex; align-items: center; gap: 10px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
table.simple { border-collapse: collapse; width: 100%; }
table.simple th, table.simple td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: center; }
table.simple th:first-child, table.simple td:first-child { text-align: left; }
table.simple tfoot td { font-weight: 800; font-size: 1.05rem; }
.made-cell { color: var(--good); font-weight: 800; }
.miss-cell { color: var(--bad); }

.winner-box { text-align: center; padding: 10px; }
.winner-box .trophy { font-size: 4rem; }
.winner-box h2 { font-size: 2rem; }

.spectator-note { background: rgba(255, 179, 71, 0.15); border: 1px solid rgba(255, 179, 71, 0.4); padding: 10px 14px; border-radius: 12px; text-align: center; }
.game-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toasts & floaters ---------- */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #111526; border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); animation: drop 0.2s; }
.toast.error { border-color: var(--bad); }
.floaters { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.floater { position: absolute; bottom: -40px; font-size: 2.4rem; animation: floatUp 2.6s ease-out forwards; text-align: center; }
.floater small { display: block; font-size: 0.8rem; font-weight: 800; color: #fff; text-shadow: 0 1px 4px #000; }
@keyframes floatUp { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-75vh); opacity: 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .yz { grid-template-columns: 1fr; }
  .tray { position: static; }
}
@media (max-width: 860px) {
  .sidebar-toggle { display: inline-block; }
  .sidebar { position: fixed; right: 0; top: 0; bottom: 0; z-index: 35; width: min(340px, 90vw); background: var(--bg); transform: translateX(100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5); }
  main { padding: 14px; }
  .die { width: 56px; height: 56px; padding: 7px; }
  .pip { width: 10px; height: 10px; }
  .card { width: 60px; height: 86px; }
  .card .center { font-size: 1.8rem; }
  .hand .card { margin-left: -22px; }
  .top-voice { margin-left: 0; }
}

/* ---------- Uno ---------- */
.uno-table { background: radial-gradient(ellipse at 50% 40%, #3a4a8c, #27326a 60%, #1c2552); }
.ucard {
  --c: #333;
  width: 74px; height: 110px; border-radius: 10px; background: var(--c); border: 4px solid #fff;
  position: relative; flex: none; padding: 0; color: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-weight: 700; user-select: none;
}
.uc-R { --c: #e53935; } .uc-Y { --c: #f9c80e; } .uc-G { --c: #43a047; } .uc-B { --c: #1e88e5; } .uc-W { --c: #1b1b1f; }
.uc-oval {
  position: absolute; inset: 14px 8px; border-radius: 50%; background: #fff; transform: rotate(-24deg);
  display: grid; place-items: center;
}
.uc-label { transform: rotate(24deg); font-size: 1.9rem; color: var(--c); text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.15); }
.uc-W .uc-oval { background: conic-gradient(#e53935 0 25%, #1e88e5 0 50%, #f9c80e 0 75%, #43a047 0); }
.uc-W .uc-label { color: #fff; text-shadow: 0 0 4px #000, 0 0 2px #000; }
.uc-corner { position: absolute; top: 3px; left: 6px; font-size: 0.95rem; line-height: 1; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.uc-corner.br { top: auto; left: auto; bottom: 3px; right: 6px; transform: rotate(180deg); }
.uc-Y .uc-corner { color: #fff; }
.ucard.big { width: 96px; height: 142px; }
.ucard.big .uc-label { font-size: 2.5rem; }
.uc-back { --c: #1b1b1f; }
.uc-back .uc-oval { background: #e53935; }
.ucard.uc-back .uc-label { color: #fff; font-size: 1.05rem; letter-spacing: 1px; }
.ucard.glow { cursor: pointer; box-shadow: 0 0 0 4px var(--accent), 0 0 24px rgba(255, 179, 71, 0.7); }
.ucard.glow:hover { transform: translateY(-4px); }

.uno-center { display: flex; justify-content: center; align-items: center; gap: 40px; padding: 10px 0; }
.pile { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pile-label { font-size: 0.9rem; color: #dfe4ff; font-weight: 700; }
.discard { padding: 10px; border-radius: 18px; }
.ring-R { box-shadow: 0 0 0 5px #e53935, 0 0 30px #e53935; }
.ring-Y { box-shadow: 0 0 0 5px #f9c80e, 0 0 30px #f9c80e; }
.ring-G { box-shadow: 0 0 0 5px #43a047, 0 0 30px #43a047; }
.ring-B { box-shadow: 0 0 0 5px #1e88e5, 0 0 30px #1e88e5; }
.ring-W { box-shadow: 0 0 0 5px #888; }
.color-swatch { width: 18px; height: 18px; border-radius: 50%; background: var(--c); border: 2px solid #fff; display: inline-block; }
.uc-W.color-swatch { background: conic-gradient(#e53935 0 25%, #1e88e5 0 50%, #f9c80e 0 75%, #43a047 0); }
.dir-arrow { font-size: 1.5rem; line-height: 1; }

.uno-log { text-align: center; font-size: 0.9rem; color: #c8cff5; min-height: 3.6em; display: flex; flex-direction: column; gap: 2px; }
.uno-log .latest { color: #fff; font-weight: 700; }
.uno-controls { display: flex; gap: 10px; min-height: 44px; align-items: center; }
.uno-btn { background: #e53935; color: #fff; font-size: 1.3rem; padding: 10px 26px; border-radius: 99px; box-shadow: 0 4px 0 #9c1f1c; letter-spacing: 1px; }
.uno-btn.urgent { animation: pulse 0.7s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); box-shadow: 0 0 24px #ff5252; } }
.uno-flag { display: inline-block; margin-top: 6px; background: #e53935; color: #fff; font-family: 'Fredoka', 'Nunito', sans-serif; font-weight: 700; border-radius: 99px; padding: 2px 10px; }
.uno-flag.inline { margin: 0; font-size: 0.9rem; }
.catch-btn { margin-top: 8px; background: #ffb347; color: #2a1606; animation: pulse 0.6s infinite alternate; }
.mini-back.uno-back { background: #1b1b1f; border-color: #fff; position: relative; }
.mini-back.uno-back::after { content: ''; position: absolute; inset: 5px 3px; border-radius: 50%; background: #e53935; }
.uno-hand .ucard { margin-left: -20px; transition: transform 0.12s, opacity 0.12s; }
.uno-hand .ucard:first-child { margin-left: 0; }
.hand.active .ucard.ok { cursor: pointer; transform: translateY(-12px); box-shadow: 0 0 0 3px var(--accent), 0 8px 14px rgba(0, 0, 0, 0.45); }
.hand.active .ucard.ok:hover { transform: translateY(-22px); }
.hand.active .ucard.no { filter: brightness(0.5) saturate(0.6); }
.ucard.just-drawn { outline: 3px dashed #fff; outline-offset: 3px; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 16px 0; }
.color-btn { background: var(--c); color: #fff; border: 0; border-radius: 14px; padding: 26px 10px; font-family: 'Fredoka', 'Nunito', sans-serif; font-size: 1.3rem; font-weight: 700; cursor: pointer; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.color-btn:hover { filter: brightness(1.12); transform: translateY(-2px); }
@media (max-width: 860px) {
  .ucard { width: 58px; height: 88px; border-width: 3px; }
  .ucard .uc-label { font-size: 1.5rem; }
  .ucard.big { width: 78px; height: 116px; }
  .uno-center { gap: 24px; }
  .uno-hand .ucard { margin-left: -24px; }
}

/* ---------- Wahoo ---------- */
.wahoo { display: grid; grid-template-columns: minmax(300px, 680px) minmax(260px, 340px); gap: 22px; max-width: 1080px; margin: 0 auto; align-items: start; justify-content: center; }
.wahoo-board-wrap { width: 100%; }
.wahoo-board { width: 100%; height: auto; display: block; filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45)); }
.wb-wood { fill: #7a4a2a; stroke: #5b3720; stroke-width: 4; }
.wb-face { fill: #f1e3c6; }
.wb-hole { fill: #3b2a1d; stroke: rgba(0, 0, 0, 0.25); stroke-width: 1.5; }
.wb-name { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 17px; font-weight: 700; paint-order: stroke; stroke: #3d2516; stroke-width: 4px; }
.wb-name.turn { font-size: 20px; text-decoration: underline; }
.wb-trail { fill: none; stroke: rgba(60, 40, 20, 0.45); stroke-width: 4; stroke-dasharray: 2 7; stroke-linecap: round; }
.wb-marble { stroke: rgba(0, 0, 0, 0.45); stroke-width: 1.5; transition: r 0.1s; }
.wb-marble.can { cursor: pointer; stroke: #fff; stroke-width: 3; animation: marbleGlow 0.9s infinite alternate; }
.wb-marble.sel { stroke: #111; stroke-width: 4; r: 12.5; }
@keyframes marbleGlow { from { filter: drop-shadow(0 0 0 #ffb347); } to { filter: drop-shadow(0 0 7px #ffb347); } }
.wb-dest { fill: rgba(255, 179, 71, 0.35); stroke: #ff8c1a; stroke-width: 3; cursor: pointer; animation: destPulse 0.8s infinite alternate; }
.wb-dest.capture { fill: rgba(255, 82, 82, 0.35); stroke: #ff3b3b; }
@keyframes destPulse { from { stroke-opacity: 0.5; } to { stroke-opacity: 1; } }
.wahoo-panel { display: flex; flex-direction: column; gap: 14px; }
.wahoo-tray { position: static; }
.wahoo-players { background: var(--panel); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.wp { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; }
.wp.turn { background: rgba(255, 179, 71, 0.16); box-shadow: inset 0 0 0 1px rgba(255, 179, 71, 0.5); }
.wp .name { flex: 1; font-weight: 700; }
.wahoo-log { background: var(--panel); border-radius: var(--radius); padding: 10px; text-align: left; }
@media (max-width: 980px) {
  .wahoo { grid-template-columns: 1fr; }
}

/* ---------- Spades ---------- */
.card.card-back { background: repeating-linear-gradient(45deg, #7a2732, #7a2732 6px, #9a3542 6px, #9a3542 12px); border: 4px solid #fff; }

/* ---------- Hearts ---------- */
.hand.active .card.picked { transform: translateY(-28px); box-shadow: 0 0 0 4px #ff5c8a, 0 10px 16px rgba(0, 0, 0, 0.45); }
.hand.active .card.picked:hover { transform: translateY(-30px); }
.card.received::before { content: 'NEW'; position: absolute; top: -10px; right: -6px; background: #ff5c8a; color: #fff; font-size: 0.62rem; font-weight: 800; padding: 1px 5px; border-radius: 6px; z-index: 1; }

/* ---------- Rummy ---------- */
.rum-piles { gap: 30px; padding: 4px 0; }
.card.glow-card { cursor: pointer; box-shadow: 0 0 0 4px var(--accent), 0 0 22px rgba(255, 179, 71, 0.7); }
.card.glow-card:hover { transform: translateY(-4px); }
.card.empty-pile { background: rgba(0, 0, 0, 0.2); border: 2px dashed rgba(255, 255, 255, 0.3); box-shadow: none; }
.rum-melds { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; min-height: 40px; }
.rum-meld { background: rgba(0, 0, 0, 0.22); border: 2px solid transparent; border-radius: 12px; padding: 8px 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; color: inherit; }
.rum-meld.target { cursor: pointer; border-color: rgba(255, 179, 71, 0.7); }
.rum-meld.target:hover { background: rgba(255, 179, 71, 0.18); }
.rum-meld-cards { display: flex; }
.rum-meld-cards .card { margin-left: -28px; }
.rum-meld-cards .card:first-child { margin-left: 0; }
.rum-meld-owner { font-size: 0.78rem; font-weight: 800; }
.rum-controls { flex-wrap: wrap; justify-content: center; }
.mini-cards { display: flex; flex-wrap: wrap; gap: 2px; }
.card.tiny { width: 34px; height: 48px; }
.card.tiny .center { display: none; }
.card.tiny .corner.br { display: none; }
.card.tiny .corner .r { font-size: 0.8rem; }
.card.tiny .corner .s { font-size: 0.7rem; }

/* ---------- Top bar tools ---------- */
.top-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tool-btn { padding: 8px 12px; font-size: 0.95rem; }
.tool-btn[aria-pressed="true"] { background: var(--accent); color: #2a1606; }

/* ---------- Lobby: compact tiles ---------- */
.lobby { padding-bottom: 8px; }
.invite { padding: 12px 18px; margin-bottom: 16px; }
.invite .big-code { font-size: 2rem; }
.invite-label { color: var(--muted); font-weight: 700; }
.invite-text { flex: 1; min-width: 200px; }
.picker-groups { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.picker-label { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); font-weight: 800; margin-bottom: 6px; }
.game-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.game-tile {
  background: var(--panel); border: 2px solid transparent; border-radius: 14px; padding: 12px 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; box-shadow: var(--shadow);
  font: inherit; color: var(--text); transition: transform 0.1s, background 0.15s;
}
.game-tile:hover:not(:disabled) { transform: translateY(-2px); background: var(--panel2); }
.game-tile:disabled { cursor: default; }
.game-tile .emoji { font-size: 2rem; line-height: 1.2; }
.game-tile .title { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.15rem; font-weight: 600; }
.tile-players { font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.game-tile.selected { border-color: var(--accent); background: var(--panel2); box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.25), var(--shadow); }
.game-tile.unfit { opacity: 0.6; }
.game-tile.unfit .tile-players { color: #ffb3b3; }
.game-tile.unfit.selected { opacity: 1; }
.game-details { background: var(--panel); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 14px; }
.details-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.details-head .emoji { font-size: 2.4rem; }
.details-head > div { flex: 1; min-width: 200px; }
.details-head .title { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.5rem; font-weight: 600; }
.details-head .desc { color: var(--muted); }
.game-details .options-row { background: rgba(0, 0, 0, 0.15); margin: 12px 0 0; }
.start-bar {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between;
  background: rgba(29, 34, 56, 0.96); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
}
.start-note { font-weight: 700; flex: 1; min-width: 200px; }
.start-note.warn { color: #ffd5a8; }

/* ---------- Your turn alert ---------- */
.turn-alert {
  position: fixed; top: 22%; left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  background: linear-gradient(180deg, var(--accent), var(--accent2)); color: #2a1606;
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-weight: 700; font-size: 2.4rem;
  padding: 18px 40px; border-radius: 22px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.turn-alert.show { animation: turnPop 2.2s ease forwards; }
@keyframes turnPop {
  0% { opacity: 0; transform: translateX(-50%) scale(0.7); }
  12% { opacity: 1; transform: translateX(-50%) scale(1.06); }
  20% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- Rules ---------- */
.rules-modal { max-width: 640px; }
.rules-section h3 { color: var(--accent); text-transform: none; letter-spacing: 0; font-size: 1.15rem; margin: 14px 0 6px; }
.rules-section ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; font-size: 1.05rem; }

@media (max-width: 860px) {
  .top-tools { margin-left: 0; }
  .tool-btn { padding: 7px 10px; font-size: 0.9rem; }
  .game-tiles { grid-template-columns: repeat(2, 1fr); }
  .turn-alert { font-size: 1.9rem; padding: 14px 28px; }
}

.turn-alert { white-space: nowrap; }
.tool-btn .ico, .voice-btn .ico { margin-right: 5px; }
@media (max-width: 860px) {
  .topbar { gap: 8px; padding: 8px 12px; }
  .brand { font-size: 1.1rem; }
  .brand-dice { font-size: 1.3rem; }
  .top-room .label { display: none; }
  .room-code { font-size: 1rem; padding: 3px 9px; }
  .top-tools, .top-voice { gap: 5px; }
  #soundBtn .lbl { display: none; }
  #soundBtn .ico { margin-right: 0; }
  .voice-btn { padding: 7px 10px; font-size: 0.9rem; }
}

.details-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- iPhone / iPad safe areas ----------
   Keep content clear of the status bar / camera notch at the top, the rounded corners
   on the sides, and the home bar at the bottom. env() is 0 on other devices. */
html { background: var(--bg); }
.topbar {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: calc(18px + env(safe-area-inset-left, 0px));
  padding-right: calc(18px + env(safe-area-inset-right, 0px));
}
main {
  padding-left: calc(22px + env(safe-area-inset-left, 0px));
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}
.sidebar { padding-right: env(safe-area-inset-right, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.start-bar { margin-bottom: env(safe-area-inset-bottom, 0px); }
.toasts { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.overlay {
  padding: calc(16px + env(safe-area-inset-top, 0px)) calc(16px + env(safe-area-inset-right, 0px))
           calc(16px + env(safe-area-inset-bottom, 0px)) calc(16px + env(safe-area-inset-left, 0px));
}
.modal { max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
@media (max-width: 860px) {
  .topbar {
    padding-top: calc(8px + env(safe-area-inset-top, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
  }
  main {
    padding-left: calc(14px + env(safe-area-inset-left, 0px));
    padding-right: calc(14px + env(safe-area-inset-right, 0px));
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar { padding-top: env(safe-area-inset-top, 0px); }
}

/* ---------- Pinned top bar ----------
   Safari on iOS/iPadOS 26 only paints a solid band behind the status bar when the page
   has a header pinned (position: fixed) to the top; otherwise it lays a see-through fade
   over the page. So the top bar is fixed, with an opaque background, and the rest of the
   page starts below it (its height is measured by app.js into --topbar-h). */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  background: #171b2d;
}
.layout { margin-top: var(--topbar-h, 64px); }
@media (max-width: 860px) {
  .sidebar { top: var(--topbar-h, 64px); padding-top: 0; }
}

.call-rummy { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; font-weight: 800; font-size: 1.1rem; }
.call-rummy.quiet { font-weight: 600; font-size: 0.95rem; color: #ffd5a8; }

/* ---------- Yahtzee: keep player names in view ----------
   One scroll only: the page. The scorecard box is not a scroll area (overflow: clip),
   so its names row can stay pinned just under the top bar while the page scrolls.
   To fit without sideways scrolling, columns tighten up on small screens. */
.scorecard-wrap { overflow: clip; }
.scorecard thead th {
  position: sticky; z-index: 2;
  top: -22px; /* the page's top padding, so the names sit right under the top bar */
  background: var(--card);
  box-shadow: inset 0 -2px 0 #e0d8c4, 0 4px 6px -4px rgba(0, 0, 0, 0.25);
}
@media (max-width: 860px) { .scorecard thead th { top: -14px; } }
.scorecard thead th.cur { background: #fff1d6; }
.scorecard td:first-child { position: static; }
.scorecard thead th:first-child { left: auto; z-index: 3; }
.scorecard thead th:not(:first-child) { max-width: 7em; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .scorecard th, .scorecard td { padding: 6px 4px; }
  .scorecard thead th:not(:first-child) { max-width: 4.2em; font-size: 0.85rem; }
  .scorecard .cat-name { font-size: 0.88rem; }
  .scorecard .cat-hint { font-size: 0.66rem; }
  .pick { min-width: 0; padding: 2px 5px; }
}
@media (max-width: 600px) {
  /* 6+ players on a phone: drop the little hints under the totals to save width */
  .scorecard.many .cat-hint { display: none; }
  .scorecard.many th, .scorecard.many td { padding: 5px 2px; font-size: 0.82rem; }
  .scorecard.many thead th:not(:first-child) { max-width: 3.2em; font-size: 0.75rem; }
}

/* Dice and scorecard side by side only when there's room; otherwise stack them.
   (Measured on the game area itself.) */
main { container-type: inline-size; container-name: gamearea; }
.yz { grid-template-columns: minmax(250px, 0.9fr) minmax(0, 1.15fr); }
@container gamearea (max-width: 700px) {
  .yz { grid-template-columns: 1fr; }
  .yz .tray { position: static; }
}
.yz > * { min-width: 0; }
@media (max-width: 900px) {
  .scorecard td:first-child, .scorecard th:first-child { white-space: normal; min-width: 5.5em; }
}
@media (max-width: 600px) {
  .scorecard.many td:first-child { min-width: 4.6em; font-size: 0.78rem; }
  .scorecard.many .cat-name { font-size: 0.78rem; }
  .scorecard.many td { font-size: 0.8rem; }
}
@media (max-width: 900px) and (max-height: 500px) {
  /* phone held sideways with many players */
  .scorecard.many th, .scorecard.many td { padding: 4px 3px; }
  .scorecard.many .cat-hint { display: none; }
  .scorecard.many thead th:not(:first-child) { max-width: 4em; font-size: 0.8rem; }
}
@media (max-width: 600px) {
  .scorecard.many th, .scorecard.many td { padding: 4px 1px; }
  .scorecard.many td:first-child { min-width: 4.2em; padding-left: 5px; font-size: 0.74rem; }
  .scorecard.many .cat-name { font-size: 0.74rem; }
  .scorecard.many thead th:not(:first-child) { max-width: 2.7em; font-size: 0.7rem; }
  .scorecard.many tr.total td { font-size: 0.9rem; }
}

/* Game name in the top bar while playing */
.brand.in-game { color: var(--accent); }
@media (max-width: 860px) { .brand.in-game { font-size: 1.15rem; } }

/* ---------- Jacktionary ---------- */
.jk-main { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
.jk-play { display: flex; flex-direction: column; gap: 12px; align-items: center; min-width: 0; }
.jk-msg { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.3rem; text-align: center; }
.jk-board-wrap { width: 100%; max-width: max(300px, min(640px, calc(100dvh - var(--topbar-h, 70px) - 360px))); container-type: inline-size; }
.jk-board {
  display: grid; grid-template-columns: repeat(15, 1fr); gap: 2px; padding: 6px;
  background: #1d5b4a; border-radius: 12px; border: 4px solid #6b4a2b; box-shadow: var(--shadow);
}
.jk-cell { aspect-ratio: 1; background: #e9e2c8; border-radius: 3px; display: grid; place-items: center; position: relative; min-width: 0; }
.jk-cell.p-TW { background: #e4572e; }
.jk-cell.p-DW { background: #f4a6a0; }
.jk-cell.p-TL { background: #2e86ab; }
.jk-cell.p-DL { background: #a6d4ec; }
.jk-cell.drop { cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 179, 71, 0.9); }
.jk-cell.drop:hover { filter: brightness(1.08); }
.jk-prem { font-size: 2.1cqw; font-weight: 800; color: rgba(0, 0, 0, 0.55); letter-spacing: -0.5px; }
.p-TW .jk-prem, .p-TL .jk-prem { color: rgba(255, 255, 255, 0.92); }
.jk-prem.star { font-size: 4cqw; color: #8a2a1d; }

.jk-tile {
  position: relative; width: 100%; height: 100%; border-radius: 4px; display: grid; place-items: center;
  background: linear-gradient(180deg, #fbe7b5, #f1d08b); color: #3b2508; box-shadow: 0 1px 0 #b98d3f, inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; user-select: none;
}
.jk-board .jk-letter { font-size: 3.6cqw; font-weight: 700; line-height: 1; }
.jk-board .jk-val { position: absolute; right: 6%; bottom: 3%; font-size: 1.6cqw; font-weight: 700; }
.jk-tile.blank .jk-letter { color: #9c4a12; }
.jk-board .jk-tile.recent { background: linear-gradient(180deg, #fff3a8, #ffd75e); box-shadow: 0 0 0 2px #ffb347; }
.jk-board .jk-tile.mine { background: linear-gradient(180deg, #c9f2d6, #8fdcaa); box-shadow: 0 0 0 2px #2e9d5b; cursor: pointer; }

.jk-hand { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.jk-rack { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; min-height: 60px; padding: 8px 12px; background: #6b4a2b; border-radius: 12px; box-shadow: var(--shadow); }
.jk-rack .jk-tile { width: 52px; height: 52px; cursor: pointer; transition: transform 0.12s; }
.jk-rack .jk-letter { font-size: 1.8rem; font-weight: 700; }
.jk-rack .jk-val { position: absolute; right: 5px; bottom: 2px; font-size: 0.8rem; font-weight: 800; }
.jk-rack .jk-tile.picked { transform: translateY(-8px); box-shadow: 0 0 0 3px #ffb347, 0 6px 10px rgba(0, 0, 0, 0.35); }
.jk-controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.jk-preview { font-weight: 800; font-size: 1.1rem; text-align: center; min-height: 1.4em; }
.jk-preview.good { color: var(--good); }
.jk-preview.bad { color: var(--bad); }
.jk-preview.muted { color: var(--muted); font-weight: 600; }

.jk-side { display: flex; flex-direction: column; gap: 12px; }
.jk-scores { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.jk-score { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.jk-score.turn { background: rgba(255, 179, 71, 0.18); box-shadow: inset 3px 0 0 var(--accent); }
.jk-score .jk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.jk-score b { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.25rem; }
.jk-log { background: var(--panel); border-radius: var(--radius); padding: 10px 12px; font-size: 0.9rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.jk-log .latest { color: var(--text); font-weight: 700; }
.jk-banner { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: center; background: rgba(255, 179, 71, 0.15); border: 1px solid rgba(255, 179, 71, 0.5); border-radius: 12px; padding: 10px 14px; font-weight: 700; text-align: center; }
.jk-banner-btns { display: flex; gap: 8px; }
.jk-timer.low { background: #7a2630; animation: pulse 0.7s infinite alternate; }
.jk-letters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.jk-letter-btn { font-family: 'Fredoka', 'Nunito', system-ui, sans-serif; font-size: 1.4rem; padding: 10px 0; }
.jk-blank-modal { max-width: 460px; }

@container gamearea (max-width: 700px) {
  .jk-board-wrap { max-width: max(300px, min(640px, calc(100dvh - var(--topbar-h, 70px) - 400px))); }
  .jk-main { grid-template-columns: 1fr; }
  .jk-side { order: -1; }
  .jk-scores { flex-direction: row; flex-wrap: wrap; padding: 6px; }
  .jk-score { flex: 1 1 140px; }
  .jk-log { display: none; }
}
@media (max-width: 520px) {
  .jk .oh-info { gap: 6px; }
  .jk .oh-info .info-pill { padding: 5px 10px; font-size: 0.9rem; }
  .jk .jk-mode { display: none; }
  .jk-msg { font-size: 1.05rem; }
  .jk-play { gap: 8px; }
  .jk-score { padding: 3px 6px; flex: 1 1 120px; }
  .jk-score b { font-size: 1.05rem; }
  .jk-rack { gap: 5px; padding: 6px; }
  .jk-rack .jk-tile { width: 42px; height: 42px; }
  .jk-rack .jk-letter { font-size: 1.45rem; }
  .jk-board { gap: 1px; padding: 3px; border-width: 3px; }
  .jk-controls .btn { padding: 9px 12px; }
}

/* ---------- Bots ---------- */
.bot-box { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.bot-head { font-weight: 800; font-size: 1.05rem; }
.bot-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bot-btn { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 8px; text-align: center; }
.bot-btn small { font-weight: 500; font-size: 0.78rem; color: var(--muted); line-height: 1.2; }
.bot-btn.easy { border-bottom: 3px solid #76b041; }
.bot-btn.normal { border-bottom: 3px solid #f2a541; }
.bot-btn.hard { border-bottom: 3px solid #e4572e; }
.bot-list { display: flex; flex-wrap: wrap; gap: 8px; }
.bot-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-weight: 700; }
.bot-chip .kick { position: static; opacity: 1; }
.tag.lvl-easy { background: rgba(118, 176, 65, 0.25); }
.tag.lvl-normal { background: rgba(242, 165, 65, 0.25); }
.tag.lvl-hard { background: rgba(228, 87, 46, 0.3); }
@media (max-width: 520px) { .bot-buttons { grid-template-columns: 1fr; } }
