/* ============================================================
   Monopoly demo - stylesheet (1280x800 desktop target)
   ============================================================ */
:root {
  --bg: #eef1f6;
  --card: #ffffff;
  --line: #e3e7ee;
  --ink: #1c2333;
  --ink-2: #5a6478;
  --ink-3: #9aa3b5;
  --accent: #3556d4;
  --accent-2: #2743b0;
  --good: #17915b;
  --bad: #d13a3a;
  --gold: #f5a623;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(28, 35, 51, 0.08);
  --player-colors: #e0453a #2f6fed #149a68 #8e44ad;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  background: linear-gradient(160deg, #f4f6fb 0%, #e8ecf4 100%);
  color: var(--ink);
  font-size: 14px;
  overflow: hidden;
}

#app { height: 100vh; display: flex; flex-direction: column; padding: 12px 20px 14px; }

/* ---------------- top bar ---------------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 2px 4px 10px;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: 2px; }
.brand .sub { font-size: 12px; font-weight: 500; color: var(--ink-3); margin-left: 10px; letter-spacing: 4px; }
.bank { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------------- layout ---------------- */
.layout { flex: 1; display: flex; gap: 18px; min-height: 0; }
.board-wrap { flex: none; }
.side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; min-height: 0; }

.side-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px;
}
.side-title { font-size: 12px; font-weight: 700; color: var(--ink-3); letter-spacing: 3px; margin-bottom: 8px; }
.log-card { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ============================================================
   Board (11x11 grid, corners 1.55x)
   ============================================================ */
.board {
  position: relative;
  /* fluid square: capped at the 706px desktop design size, shrinks on shorter
     or narrower viewports so the side column keeps usable room; <=768px below
     makes it fill the phone width */
  width: min(706px, calc(100vw - 372px), calc(100vh - 90px));
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: 1.55fr repeat(9, 1fr) 1.55fr;
  grid-template-rows: 1.55fr repeat(9, 1fr) 1.55fr;
  gap: 3px;
}

.cell {
  position: relative;
  background: var(--card);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 3px 2px;
}
.cell .name { font-size: clamp(8px, 2.2vw, 10.5px); font-weight: 600; line-height: 1.15; color: var(--ink); }
.cell .price { font-size: clamp(6.5px, 1.9vw, 9px); color: var(--ink-2); margin-top: 2px; font-variant-numeric: tabular-nums; }
/* full price ("¥1,500") on desktop, compact form ("1.5k") on phones */
.cell .price .p-short { display: none; }
.cell .icon { font-size: clamp(12px, 3.6vw, 17px); line-height: 1.1; }
.cell .icon + .name { margin-top: 1px; }
.cell.corner .icon { font-size: clamp(16px, 4.6vw, 24px); }
.cell.corner .name { font-size: clamp(9px, 2.5vw, 12px); margin-top: 3px; }

/* group color strip on the inner edge, owner strip on the outer edge */
.strip { position: absolute; display: flex; align-items: center; justify-content: center; z-index: 1; }
.strip.group { background: #cbd2de; }
.strip.owner { display: none; }

.cell.s-bottom .strip.group { top: 0; left: 0; right: 0; height: 8px; border-radius: 8px 8px 0 0; }
.cell.s-bottom .strip.owner { bottom: 0; left: 0; right: 0; height: 4px; }
.cell.s-left   .strip.group { right: 0; top: 0; bottom: 0; width: 8px; border-radius: 0 8px 8px 0; }
.cell.s-left   .strip.owner { left: 0; top: 0; bottom: 0; width: 4px; }
.cell.s-top    .strip.group { bottom: 0; left: 0; right: 0; height: 8px; border-radius: 0 0 8px 8px; }
.cell.s-top    .strip.owner { top: 0; left: 0; right: 0; height: 4px; }
.cell.s-right  .strip.group { left: 0; top: 0; bottom: 0; width: 8px; border-radius: 8px 0 0 8px; }
.cell.s-right  .strip.owner { right: 0; top: 0; bottom: 0; width: 4px; }

.cell .houses {
  position: absolute; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; line-height: 1; letter-spacing: -1px;
  color: #0c7a43; text-shadow: 0 0 2px #fff;
}
.cell.s-bottom .houses { top: 0;  left: 0; right: 0; height: 8px; }
.cell.s-top    .houses { bottom: 0; left: 0; right: 0; height: 8px; }
.cell.s-left   .houses { right: 0; top: 0; bottom: 0; width: 8px; flex-direction: column; }
.cell.s-right  .houses { left: 0; top: 0; bottom: 0; width: 8px; flex-direction: column; }
.cell .houses .hotel { color: #b3261e; }

.cell.mortgaged .name, .cell.mortgaged .price, .cell.mortgaged .icon { opacity: 0.38; }
.cell .mtag {
  display: none; position: absolute; z-index: 3;
  top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-14deg);
  font-size: 9px; font-weight: 800; color: #b3261e;
  border: 1px solid #b3261e; border-radius: 4px; padding: 0 3px;
  background: rgba(255, 255, 255, 0.85);
}
.cell.mortgaged .mtag { display: block; }

/* landing flash + purchasable pulse */
@keyframes cellFlash {
  0% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 3px rgba(245, 166, 35, 0.55); }
  100% { box-shadow: inset 0 0 0 1px var(--line); }
}
.cell.flash { animation: cellFlash 0.9s ease-out; }

@keyframes cellPulse {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 0 rgba(53, 86, 212, 0.4); }
  50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 5px rgba(53, 86, 212, 0.18); }
}
.cell.pending { animation: cellPulse 1.2s ease-in-out infinite; }

