/* MAHJONG GARDEN — ivory tiles in a garden at dusk: deep moss panels, bone
   text, one blossom-pink accent. Nothing here depends on web/style.css (it is
   not loaded). The garden itself is painted on #bg by js/backdrops.js. */
:root {
  --ink: #0e1f18;
  --moss: rgba(14, 34, 26, 0.84);
  --moss-solid: #10261d;
  --edge: rgba(240, 232, 208, 0.18);
  --text: #f6f0dc;
  --dim: rgba(246, 240, 220, 0.66);
  --accent: #f3a9c0;
  --gold: #ffd34d;
  --jade: #4be08a;
  --fs-accent: #ffd34d;
  --fs-text: #f6f0dc;
  --fs-dim: rgba(246, 240, 220, 0.62);
  --fs-edge: rgba(240, 232, 208, 0.16);
  --fs-panel: rgba(255, 255, 255, 0.05);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #16301f; color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
/* web/style.css pins .volume-slider position:fixed top:12px on pages that load
   it. This page does not, but a shared strip must never land in a corner. */
.volume-slider { position: static !important; top: auto !important; }

.mg-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.muted { color: var(--dim); font-size: 13px; }
.tile-icon { display: inline-block; vertical-align: middle; }

/* ── menus ─────────────────────────────────────────────────────────────── */
#lobbyOverlay {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-start;
  justify-content: center; overflow-y: auto; padding: 18px 12px 28px;
  background: rgba(6, 18, 12, 0.3);
}
.card {
  width: 100%; max-width: 460px; margin: auto; padding: 22px 22px 18px;
  background: var(--moss); border: 1px solid var(--edge); border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px); text-align: center;
}
.card.wide { max-width: 1020px; text-align: left; }
.card.mid { max-width: 740px; }
.mg-title {
  margin: 4px 0 6px; font-size: 42px; font-weight: 900; letter-spacing: 0.02em; line-height: 1;
  font-family: Georgia, "Times New Roman", serif; color: var(--text);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.mg-title.small { font-size: 26px; margin: 0; }
.title-accent { margin-left: 0.22em; color: var(--accent); font-style: italic; }
.tagline { color: var(--dim); font-size: 15px; line-height: 1.45; margin: 8px 0 12px; }
.tagline b { color: var(--text); }
.join-demo { display: flex; justify-content: center; gap: 5px; margin: 6px 0 16px; flex-wrap: wrap; }
#nameInput {
  width: 100%; padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; font-size: 16px;
  border: 1px solid var(--edge); background: rgba(0, 0, 0, 0.3); color: var(--text); text-align: center;
}
button.primary {
  display: block; width: 100%; padding: 13px 16px; border: 0; border-radius: 12px;
  font-weight: 800; font-size: 16px; color: #1c1408;
  background: linear-gradient(180deg, #ffe08a, #f2b632);
  box-shadow: 0 3px 0 #9a6a10, 0 8px 20px rgba(0, 0, 0, 0.3);
}
button.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #9a6a10; }
button.primary:disabled { opacity: 0.5; cursor: default; }
button.ghost {
  padding: 9px 14px; border-radius: 11px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.06); font-weight: 700; font-size: 14px;
}
button.ghost:hover { background: rgba(255, 255, 255, 0.12); }
#joinPane .ghost { width: 100%; margin-top: 8px; }
.lobby-audio { margin: 12px auto 0; display: flex; justify-content: center; }
.back-link { display: inline-block; margin-top: 12px; color: var(--dim); font-size: 13px; text-decoration: none; }
.back-link:hover { color: var(--text); }
.btn-row { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.btn-row .primary { width: auto; flex: 1 1 160px; }
.btn-row .ghost { flex: 0 1 auto; }

.hub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hub-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; margin: 14px 0 12px; border-bottom: 1px solid var(--edge); }
.tab {
  padding: 10px 16px; border: 1px solid transparent; border-bottom: 0; border-radius: 12px 12px 0 0;
  background: transparent; font-weight: 800; color: var(--dim);
}
.tab.active { background: rgba(255, 255, 255, 0.08); color: var(--text); border-color: var(--edge); }
.tab-stars { font-weight: 600; font-size: 12px; color: var(--gold); margin-left: 6px; }
.save-note { margin: 0 0 10px; }

