:root {
  --bg: #12151a;
  --panel: #1b2027;
  --panel-2: #232a33;
  --line: #333c48;
  --text: #dfe5ec;
  --muted: #8b96a5;
  --accent: #e0b84c;
  --friend: #4aa3ff;
  --enemy: #ff5a4f;
  --good: #5ccf7a;
  --hear: #c08cff;
  font-family: "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: .5px; }
h2 { font-size: 16px; color: var(--accent); }
h3 { font-size: 14px; }

button, input, select, textarea {
  font: inherit; color: inherit; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px;
}
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); color: #1a1a1a; border-color: var(--accent); font-weight: 600; }
button.danger { border-color: #7a2b28; }
textarea { width: 100%; font-family: Consolas, monospace; font-size: 12px; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.topbar a { text-decoration: none; }
.topbar h1 { margin: 0; white-space: nowrap; }

.menu { position: relative; }
.menu > summary {
  list-style: none; cursor: pointer; user-select: none;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ' \25BE'; color: var(--muted); }
.menu > summary:hover, .menu[open] > summary { border-color: var(--accent); }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 210px;
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}
.menu-items button { text-align: left; }
.menu-items label { display: flex; align-items: center; gap: 6px; padding: 2px 4px; cursor: pointer; }
.menu-items .danger { margin-top: 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.hidden { display: none !important; }

/* Lobby ------------------------------------------------------------------ */
.lobby { max-width: 1100px; margin: 24px auto; padding: 0 16px; display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.lobby .wide { grid-column: 1 / -1; }
.lobby label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
.lobby input, .lobby select { width: 100%; }
.lobby input[type=radio], .lobby input[type=checkbox] { width: auto; }
.lobby .row > label { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.lobby .row > label select { width: auto; }
.lobby .squad-pick label { display: flex; margin: 0; color: var(--text); font-size: 13px; }
.games-list { list-style: none; padding: 0; margin: 0; }
.games-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.badge.turn { background: var(--accent); color: #111; border-color: var(--accent); }

table.rules { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rules th, table.rules td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.rules th { color: var(--muted); font-weight: 500; }

/* Game ------------------------------------------------------------------- */
body:has(> main.game) { display: flex; flex-direction: column; height: 100vh; }
.game { display: grid; grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(260px, 340px); gap: 12px; padding: 12px; flex: 1; min-height: 0; }
.turn-row { justify-content: center; }
.end-turn { padding: 7px 20px; font-size: 15px; border-radius: 20px; }
.end-turn:not(:disabled) { box-shadow: 0 0 0 3px rgba(224, 184, 76, 0.25); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; min-height: 0; }
.board-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-start; min-height: 0; min-width: 0; gap: 8px; }
#board { width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 140px); background: #34332f; border-radius: 2px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); cursor: crosshair; }
.turn-banner { padding: 6px 14px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 600; }
.turn-banner.mine { background: var(--accent); color: #111; border-color: var(--accent); }
.hint { min-height: 20px; color: var(--muted); font-size: 13px; text-align: center; }
.error-toast { color: var(--enemy); }
.account { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.account form { flex: 1 1 100%; margin: 0; }
.account .avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--accent); font-weight: 700; border: 1px solid var(--line);
}
.profile-form { flex: 1 1 100%; display: flex; flex-direction: column; gap: 8px; margin: 0; }
.profile-form input:not([type=file]) { width: 100%; margin-top: 4px; }
.button-like {
  display: inline-block; margin: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text); font-size: inherit;
}
.button-like:hover { border-color: var(--accent); }
.account button { padding: 3px 10px; }
.menu-account { min-width: 240px; margin: 0 0 4px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.menu-items .menu-account label { display: block; padding: 0; cursor: auto; }
.menu-items .menu-account .button-like { display: inline-block; padding: 6px 10px; cursor: pointer; }
.menu-account .avatar { width: 28px; height: 28px; }
#menuAvatar:not(:empty) { display: inline-flex; vertical-align: middle; margin-right: 6px; }
#menuAvatar .avatar {
  width: 20px; height: 20px; border-radius: 50%; object-fit: cover; font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--accent); border: 1px solid var(--line);
}

.unit-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; cursor: pointer; background: var(--panel-2); }
.unit-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.unit-card.down { opacity: .55; }
.unit-card .name { font-weight: 600; display: flex; justify-content: space-between; }
.ap-bar { display: flex; gap: 2px; margin-top: 6px; flex-wrap: wrap; }
.ap-pip { width: 12px; height: 8px; border-radius: 2px; background: #39424e; }
.ap-pip.on { background: var(--accent); }
.tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 8px; background: #2d3540; color: var(--muted); }
.tag.bad { color: var(--enemy); }

.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.chip { font-size: 11px; padding: 1px 7px; border-radius: 8px; background: #2a3039; color: #6b7480; border: 1px solid #333c48; }
.chip.ok { color: #bff0cc; background: #1f3a2a; border-color: #2f6b45; }
.sel-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; font-size: 15px; }
.ap-big { background: var(--accent); color: #111; border-radius: 12px; padding: 2px 10px; font-size: 14px; }
.ap-big.empty { background: #4a525d; color: #ccc; }
.board-stage { position: relative; display: flex; justify-content: center; max-width: 100%; }
.view-3d .board-stage { width: 100%; flex: 1; min-height: 0; }
.view-3d #board { width: 100%; height: 100%; max-height: none; background: #050607; cursor: crosshair; touch-action: none; }
.squad-bar { display: none; }
.sq-unit {
  width: 44px; height: 44px; padding: 3px 2px; border-radius: 10px; border: 2px solid var(--team);
  background: rgba(14, 17, 21, 0.9); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.sq-unit { position: relative; }
.sq-unit b { font-size: 14px; line-height: 1; }
.sq-alert {
  position: absolute; left: 50%; top: calc(100% + 4px); transform: translateX(-50%);
  width: 20px; height: 20px; border-radius: 50%; background: var(--enemy); color: #fff;
  font: 800 14px/20px system-ui, sans-serif; text-align: center; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(14, 17, 21, 0.9); animation: sq-alert 1.6s ease-in-out infinite;
}
.sq-alert::before { content: ''; position: absolute; inset: -12px; }
.board-toast {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%); z-index: 4; pointer-events: none;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--enemy);
  background: rgba(17, 20, 25, 0.9); color: var(--text); font-size: 13px; white-space: nowrap;
}
@keyframes sq-alert { 50% { box-shadow: 0 0 0 2px rgba(14, 17, 21, 0.9), 0 0 8px 2px var(--enemy); } }
.sq-unit.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(224, 184, 76, 0.4); color: var(--accent); }
.sq-unit.downed { border-color: var(--enemy); }
.sq-unit.dead { opacity: 0.4; border-color: #555; }
.sq-ap { font-size: 10px; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.sq-ap.empty { color: var(--muted); }
.sq-state { font-size: 9px; text-transform: uppercase; color: var(--enemy); }
.sq-unit.dead .sq-state { color: var(--muted); }
.cam-controls { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; z-index: 3; }
.cam-controls button {
  width: 34px; height: 34px; padding: 0; border-radius: 50%; font-size: 18px; line-height: 1;
  background: rgba(20, 24, 30, 0.8); border: 1px solid var(--line); color: var(--muted);
}
.cam-controls button:hover { color: var(--accent); border-color: var(--accent); }
.radial { position: absolute; inset: 0; pointer-events: none; transition: opacity .15s; }
.radial.walking { opacity: 0; }
.radial-btn {
  position: absolute; width: 28px; height: 28px; padding: 5px; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: auto;
  background: rgba(20, 24, 30, 0.92); border: 2px solid var(--friend); color: #e8f2ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); display: grid; place-items: center;
}
.radial-btn svg { width: 100%; height: 100%; }
.radial-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.radial-btn.active { background: #3a3320; border-color: var(--accent); color: var(--accent); }
.radial-btn.blocked { border-color: #555e6a; color: #6f7884; }
.radial-btn.blocked::after {
  content: ''; position: absolute; left: 6px; right: 6px; top: 50%; height: 2px;
  background: var(--enemy); transform: rotate(-45deg);
}
.radial-cost {
  position: absolute; right: -7px; bottom: -6px; min-width: 14px; height: 14px; padding: 0 3px;
  border-radius: 7px; background: var(--accent); color: #1a1a1a; font-size: 9px; font-weight: 700; line-height: 14px;
}
.radial-btn.blocked .radial-cost { background: #555e6a; color: #ddd; }
.radial-btn.lost { border-color: var(--enemy); color: #8a6f6c; background: rgba(60, 22, 20, 0.92); }
.radial-btn.lost::before, .radial-btn.lost::after {
  content: ''; position: absolute; left: 5px; right: 5px; top: 50%; height: 3px; border-radius: 2px;
  background: var(--enemy);
}
.radial-btn.lost::before { transform: rotate(45deg); }
.radial-btn.lost::after { transform: rotate(-45deg); }
.radial-btn.lost .radial-cost { background: var(--enemy); color: #fff; }
.radial-key {
  position: absolute; left: -6px; top: -6px; width: 13px; height: 13px; border-radius: 3px;
  background: #0c0e11; border: 1px solid var(--line); color: var(--muted); font-size: 8px; line-height: 11px;
}
.move-confirm {
  position: absolute; transform: translate(-50%, -100%); z-index: 4;
  padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 700;
  background: var(--good); color: #0d1a10; border: 2px solid rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); animation: confirm-pulse 1.2s ease-in-out infinite;
}
@keyframes confirm-pulse { 50% { box-shadow: 0 0 0 4px rgba(127, 224, 138, 0.35), 0 2px 8px rgba(0, 0, 0, 0.5); } }
.ability-tip {
  position: absolute; width: 240px; pointer-events: none; z-index: 5;
  background: rgba(20, 24, 30, 0.97); border: 1px solid var(--accent); border-radius: 8px;
  padding: 8px 10px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6); font-size: 12px;
}
.tip-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.tip-head span { color: var(--accent); font-weight: 600; white-space: nowrap; }
.tip-status { color: var(--enemy); }
.tip-status.ok { color: var(--good); }
.tip-desc { color: var(--muted); margin-top: 4px; }
.tip-next { margin-top: 6px; color: var(--text); font-weight: 600; }
.ability .status { font-size: 12px; color: var(--muted); }
.ability .status.ok { color: var(--good); }

.abilities { margin-top: 12px; display: grid; gap: 6px; }
.ability { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.ability.active { border-color: var(--accent); background: #3a3320; }
.ability .title { display: flex; justify-content: space-between; font-weight: 600; }
.ability .desc { font-size: 11px; color: var(--muted); font-weight: 400; }

.log-panel { display: flex; flex-direction: column; gap: 8px; }
.log-btn, .log-close { display: none; }
.log-btn { position: relative; }
.log-badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #1a1a1a; font-size: 11px; font-weight: 700; line-height: 18px;
  animation: log-ping 1.6s ease-out infinite;
}
.log-badge.alert { background: var(--enemy); color: #fff; }
@keyframes log-ping { 0% { box-shadow: 0 0 0 0 rgba(224, 184, 76, 0.6); } 70%, 100% { box-shadow: 0 0 0 8px rgba(224, 184, 76, 0); } }
.log { flex: 1; overflow: auto; min-height: 0; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.log .turn-head { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; margin-top: 8px; }
.log .entry { padding: 5px 8px; border-left: 3px solid var(--line); background: var(--panel-2); border-radius: 0 6px 6px 0; cursor: pointer; }
.log .entry.self { border-left-color: var(--friend); }
.log .entry.see { border-left-color: var(--accent); }
.log .entry.hear { border-left-color: var(--hear); }
.log .entry.alert { border-left-color: var(--enemy); }
.log .entry.system { border-left-color: var(--muted); color: var(--muted); }
.log .entry.playing { outline: 1px solid var(--accent); }
.zone-legend { margin: 0 0 8px; color: var(--muted, #9aa5b1); }
.nowrap { white-space: nowrap; }
.zone { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 2px solid; margin-left: 6px; vertical-align: -2px; }
.zone.z2 { background: rgba(74, 163, 255, 0.3); border-color: rgba(120, 190, 255, 0.9); }
.zone.z1 { background: rgba(224, 184, 76, 0.3); border-color: rgba(224, 184, 76, 0.9); }
.zone.z0 { background: rgba(255, 90, 79, 0.25); border-color: rgba(255, 90, 79, 0.8); }
.log .entry:hover { background: #2b333e; }
.log .entry.pinned { outline: 2px solid var(--accent); background: #2f3020; }
.log .entry .kind { font-size: 10px; text-transform: uppercase; color: var(--muted); margin-right: 6px; }

.replay-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; }
.replay-bar input[type=range] { width: 260px; }
.log .replay-entry { display: flex; flex-direction: column; gap: 3px; }
.log .replay-entry .who { font-weight: 600; margin-right: 4px; }
.log .replay-entry .me { color: var(--friend); }
.log .replay-entry .them { color: var(--enemy); }
.log .replay-entry .none { color: var(--muted); font-style: italic; }

#fbText { font-family: inherit; font-size: 14px; margin: 8px 0; }
#feedbackOverlay select { width: 100%; margin: 4px 0 4px; }
.tab.active { border-color: var(--accent); color: var(--accent); }
.report { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--panel-2); }
.report.resolved { opacity: .55; }
.report-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; color: var(--muted, #9aa5b1); }
.report-text { white-space: pre-wrap; margin: 8px 0; }
.report-event { font-size: 12px; border-left: 3px solid var(--accent); padding-left: 8px; margin: 6px 0; }
.badge.bug { border-color: var(--enemy); color: var(--enemy); }
.badge.balance { border-color: var(--accent); color: var(--accent); }
.badge.idea { border-color: var(--good); color: var(--good); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 10; }
.overlay .card { width: min(520px, 92vw); }
.overlay .card.wide { width: min(900px, 95vw); max-height: 90vh; overflow: auto; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #555; margin-right: 4px; }
.dot.on { background: var(--good); }
.player-tag { display: inline-block; padding: 1px 8px 1px 6px; border-left: 4px solid var(--team); border-radius: 4px; white-space: nowrap; }
.player-tag.turn { background: rgba(255, 255, 255, 0.08); font-weight: 600; }
.player-tag.out { opacity: 0.45; text-decoration: line-through; }

.turn-clock { padding: 6px 12px; border-radius: 20px; background: var(--panel-2); border: 1px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; }
.turn-clock.mine { border-color: var(--accent); }
.turn-clock.low { background: var(--enemy); color: #111; border-color: var(--enemy); }

.squad-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.squad-pick label { display: flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 16px; cursor: pointer; }
.squad-pick label:has(input:checked) { border-color: var(--accent); background: rgba(224, 184, 76, 0.15); }
.squad-pick input:disabled + span { opacity: 0.45; }

/* Editor ----------------------------------------------------------------- */
.artlab { display: flex; flex-direction: column; gap: 12px; padding: 12px; max-width: 1400px; margin: 0 auto; }
.artlab h2 { margin: 0 0 4px; }
.artlab .row { align-items: center; gap: 16px; }
.lab-board { display: block; max-width: 100%; margin: 8px 0; border-radius: 2px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55); }
.art-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.art-table td, .art-table th { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.art-table .ok { color: #7fe08a; }
.art-table .warn { color: var(--enemy); }
.templates { display: flex; flex-direction: column; gap: 12px; padding: 12px; max-width: 1000px; margin: 0 auto; }
.templates .row { align-items: center; gap: 16px; flex-wrap: wrap; }
.tpl-intro, .tpl { background: #fff; color: #1d1b24; border-radius: 4px; padding: 14px 18px; }
.tpl-intro h2 { margin: 0 0 6px; color: #1d1b24; }
.tpl-intro ul { margin: 6px 0; padding-left: 20px; }
.tpl-intro li { margin: 4px 0; }
.tpl-intro code, .tpl code { background: #eef3f6; color: #1d1b24; padding: 1px 5px; border-radius: 3px; }
#sheets { display: flex; flex-direction: column; gap: 12px; }
.tpl header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tpl h3 { margin: 0; color: #1d1b24; }
.tpl p { margin: 4px 0 10px; }
.tpl .muted { color: #666; }
.tpl-opt { font-size: 12px; font-weight: normal; color: #4aa8d0; border: 1px solid #7cc8e8; border-radius: 10px; padding: 0 7px; }
.tpl-frames { display: grid; grid-template-columns: repeat(var(--per-row, 4), 1fr); gap: 10px; }
.tpl-frames canvas { width: 100%; height: auto; display: block; }
.tpl button { margin-top: 10px; color: #e8edf2; }
@media print {
  @page { margin: 12mm; }
  body.templates-page { background: #fff; }
  .no-print { display: none !important; }
  .templates { padding: 0; max-width: none; }
  .tpl-intro, .tpl { padding: 0 0 6mm; border-radius: 0; }
  .tpl { break-inside: avoid; border-top: 1px solid #cfe6f0; padding-top: 4mm; }
  .tpl-intro code, .tpl code { background: none; padding: 0; }
}
.editor { display: grid; grid-template-columns: 300px 1fr; gap: 12px; padding: 12px; }
.editor label { display: block; margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
.editor input[type=number], .editor input[type=text] { width: 100%; }
#editorBoard { background: #0c0e11; border-radius: 8px; cursor: pointer; max-width: 100%; }

@media (max-width: 1100px) {
  body:has(> main.game) { height: auto; }
  .game { grid-template-columns: 1fr; }
  .game .board-wrap { order: -1; }
  .view-3d .board-stage { flex: none; height: var(--stage-h, 70svh); }
  .log-btn, .log-close { display: inline-block; }
  .squad-bar { display: flex; gap: 6px; position: absolute; top: 8px; left: 8px; z-index: 3; }
  .log-close { padding: 2px 10px; font-size: 18px; line-height: 1; }
  /* The log opens over the lower part of the board, see-through, so the game stays in view. */
  .game .log-panel {
    position: absolute; left: 6px; right: 6px; bottom: 6px; height: min(55%, 420px); z-index: 6;
    padding: 10px; gap: 6px; border-radius: 10px;
    background: rgba(17, 20, 25, 0.78); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
    border: 1px solid rgba(255, 255, 255, 0.08); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    opacity: 0; transform: translateY(12px); visibility: hidden;
    transition: opacity .18s ease, transform .18s ease, visibility 0s .18s;
  }
  .log-open .game .log-panel { opacity: 1; transform: none; visibility: visible; transition: opacity .18s ease, transform .18s ease; }
  .game .log-panel h2 { font-size: 15px; }
  .game .log-panel .log .entry { background: rgba(37, 43, 52, 0.7); }
  .lobby { grid-template-columns: 1fr; }
  .editor { grid-template-columns: 1fr; }
}

/* Phones: tighter chrome so the board gets the screen. */
@media (max-width: 600px) {
  .topbar { padding: 6px 10px; gap: 6px 8px; }
  .topbar h1 { font-size: 17px; }
  .topbar button, .topbar .menu > summary { padding: 4px 9px; }
  .topbar .small { font-size: 11px; }
  /* The Menu button can sit anywhere in the wrapped bar; span the screen so the list never runs off it. */
  .menu-items { position: fixed; left: 8px; right: 8px; top: auto; margin-top: 6px; min-width: 0; }
  .game { padding: 6px; gap: 6px; }
  .board-wrap { gap: 6px; }
  .turn-row { gap: 6px; }
  .turn-banner { padding: 4px 10px; font-size: 13px; }
  .end-turn { padding: 5px 14px; font-size: 14px; }
  .turn-row button:not(.end-turn) { padding: 4px 10px; }
}

/* Touch screens: ability buttons dock along the bottom of the board (see positionRadial). */
@media (pointer: coarse) {
  /* Quick repeat taps on controls must not zoom the page or select text elsewhere. */
  button, summary, label, .game .board-wrap, .game .panel:not(.log-panel) { touch-action: manipulation; }
  .game .board-wrap, .game .panel:not(.log-panel), button {
    -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  }
  .cam-controls button { width: 42px; height: 42px; font-size: 22px; }
  .radial-btn { width: 44px; height: 44px; padding: 9px; }
  .radial.docked .radial-btn { background: rgba(14, 17, 21, 0.94); }
  .radial-cost { min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; border-radius: 9px; }
  .radial-key { display: none; }
}
