:root {
  color-scheme: dark;
  --bg: #0b121c;
  --panel: #1b2a38;
  --line: #344b5e;
  --text: #e9f2f4;
  --muted: #9bafbd;
  --lime: #c9f07c;
  --orange: #ffbd71;
  --board-width: clamp(230px, calc((100svh - 164px) / 2), 340px);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; }
.cabinet { width: fit-content; max-width: 100%; margin: 16px auto; padding: 18px; background: #101d29; border: 1px solid #223344; border-radius: 10px; }
header { display: flex; align-items: center; gap: 20px; margin-bottom: 16px; }
.brand { color: var(--text); font-size: 24px; font-weight: 900; letter-spacing: -1px; text-decoration: none; }
.brand span { color: var(--lime); }
.brand b { color: var(--orange); font-size: 17px; padding-left: 7px; }
.edition { color: var(--muted); font-size: 8px; letter-spacing: 1px; line-height: 1.7; }
.edition span { display: block; color: var(--lime); }
button { cursor: pointer; font: inherit; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.small { border: 1px solid var(--line); background: transparent; color: var(--text); padding: 7px 9px; font-size: 9px; }
header .small { margin-left: auto; }
.topline { display: flex; justify-content: space-between; gap: 15px; margin-bottom: 12px; font-size: 8px; letter-spacing: 1px; color: var(--muted); }
.live-dot { display: inline-block; width: 5px; height: 5px; margin-right: 5px; background: var(--lime); }
.game-layout { display: grid; grid-template-columns: 150px var(--board-width) 150px; gap: 8px; align-items: stretch; }
.left-panel, .right-panel { min-width: 0; background: var(--panel); border-radius: 4px; padding: 15px 10px; }
h2 { color: var(--muted); font-size: 9px; font-weight: 400; letter-spacing: 1px; margin: 0; }
.panel { padding: 0; background: none; border: 0; }
canvas { display: block; image-rendering: pixelated; }
.next-panel { text-align: center; }
.next-panel canvas { width: 128px; max-width: 100%; height: auto; margin: 3px auto; }
.next-panel p { color: var(--lime); font-size: 9px; margin: 0 0 10px; }
.queue { color: var(--muted); font-size: 9px; padding: 10px 0 16px; border-bottom: 1px solid var(--line); }
.stats { padding-top: 20px; }
.stats strong { display: block; font-size: 23px; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-pair { display: flex; justify-content: space-between; margin: 23px 0; }
.stat-pair strong { font-size: 20px; }
.time-stat { margin-bottom: 22px; }
.time-stat strong { font-size: 21px; }
.record { border-top: 1px solid var(--line); padding-top: 17px; }
.record strong { font-size: 17px; color: var(--orange); }
.progress { height: 4px; background: #0c1825; margin-top: 22px; }
.progress i { display: block; height: 100%; background: var(--lime); width: 0; transition: width .2s; }
#level-hint { color: var(--muted); font-size: 8px; line-height: 1.7; }
.board-shell { min-width: 0; border: 1px solid #486173; background: #0a1420; }
.board-top, .board-bottom { display: flex; align-items: center; justify-content: space-between; height: 27px; padding: 0 8px; font-size: 8px; color: var(--muted); }
.board-top .small { border: 0; padding: 0; font-size: 9px; }
.board-wrap { position: relative; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#board { width: 100%; height: auto; }
.board-bottom { font-size: 8px; }
.board-bottom > span:last-child { display: none; }
.board-bottom i { display: inline-block; width: 4px; height: 4px; margin-right: 4px; background: var(--lime); }
.tools-heading { padding: 0 0 16px; text-align: center; }
.tool { display: block; width: 100%; text-align: center; border: 1px solid #726047; background: #273039; color: var(--text); padding: 14px 7px; border-radius: 4px; margin-bottom: 14px; }
.tool:hover:not(:disabled) { border-color: var(--orange); background: #33363a; }
.tool-top { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tool-icon { font-size: 26px; }
kbd { border: 1px solid #486073; padding: 3px 5px; background: #142333; color: #c8d8e1; font-family: inherit; font-size: 9px; }
.tool h3 { color: var(--orange); font-size: 11px; letter-spacing: 1px; margin: 13px 0 8px; }
.tool p { color: #b1c0c9; font-size: 9px; line-height: 1.7; margin: 0; }
.stock { margin: 16px 0 12px; color: var(--orange); }
.stock span { display: none; }
.stock b { font-size: 22px; font-weight: 700; }
.tool-action { border-top: 1px solid #52606b; padding-top: 10px; font-size: 8px; color: #c8d8e1; }
.tool-action span { margin-left: 6px; }
.miner { background: #20353a; border-color: #426c60; }
.miner h3, .miner .stock { color: #94e6bd; }
.miner:hover:not(:disabled) { background: #29453f; border-color: #94e6bd; }
.tool:disabled { cursor: default; border-color: #435462; }
.tool:disabled .tool-action { color: #8d9eab; }
.reward { border-top: 1px solid var(--line); padding-top: 17px; margin-top: 20px; text-align: center; font-size: 8px; color: var(--lime); }
.reward p { line-height: 1.9; color: #c5d4dc; }
.reward b { font-weight: 400; }
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 22px 16px; text-align: center; background: #0c1726ed; }
.overlay.hidden { display: none; }
.overlay-icon { font-size: 32px; color: var(--orange); margin-bottom: 20px; }
.eyebrow { color: var(--lime); font-size: 8px; letter-spacing: 1px; }
h1 { font-size: 64px; letter-spacing: -4px; line-height: 1; margin: 22px 0; }
h1 span { color: var(--lime); }
.overlay > p { color: #b6c6d1; font-size: 10px; line-height: 1.9; margin: 0 0 25px; }
.primary { width: 100%; max-width: 250px; padding: 15px 10px; border: 0; border-radius: 3px; background: var(--lime); color: #15221a; font-size: 10px; font-weight: 700; }
.primary:hover { background: #e1ffa7; }
.primary span { float: right; }
.overlay > small { color: var(--muted); font-size: 8px; margin-top: 14px; }
.result[hidden] { display: none; }
.result { width: 100%; margin: 0 0 24px; padding: 20px 10px; background: #1b2a38; border: 1px solid #4e6973; border-radius: 4px; }
.result > div + div { margin-top: 20px; }
.result span { display: block; color: #b7c8d1; font-size: 9px; letter-spacing: 2px; }
.result strong { display: block; color: var(--lime); font-size: 38px; margin-top: 6px; font-variant-numeric: tabular-nums; }
#result-time { font-size: 30px; color: var(--text); }
.result p { color: #aebfc9; font-size: 9px; margin: 18px 0 12px; }
.result small { color: #b3c7d1; font-size: 8px; line-height: 1.6; }
.overlay.finished h1 { font-size: 32px; letter-spacing: -1px; margin: 16px 0 23px; }
.overlay.finished .overlay-icon { margin-bottom: 12px; }
.overlay.finished > p { display: none; }
.controls { max-width: 100%; margin-top: 14px; color: #adc0cd; font-size: 9px; line-height: 1.8; }
summary { cursor: pointer; list-style: none; padding: 8px 0; }
summary span { float: right; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.controls p { max-width: 640px; }
footer { display: flex; justify-content: space-between; font-size: 7px; color: #829aa9; margin-top: 9px; }
#announcement { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); width: max-content; max-width: 95vw; padding: 12px 18px; color: #17251a; background: var(--lime); border-radius: 4px; opacity: 0; pointer-events: none; transition: opacity .2s; font-size: 10px; z-index: 2; }
#announcement.show { opacity: 1; }
@media (max-width: 740px) {
  :root { --board-width: min(320px, calc(100vw - 238px)); }
  .cabinet { padding: 10px; margin: 8px auto; }
  .game-layout { grid-template-columns: 100px var(--board-width) 100px; gap: 5px; }
  .left-panel, .right-panel { padding: 12px 7px; }
  .edition { display: none; }
  .stats strong { font-size: 19px; }
  .stat-pair strong, .time-stat strong { font-size: 17px; }
  .tool p { display: none; }
  .tool { padding: 10px 4px; }
  .stock b { font-size: 19px; }
  .tool kbd { font-size: 8px; padding: 3px; }
  h1 { font-size: 46px; }
  .overlay { padding: 15px 9px; }
  .overlay.finished h1 { font-size: 27px; }
  .result { padding: 12px 6px; margin-bottom: 15px; }
  .result strong { font-size: 28px; }
  #result-time { font-size: 24px; }
  .topline { font-size: 7px; letter-spacing: 0; }
}
@media (max-width: 470px) {
  :root { --board-width: calc(100vw - 174px); }
  .game-layout { grid-template-columns: 68px var(--board-width) 68px; gap: 5px; }
  .left-panel, .right-panel { padding: 10px 4px; }
  .brand { font-size: 21px; }
  .small { font-size: 8px; padding: 6px; }
  .stats strong { font-size: 14px; }
  .stat-pair { flex-direction: column; gap: 15px; margin: 18px 0; }
  .tool kbd { font-size: 7px; border: 0; background: transparent; padding: 0; }
  .tool h3, .tool-action { font-size: 8px; }
  .stock b { font-size: 17px; }
  .queue, #level-hint, .reward, .next-panel p { font-size: 7px; }
  h2 { font-size: 8px; }
  .control-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
