/* ============================================================
   TeamUp: dark glass UI
   ============================================================ */
:root {
  --bg: #0b0820;
  --bg-2: #15103a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --surface-3: rgba(255, 255, 255, 0.16);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f3ff;
  --muted: #a69fcc;
  --accent: #ff4fa3;
  --accent-2: #ffb547;
  --violet: #7c5cff;
  --cyan: #22d3ee;
  --good: #34d399;
  --bad: #fb7185;
  --grad: linear-gradient(120deg, #7c5cff 0%, #ff4fa3 50%, #ffb547 100%);
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.6);
  --font-display: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: rgba(255, 79, 163, 0.4); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.error { color: var(--bad); min-height: 1.2em; margin: 6px 0 0; font-weight: 600; font-size: 0.9rem; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.02em; margin: 0; }

/* Animated background */
.backdrop { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(1200px 700px at 80% -10%, #2a1670 0%, transparent 60%), var(--bg); }
.backdrop i { position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(90px); opacity: 0.35; animation: float 22s ease-in-out infinite; }
.backdrop i:nth-child(1) { background: #7c5cff; left: -12vmax; top: -10vmax; }
.backdrop i:nth-child(2) { background: #ff4fa3; right: -14vmax; top: 20vh; animation-delay: -7s; }
.backdrop i:nth-child(3) { background: #22d3ee; left: 20vw; bottom: -22vmax; opacity: 0.22; animation-delay: -14s; }
@keyframes float { 50% { transform: translate(6vmax, 4vmax) scale(1.08); } }

.glass {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
}

.screen { display: none; height: 100%; }
.screen.active { display: flex; }

.brand { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.03em; }
.brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Buttons & controls ---------- */
.btn {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 18px; font-weight: 700;
  background: var(--surface-2); color: var(--text);
  transition: transform 0.12s ease, background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: var(--grad); border: 0; color: #fff;
  box-shadow: 0 10px 30px -10px rgba(255, 79, 163, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 14px 34px -10px rgba(255, 79, 163, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn.big { width: 100%; padding: 15px 18px; font-size: 1.05rem; border-radius: 16px; }
.btn.small { padding: 7px 12px; font-size: 0.88rem; border-radius: 12px; }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(251, 113, 133, 0.18); border-color: rgba(251, 113, 133, 0.4); color: #ffd1d9; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; transition: background 0.2s, transform 0.12s;
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.94); }
.link-btn { background: none; border: 0; color: var(--muted); font-weight: 600; font-size: 0.85rem; text-decoration: underline; text-underline-offset: 3px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.8rem; font-weight: 600; color: var(--muted); }

input:not([type=checkbox]):not([type=color]):not([type=range]), select, textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.25); outline: none; transition: border 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: rgba(255, 79, 163, 0.7); box-shadow: 0 0 0 4px rgba(255, 79, 163, 0.15); }
textarea { resize: vertical; min-height: 70px; }
.field { display: block; text-align: left; }
.field > span { display: block; font-weight: 600; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

/* segmented control */

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 46px; height: 26px; border-radius: 999px; background: rgba(255, 255, 255, 0.15); position: relative; transition: background 0.2s; flex-shrink: 0; }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.2s cubic-bezier(.3, 1.4, .6, 1); }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(20px); }
.switch input:disabled + .track { opacity: 0.5; }

/* stepper */

/* ---------- Home ---------- */
#screen-home { flex-direction: column; overflow-y: auto; }
.site-head { display: flex; justify-content: space-between; align-items: center; padding: 22px clamp(16px, 4vw, 48px); }
.head-meta { color: var(--muted); font-size: 0.88rem; }
.home { flex: 1; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: clamp(24px, 4vw, 64px); align-items: center; padding: 0 clamp(16px, 4vw, 48px) 40px; max-width: 1240px; width: 100%; margin: 0 auto; }
.eyebrow { display: inline-block; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.85rem; font-weight: 600; margin-bottom: 18px; }
.hero h1 { font-size: clamp(2.6rem, 6vw, 4.8rem); line-height: 0.98; font-weight: 800; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { color: var(--muted); font-size: 1.12rem; line-height: 1.55; max-width: 540px; margin: 20px 0 28px; }
.game-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 600px; }
.game-tile { position: relative; padding: 16px; border-radius: 20px; border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column; gap: 2px; min-height: 116px; justify-content: flex-end; animation: rise 0.6s both; }
.game-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.game-tile:nth-child(2) { animation-delay: 0.08s; }
.game-tile:nth-child(3) { animation-delay: 0.16s; }
.game-tile:nth-child(4) { animation-delay: 0.24s; }
.game-tile:nth-child(5) { animation-delay: 0.32s; }
.game-tile .tile-art { position: absolute; top: 10px; right: 12px; font-size: 2.6rem; filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.35)); transition: transform 0.3s; }
.game-tile:hover .tile-art { transform: rotate(-8deg) scale(1.1); }
.game-tile small { color: rgba(255, 255, 255, 0.75); }
.t-pict { background: linear-gradient(160deg, rgba(255, 79, 163, 0.45), rgba(124, 92, 255, 0.25)); }
.t-tel { background: linear-gradient(160deg, rgba(34, 211, 238, 0.4), rgba(124, 92, 255, 0.25)); }
.t-kart { background: linear-gradient(160deg, rgba(255, 181, 71, 0.45), rgba(255, 79, 163, 0.25)); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
/* 4+ games: three per row, and a short last row stretches to fill it */
@media (min-width: 561px) {
  .game-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); max-width: 640px; }
  .game-tile { grid-column: span 2; }
  .game-tile:last-child:nth-child(3n + 2), .game-tile:nth-last-child(2):nth-child(3n + 1) { grid-column: span 3; min-height: 112px; }
  .game-tile:last-child:nth-child(3n + 1) { grid-column: span 6; min-height: 100px; }
  .game-tile:nth-child(4) { animation-delay: 0.24s; }
  .game-tile:nth-child(5) { animation-delay: 0.32s; }
}

