:root {
  color-scheme: dark;
  --bg: #111811;
  --panel: #182219;
  --line: #324432;
  --text: #eef5e8;
  --muted: #a9bba6;
  --lime: #c5f477;
  font-family: system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: radial-gradient(ellipse at 40% 0%, #202b1b, var(--bg) 58%); min-height: 100vh; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
[hidden] { display: none !important; }
.header { min-height: 66px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); padding: 0 max(24px, calc((100vw - 1050px) / 2)); }
.brand, .source, .cabinet-footer, .score, h2 { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.brand { display: flex; align-items: center; font-weight: 800; letter-spacing: .04em; }
.brand-icon { display: grid; place-items: center; border-radius: 7px; background: var(--lime); color: #1e2c18; width: 28px; height: 28px; margin-right: 10px; font-size: 22px; }
.brand-accent, h1 span { color: var(--lime); }
.source { color: var(--muted); text-decoration: none; font-size: 13px; white-space: nowrap; }
.source:hover { color: var(--lime); }
main { width: min(900px, calc(100% - 40px)); margin: 40px auto 48px; }
h1 { font-size: clamp(52px, 9vw, 88px); margin: 0 0 23px; line-height: .95; letter-spacing: -.075em; }
.layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(245px, 1fr); gap: 20px; align-items: start; }
.cabinet, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.cabinet { padding: 12px 12px 0; }
.board { position: relative; overflow: hidden; border-radius: 8px; border: 1px solid var(--line); }
canvas { touch-action: none; width: 100%; display: block; aspect-ratio: 1; }
.overlay { position: absolute; inset: 0; background: #101b12a6; display: grid; place-items: center; }
.overlay-card { display: grid; justify-items: center; background: #161f16f5; border: 1px solid #465e3b; border-radius: 14px; min-width: min(235px, 90%); padding: 20px; box-shadow: 0 18px 65px #081008a0; }
.overlay-card p { margin: 0 0 15px; font-size: 20px; font-weight: 750; }
.primary { background: var(--lime); color: #162214; border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 800; }
.primary:hover { background: #d8ffa0; }
.primary span { margin-left: 7px; font-size: 12px; }
.cabinet-footer { display: flex; justify-content: space-between; align-items: center; min-height: 42px; color: var(--muted); font-size: 12px; }
.cabinet-footer i { display: inline-block; width: 7px; height: 7px; background: var(--lime); border-radius: 50%; margin: 0 6px 1px 4px; }
.sidebar { display: grid; gap: 14px; }
.scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.score { padding: 15px clamp(8px, 1.25vw, 17px); display: grid; gap: 6px; }
.score span, h2 { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .10em; }
.score strong { font-size: clamp(23px, 4vw, 38px); font-weight: 750; line-height: 1.05; }
.score:first-child strong { color: var(--lime); }
.settings, .controls { padding: 16px; }
h2 { margin: 0 0 12px; }
.mode-rules { margin: 8px 0 16px; color: var(--muted); font-size: 13px; }
.options, .actions { display: flex; gap: 6px; }
.mode-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.actions { margin-top: 12px; }
.options button, .actions button, .arrows button { border: 1px solid var(--line); background: #202e20; border-radius: 7px; padding: 8px 4px; font-size: 13px; }
.options button, .actions button { flex: 1; }
.options button[aria-pressed="true"], #sound[aria-pressed="true"] { border-color: #87a957; background: #334827; color: var(--lime); }
.options button:hover, .actions button:enabled:hover, .arrows button:hover { border-color: var(--lime); }
.arrows { display: grid; grid-template-columns: repeat(3, 44px); gap: 5px; }
.arrows button { min-height: 44px; touch-action: manipulation; font-size: 18px; }
.arrows button:first-child { grid-column: 2; }
.arrows button:nth-child(2) { grid-column: 1; }
.controls p { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
kbd { display: inline-block; border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; color: var(--text); }
@media (max-width: 650px) {
  main { margin-top: 27px; }
  .layout { grid-template-columns: 1fr; gap: 12px; }
  .sidebar { gap: 10px; }
  .controls { grid-row: 1; }
  .controls p { display: none; }
  .controls { display: flex; align-items: center; justify-content: space-between; }
  .controls h2 { margin: 0; }
  .controls .swipe-help { display: block; margin: 0; max-width: 105px; }
}

.overlay[data-phase="countdown"] #message { margin: 0; font: 750 60px/1 ui-monospace, monospace; color: var(--lime); }