/* ---------------- board center panel ---------------- */
.center-panel {
  grid-area: 2 / 2 / 11 / 11;
  border-radius: 16px;
  background: radial-gradient(120% 120% at 20% 0%, #2c3a63 0%, #1b2542 55%, #141d36 100%);
  color: #f2f5ff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(5px, 1.4vw, 10px);
  box-shadow: 0 10px 30px rgba(20, 29, 54, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}
.game-title { font-size: clamp(16px, 8vw, 40px); font-weight: 900; letter-spacing: clamp(4px, 3vw, 14px); text-indent: clamp(4px, 3vw, 14px); }
.turn-line { font-size: clamp(11px, 3vw, 15px); font-weight: 700; display: flex; align-items: center; gap: 8px; }
.turn-line .dot { width: clamp(8px, 2.4vw, 12px); height: clamp(8px, 2.4vw, 12px); border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.65); }
.phase-line { font-size: clamp(9px, 2.4vw, 12px); color: #b9c3e2; text-align: center; padding: 0 8px; }

.dice-area { display: flex; align-items: center; gap: clamp(7px, 2vw, 12px); margin-top: 6px; }
.die {
  width: clamp(34px, 9vw, 46px); height: clamp(34px, 9vw, 46px); background: #fdfdfd; border-radius: 10px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  padding: clamp(4px, 1.2vw, 6px); gap: clamp(1px, 0.4vw, 2px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.08);
  flex: none;
}
.die .pip { border-radius: 50%; background: #23293c; place-self: center; width: clamp(5px, 1.4vw, 8px); height: clamp(5px, 1.4vw, 8px); }
.die.rolling { animation: diceShake 0.42s ease-in-out infinite; }
@keyframes diceShake {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-14deg) translateY(-4px); }
  75% { transform: rotate(14deg) translateY(-2px); }
}
.dice-sum { font-size: clamp(11px, 3vw, 15px); font-weight: 800; color: #ffd76a; min-width: clamp(30px, 8vw, 44px); text-align: center; }

.banner {
  position: absolute; left: 50%; bottom: 14%; transform: translateX(-50%);
  background: rgba(10, 14, 28, 0.85); border: 1px solid rgba(255, 255, 255, 0.22);
  color: #fff; font-size: clamp(11px, 3vw, 14px); font-weight: 700;
  border-radius: 999px; padding: 8px 20px; white-space: nowrap;
  max-width: 92%; overflow: hidden; text-overflow: ellipsis;
  animation: bannerIn 0.25s ease-out;
}
.banner.hidden { display: none; }
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------------- player tokens ---------------- */
.tokens-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.token {
  position: absolute; width: 17px; height: 17px; border-radius: 50%;
  border: 2.5px solid #fff; border-radius: 50%;
  border-width: clamp(1.5px, 0.5vw, 2.5px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -50%);
  transition: left 0.11s linear, top 0.11s linear;
  z-index: 5;
}
.token.jail::after {
  content: "⛓"; position: absolute; right: -7px; top: -9px; font-size: 10px;
}

/* ============================================================
   Player panels
   ============================================================ */
.players { display: flex; flex-direction: column; gap: 8px; }
.pcard {
  position: relative;
  border: 1px solid var(--line); border-left-width: 5px; border-radius: 10px;
  padding: 8px 10px; background: #fbfcfe;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.pcard.active { box-shadow: 0 0 0 2px var(--accent), var(--shadow); border-color: var(--line); }
.pcard.active::after {
  content: "行动中"; position: absolute; right: 8px; top: 8px;
  font-size: 10px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 2px 8px;
}
.pcard.active .row1 { padding-right: 58px; } /* keep cash clear of the badge */
.pcard.bankrupt { opacity: 0.45; filter: grayscale(1); }
.pcard .row1 { display: flex; align-items: center; gap: 8px; }
.pcard .pdot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.pcard .pname { font-weight: 800; font-size: clamp(12px, 3vw, 14px); }
.pcard .pcash { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; font-size: clamp(13px, 3.2vw, 15px); }
.pcard .row2 { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.pcard .meta { font-size: 11px; color: var(--ink-2); }
.badge {
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 2px 7px;
  background: #eceff5; color: var(--ink-2);
}
.badge.jail { background: #fdeaea; color: #b3261e; }
.badge.card { background: #fff6e0; color: #9a6b00; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; border: 1px solid var(--line); border-radius: 6px;
  padding: 1px 6px; background: #fff; color: var(--ink);
}
.chip i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chip.mt { opacity: 0.5; text-decoration: line-through; }
.chip .lv { color: #0c7a43; font-weight: 700; }

/* floating +/- hints over panels */
@keyframes floatUp { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-26px); } }
.floater {
  position: absolute; right: 10px; top: 4px; z-index: 8;
  font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums;
  pointer-events: none; animation: floatUp 1.2s ease-out forwards;
  text-shadow: 0 1px 0 #fff;
}
.floater.good { color: var(--good); }
.floater.bad { color: var(--bad); }

/* ============================================================
   Actions
   ============================================================ */
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn {
  font: inherit; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink);
  padding: 8px 14px; transition: transform 0.06s, box-shadow 0.15s, background 0.15s;
  touch-action: manipulation; /* kill the double-tap-zoom delay on touch */
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent-2); color: #fff; }
.btn.big { font-size: 16px; padding: 10px 34px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }
.hint { font-size: 11px; color: var(--ink-3); }

/* hover is an enhancement only: never gate information behind it */
@media (hover: hover) {
  .btn:hover { background: #f4f6fb; }
  .btn.primary:hover { background: var(--accent-2); }
  .mgmt-btn:hover { background: #f0f3fa; }
  .count-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(53, 86, 212, 0.18); }
}

.buy-box {
  border: 1px dashed var(--accent); background: #f4f7ff;
  border-radius: 10px; padding: 10px 12px; font-size: 13px;
}
.buy-box .bname { font-weight: 800; font-size: 15px; }
.buy-box .bprice { color: var(--accent); font-weight: 800; }

.mgmt-block { display: flex; flex-direction: column; gap: 5px; }
.mgmt-toggle {
  display: none; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 4px 10px; touch-action: manipulation;
}
.mgmt-list { display: flex; flex-direction: column; gap: 5px; max-height: 168px; overflow: auto; overscroll-behavior: contain; }
.mgmt-row {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px 4px 8px; font-size: 12px;
}
.mgmt-row .gdot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.mgmt-row .gname { font-weight: 700; white-space: nowrap; }
.mgmt-row .gstate { color: var(--ink-3); font-size: 10.5px; }
.mgmt-row .spacer { flex: 1; }
.mgmt-btn {
  font: inherit; font-size: 11px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 7px;
  white-space: nowrap;
  touch-action: manipulation;
}
.mgmt-btn.build { color: #0c7a43; border-color: #bfe3d0; }
.mgmt-btn.sell { color: #9a6b00; border-color: #ecd9a8; }
.mgmt-btn.mtg { color: #b3261e; border-color: #f0c4c4; }
.mgmt-btn.rdm { color: var(--accent); border-color: #c3cff2; }

/* ============================================================
   Log
   ============================================================ */
.log { flex: 1; min-height: 0; overflow-y: auto; font-size: 12px; line-height: 1.5; padding-right: 4px; overscroll-behavior: contain; }

/* log card header: title + latest-line preview + (mobile-only) expand toggle */
.log-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.log-head .side-title { margin-bottom: 0; flex: none; }
.log-preview {
  display: none; flex: 1; min-width: 0;
  font-size: 11px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.log-toggle {
  display: none; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 8px; padding: 4px 10px; touch-action: manipulation;
}
.log .log-line { padding: 1px 0; color: var(--ink-2); border-bottom: 1px dashed #eef1f6; }
.log .sep { color: var(--accent); font-weight: 800; }
.log .good { color: var(--good); }
.log .bad { color: var(--bad); }
.log .warn { color: #9a6b00; }
.log .big { font-weight: 800; }

/* ============================================================
   Overlays & dialogs
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 21, 38, 0.62); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
}
.overlay.hidden { display: none; }
.dialog {
  background: var(--card); border-radius: 20px; box-shadow: 0 24px 70px rgba(10, 15, 30, 0.45);
  padding: 34px 46px; text-align: center; max-width: 460px;
  animation: dialogIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes dialogIn { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
.dialog-logo { font-size: 46px; }
.dialog-title { font-size: 34px; font-weight: 900; letter-spacing: 8px; text-indent: 8px; margin: 6px 0 4px; }
.dialog-sub { color: var(--ink-2); font-size: 13px; }
.dialog-label { margin: 22px 0 10px; font-size: 13px; color: var(--ink-2); font-weight: 700; }
.count-row { display: flex; gap: 12px; justify-content: center; }
.count-btn {
  font: inherit; font-size: 17px; font-weight: 800; cursor: pointer;
  width: 92px; padding: 14px 0; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
  transition: all 0.15s;
  touch-action: manipulation;
}
.dialog-hint { margin-top: 20px; font-size: 11px; color: var(--ink-3); }

.card-dialog { padding: 30px 38px 26px; }
.card-deck-tag {
  display: inline-block; font-size: 13px; font-weight: 800; letter-spacing: 6px; text-indent: 6px;
  color: #fff; border-radius: 999px; padding: 5px 16px; margin-bottom: 14px;
}
.card-deck-tag.chance { background: linear-gradient(135deg, #f5a623, #ed7226); }
.card-deck-tag.chest { background: linear-gradient(135deg, #2f9e6e, #1d7a8c); }
.card-text { font-size: 15px; line-height: 1.7; margin-bottom: 20px; color: var(--ink); }

/* scrollbars (webkit) */
.log::-webkit-scrollbar, .mgmt-list::-webkit-scrollbar { width: 6px; }
.log::-webkit-scrollbar-thumb, .mgmt-list::-webkit-scrollbar-thumb { background: #cdd4e0; border-radius: 3px; }

/* ============================================================
   Mobile & narrow screens (<= 768px portrait)
   Board keeps its 11x11 square and fills the viewport width;
   players collapse to compact strips; primary actions dock to
   the bottom (safe-area aware); the log becomes a drawer.
   Desktop (>=1024px) is untouched by this block.
   ============================================================ */
@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  body { overflow-y: auto; }

  #app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: calc(6px + env(safe-area-inset-top, 0px))
             calc(8px + env(safe-area-inset-right, 0px))
             calc(180px + env(safe-area-inset-bottom, 0px)) /* room for the tallest closed action dock (~170px) */
             calc(8px + env(safe-area-inset-left, 0px));
  }

  .topbar { padding: 2px 2px 8px; }
  .layout { flex-direction: column; gap: 10px; }
  .side { gap: 8px; }
  .side-card { padding: 8px 10px; }

  /* ---- board: square, full width ---- */
  .board-wrap { width: 100%; }
  .board {
    width: min(100%, calc(100vh - 330px));
    gap: 2px;
  }
  .cell { padding: 2px 1px; border-radius: 5px; }
  /* long property names ellipsize instead of wrapping the tiny cell */
  .cell .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .cell .price .p-full { display: none; }
  .cell .price .p-short { display: inline; }

  .center-panel { gap: 4px; border-radius: 10px; }
  .dice-area { margin-top: 2px; }
  .banner { bottom: 10%; padding: 6px 14px; }

  /* ---- players: compact horizontal strips ---- */
  .players { gap: 6px; }
  .pcard { padding: 5px 8px; border-radius: 8px; border-left-width: 4px; }
  .pcard.active::after { font-size: 9px; padding: 1px 7px; right: 6px; top: 5px; }
  .pcard.active .row1 { padding-right: 52px; }
  .pcard .row1 { gap: 6px; }
  .pcard .pdot { width: 10px; height: 10px; }
  /* property chips become a single horizontally scrollable strip */
  .pcard .row2 { flex-wrap: nowrap; overflow-x: auto; margin-top: 4px; padding-bottom: 2px; overscroll-behavior: contain; }
  .pcard .chip { flex: none; }
  .pcard .row2::-webkit-scrollbar { height: 3px; }
  .pcard .row2::-webkit-scrollbar-thumb { background: #cdd4e0; border-radius: 2px; }

  /* ---- actions: fixed bottom dock, safe-area aware ---- */
  .actions-card {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    border-radius: 16px 16px 0 0;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -6px 24px rgba(28, 35, 51, 0.16);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  /* hide the empty dock before a game starts / after it ends */
  .actions-card:has(#actions:empty) { display: none; }
  .actions-card .side-title { display: none; }
  .actions { flex-direction: row; flex-wrap: wrap; gap: 8px; }
  .actions .btn { flex: 1 1 44%; min-height: 44px; font-size: 15px; }
  .actions .btn.big { flex-basis: 100%; font-size: 16px; padding: 10px 20px; }
  .actions .btn-row { flex: 1 1 100%; }
  .actions .btn-row .btn { min-height: 44px; }
  .actions .hint { flex-basis: 100%; }
  .buy-box { flex: 1 1 100%; padding: 8px 10px; font-size: 12px; }
  .buy-box .bname { font-size: 14px; }
  .buy-box .btn-row { margin-top: 6px; }
  .mgmt-block { flex: 1 1 100%; }
  .mgmt-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 6px 14px; border-radius: 10px;
  }
  .mgmt-block .hint { display: none; }
  .mgmt-block:not(.open) .mgmt-list { display: none; }
  .mgmt-block.open .mgmt-list { max-height: 30vh; } /* expanded on purpose: may cover content, collapsible */
  .mgmt-row { flex-wrap: wrap; min-height: 44px; padding: 4px 6px 4px 8px; row-gap: 2px; }
  .mgmt-btn { min-height: 44px; padding: 4px 12px; font-size: 12px; }

  /* ---- log: collapsible drawer ---- */
  .log-card { flex: none; }
  .log-head { margin-bottom: 0; gap: 10px; }
  .log-head .side-title { display: none; }
  .log-preview { display: block; }
  .log-toggle { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 6px 14px; border-radius: 10px; flex: none; }
  .log-card:not(.open) .log { display: none; }
  .log-card.open .log { max-height: 34vh; -webkit-overflow-scrolling: touch; }

  /* ---- dialogs: never spill off a small screen ---- */
  .overlay { padding: 12px; }
  .dialog {
    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    padding: 24px 18px 20px;
    border-radius: 16px;
  }
  .dialog-logo { font-size: 36px; }
  .dialog-title { font-size: clamp(22px, 7vw, 34px); letter-spacing: clamp(3px, 1.6vw, 8px); text-indent: clamp(3px, 1.6vw, 8px); }
  .count-row { gap: 10px; }
  .count-btn { width: min(92px, 25vw); min-height: 44px; font-size: 15px; padding: 10px 0; }
  .dialog-hint { margin-top: 14px; }
  .card-dialog { padding: 22px 18px 18px; }
  .card-text { font-size: 14px; margin-bottom: 16px; }
}

/* ============================================================
   Audio toggles (topbar) — appended for js/audio.js integration.
   Desktop: bank text + the two switches share the right side of
   the topbar. Phones: the topbar wraps so the switches stay
   reachable without ever forcing horizontal scroll.
   ============================================================ */
.topbar-right { display: flex; align-items: center; gap: 14px; min-width: 0; }
.audio-controls { display: flex; align-items: center; gap: 6px; }
.audio-toggle {
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 5px 12px; white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  touch-action: manipulation;
}
.audio-toggle.off { color: var(--ink-3); background: #f1f3f8; border-style: dashed; }
@media (hover: hover) {
  .audio-toggle:hover { border-color: var(--accent); color: var(--accent); }
  .audio-toggle.off:hover { color: var(--ink-2); }
}

@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar-right { flex: 1 1 100%; justify-content: space-between; }
  .audio-controls { gap: 8px; }
  .audio-toggle { min-height: 44px; padding: 6px 14px; }
}