.feature-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.feature {
  padding: 14px; border-radius: 14px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.05);
  display: flex; flex-direction: column; gap: 8px;
}
.daily-card { background: linear-gradient(135deg, rgba(243, 169, 192, 0.18), rgba(255, 255, 255, 0.04)); }
.feature-title { font-size: 20px; font-weight: 800; font-family: Georgia, serif; }
.feature p { margin: 0; }
.feature select, .setting select {
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--edge);
  background: #15301f; color: var(--text); max-width: 100%;
}
.check { font-size: 13px; color: var(--dim); display: flex; gap: 8px; align-items: flex-start; }
.path-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 8px; }
.path-head h3 { margin: 0; font-family: Georgia, serif; font-size: 19px; }
.path-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.node {
  position: relative; padding: 9px 9px 8px; border-radius: 13px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.05); text-align: left; display: flex; flex-direction: column; gap: 3px;
}
.node:hover:not(.locked) { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 211, 77, 0.6); }
.node.next { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(255, 211, 77, 0.25); }
.node.locked { opacity: 0.5; cursor: default; }
.node canvas { align-self: center; margin: 2px 0 4px; }
.node-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--dim); }
.node-name { font-weight: 800; font-size: 14px; line-height: 1.15; }
.node-foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--dim); }
.node-stars span { color: rgba(255, 255, 255, 0.22); }
.node-stars b { color: var(--gold); font-weight: 400; }
.diff { padding: 1px 7px; border-radius: 99px; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; border: 1px solid var(--edge); }
.diff.easy { color: #a8e6a1; } .diff.medium { color: #ffd98a; } .diff.hard { color: #ffab9e; }

.multi-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 18px; }
.player-list { display: flex; flex-direction: column; gap: 5px; margin: 6px 0 10px; }
.player-row {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.05); border: 1px solid transparent; font-size: 14px; flex-wrap: wrap;
}
.player-row.me { border-color: rgba(255, 211, 77, 0.5); }
.player-name { font-weight: 700; }
.pstars { color: var(--gold); font-size: 12px; }
.tag { margin-left: auto; font-size: 11px; color: var(--dim); }
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 6px 0 6px; }
.mode-grid button {
  padding: 9px 10px; border-radius: 12px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.05);
  text-align: left; display: flex; flex-direction: column; gap: 2px;
}
.mode-grid button b { font-size: 14px; }
.mode-grid button small { font-size: 11px; color: var(--dim); }
.mode-grid button.on { border-color: var(--gold); background: rgba(255, 211, 77, 0.14); }
.mode-grid button:disabled, .seg button:disabled, .stepper button:disabled { cursor: default; }
.mode-blurb { min-height: 34px; margin: 4px 0 8px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; font-size: 14px; }
.setting select { flex: 1 1 auto; min-width: 0; max-width: 260px; }
.seg { display: inline-flex; border: 1px solid var(--edge); border-radius: 10px; overflow: hidden; }
.seg button { padding: 7px 12px; border: 0; background: transparent; font-weight: 700; font-size: 13px; }
.seg button.on { background: rgba(255, 211, 77, 0.2); color: var(--gold); }
.stepper { display: inline-flex; align-items: center; gap: 10px; }
.stepper button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); font-weight: 800; }
.stepper b { min-width: 16px; text-align: center; }
#startBtn { margin-top: 12px; }
.round-note { padding: 10px 12px; border-radius: 10px; background: rgba(255, 211, 77, 0.12); border: 1px solid rgba(255, 211, 77, 0.35); margin-bottom: 10px; font-size: 14px; }
.round-note .ghost { margin-left: 8px; padding: 5px 10px; }

