@font-face { font-family: Torus; src: url('/Torus Regular.otf') format('opentype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Torus; src: url('/Torus Bold.otf') format('opentype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: dark;
  --game-bg: #0f172a;
  --game-ink: #e2e8f0;
  --game-muted: #94a3b8;
  --game-accent: #39c5bb;
  --game-border: rgba(226, 232, 240, .12);
  --board-side: min(576px, calc(100vw - 32px));
}

* { box-sizing: border-box; }
.game-page {
  margin: 0;
  min-height: 100svh;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(circle at 50% 0, rgba(57,197,187,.052), transparent 30rem), var(--game-bg);
  color: var(--game-ink);
  font: 400 16px/1.5 Torus, 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.game-page button, .game-page a { -webkit-tap-highlight-color: transparent; }
.game-page button { font: inherit; }
.game-page button:disabled { cursor: default; opacity: .4; }
.game-page svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.game-page :focus-visible { outline: 2px solid var(--game-accent); outline-offset: 4px; }
.game-page ::selection { color: var(--game-ink); background: rgba(57,197,187,.28); }

.game-header { max-width: 960px; margin: 0 auto 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.game-back { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; color: var(--game-muted); text-decoration: none; border-radius: 6px; }
.game-back svg { width: 19px; height: 19px; }
.game-language { min-width: 48px; min-height: 44px; padding: 0 12px; border: 1px solid var(--game-border); border-radius: 6px; color: var(--game-muted); background: transparent; cursor: pointer; font-size: 13px !important; font-weight: 700 !important; }
.game-shell { width: 100%; max-width: 620px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.game-heading { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.game-heading h1 { margin: 0; font-size: 25px; line-height: 1.2; font-weight: 700; }
.game-heading h1 > span { color: var(--game-accent); margin-right: 6px; }
.game-level { color: var(--game-muted); font-size: 14px; }
.game-status { display: grid; grid-template-columns: minmax(55px, 1fr) minmax(60px, 1fr) minmax(130px, 1.6fr); width: 100%; padding: 12px 0; border-block: 1px solid var(--game-border); gap: 14px; }
.game-stat { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 10px; }
.game-stat > span, .game-next-caption { color: var(--game-muted); font-size: 14px; }
.game-stat strong { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.game-stat-time.is-urgent strong { color: #fca5a5; }
.game-next { min-width: 0; }
.game-next-caption { display: flex; justify-content: space-between; gap: 4px; margin-bottom: 3px; line-height: 1.1; }
.game-queue { display: flex; align-items: center; min-height: 22px; gap: 4px; }
.game-queue-window { width: 116px; max-width: 100%; height: 22px; min-width: 0; overflow: hidden; }
.game-queue-track { display: flex; align-items: center; width: max-content; min-height: 22px; gap: 4px; }
.game-queue img { width: 20px; height: 20px; flex-shrink: 0; }
.game-queue-more { color: var(--game-muted); font-size: 12px; }

.game-board-frame { position: relative; width: var(--board-side); height: var(--board-side); max-width: 100%; flex-shrink: 0; background: #b5b5b5; border-radius: 3px; box-shadow: 0 8px 30px rgba(2,6,23,.22); isolation: isolate; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: crosshair; border-radius: inherit; }
.game-canvas.is-eraser { cursor: cell; }
.game-canvas.is-locked { cursor: default; }
.game-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: clamp(10px, 4vw, 28px); overflow: auto; background: rgba(15,23,42,.78); border-radius: inherit; }
.game-overlay[hidden] { display: none; }
.game-panel { width: 100%; max-width: 360px; flex-shrink: 0; margin-block: auto; padding: clamp(14px, 4vw, 25px); background: rgba(15,23,42,.96); border: 1px solid rgba(57,197,187,.3); border-radius: 10px; box-shadow: 0 12px 30px rgba(2,6,23,.25); text-align: center; }
.game-panel-kicker { display: block; color: var(--game-accent); font-size: 11px; font-weight: 700; letter-spacing: .16em; margin-bottom: 7px; }
.game-panel h2 { margin: 0 0 10px; font-size: clamp(21px, 5vw, 27px); line-height: 1.15; }
.game-panel p { margin: 7px 0; color: var(--game-muted); font-size: 15px; line-height: 1.5; }
.game-panel-actions { margin-top: 19px; display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }
.game-action { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 9px 18px; border: 1px solid var(--game-border); border-radius: 7px; background: #182438; color: var(--game-ink); cursor: pointer; font-weight: 700 !important; }
.game-action-primary { color: var(--game-bg); background: var(--game-accent); border-color: var(--game-accent); }
.game-action svg { width: 19px; height: 19px; }
.game-panel-details { margin-top: 15px; text-align: left; color: var(--game-muted); font-size: 14px; }
.game-panel-details summary { min-height: 36px; cursor: pointer; color: var(--game-accent); display: list-item; }
.game-panel-details p { font-size: 14px; margin: 4px 0; }
.game-toolbar { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; }
.game-tools { display: flex; align-items: center; gap: 8px; }
.game-control { min-height: 48px; min-width: 93px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--game-border); border-radius: 7px; color: var(--game-muted); background: rgba(15,23,42,.9); padding: 9px 13px; cursor: pointer; box-shadow: 0 3px 0 rgba(2,6,23,.6); }
.game-control.is-selected { color: var(--game-accent); border-color: rgba(57,197,187,.65); background: rgba(57,197,187,.13); }
.game-pressable { transition: transform 130ms ease-out, box-shadow 130ms ease-out, background-color 150ms ease, color 150ms ease, border-color 150ms ease; }
.game-pressable.is-pressed { transform: translateY(2px) scale(.985); box-shadow: 0 0 0 rgba(2,6,23,0); transition-duration: 45ms; }
.game-hint { margin: 0; min-height: 24px; width: 100%; color: var(--game-muted); font-size: 14px; line-height: 1.5; }
.game-shortcuts { width: 100%; margin: 0; color: var(--game-muted); font-size: 14px; line-height: 1.5; }
.game-announcement { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.game-noscript { color: #fca5a5; }

@media (hover: hover) and (pointer: fine) {
  .game-back:hover, .game-language:hover { color: var(--game-accent); }
  .game-control:hover:not(:disabled), .game-action:hover:not(:disabled) { border-color: var(--game-accent); color: var(--game-ink); background: rgba(57,197,187,.18); }
  .game-action-primary:hover:not(:disabled) { color: var(--game-bg); background: #67d7cf; }
}
@media (max-width: 430px) {
  .game-page { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .game-header { margin-bottom: 12px; }
  .game-shell { gap: 10px; }
  .game-heading h1 { font-size: 23px; }
  .game-status { grid-template-columns: .85fr .9fr 1.5fr; gap: 8px; padding-block: 10px; }
  .game-stat { flex-direction: column; gap: 1px; }
  .game-stat strong { font-size: 21px; }
  .game-control { min-width: 0; padding-inline: 12px; gap: 6px; font-size: 14px !important; }
  .game-tools { gap: 6px; }
}
@media (max-height: 580px) {
  .game-page { padding-top: max(8px, env(safe-area-inset-top)); }
  .game-header { margin-bottom: 6px; }
  .game-shell { gap: 7px; }
  .game-heading h1 { font-size: 21px; }
  .game-status { padding-block: 6px; }
  .game-panel { padding: 13px 16px; }
  .game-panel h2 { margin-bottom: 7px; font-size: 21px; }
  .game-panel p { font-size: 13px; margin-block: 4px; }
  .game-panel-actions { margin-top: 12px; }
}
@media (orientation: landscape) and (max-height: 580px) and (min-width: 480px) {
  /* Give a short landscape board its own column; controls stay reachable. */
  .game-shell {
    max-width: 960px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    grid-template-areas: 'board heading' 'board status' 'board toolbar' 'board hint' 'board shortcuts';
    column-gap: 16px;
    align-items: start;
  }
  .game-board-frame { grid-area: board; justify-self: center; }
  .game-heading { grid-area: heading; }
  .game-status { grid-area: status; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .game-next { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .game-next-caption { flex-direction: column; margin: 0; gap: 2px; }
  .game-toolbar { grid-area: toolbar; gap: 6px; }
  .game-tools { gap: 6px; }
  .game-control { min-width: 0; padding-inline: 6px; gap: 4px; font-size: 14px !important; }
  .game-control svg { width: 18px; height: 18px; }
  .game-hint { grid-area: hint; display: none; }
  .game-shortcuts { grid-area: shortcuts; }
}
@media (prefers-reduced-motion: reduce) {
  .game-pressable, .game-pressable.is-pressed { transition: none; }
}