.join-card { padding: 26px; display: flex; flex-direction: column; gap: 14px; max-width: 420px; width: 100%; justify-self: end; animation: rise 0.6s 0.1s both; }
.avatar-picker { display: flex; align-items: center; justify-content: center; gap: 14px; }
.avatar-big { width: 116px; height: 116px; border-radius: 50%; border: 0; padding: 0; background: none; transition: transform 0.25s cubic-bezier(.3, 1.4, .6, 1); }
.avatar-big:hover { transform: scale(1.05) rotate(-3deg); }
.avatar-big .avatar-svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.45)); }
.join-card .link-btn { align-self: center; margin-top: -6px; }
.divider { position: relative; text-align: center; color: var(--muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.divider::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.divider span { position: relative; background: #1a1340; padding: 0 10px; border-radius: 6px; }
.code-boxes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.code-boxes input { text-align: center; font-family: var(--font-display); font-size: 1.7rem !important; font-weight: 800; text-transform: uppercase; padding: 10px 0 !important; }

/* ---------- Room layout ---------- */
#screen-room { flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 18px; }
.room-code { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); transition: background 0.2s; }
.room-code:hover { background: var(--surface-2); }
.room-code small { color: var(--muted); font-weight: 600; }
.room-code b { font-family: var(--font-display); font-size: 1.25rem; letter-spacing: 0.18em; }
.copy-hint { font-size: 0.8rem; font-weight: 600; padding: 5px 9px; border-radius: 10px; background: var(--grad); color: #fff; }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.room-body { flex: 1; display: flex; gap: 14px; padding: 0 14px 14px; min-height: 0; }
#main { flex: 1; min-width: 0; min-height: 0; position: relative; }
.view { display: none; height: 100%; }
.view.active { display: block; animation: fade 0.3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
#side { width: 310px; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.in-lobby .side-players { display: none; }

.side-players { padding: 14px; max-height: 42%; display: flex; flex-direction: column; min-height: 0; }
.side-head, .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.side-head h3 { font-size: 1.05rem; }
#player-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
#player-list li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 12px; font-size: 0.93rem; transition: background 0.2s; }
#player-list li.me { background: var(--surface-2); }
#player-list li.offline { opacity: 0.4; }
#player-list li.guessed { background: rgba(52, 211, 153, 0.16); }
#player-list li.drawing { background: rgba(255, 181, 71, 0.16); }
.av { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; display: inline-block; }
.av .avatar-svg { width: 100%; height: 100%; display: block; }
.av.team { box-shadow: 0 0 0 2px var(--team); }
#player-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#player-list .score { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
#player-list .kick { border: 0; background: none; color: var(--muted); padding: 0 4px; opacity: 0; transition: opacity 0.2s; }
#player-list li:hover .kick { opacity: 1; }
.tag { font-size: 0.7rem; font-weight: 700; background: rgba(255, 181, 71, 0.2); color: var(--accent-2); border-radius: 6px; padding: 2px 6px; }

.chat { flex: 1; display: flex; flex-direction: column; min-height: 180px; overflow: hidden; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px; font-size: 0.92rem; display: flex; flex-direction: column; gap: 6px; }
.chat-log .msg { display: flex; gap: 8px; align-items: flex-start; animation: rise 0.25s both; }
.chat-log .msg .av { width: 24px; height: 24px; margin-top: 1px; }
.chat-log .msg .body { min-width: 0; word-wrap: break-word; line-height: 1.35; }
.chat-log .msg b { margin-right: 4px; }
.chat-log .sys { color: var(--muted); font-size: 0.86rem; justify-content: center; text-align: center; }
.chat-log .good { color: #a7f3d0; background: rgba(52, 211, 153, 0.14); border-radius: 10px; padding: 5px 10px; font-weight: 600; }
.chat-log .secret .body { background: rgba(52, 211, 153, 0.14); border-radius: 8px; padding: 2px 8px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form input { padding: 10px 12px !important; }
.chat-form .send { width: 42px; flex-shrink: 0; border-radius: 12px; border: 0; background: var(--grad); color: #fff; font-size: 1rem; }

/* ---------- Lobby ---------- */
.lobby { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 0.85fr); gap: 14px; height: calc(100% - 92px); min-height: 0; }
.panel { padding: 20px; overflow-y: auto; min-height: 0; }
/* Lobby panels scroll inside the glass, and the content fades at the edges as a scroll cue. */
.lobby .panel { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; -webkit-mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 16px), transparent); mask-image: linear-gradient(transparent, #000 16px, #000 calc(100% - 16px), transparent); }
.panel h2 { font-size: 1.35rem; }
.game-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.game-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.game-card {
  position: relative; display: flex; flex-direction: row; align-items: center; gap: 12px; text-align: left; padding: 12px 40px 12px 14px; min-height: 84px; border-radius: 18px;
  border: 1px solid var(--line); background: var(--surface); transition: transform 0.2s, border 0.2s, background 0.2s; overflow: hidden;
}
.game-card:hover:not(:disabled) { transform: translateY(-3px); }
.game-card .gc-art { font-size: 2.2rem; }
.game-card b { font-family: var(--font-display); font-size: 1.12rem; }
.game-card small { color: var(--muted); font-size: 0.82rem; line-height: 1.35; display: block; margin-top: 2px; }
.game-card.selected { border-color: transparent; background: linear-gradient(var(--bg-2), var(--bg-2)) padding-box, var(--grad) border-box; border: 2px solid transparent; }
.game-card.selected::after { content: "✓"; position: absolute; top: 10px; right: 12px; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-weight: 800; font-size: 0.8rem; }
.game-card:disabled { cursor: default; }
.settings-head { margin: 4px 0 12px; }
.settings-head h3 { font-size: 1.05rem; color: var(--muted); font-family: var(--font); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.78rem; }
/* segmented control: equal-width buttons that fill their slot */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border-radius: 13px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); min-width: 0; }
.seg button { min-width: 0; border: 0; background: transparent; padding: 6px 6px; border-radius: 10px; font-weight: 600; font-size: 0.82rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background 0.2s, color 0.2s, box-shadow 0.2s; }
.seg button:hover:not(:disabled):not(.on) { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.seg button.on { background: #f5f3ff; color: #160f35; box-shadow: 0 6px 16px -8px rgba(255, 255, 255, 0.6); }
.seg button:disabled { cursor: default; }
.seg button:disabled:not(.on) { opacity: 0.55; }
/* stepper: compact, sized to its content */
.stepper { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: 13px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); flex-shrink: 0; }
.stepper button { width: 32px; height: 32px; border-radius: 10px; border: 0; background: rgba(255, 255, 255, 0.08); font-size: 1.05rem; font-weight: 700; line-height: 1; transition: background 0.2s; }
.stepper button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.stepper b { min-width: 40px; text-align: center; font-variant-numeric: tabular-nums; font-size: 1rem; }

/* settings layout */
.settings-body { display: flex; flex-direction: column; gap: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.setting { min-width: 0; border-radius: 16px; background: rgba(0, 0, 0, 0.16); border: 1px solid var(--line); }
.setting.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 14px; min-height: 60px; }
.setting.row .seg { flex: 0 1 auto; }
.setting.block { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 10px; padding: 14px; }
.setting.t-slider { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px 12px; }
.setting.t-slider .slider { grid-column: 1 / -1; }
.lbl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lbl b { font-size: 0.92rem; font-weight: 600; }
.lbl small { font-size: 0.76rem; color: var(--muted); line-height: 1.3; }
.setting.block > .lbl b { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.slider-val { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; padding: 2px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); font-variant-numeric: tabular-nums; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 999px; outline: none; cursor: pointer;
  background: linear-gradient(90deg, #7c5cff, #ff4fa3 calc(var(--pct) * 0.9), #ffb547 var(--pct), rgba(255, 255, 255, 0.12) var(--pct)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 0 5px rgba(255, 79, 163, 0.25); }
.slider::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 0; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45), 0 0 0 5px rgba(255, 79, 163, 0.25); }
.slider:disabled { cursor: default; opacity: 0.7; }

/* option cards: icon tile + text, top-aligned, equal height */
.option-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.option-card { display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 10px; text-align: left; padding: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); position: relative; transition: border 0.2s, background 0.2s, transform 0.15s; }
.option-card:hover:not(:disabled) { transform: translateY(-2px); background: rgba(255, 255, 255, 0.06); }
.option-card .oc-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-size: 1.25rem; background: rgba(255, 255, 255, 0.07); }
.option-card .oc-text { display: flex; flex-direction: column; gap: 3px; }
.option-card b { font-size: 0.95rem; }
.option-card small { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.option-card.on { border-color: transparent; background: linear-gradient(rgba(40, 24, 86, 0.95), rgba(40, 24, 86, 0.95)) padding-box, var(--grad) border-box; border: 1.5px solid transparent; }
.option-card.on .oc-icon { background: var(--grad); }
.option-card.on::after { content: "✓"; position: absolute; top: 10px; right: 10px; width: 20px; height: 20px; border-radius: 50%; background: var(--grad); display: grid; place-items: center; font-size: 0.7rem; font-weight: 800; }
.option-card:disabled { cursor: default; }

/* "More options" disclosure */
.adv-toggle { display: flex; align-items: center; gap: 8px; width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px dashed rgba(255, 255, 255, 0.18); background: transparent; color: var(--muted); font-weight: 600; transition: background 0.2s, color 0.2s; }
.adv-toggle:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.adv-toggle small { padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-size: 0.75rem; }
.adv-toggle i { margin-left: auto; font-style: normal; transition: transform 0.2s; }
.adv-toggle.open i { transform: rotate(180deg); }

/* map overview + thumbnails */
.map-overview { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); }
.mo-art { position: relative; aspect-ratio: 16 / 10; background: var(--art) center / cover no-repeat, linear-gradient(135deg, #2a1c5c, #3b1452); }
.mo-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 60%, rgba(12, 8, 30, 0.6)); }
.mo-art .map-inset { position: absolute; right: 8px; bottom: 8px; width: 32%; max-width: 150px; aspect-ratio: 1; z-index: 1; display: block; }
.mo-art .map-outline { position: absolute; right: 10px; bottom: 10px; width: 28%; aspect-ratio: 1; z-index: 1; padding: 6px; border-radius: 12px; background: rgba(12, 8, 30, 0.55); backdrop-filter: blur(6px); }
.mo-info { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.mo-kicker { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.mo-info h4 { margin: 0; font-family: var(--font-display); font-size: 1.4rem; }
.mo-info p { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.mo-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mo-chips span { font-size: 0.75rem; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); white-space: nowrap; }
.map-outline { display: block; }
.map-outline .mo-road-edge { fill: none; stroke: rgba(255, 255, 255, 0.95); stroke-linejoin: round; }
.map-outline .mo-road { fill: none; stroke: #2b2350; stroke-linejoin: round; }
.map-outline .mo-start { fill: #ffb547; stroke: #fff; stroke-width: 0.8; }
.map-outline .mo-floor { fill: rgba(255, 255, 255, 0.1); stroke: rgba(255, 255, 255, 0.9); stroke-width: 1.4; }
.map-outline .mo-lava { fill: #ff6a1a; }
.map-outline .mo-block { fill: rgba(255, 255, 255, 0.55); }
.map-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.map-thumb { position: relative; padding: 0; border-radius: 12px; overflow: hidden; border: 1.5px solid var(--line); background: var(--art) center / cover no-repeat, #241a4a; aspect-ratio: 16 / 10; transition: transform 0.15s, border 0.2s; }
.map-thumb:hover:not(:disabled) { transform: translateY(-2px); }
.map-thumb::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 35%, rgba(8, 5, 25, 0.85)); }
.map-thumb .mt-name { position: absolute; left: 8px; right: 8px; bottom: 6px; text-align: left; font-size: 0.78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-thumb.on { border-color: transparent; box-shadow: 0 0 0 2px #ff4fa3, 0 8px 24px -10px rgba(255, 79, 163, 0.8); }
.map-thumb:disabled { cursor: default; }
/* the weekly arena: no picture, its look's colours and a big map instead */
.mo-art.weekly, .map-thumb.weekly { background: radial-gradient(120% 90% at 50% 110%, rgba(255, 255, 255, 0.14), transparent 60%), var(--wk, linear-gradient(135deg, #2a1c5c, #3b1452)); }
.wk-keep { --wk: linear-gradient(160deg, #3f7fc7 0%, #8fc1e8 45%, #4f8c3a 46%, #2f5a24 100%); }
.wk-graveyard { --wk: linear-gradient(160deg, #0d0a2a 0%, #3a2f6e 50%, #253325 51%, #141c14 100%); }
.wk-ruins { --wk: linear-gradient(160deg, #3f8fde 0%, #f3d9ae 45%, #d6ae76 46%, #9a6f3e 100%); }
.wk-glacier { --wk: linear-gradient(160deg, #6f9fdc 0%, #e3edf8 45%, #dce8f2 46%, #8eaac4 100%); }
.wk-basalt { --wk: linear-gradient(160deg, #40161a 0%, #ff8a52 45%, #3a2f2b 46%, #1a1412 100%); }
.mo-art.weekly .map-inset { right: 50%; bottom: 7%; transform: translateX(50%); width: 54%; max-width: 230px; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.45)); }
.mo-art.weekly::after { background: linear-gradient(90deg, transparent 70%, rgba(12, 8, 30, 0.45)); }
/* ...and once its picture is drawn (app.js, weeklyArtFor), like every other map */
.mo-art.weekly.has-art, .map-thumb.weekly.has-art { background: var(--art) center / cover no-repeat, #241a4a; }
.mo-art.weekly.has-art .map-inset { right: 8px; bottom: 8px; transform: none; width: 32%; max-width: 150px; filter: none; }
.mo-art.weekly.has-art::after { background: linear-gradient(90deg, transparent 60%, rgba(12, 8, 30, 0.6)); }
.mo-ribbon { position: absolute; left: 10px; top: 10px; z-index: 2; padding: 4px 10px; border-radius: 999px; background: linear-gradient(90deg, #ff4fa3, #ffb86b); color: #1a0b20; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; box-shadow: 0 6px 16px -6px rgba(255, 79, 163, 0.8); }
.map-thumb .mt-tag { position: absolute; left: 6px; top: 6px; z-index: 1; padding: 1px 7px; border-radius: 999px; background: linear-gradient(90deg, #ff4fa3, #ffb86b); color: #1a0b20; font-size: 0.66rem; font-weight: 800; }

/* item picker */
.item-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.item-pick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 0.76rem; font-weight: 600; color: var(--muted); transition: background 0.2s, opacity 0.2s, transform 0.15s; }
.item-pick .item-icon { width: 36px; height: 36px; filter: grayscale(1) opacity(0.45); transition: filter 0.2s; }
.item-pick.on { color: var(--text); background: rgba(124, 92, 255, 0.16); border-color: rgba(124, 92, 255, 0.5); }
.item-pick.on .item-icon { filter: none; }
.item-pick:hover:not(:disabled) { transform: translateY(-2px); }
.item-icon { display: block; }

/* people */
.person { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 16px; background: rgba(0, 0, 0, 0.18); text-align: center; position: relative; }
.person.enter, .team-col .member.enter { animation: rise 0.35s both; }
.person.offline, .team-col .member.offline { opacity: 0.45; }
.person .crown { position: absolute; top: 4px; right: 8px; font-style: normal; font-size: 0.85rem; }
.team-col { border-radius: 18px; padding: 12px; background: rgba(0, 0, 0, 0.18); border: 1px solid var(--line); border-top: 4px solid var(--team); cursor: pointer; transition: background 0.2s; }
.team-col.mine { background: rgba(255, 255, 255, 0.06); }
.team-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.team-row .seg { width: auto; }

.me-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 18px; background: var(--surface-2); margin-bottom: 18px; }
.me-card .av { width: 54px; height: 54px; cursor: pointer; transition: transform 0.2s; }
.me-card .av:hover { transform: scale(1.06) rotate(-4deg); }
.me-card input { padding: 9px 12px !important; width: 100%; }
.me-card .me-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.me-card .me-info small { color: var(--muted); font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.people { display: grid; gap: 10px; }
.people.solo { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
.person .av { width: 52px; height: 52px; }
.person span { font-size: 0.85rem; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person.me { background: rgba(255, 79, 163, 0.14); }
.team-col:hover { background: rgba(255, 255, 255, 0.06); }
.team-col h4 { margin: 0 0 8px; display: flex; justify-content: space-between; align-items: center; color: var(--team); font-family: var(--font-display); font-size: 1.05rem; }
.team-col .members { display: flex; flex-wrap: wrap; gap: 6px; }
.team-col .member { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 0.85rem; font-weight: 600; }
.team-col .member .av { width: 24px; height: 24px; }
.team-col .join { font-size: 0.75rem; color: var(--muted); font-weight: 600; font-family: var(--font); }

.start-bar { display: flex; align-items: center; justify-content: flex-end; gap: 14px; height: 78px; padding-top: 14px; }
.start-bar .btn.big { width: auto; min-width: 240px; }
.start-bar .error { margin: 0 auto 0 0; }

/* avatar modal */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(5, 3, 15, 0.6); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; animation: fade 0.2s; }
.modal-card { width: min(620px, 100%); max-height: 90vh; overflow-y: auto; padding: 20px; background: rgba(28, 20, 66, 0.9); }
.avatar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.avatar-grid button { border: 2px solid transparent; border-radius: 50%; padding: 4px; background: none; aspect-ratio: 1; transition: transform 0.2s, border 0.2s; }
.avatar-grid button:hover { transform: scale(1.08); }
.avatar-grid button.on { border-color: var(--accent); }
.avatar-grid .avatar-svg { width: 100%; height: 100%; display: block; }

/* ---------- Results ---------- */
.results { position: relative; max-width: 760px; margin: 0 auto; padding: 26px; max-height: 100%; overflow-y: auto; text-align: center; }
.results h2 { font-size: 2rem; margin-bottom: 18px; }
.results-teams { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-bottom: 18px; }
.team-score small { display: block; font-size: 0.7rem; font-weight: 600; opacity: 0.7; }
.team-score { flex: 1; min-width: 130px; border-radius: 18px; padding: 14px; background: rgba(0, 0, 0, 0.2); border-top: 4px solid var(--team); }
.team-score b { display: block; font-family: var(--font-display); font-size: 2rem; }
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.results-label { width: 100%; text-align: center; font-weight: 700; margin-bottom: 6px; }
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 10px 0 22px; min-height: 40px; }
.podium .step { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 150px; animation: rise 0.6s both; }
.podium .step .av { width: 74px; height: 74px; }
.podium .step.first .av { width: 96px; height: 96px; }
.podium .step .block { width: 100%; border-radius: 16px 16px 6px 6px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding-top: 10px; font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; }
.podium .step.first .block { height: 130px; background: linear-gradient(180deg, #ffd166, #f59e0b); color: #4a2a00; }
.podium .step.second .block { height: 96px; background: linear-gradient(180deg, #e5e7eb, #9ca3af); color: #1f2937; }
.podium .step.third .block { height: 74px; background: linear-gradient(180deg, #fdba74, #c2410c); color: #3b1203; }
.podium .step .nm { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .step .pts { font-size: 0.78rem; color: var(--muted); font-weight: 600; white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.podium .step.first { animation-delay: 0.25s; }
.podium .step.third { animation-delay: 0.1s; }
.results-players { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; display: grid; gap: 6px; }
.results-players li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.18); }
.results-players .rank { width: 26px; color: var(--muted); font-weight: 700; }
.results-players .nm { flex: 1; font-weight: 600; }
.results-players .extra { color: var(--muted); font-size: 0.85rem; }
.results-players .pts { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.results-players .pts small { font-size: 0.75em; font-weight: 700; color: var(--muted); margin-left: 2px; }
.results-players li.me { background: rgba(255, 79, 163, 0.18); box-shadow: inset 0 0 0 1px rgba(255, 79, 163, 0.45); }
.podium .step.me .nm { color: #ffc1df; }
.results h2 { display: flex; align-items: center; justify-content: center; gap: 10px; }
.results h2 .res-ic { width: 34px; height: 34px; flex: none; }
.results .btn.big { max-width: 320px; margin: 0 auto; }
.results .results-actions .btn.big { width: auto; min-width: 200px; margin: 0; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: var(--radius); }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: drop 3.2s linear forwards; }
@keyframes drop { to { transform: translateY(110vh) rotate(720deg); opacity: 0.6; } }

/* ---------- Game: shared ---------- */
.game-wrap { height: 100%; display: flex; flex-direction: column; gap: 12px; }
.game-bar { padding: 10px 14px; display: flex; align-items: center; gap: 14px; }
.timer-ring { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring circle { fill: none; stroke-width: 5; }
.timer-ring .bg { stroke: rgba(255, 255, 255, 0.12); }
.timer-ring .fg { stroke: url(#timer-grad); stroke-linecap: round; transition: stroke-dashoffset 0.25s linear; }
.timer-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.15rem; }
.timer-ring.urgent b { color: var(--bad); animation: tick 0.5s infinite alternate; }
@keyframes tick { to { transform: scale(1.12); } }
.game-bar .info { color: var(--muted); font-weight: 600; font-size: 0.9rem; white-space: nowrap; }
.word-tiles { flex: 1; display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; min-width: 0; }
.word-tiles i { font-style: normal; width: 30px; height: 40px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); border-bottom: 3px solid rgba(255, 255, 255, 0.25); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; text-transform: uppercase; }
.word-tiles i.space { width: 14px; background: none; border: 0; }
.word-tiles .tile-word { display: inline-flex; flex-wrap: nowrap; gap: 5px; }
.word-tiles i.punct { width: auto; min-width: 10px; background: none; border: 0; }
.word-tiles i.shown { background: rgba(52, 211, 153, 0.2); border-color: var(--good); animation: rise 0.3s; }
.word-tiles .plain { font-family: var(--font-display); font-size: 1.35rem; font-weight: 800; }
.word-tiles .count { align-self: flex-end; color: var(--muted); font-size: 0.8rem; margin-left: 6px; }
.rate { display: flex; gap: 6px; }
.rate button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 6px 10px; font-weight: 700; transition: transform 0.15s, background 0.2s; }
.rate button.on { background: rgba(255, 79, 163, 0.25); border-color: var(--accent); }
.rate button:active { transform: scale(0.9); }
.stage { flex: 1; position: relative; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.overlay { position: absolute; inset: 0; background: rgba(8, 5, 25, 0.7); backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; padding: 20px; z-index: 5; border-radius: var(--radius); animation: fade 0.25s; }
.overlay h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
.overlay .av { width: 84px; height: 84px; }
.overlay .choices { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.overlay .choices .btn { min-width: 150px; font-size: 1.1rem; padding: 14px 20px; }
.overlay .big-word { font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }
.floaters span { position: absolute; bottom: 10px; font-size: 2rem; animation: floatup 2.2s ease-out forwards; }
@keyframes floatup { to { transform: translateY(-60vh) scale(1.4); opacity: 0; } }

/* Drawing board */
.board { display: flex; flex-direction: column; gap: 10px; height: 100%; width: 100%; }
.board-canvas-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.board-paper { position: relative; border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.08); background: #fff; }
.board-paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.board.editable .board-live { cursor: crosshair; }
.board-paper.blind canvas:first-child { visibility: hidden; }
.board-paper.blind::after { content: "🙈 Drawing blind: your picture appears in the album"; position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 0.8rem; font-weight: 600; color: #6b7280; background: #f3f4f6; padding: 4px 10px; border-radius: 999px; pointer-events: none; white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.board-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; padding: 10px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.tool-group { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tool-group.colors { max-width: 460px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.25); padding: 0; background: var(--c); transition: transform 0.15s; position: relative; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { transform: scale(1.15); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px #fff; }
.swatch.custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); overflow: hidden; cursor: pointer; }
.swatch.custom input { opacity: 0; position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
.size-btn { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; }
.size-btn i { display: block; width: var(--d); height: var(--d); border-radius: 50%; background: var(--text); }
.size-btn.active { background: var(--text); }
.size-btn.active i { background: #160f35; }
.tool-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 10px; padding: 7px 10px; font-weight: 600; font-size: 0.85rem; }
.tool-btn.active { background: var(--text); color: #160f35; }
.tool-btn.done { background: var(--grad); border: 0; color: #fff; }

/* Telephone */
.tel-stage { padding: 12px; }
.tel-board { height: 100%; width: 100%; }
.tel-title { overflow-wrap: anywhere; text-align: center; min-width: 0; }
.tel-title.long { font-size: 1.1rem; line-height: 1.25; }
/* "safe": a tall step on a short window scrolls instead of losing its top */
.tel-center { display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 16px; height: 100%; width: 100%; padding: 16px; overflow-y: auto; }
.tel-hint { margin: -6px 0 0; }
.tel-step { font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.tel-prompt { font-family: var(--font-display); font-size: clamp(1.4rem, 3.2vw, 2.2rem); font-weight: 800; text-align: center; max-width: 760px; line-height: 1.15; overflow-wrap: anywhere; }
.tel-prev img { max-width: min(560px, 100%); max-height: 46vh; border-radius: 16px; box-shadow: var(--shadow); background: #fff; display: block; }
.tel-form { display: flex; gap: 10px; width: min(620px, 100%); }
.tel-form input { flex: 1; font-size: 1.1rem; padding: 15px 16px !important; }
.tel-form .btn { width: auto; }
.tel-memo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tel-memo .count { font-family: var(--font-display); font-size: 2.6rem; font-weight: 800; }
.waiting-avatars { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 620px; }
.waiting-avatars .av { width: 44px; height: 44px; opacity: 0.35; transition: opacity 0.3s, transform 0.3s; position: relative; }
.waiting-avatars .av.done { opacity: 1; transform: translateY(-4px); }
.waiting-avatars .away .av { filter: grayscale(1); }
.waiting-avatars .av.done::after { content: "✓"; position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; background: var(--good); color: #052e1c; font-size: 0.7rem; font-weight: 800; display: grid; place-items: center; }
.tel-album { width: min(700px, 100%); display: flex; flex-direction: column; gap: 14px; }
.tel-entry { display: flex; gap: 12px; align-items: flex-start; animation: rise 0.4s both; }
.tel-entry > div { min-width: 0; }
.tel-entry .av { width: 40px; height: 40px; }
.tel-entry .who { font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.tel-entry .bubble { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; padding: 12px 16px; font-size: 1.15rem; font-weight: 600; max-width: 100%; overflow-wrap: anywhere; }
.tel-entry img { max-width: 100%; max-height: 320px; border-radius: 12px; background: #fff; display: block; }
.tel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.reactions { display: flex; gap: 6px; }
.reactions button { font-size: 1.3rem; width: 46px; height: 46px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); transition: transform 0.15s; }
.reactions button:hover { transform: translateY(-3px) scale(1.08); }

/* Kart */
.kart-stage { background: #87c4f0; border-radius: var(--radius); }
.kart-canvas { position: absolute; inset: 0; display: block; }
.kart-stage > div, .kart-stage > canvas.kart-minimap { z-index: 2; }
/* HUD kit: one glass panel style, tabular numbers, SVG icons */
.kart-panel {
  background: rgba(14, 10, 36, 0.58); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 14px; color: #fff;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
}
.kart-stage .hud-ic { width: 18px; height: 18px; flex: none; display: block; }
.kart-stage .av { width: 20px; height: 20px; }
.kart-card { position: absolute; top: 12px; left: 12px; min-width: 176px; padding: 8px 12px 10px; pointer-events: none; transform-origin: 0 0; }
.kart-card > div { display: none; }
.kart-card.race .kc-race, .kart-card.arena .kc-arena, .kart-card.spec .kc-spec { display: flex; }
.kc-race { align-items: center; gap: 12px; }
.kc-place b { display: block; font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 44px; line-height: 0.95; letter-spacing: -0.04em; padding-right: 4px; color: #fff; }
.kc-place b sup { font-size: 18px; vertical-align: top; margin-left: 1px; line-height: 1.6; }
.kc-place b.p1, .kc-place b.p2, .kc-place b.p3 { -webkit-background-clip: text; background-clip: text; color: transparent; }
.kc-place b.p1 { background-image: linear-gradient(180deg, #fff3c4, #ffb547 55%, #f97316); }
.kc-place b.p2 { background-image: linear-gradient(180deg, #f8fafc, #cbd5e1 50%, #94a3b8); }
.kc-place b.p3 { background-image: linear-gradient(180deg, #fed7aa, #fb923c 50%, #c2410c); }
.kc-meta { display: flex; flex-direction: column; gap: 2px; }
.kc-kicker { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kc-kicker .hud-ic { width: 14px; height: 14px; }
.kc-num { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 16px; }
.kc-arena { flex-direction: column; gap: 7px; }
.kc-hp { display: flex; align-items: center; gap: 8px; }
.kc-bar { position: relative; flex: 1; height: 10px; border-radius: 5px; background: rgba(255, 255, 255, 0.14); overflow: hidden; }
.kc-bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 5px; background: linear-gradient(90deg, #22c55e, #4ade80); box-shadow: 0 0 10px rgba(74, 222, 128, 0.5); transition: width 0.15s; }
.kc-bar i.mid { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.kc-bar i.low { background: linear-gradient(90deg, #e11d48, #fb7185); box-shadow: 0 0 10px rgba(251, 113, 133, 0.6); animation: hp-low 1s ease-in-out infinite; }
@keyframes hp-low { 50% { opacity: 0.55; } }
.kc-hp .kc-num { font-size: 14px; min-width: 26px; text-align: right; }
.kc-stats { display: flex; gap: 6px; }
.kc-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.08); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kc-chip .hud-ic { width: 14px; height: 14px; }
.kc-chip.kc-muted { color: var(--muted); font-weight: 700; }
.kc-spec { align-items: center; gap: 8px; font-weight: 700; font-size: 14px; }
/* top centre: timer and held item */
.kart-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: flex-start; gap: 10px; pointer-events: none; }
.kart-timer { height: 44px; padding: 0 14px; display: flex; align-items: center; font-family: var(--font-display); font-weight: 800; font-size: 24px; font-variant-numeric: tabular-nums; transition: background 0.3s; }
.kart-timer.urgent { background: #dc2626; border-color: rgba(255, 255, 255, 0.35); animation: urgent 1s ease-in-out infinite; }
@keyframes urgent { 50% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.35), 0 8px 24px -12px rgba(0, 0, 0, 0.6); } }
.kart-item {
  --cell: 60px;
  position: relative; width: 64px; height: 64px; border-radius: 18px; color: #fff;
  background: radial-gradient(circle at 50% 40%, rgba(255, 181, 71, 0.35), rgba(14, 10, 36, 0.6) 70%); border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(255, 79, 163, 0.35), 0 10px 24px -10px rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.18s, transform 0.18s, border-color 0.18s;
}
.mode-arena .kart-item { position: absolute; top: 0; left: calc(100% + 10px); }
.kart-item.empty { opacity: 0; transform: scale(0.85); }
/* Item roulette: a slot-machine reel inside the glass slot that decelerates onto the item. */
.kart-slot { position: absolute; inset: 0; border-radius: 16px; overflow: hidden; display: grid; place-items: center; }
.kart-item .item-icon { width: 46px; height: 46px; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.kart-item-icon { display: none; }
.kart-item.ready .kart-item-icon { display: grid; place-items: center; }
.kart-reel { position: absolute; left: 0; right: 0; top: 0; display: none; will-change: transform; }
.kart-reel .cell { height: var(--cell); display: grid; place-items: center; }
.kart-reel .item-icon { width: 40px; height: 40px; }
.kart-item.rolling { border-color: #fde047; }
.kart-item.rolling .kart-reel { display: block; }
.kart-item.rolling .kart-slot::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(rgba(14, 10, 36, 0.85), rgba(14, 10, 36, 0) 32%, rgba(14, 10, 36, 0) 68%, rgba(14, 10, 36, 0.85));
}
.kart-item.ready { animation: item-ready 1.1s ease-in-out infinite; }
.kart-item.landed .kart-item-icon { animation: item-land 0.38s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes item-ready {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 79, 163, 0.35), 0 10px 24px -10px rgba(0, 0, 0, 0.7); }
  50% { box-shadow: 0 0 0 5px rgba(253, 224, 71, 0.5), 0 0 24px 6px rgba(255, 140, 220, 0.5), 0 10px 24px -10px rgba(0, 0, 0, 0.7); }
}
@keyframes item-land { 0% { transform: scale(0.4) rotate(-12deg); } 70% { transform: scale(1.18) rotate(4deg); } 100% { transform: scale(1); } }
.kart-item small { position: absolute; z-index: 1; top: -7px; right: -7px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #ff4fa3; border: 2px solid #fff; font-weight: 800; font-size: 12px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.kart-item small:empty, .kart-item.rolling small { display: none; } /* the ammo would give the roulette away */
.kart-key, .kart-rkey, .kart-help kbd { font: inherit; font-weight: 800; font-size: 10.5px; letter-spacing: 0.04em; text-transform: uppercase; padding: 1px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.92); color: #160f35; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.kart-key { position: absolute; z-index: 1; bottom: -11px; left: 50%; transform: translateX(-50%); font-size: 9.5px; transition: opacity 0.18s; }
.kart-item:not(.ready) .kart-key { opacity: 0; }
/* the reserve slot: a smaller glass box beside the main one, Q swaps the two */
.kart-reserve {
  position: absolute; left: calc(100% + 9px); bottom: 0; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 181, 71, 0.22), rgba(14, 10, 36, 0.62) 70%); border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px -10px rgba(0, 0, 0, 0.7); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.18s, transform 0.18s, border-color 0.18s;
}
.kart-reserve.empty { opacity: 0; transform: translateX(-10px) scale(0.75); }
.kart-reserve .item-icon { width: 28px; height: 28px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35)); }
.kart-reserve-icon { display: grid; place-items: center; }
.kart-reserve.rolling { border-color: #fde047; border-style: dashed; }
.kart-reserve.rolling .item-icon { opacity: 0.7; }
.kart-reserve.landed .kart-reserve-icon { animation: item-land 0.38s cubic-bezier(.3, 1.6, .5, 1); }
.kart-reserve b { position: absolute; top: -8px; right: -8px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: #ff4fa3; border: 2px solid #fff; font-size: 10px; font-weight: 800; line-height: 14px; text-align: center; font-variant-numeric: tabular-nums; }
.kart-reserve b:empty, .kart-reserve.rolling b { display: none; }
.kart-rkey { position: absolute; bottom: -11px; left: 50%; transform: translateX(-50%); font-size: 9px; }
.kart-reserve:not(.ready) .kart-rkey { opacity: 0; }
/* under the top cluster: the item's name when it lands, and the comet warning */
.kart-top-sub { position: absolute; top: calc(100% + 18px); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mode-arena .kart-top-sub { left: calc(100% + 42px); }
.kart-item-name { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; opacity: 0; transform: translateY(-4px); transition: opacity 0.2s, transform 0.2s; }
.kart-item-name.show { opacity: 1; transform: none; }
.kart-warn {
  display: flex; align-items: center; gap: 8px; padding: 5px 14px 5px 6px; border-radius: 999px; white-space: nowrap;
  background: linear-gradient(90deg, rgba(67, 56, 202, 0.92), rgba(190, 24, 93, 0.92)); color: #fff; font-weight: 900; font-style: italic; letter-spacing: 0.04em; text-transform: uppercase;
  font-size: 0.85rem; animation: warn-blink 0.52s steps(2, jump-none) infinite; box-shadow: 0 0 22px rgba(129, 140, 248, 0.8);
}
.kart-warn .item-icon { width: 28px; height: 28px; }
.kart-warn.sticky { background: linear-gradient(90deg, rgba(190, 24, 93, 0.94), rgba(236, 72, 153, 0.94)); animation: sticky-warn 0.5s ease-in-out infinite alternate; }
.kart-warn.sticky b { font-variant-numeric: tabular-nums; margin-left: 4px; }
@keyframes sticky-warn { to { transform: scale(1.05); } }
@keyframes warn-blink { 50% { opacity: 0.55; transform: scale(1.06); } }
/* Ink on your screen (never on the HUD). Each blot splats in, drips a little, and the whole layer fades out. */
.kart-stage > .kart-ink { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; overflow: hidden; border-radius: inherit; }
.kart-ink.on { opacity: 1; }
.kart-ink.fading { opacity: 0; transition: opacity 0.9s ease-in; }
.kart-ink .blot { position: absolute; aspect-ratio: 140 / 160; transform: translate(-50%, -50%) rotate(var(--r)); animation: splat 0.34s cubic-bezier(.2, 1.5, .5, 1) both, drip 4s 0.35s ease-in both; }
.kart-ink .blot svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35)); }
@keyframes splat { from { transform: translate(-50%, -50%) rotate(var(--r)) scale(0.15); } to { transform: translate(-50%, -50%) rotate(var(--r)) scale(1); } }
@keyframes drip { to { margin-top: 3%; } }
/* Thunder: everyone's screen flashes. */
.kart-stage > .kart-flash { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: radial-gradient(circle at 50% 30%, #fff, #dbeafe 60%, #a5b4fc); mix-blend-mode: screen; border-radius: inherit; }
.kart-flash.on { animation: thunder-flash 0.5s ease-out; }
/* A quick double flicker, never a white screen: the bolts themselves carry the strike. */
@keyframes thunder-flash { 0% { opacity: 0.38; } 12% { opacity: 0.06; } 22% { opacity: 0.26; } 100% { opacity: 0; } }
.kart-intro { position: absolute; top: 74px; left: 50%; transform: translate(-50%, -6px); padding: 7px 16px 8px; text-align: center; pointer-events: none; opacity: 0; transition: opacity 0.35s, transform 0.35s; }
.mode-arena .kart-intro { top: 68px; }
.kart-intro.show { opacity: 1; transform: translate(-50%, 0); }
.kart-intro small { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-2); }
.kart-intro b { font-family: var(--font-display); font-size: 1.25rem; font-weight: 800; white-space: nowrap; }
/* leaderboard */
.kart-board { position: absolute; top: 12px; right: 12px; width: 196px; padding: 6px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.kart-board:empty { display: none; }
.kb-row { display: grid; grid-template-columns: 16px 20px minmax(0, 1fr) auto; align-items: center; gap: 7px; height: 26px; padding: 0 7px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.kb-row .rk { color: var(--muted); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.kb-row .av { border-radius: 50%; box-shadow: 0 0 0 1.5px var(--c); }
.kb-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-row b { font-weight: 800; font-variant-numeric: tabular-nums; }
.kb-row .hud-ic { width: 15px; height: 15px; }
.kb-row.me { background: rgba(255, 79, 163, 0.24); }
.kb-gap { display: block; height: 1px; background: rgba(255, 255, 255, 0.12); margin: 2px 6px; }
/* kill feed */
.kart-feed { position: absolute; top: 200px; right: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; pointer-events: none; }
.kf-row { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 5px; border-radius: 12px; font-size: 12.5px; font-weight: 700; white-space: nowrap; animation: feed-in 0.25s ease-out; transition: opacity 0.3s, transform 0.3s; }
.kf-row b { max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
.kf-row .item-icon, .kf-row .hud-ic { width: 20px; height: 20px; margin: 0 2px; }
.kf-row em { font-style: normal; font-weight: 800; color: #ffd166; letter-spacing: 0.04em; }
.kf-row.mine { border-color: rgba(255, 79, 163, 0.6); box-shadow: 0 0 0 1px rgba(255, 79, 163, 0.35), 0 8px 24px -12px rgba(0, 0, 0, 0.6); }
.kf-row.out { opacity: 0; transform: translateX(12px); }
@keyframes feed-in { from { opacity: 0; transform: translateX(16px); } }
/* callouts: 3-2-1, GO, FINAL LAP, streaks, FINISH */
.kart-callout { position: absolute; left: 0; right: 0; top: 24%; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; opacity: 0; }
.kart-callout b {
  font-family: var(--font-display); font-weight: 800; font-style: italic; font-size: 56px; line-height: 1; letter-spacing: -0.02em; color: #fff; white-space: nowrap; padding: 0 12px;
  -webkit-text-stroke: 7px #160f35; paint-order: stroke fill; text-shadow: 0 6px 0 rgba(22, 15, 53, 0.55);
}
.kart-callout.count b { font-size: 120px; -webkit-text-stroke-width: 10px; text-shadow: 0 8px 0 rgba(22, 15, 53, 0.55); }
.kart-callout.go b { color: #ffd166; }
.kart-stage.touch .kart-callout.count b { font-size: 72px; -webkit-text-stroke-width: 7px; }
.kart-callout.gold b { color: #ffd166; }
.kart-callout.small b { font-size: 30px; -webkit-text-stroke-width: 5px; text-shadow: 0 4px 0 rgba(22, 15, 53, 0.55); }
.kart-callout.small { top: 30%; }
.kart-callout small { font-weight: 800; font-size: 15px; padding: 4px 12px; border-radius: 999px; background: rgba(14, 10, 36, 0.62); border: 1px solid rgba(255, 255, 255, 0.14); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.kart-callout.show { animation: callout-in 0.15s ease-out forwards, callout-out 0.32s ease-in var(--hold, 900ms) forwards; }
@keyframes callout-in { from { opacity: 0; transform: scale(1.6); } to { opacity: 1; transform: scale(1); } }
@keyframes callout-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-26px); } }
.kart-speedlines {
  position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.2s;
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,0.0) 0deg 4deg, rgba(255,255,255,0.22) 4.5deg 5deg, rgba(255,255,255,0) 5.5deg 11deg);
  -webkit-mask-image: radial-gradient(circle at 50% 55%, transparent 28%, #000 70%);
  mask-image: radial-gradient(circle at 50% 55%, transparent 28%, #000 70%);
}
.kart-speedlines.on { opacity: 1; animation: speedlines 0.25s linear infinite; }
.kart-speedlines.star {
  background: repeating-conic-gradient(from 0deg at 50% 55%, rgba(255,255,255,0) 0deg 4deg, rgba(255,120,220,0.3) 4.5deg 5deg, rgba(255,255,255,0) 5.5deg 8deg, rgba(120,220,255,0.3) 8.5deg 9deg, rgba(255,255,255,0) 9.5deg 13deg);
  animation: speedlines 0.25s linear infinite, star-hue 0.8s linear infinite;
}
@keyframes star-hue { to { filter: hue-rotate(360deg); } }
@keyframes speedlines { 50% { transform: rotate(1.5deg) scale(1.03); } }
/* hit marker and low-health pulse */
.kart-hit { position: absolute; left: 50%; top: 46%; width: 28px; height: 28px; margin: -14px 0 0 -14px; pointer-events: none; opacity: 0; }
.kart-hit svg { width: 100%; height: 100%; fill: none; stroke: #fff; stroke-width: 3.2; stroke-linecap: round; filter: drop-shadow(0 0 2px rgba(22, 15, 53, 0.9)); }
.kart-hit.kill svg { stroke: #fb7185; }
.kart-hit.show { animation: hit 0.18s ease-out forwards; }
.kart-hit.kill.show { animation-duration: 0.26s; }
@keyframes hit { 0% { opacity: 1; transform: scale(1.35); } 60% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(1); } }
.kart-vignette { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(220, 38, 38, 0.35)); border-radius: inherit; transition: opacity 0.3s; }
.kart-vignette.show { animation: vignette 1s ease-in-out infinite; }
@keyframes vignette { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
/* death card: who smashed you and the respawn ring */
.kart-dead { position: absolute; left: 50%; bottom: 24px; display: flex; align-items: center; gap: 12px; padding: 10px 18px 10px 10px; pointer-events: none; opacity: 0; transform: translate(-50%, 16px); transition: opacity 0.25s, transform 0.25s; }
.kart-dead.show { opacity: 1; transform: translate(-50%, 0); }
.kd-ring { position: relative; width: 48px; height: 48px; flex: none; }
.kd-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.kd-ring circle { fill: none; stroke-width: 4; }
.kd-ring .bg { stroke: rgba(255, 255, 255, 0.14); }
.kd-ring .fg { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 100; }
.kd-ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.kd-text { display: flex; flex-direction: column; gap: 3px; }
.kd-kicker { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.kd-who { display: flex; align-items: center; gap: 7px; font-size: 17px; font-weight: 800; white-space: nowrap; }
.kd-who .av { width: 26px; height: 26px; }
.kd-who .item-icon, .kd-who .hud-ic { width: 24px; height: 24px; }
.kd-watch { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, 0.8); }
.kd-watch .hud-ic { width: 14px; height: 14px; }
/* minimap, help, tools */
.kart-minimap { position: absolute; right: 14px; bottom: 14px; width: 168px; height: 168px; pointer-events: none; }
.kart-help { position: absolute; bottom: 12px; left: 58px; display: flex; gap: 6px; align-items: center; padding: 7px 10px; font-size: 11.5px; font-weight: 600; color: rgba(255, 255, 255, 0.88); pointer-events: none; opacity: 0; transform: translateY(6px); transition: opacity 0.4s, transform 0.4s; }
.kart-help.show { opacity: 1; transform: none; }
.kart-dead.show ~ .kart-help { opacity: 0; } /* the death card sits in the same corner on small screens */
.kart-help kbd { margin-left: 2px; }
.kart-tools { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 6px; }
.kart-tool { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; padding: 0; color: #fff; border: 1px solid rgba(255, 255, 255, 0.16); background: rgba(14, 10, 36, 0.5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); transition: background 0.2s; }
.kart-tool:hover { background: rgba(14, 10, 36, 0.75); }
.kart-tool .tc-ic { width: 18px; height: 18px; }
.kart-tool.tool-chat, .kart-tool.tool-menu { display: none; }
.kart-rotate { position: absolute; top: 46%; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.kart-rotate .tc-ic { width: 20px; height: 20px; }
/* touch controls */
.touch-controls { display: none; }
.kart-stage.touch .touch-controls { display: block; }
.touch-controls button {
  position: relative; display: grid; place-items: center; padding: 0; border: 1.5px solid rgba(255, 255, 255, 0.35); background: rgba(14, 10, 36, 0.45); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: background 0.12s, transform 0.12s;
}
.touch-controls button.on { background: rgba(255, 255, 255, 0.25); transform: scale(0.95); }
.touch-controls .tc-ic { width: 26px; height: 26px; }
.tc-steer { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: 14px; display: flex; gap: 10px; }
.tc-steer button { width: 76px; height: 64px; border-radius: 32px; }
.tc-act { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: 8px; width: 170px; height: 158px; pointer-events: none; }
.tc-act button { position: absolute; border-radius: 50%; pointer-events: auto; }
.tc-fire { right: 0; bottom: 32px; width: 84px; height: 84px; border-width: 2px; opacity: 0.6; }
.tc-fire.armed { opacity: 1; border-color: #fff; background: radial-gradient(circle at 50% 40%, rgba(255, 181, 71, 0.4), rgba(14, 10, 36, 0.55) 70%); box-shadow: 0 0 0 3px rgba(255, 79, 163, 0.45); }
.tc-fire .item-icon { width: 50px; height: 50px; }
.tc-fire.rolling { opacity: 0.85; border-color: #fde047; border-style: dashed; }
.tc-fire.rolling .item-icon { width: 40px; height: 40px; opacity: 0.75; }
.tc-fire.armed.on { transform: scale(0.92); }
/* the reserve item: a bubble above the fire button, tap it to swap the two */
.tc-swap { right: 4px; bottom: 126px; width: 54px; height: 54px; border-width: 2px; border-color: rgba(255, 255, 255, 0.75); background: radial-gradient(circle at 50% 40%, rgba(255, 181, 71, 0.28), rgba(14, 10, 36, 0.55) 70%); }
.tc-swap.empty { display: none; }
.tc-swap .item-icon { width: 30px; height: 30px; }
.tc-swap.rolling { border-color: #fde047; border-style: dashed; }
.tc-swap.rolling .item-icon { opacity: 0.7; }
.tc-swap.on { transform: scale(0.9); }
.tc-swap-badge { position: absolute; left: -6px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: #ff4fa3; border: 2px solid #fff; }
.tc-swap-badge .tc-ic { width: 12px; height: 12px; }
.tc-drift { right: 92px; bottom: 92px; width: 60px; height: 60px; }
.tc-drift small { position: absolute; bottom: 7px; font-size: 9px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; opacity: 0.8; }
.tc-drift .tc-ic { width: 22px; height: 22px; margin-top: -8px; }
.tc-brake { right: 100px; bottom: 12px; width: 52px; height: 52px; }
.tc-brake .tc-ic { width: 22px; height: 22px; }
.kart-stage.no-items .tc-fire, .kart-stage.no-items .tc-swap, .kart-stage.no-items .kh-item { display: none; }
.kart-stage.spectating .touch-controls, .kart-stage.spectating .kart-help { display: none; }
/* empty fire button: a faint item box, so it reads as "no item yet", not as a missing control */
.tc-fire:not(.armed)::before { content: "?"; position: absolute; inset: 0; margin: auto; width: 30px; height: 30px; box-sizing: border-box; border: 2px solid rgba(255, 255, 255, 0.55); border-radius: 9px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: rgba(255, 255, 255, 0.7); transform: rotate(-8deg); }
/* Touch: the HUD lives in the top band and the controls at the bottom, so the middle, where your
   kart and the road ahead are, stays clear. */
.kart-stage.touch .kart-key, .kart-stage.touch .kart-reserve { display: none; }
.kart-stage.touch .kart-card { top: 10px; left: 10px; min-width: 0; transform: scale(0.8); }
.kart-stage.touch .kart-minimap { top: 10px; right: 10px; bottom: auto; width: 102px; height: 102px; }
.kart-stage.touch .kart-tools { left: auto; bottom: auto; top: 10px; right: 120px; }
/* leaderboard: one pill under the card with the top 3 and you (avatar, rank, kills) */
.kart-stage.touch .kart-board { top: 68px; left: 10px; right: auto; width: auto; flex-direction: row; align-items: center; gap: 1px; padding: 3px; border-radius: 999px; }
.kart-stage.touch .kb-row { grid-template-columns: auto 20px; grid-auto-flow: column; height: 24px; gap: 4px; padding: 0 7px 0 6px; border-radius: 999px; font-size: 12px; }
.kart-stage.touch .kb-row .rk { font-size: 11px; text-align: left; }
.kart-stage.touch .kb-row .nm, .kart-stage.touch .kb-gap, .kart-stage.touch .kb-row:nth-child(n+4):not(.me) { display: none; }
.kart-stage.touch .kb-row.me:nth-child(n+4) { margin-left: 3px; box-shadow: -4px 0 0 -3px rgba(255, 255, 255, 0.3); }
.kart-stage.touch .kart-feed { top: 120px; right: 10px; }
.kart-stage.touch .kf-row { font-size: 11.5px; padding: 3px 8px 3px 4px; }
.kart-stage.touch .kf-row b { max-width: 72px; }
.kart-stage.touch .kf-row:nth-child(n+3) { display: none; }
.kart-stage.touch .kart-warn { font-size: 0.72rem; padding: 4px 11px 4px 5px; }
.kart-stage.touch .kart-warn .item-icon { width: 22px; height: 22px; }
.kart-stage.touch .kart-top-sub { top: calc(100% + 14px); }
.kart-stage.touch .kart-callout { top: 36%; }
.kart-stage.touch .kart-intro, .kart-stage.touch .kart-dead { top: 78px; bottom: auto; }
.kart-stage.touch .kart-dead { padding: 8px 14px 8px 8px; gap: 10px; transform: translate(-50%, -8px); }
.kart-stage.touch .kart-dead.show { transform: translate(-50%, 0); }
.kart-stage.touch .kart-dead .kd-ring { width: 40px; height: 40px; }
.kart-stage.touch .kd-who { font-size: 15px; }
/* "tap to start": a caption above the steering pills, and every button pulses until the first press */
.kart-stage.touch .kart-help { left: max(12px, env(safe-area-inset-left)); bottom: 88px; flex-direction: column; align-items: flex-start; gap: 1px; padding: 6px 11px 7px; font-size: 11px; transform: translateY(6px); }
.kart-stage.touch .kart-help b { font-size: 12.5px; color: #fff; }
.kart-stage.touch .kart-help.show { transform: none; }
.kart-stage.touch.engaged .kart-help { display: none; }
.kart-stage.touch:not(.engaged) .kart-help.show ~ .touch-controls button { animation: tc-pulse 1.6s ease-out infinite; }
@keyframes tc-pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 79, 163, 0.6); } 70%, 100% { box-shadow: 0 0 0 12px rgba(255, 79, 163, 0); } }
@media (orientation: portrait) {
  /* the timer and the fullscreen button go under the minimap, the held item to the top centre */
  .kart-stage.touch .kart-top { position: static; transform: none; }
  .kart-stage.touch .kart-item { position: absolute; top: 10px; left: 50%; width: 50px; height: 50px; margin-left: -25px; border-radius: 15px; font-size: 1.6rem; }
  .kart-stage.touch .kart-item svg { width: 36px; height: 36px; }
  /* The fire button shows the item, so no name under the slot (it would run into the leaderboard
     pill); the comet warning goes under the pill, clear of the arena timer. */
  .kart-stage.touch .kart-item-name { display: none; }
  .kart-stage.touch .kart-top-sub { top: 104px; left: 10px; transform: none; align-items: flex-start; }
  .kart-stage.touch .kart-timer { position: absolute; top: 120px; right: 52px; height: 34px; padding: 0 10px; font-size: 18px; border-radius: 11px; }
  .kart-stage.touch:has([data-fullscreen].hidden) .kart-timer { right: 10px; }
  .kart-stage.touch .kart-tools { top: 120px; right: 10px; }
  .kart-stage.touch .kart-tool { width: 34px; height: 34px; }
  .kart-stage.touch .kart-feed { top: 162px; }
  .kart-stage.touch .kart-intro, .kart-stage.touch .kart-dead { top: 162px; }
  .kart-stage.touch.is-dead .kart-feed { top: 238px; }
  .kart-stage.touch .kart-rotate { top: 222px; }
  .kart-stage.touch .kart-callout { top: 33%; }
}
@media (orientation: landscape) {
  .kart-stage.touch .kart-top { top: 10px; }
  .kart-stage.touch .kart-rotate { display: none; }
}

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(120px); background: rgba(28, 20, 66, 0.95); border: 1px solid var(--line);
  color: #fff; padding: 12px 18px; border-radius: 14px; transition: transform 0.3s cubic-bezier(.3, 1.4, .6, 1); z-index: 60; pointer-events: none; font-weight: 600;
  box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ---------- Kart game focus: the game takes the screen; chat is a drawer (desktop) or a sheet (phones) ---------- */
.chat-toggle, .chat-backdrop, .chat-head, .chat-ticker { display: none; }
body.kart-playing .side-players { display: none; }
.chat-toggle { position: relative; }
.chat-toggle[data-unread]::after { content: attr(data-unread); position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); border: 2px solid var(--bg); font-size: 10.5px; font-weight: 800; line-height: 14px; text-align: center; }
body.chat-unread .kart-tool.tool-chat::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(14, 10, 36, 0.8); }
.kart-tool { position: relative; }
body.kart-playing.chat-open .chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.chat-head b { flex: 1; font-family: var(--font-display); font-size: 1.05rem; }
.chat-head .icon-btn { width: 32px; height: 32px; border-radius: 10px; font-size: 0.9rem; }
.chat-log:empty::after { content: "No messages yet. Say hi!"; margin: auto; color: var(--muted); font-size: 0.88rem; }
.game-menu { position: fixed; z-index: 70; min-width: 190px; padding: 6px; display: flex; flex-direction: column; gap: 2px; background: rgba(28, 20, 66, 0.94); border-radius: 14px; animation: fade 0.15s; }
.game-menu button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 12px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; }
.game-menu button svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.game-menu button:hover { background: var(--surface-2); }
.game-menu button.danger { color: #ffd1d9; }
@media (min-width: 981px) and (pointer: fine) {
  /* Desktop: the game gets the whole width; chat opens as a drawer over it (button or Enter) and
     new messages show briefly in a ticker over the bottom-left of the game. */
  body.kart-playing #side { display: none; }
  body.kart-playing .chat-toggle { display: inline-flex; }
  body.kart-playing.chat-open #side { display: flex; position: fixed; top: 70px; right: 14px; z-index: 55; width: 340px; height: min(560px, calc(100% - 92px)); animation: drawer-in 0.2s ease-out; }
  body.kart-playing.chat-open .chat { flex: 1; min-height: 0; background: rgba(22, 15, 53, 0.94); }
  body.kart-playing.chat-open .chat-backdrop { display: block; position: fixed; inset: 0; z-index: 54; }
  body.kart-playing .chat-ticker { display: flex; position: fixed; left: 28px; bottom: 74px; z-index: 20; flex-direction: column; align-items: flex-start; gap: 5px; max-width: 420px; pointer-events: none; }
  body.kart-playing.chat-open .chat-ticker { display: none; }
}
@keyframes drawer-in { from { opacity: 0; transform: translateX(16px); } }
.chat-ticker div { display: flex; align-items: center; gap: 7px; padding: 4px 11px 4px 4px; border-radius: 12px; font-size: 13px; line-height: 1.3; color: #fff; background: rgba(14, 10, 36, 0.62); border: 1px solid rgba(255, 255, 255, 0.12); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); animation: feed-in 0.25s ease-out; transition: opacity 0.4s; overflow: hidden; }
.chat-ticker .av { width: 20px; height: 20px; }
.chat-ticker span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-ticker div.out { opacity: 0; }

/* ---------- Responsive ---------- */
@media (min-width: 1101px) {
  .game-cards { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .game-card { grid-column: span 2; }
  .game-card:last-child:nth-child(3n + 2), .game-card:nth-last-child(2):nth-child(3n + 1) { grid-column: span 3; min-height: 0; flex-direction: row; align-items: center; gap: 14px; }
  .game-card:last-child:nth-child(3n + 1) { grid-column: span 6; min-height: 0; flex-direction: row; align-items: center; gap: 14px; }
}
@media (max-width: 1100px) {
  .game-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card { min-height: 0; flex-direction: row; align-items: center; gap: 12px; }
  .game-card:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  body { overflow: auto; }
  .home { grid-template-columns: 1fr; }
  .join-card { justify-self: stretch; max-width: none; }
  .head-meta { display: none; }
  #screen-room.active { height: auto; min-height: 100%; }
  .room-body { flex-direction: column; flex: none; }
  #side { width: 100%; }
  #main { flex: none; }
  .view.active { height: auto; }
  #view-game.active { height: 78vh; min-height: 460px; }
  .chat { min-height: 260px; max-height: 50vh; }
  .side-players { max-height: 200px; }
  .lobby { grid-template-columns: 1fr; height: auto; }
  .settings-grid { grid-template-columns: 1fr; }
  .map-overview { grid-template-columns: 1fr; }
  .start-bar { position: sticky; bottom: 0; z-index: 5; height: auto; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 40%); }
  .start-bar .btn.big { width: 100%; }
  .start-bar #lobby-wait { flex: 1; text-align: center; }
  .topbar .brand, .copy-hint, #player-count { display: none; }
}
@media (max-width: 980px) {
  /* Pictionary on a phone or tablet: the word, the drawing and the guess box fit one screen (the
     player list moves out of the way; scores show on the reveal and the results). */
  body.pict-playing #screen-room.active { height: 100vh; height: 100dvh; min-height: 0; }
  body.pict-playing .topbar { padding-top: 8px; padding-bottom: 8px; }
  body.pict-playing .room-body { flex: 1; min-height: 0; gap: 8px; }
  body.pict-playing #main { flex: 1; min-height: 0; }
  body.pict-playing #view-game.active { height: 100%; min-height: 0; }
  body.pict-playing .game-wrap { gap: 8px; }
  body.pict-playing .side-players { display: none; }
  body.pict-playing #side { flex: none; }
  body.pict-playing .chat { flex: none; min-height: 0; max-height: 30vh; max-height: 30dvh; }
  body.pict-playing .chat-log { min-height: 48px; }
  body.pict-playing .stage { padding: 8px !important; }
}
@media (max-width: 980px), (pointer: coarse) {
  body.kart-playing { overflow: hidden; }
  body.kart-playing #screen-room.active { height: 100%; height: 100dvh; min-height: 0; }
  body.kart-playing .topbar { padding: 8px 12px; }
  body.kart-playing .room-body { flex: 1; min-height: 0; padding: 0 8px 8px; }
  body.kart-playing #main { flex: 1; min-height: 0; }
  body.kart-playing #view-game.active { height: 100%; min-height: 0; }
  body.kart-playing #side { display: none; }
  body.kart-playing .chat-toggle { display: inline-flex; }
  body.kart-playing.chat-open #side { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; width: auto; height: min(62dvh, 440px); padding: 0; animation: sheet-in 0.22s ease-out; }
  body.kart-playing.chat-open .chat { min-height: 0; max-height: none; flex: 1; border-radius: 22px 22px 0 0; border-bottom: 0; background: rgba(22, 15, 53, 0.92); padding-bottom: env(safe-area-inset-bottom); }
  body.kart-playing.chat-open .chat-head { position: relative; padding-top: 18px; }
  body.kart-playing.chat-open .chat-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: rgba(255, 255, 255, 0.3); }
  body.kart-playing.chat-open .chat-backdrop { display: block; position: fixed; inset: 0; z-index: 54; background: rgba(5, 3, 15, 0.45); }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (max-height: 500px) and (orientation: landscape) and (max-width: 980px), (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  body.kart-playing .topbar { display: none; }
  body.kart-playing .room-body { padding: 0; }
  body.kart-playing .kart-stage { border-radius: 0; }
  /* the top bar's buttons move into the stage: Chat and a menu with Sound, End game and Leave */
  body.kart-playing .kart-tool.tool-menu, body.kart-playing .kart-tool.tool-chat { display: grid; }
}
@media (max-width: 560px) {
  .game-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .game-tiles .game-tile { min-height: 96px; padding: 12px; }
  .game-tiles .game-tile .tile-art { top: 8px; right: 10px; font-size: 1.9rem; }
  .game-tiles .game-tile:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 76px; }
  .game-cards { gap: 8px; }
  .game-card { flex-direction: column; align-items: flex-start; gap: 4px; padding: 11px 12px; }
  .game-card .gc-art { font-size: 1.7rem; }
  .game-card b { font-size: 1rem; }
  .game-card small { font-size: 0.76rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .game-card:last-child:nth-child(odd) { flex-direction: row; align-items: center; gap: 12px; }
  .word-tiles i { width: 22px; height: 32px; font-size: 1rem; }
  .game-bar .info { display: none; }
  /* Pictionary: the timer and the 👍/👎 on top, the word gets the whole width below them, with
     tiles small enough for a long word to fit on one line. */
  .pict-bar { flex-wrap: wrap; justify-content: space-between; row-gap: 8px; padding: 8px 12px; }
  .pict-bar .timer-ring { width: 44px; height: 44px; }
  .pict-bar .word-tiles { order: 3; flex: 1 1 100%; gap: 3px; row-gap: 6px; }
  .pict-bar .word-tiles .tile-word { gap: 3px; }
  .pict-bar .word-tiles i { width: clamp(13px, 5.4vw, 22px); height: 30px; font-size: 0.95rem; border-radius: 7px; }
  .pict-bar .word-tiles i.space { width: 8px; }
  .tel-title { font-size: 1.05rem; line-height: 1.25; }
  .tel-title.long { font-size: 0.92rem; }
  /* Drawing on a phone: the paper takes the full width (4:3) and the page grows to fit the tools,
     which shrink to two compact rows: a strip of colours, then sizes and tools as icons. */
  #view-game.active:has(.tel-board .board.editable) { height: auto; min-height: 0; }
  .tel-stage:has(.board.editable) { flex: none; overflow: visible; }
  .tel-stage:has(.board.editable) .tel-board, .tel-board .board.editable { height: auto; }
  .tel-board .board.editable .board-canvas-wrap { flex: none; width: 100%; aspect-ratio: 4 / 3; }
  .board-tools { gap: 8px; padding: 8px; border-radius: 16px; }
  .tool-group.colors, .tool-group.extra { flex: 1 1 100%; }
  .tool-group.colors { max-width: none; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 5px 4px 7px; scrollbar-width: none; }
  .tool-group.colors::-webkit-scrollbar { display: none; }
  .tool-group.colors .swatch { flex: 0 0 30px; width: 30px; height: 30px; }
  .tool-group.sizes, .tool-group.tools { gap: 4px; flex-wrap: nowrap; }
  .size-btn { width: 28px; height: 32px; }
  .tool-btn { padding: 6px 7px; min-width: 32px; justify-content: center; }
  .tool-btn span { display: none; }
  .tool-group.extra { justify-content: center; }
  .tool-group.extra:empty { display: none; }
  .tool-group.extra .tool-btn.done { flex: 1; padding: 11px; font-size: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