.count-info { font-size: 18px; font-weight: 800; }
.countdown { font-size: 110px; font-weight: 900; line-height: 1.1; color: var(--gold); font-family: Georgia, serif; }
.end-stars { font-size: 46px; letter-spacing: 8px; text-align: center; margin: 6px 0; }
.end-stars span { color: rgba(255, 255, 255, 0.16); display: inline-block; transition: transform 0.3s, color 0.3s; }
.end-stars span.on { color: var(--gold); transform: scale(1.18); text-shadow: 0 0 18px rgba(255, 211, 77, 0.6); }
.end-line { text-align: center; font-size: 16px; margin: 4px 0; }
.end-daily { text-align: center; color: var(--accent); font-weight: 700; }
.end-credits { text-align: center; color: var(--gold); font-weight: 700; min-height: 20px; margin: 6px 0; }
#soloEndPane, #roundPane, #resultsPane, #countPane, #errorPane { text-align: center; }
.series { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.chip { padding: 6px 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--edge); font-size: 13px; display: inline-flex; gap: 8px; }
.chip b { color: var(--gold); }
.fs-table .fs-name-col { min-width: 8.5em; }
.lb-panel, .lb-card { --lb-accent: #ffd34d; --lb-text: #f6f0dc; --lb-dim: rgba(246, 240, 220, 0.62); --lb-edge: rgba(240, 232, 208, 0.16); --lb-panel: rgba(14, 34, 26, 0.97); }

/* ── play ──────────────────────────────────────────────────────────────── */
#playScreen { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; }
#playTop {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(8, 22, 16, 0.9), rgba(8, 22, 16, 0.62));
  border-bottom: 1px solid var(--edge); z-index: 3;
}
.icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 11px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.07); font-size: 17px; font-weight: 800; line-height: 1;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.hud-title { font-weight: 800; font-size: 15px; line-height: 1.15; min-width: 0; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: Georgia, serif; }
.hud-title small { display: block; font-weight: 400; font-size: 11px; color: var(--dim); font-family: "Trebuchet MS", sans-serif; overflow: hidden; text-overflow: ellipsis; }
.stats { display: flex; gap: 6px; margin: 0 auto; }
.stat {
  display: flex; align-items: baseline; gap: 7px; padding: 5px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, 0.32); border: 1px solid var(--edge);
}
.stat .k { font-size: 12px; color: var(--dim); }
.stat b { font-size: 19px; font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; }
.stat b.low { color: #ff8a7a; }
.pop {
  position: absolute; right: 8px; top: 54px; z-index: 12; padding: 12px; border-radius: 14px;
  background: var(--moss-solid); border: 1px solid var(--edge); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.look-pop { width: min(330px, calc(100vw - 16px)); }
.look-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.look-row button { padding: 7px 10px; border-radius: 10px; border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.06); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.look-row button.on { border-color: var(--gold); background: rgba(255, 211, 77, 0.16); }
.swatch { width: 14px; height: 18px; border-radius: 3px; display: inline-block; border: 1px solid rgba(255, 255, 255, 0.5); }

.turn-bar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: rgba(8, 22, 16, 0.78); border-bottom: 1px solid var(--edge); font-weight: 800; font-size: 14px; z-index: 2; }
.turn-bar.mine { background: rgba(255, 211, 77, 0.2); color: var(--gold); }
.turn-track { flex: 1 1 auto; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.turn-track i { display: block; height: 100%; width: 100%; background: var(--gold); border-radius: 99px; }
.turn-track i.low { background: #ff7a66; }

#playMain { flex: 1 1 auto; min-height: 0; display: flex; position: relative; }
#boardWrap { flex: 1 1 auto; min-width: 0; position: relative; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
#rivalPanel {
  flex: 0 0 214px; padding: 10px; overflow-y: auto; z-index: 2;
  background: rgba(8, 22, 16, 0.72); border-left: 1px solid var(--edge);
}
.rival-list { display: flex; flex-direction: column; gap: 7px; margin-top: 6px; }
.rival {
  padding: 7px 9px; border-radius: 11px; background: rgba(255, 255, 255, 0.06); border: 1px solid transparent;
  border-left: 5px solid var(--seat, #888); display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center;
}
.rival.me { border-color: rgba(255, 255, 255, 0.28); border-left-color: var(--seat, #888); }
.rival.turn { background: rgba(255, 211, 77, 0.16); }
.rival.finished { background: rgba(75, 224, 138, 0.14); }
.rival.away { opacity: 0.5; }
.rival canvas { grid-row: span 2; border-radius: 6px; background: rgba(0, 0, 0, 0.28); }
.r-name { font-weight: 700; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-score { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.r-score b { color: var(--text); font-size: 15px; margin-right: 5px; }
.team-box { padding: 9px 10px; border-radius: 11px; background: rgba(243, 169, 192, 0.14); border: 1px solid rgba(243, 169, 192, 0.4); margin-top: 6px; font-size: 13px; }
.team-box b { font-size: 17px; }
.team-stars { color: var(--gold); letter-spacing: 3px; font-size: 16px; }
.team-stars .off { color: rgba(255, 255, 255, 0.2); }
.bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.3s; }

.me-plate {
  position: absolute; left: 10px; bottom: 8px; z-index: 2; padding: 5px 11px; border-radius: 10px; font-size: 13px;
  background: rgba(8, 22, 16, 0.7); border: 1px solid var(--edge); border-left: 5px solid var(--seat, var(--gold));
  max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.me-name { font-weight: 800; }
.star-box {
  position: absolute; right: 10px; bottom: 8px; z-index: 2; display: flex; gap: 10px; padding: 5px 11px;
  border-radius: 10px; background: rgba(8, 22, 16, 0.7); border: 1px solid var(--edge); font-size: 15px; pointer-events: none;
}
.pip { color: rgba(255, 255, 255, 0.25); }
.pip small { font-size: 11px; color: var(--dim); }
.pip.on { color: var(--gold); }
.pip.lost small { text-decoration: line-through; }
.combo {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); z-index: 2; padding: 4px 14px;
  border-radius: 99px; background: rgba(243, 169, 192, 0.92); color: #3a0f1f; font-weight: 900; font-size: 15px;
  pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.combo.bump { animation: bump 0.25s; }
@keyframes bump { 50% { transform: translateX(-50%) scale(1.25); } }
.banner {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); z-index: 4; padding: 16px 26px;
  border-radius: 18px; background: rgba(8, 22, 16, 0.9); border: 1px solid var(--gold); text-align: center;
  font-size: 26px; font-weight: 900; font-family: Georgia, serif; color: var(--gold); pointer-events: none;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5); max-width: 92%;
}
.banner small { display: block; font-size: 14px; font-weight: 400; color: var(--text); font-family: "Trebuchet MS", sans-serif; margin-top: 4px; }
.stuck {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 5; width: min(430px, 94%);
  padding: 14px 16px; border-radius: 16px; background: rgba(8, 22, 16, 0.94); border: 1px solid var(--gold);
  text-align: center; box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.stuck b { font-size: 19px; color: var(--gold); font-family: Georgia, serif; }
.stuck p { margin: 6px 0 0; font-size: 13px; color: var(--dim); }
.big-count { position: absolute; left: 50%; top: 44%; transform: translate(-50%, -50%); z-index: 6; font-size: 120px; font-weight: 900; color: var(--gold); font-family: Georgia, serif; text-shadow: 0 6px 30px rgba(0, 0, 0, 0.7); pointer-events: none; }
.toast {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%); z-index: 7; padding: 9px 16px;
  border-radius: 12px; background: rgba(8, 22, 16, 0.94); border: 1px solid var(--edge); font-size: 14px; font-weight: 700;
  max-width: 92%; text-align: center; pointer-events: none; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.toast.warn { border-color: #ff8a7a; color: #ffd0c8; }
.spectator-flag {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%); z-index: 8; padding: 6px 14px;
  border-radius: 99px; background: rgba(8, 22, 16, 0.9); border: 1px solid var(--edge); font-size: 12px; font-weight: 800; letter-spacing: 0.06em;
}
.spectate-grid { position: absolute; inset: 0; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.spectate-grid .rival { grid-template-columns: 1fr; text-align: center; padding: 12px; }
.spectate-grid .rival canvas { grid-row: auto; margin: 0 auto 6px; }

#toolBar {
  display: flex; justify-content: center; gap: 8px; padding: 7px 10px;
  padding-bottom: max(7px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(8, 22, 16, 0.92), rgba(8, 22, 16, 0.66)); border-top: 1px solid var(--edge); z-index: 3;
}
.tool {
  flex: 0 1 132px; min-height: 46px; padding: 6px 10px; border-radius: 13px; border: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.08); display: flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 14px;
}
.tool:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool.on { border-color: var(--gold); color: var(--gold); background: rgba(255, 211, 77, 0.14); }
.tool .ti { font-size: 19px; line-height: 1; }

/* ── modals ────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 16px 10px; background: rgba(4, 12, 8, 0.72); }
.modal-card { position: relative; width: 100%; max-width: 860px; margin: auto; padding: 20px; border-radius: 18px; background: var(--moss-solid); border: 1px solid var(--edge); box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6); }
.help-close { position: absolute; right: 12px; top: 12px; }
.help-card h2, .tutor-card h2 { margin: 0 0 10px; font-family: Georgia, serif; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 22px; }
.help-grid h3 { margin: 10px 0 4px; font-size: 15px; color: var(--gold); }
.help-grid p { margin: 6px 0; font-size: 14px; line-height: 1.45; }
.help-row { display: flex; gap: 10px; align-items: center; margin: 8px 0; font-size: 14px; line-height: 1.4; }
.help-icons { flex: 0 0 auto; display: inline-flex; gap: 3px; }
.help-card .primary { margin-top: 14px; }
.tutor-card { max-width: 620px; text-align: center; }
.coach-tag { display: inline-block; padding: 3px 10px; border-radius: 99px; background: var(--accent); color: #3a0f1f; font-size: 11px; font-weight: 900; letter-spacing: 0.1em; text-transform: uppercase; }
.tutor-text { font-size: 17px; line-height: 1.45; margin: 10px 0 6px; min-height: 74px; }
.tutor-text b { color: var(--gold); }
.tutor-board { position: relative; height: 230px; border-radius: 14px; background: radial-gradient(ellipse at center, #2f5a3a, #1a3626); border: 1px solid var(--edge); }
.tutor-board canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.tutor-note { min-height: 22px; font-size: 14px; color: #ffd0c8; margin: 8px 0 0; font-weight: 700; }
.tutor-card .primary { margin-top: 10px; }

/* ── phones ────────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
  .feature-row, .multi-cols, .help-grid { grid-template-columns: 1fr; }
  #playMain { flex-direction: column; }
  #rivalPanel { order: -1; flex: 0 0 auto; padding: 5px 8px; border-left: 0; border-bottom: 1px solid var(--edge); overflow-x: auto; overflow-y: hidden; }
  #rivalPanel .mg-label { display: none; }
  .rival-list { flex-direction: row; margin-top: 0; }
  .rival { flex: 0 0 auto; padding: 4px 8px; min-width: 96px; }
  .team-box { margin: 0 0 5px; padding: 5px 9px; }
  .spectator-flag { bottom: 70px; }
}
@media (max-width: 640px) {
  .card { padding: 16px 14px 14px; border-radius: 16px; }
  .mg-title { font-size: 34px; }
  .mg-title.small { font-size: 21px; }
  .hub-actions .ghost { padding: 7px 9px; font-size: 12px; }
  .path-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #playTop { flex-wrap: wrap; gap: 5px; padding: 5px 6px; }
  .hud-title { flex: 1 1 0; font-size: 13px; }
  .stats { order: 5; flex: 1 1 100%; margin: 0; gap: 4px; }
  .stat { flex: 1 1 0; padding: 4px 6px; gap: 4px; justify-content: center; flex-direction: column; align-items: center; }
  .stat .k { font-size: 10px; }
  .stat b { font-size: 16px; min-width: 0; }
  .icon-btn { width: 36px; height: 36px; flex-basis: 36px; }
  .pop { top: 48px; }
  #toolBar { gap: 5px; padding: 6px 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .tool { flex: 1 1 0; min-height: 52px; flex-direction: column; gap: 2px; padding: 4px 2px; font-size: 11px; }
  .tool .ti { font-size: 21px; }
  .star-box { font-size: 13px; gap: 7px; padding: 4px 8px; }
  .pip small { display: none; }
  .me-plate { font-size: 12px; }
  .banner { font-size: 21px; padding: 12px 18px; }
  .countdown { font-size: 90px; }
  .fs-table .fs-name-col { min-width: 7em; }
  .fs-table { font-size: 12.5px; }
  .fs-table th, .fs-table td { padding-left: 5px !important; padding-right: 5px !important; }
  .tutor-text { font-size: 15px; min-height: 96px; }
  .tutor-board { height: 200px; }
  .mode-grid button small { display: none; }
}
@media (max-height: 520px) and (orientation: landscape) {
  /* a phone on its side: the strips give the board every pixel they can */
  #playTop { padding: 3px 8px; }
  .icon-btn { width: 32px; height: 32px; flex-basis: 32px; font-size: 15px; }
  .stat { padding: 3px 9px; }
  .stat b { font-size: 16px; }
  #toolBar { padding: 4px 8px; }
  .tool { min-height: 36px; flex-direction: row; font-size: 12px; }
  #rivalPanel { flex-basis: 150px; }
}
