:root {
  color-scheme: dark;
  --base: #111311;
  --panel: #1a1d19;
  --border: #363a31;
  --muted: #a2a696;
  --ink: #f2f0e7;
  --accent: #ff6c4b;
  --amber: #ebc682;
  --blue: #75caed;
  --mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; background: radial-gradient(ellipse at 47% 8%, #20251c 0, var(--base) 58%); color: var(--ink); }
button { font: inherit; }
.shell {
  --hud-width: clamp(216px, 18vw, 270px);
  --content-width: min(1740px, calc(100% - 36px), max(790px, calc((100svh - 174px) * 1.5 + var(--hud-width) + 16px)));
  width: min(1740px, 100% - 36px);
  width: var(--content-width);
  margin: 0 auto;
  padding: 18px 0 8px;
}
.shell[data-fullscreen='true'] {
  width: 100%; height: 100%; margin: 0; overflow: auto; background: var(--base);
  padding-inline: 18px;
  padding-inline: max(18px, calc((100% - var(--content-width)) / 2));
}
.masthead, .wordmark, .header-tools, .field-bar, .field-tools, .section-label, .hud-title, .elapsed, .controls { display: flex; align-items: center; }
.masthead { justify-content: space-between; margin-bottom: 15px; }
.wordmark { gap: 12px; }
.mark { width: 38px; height: 38px; color: var(--accent); flex: none; }
.brand-name { font-size: 17px; font-weight: 800; letter-spacing: .10em; }
.brand-sub { font: 9px var(--mono); letter-spacing: .16em; color: var(--muted); margin-top: 4px; }
.header-tools { gap: 11px; }
.signal { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.signal i, .field-bar i { display: inline-block; width: 6px; height: 6px; background: var(--accent); border-radius: 50%; }
.signal[data-mode='playing'] i, .signal[data-mode='won'] i { background: #a9d18a; box-shadow: 0 0 10px #a9d18775; }
.button { cursor: pointer; border-radius: 4px; font-weight: 750; }
.button:focus-visible, .stage:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
.quiet { min-width: 70px; padding: 8px 12px; border: 1px solid var(--border); background: #242820; color: var(--ink); font-size: 12px; }
.quiet:hover:not(:disabled) { background: #32382d; }
.quiet:disabled { color: #a3a69b; background: #1c1e1a; cursor: default; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) var(--hud-width); gap: 16px; align-items: start; }
.field, .hud { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); overflow: hidden; }
.field-bar { height: 40px; justify-content: space-between; padding: 0 15px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--border); }
.field-bar strong { color: var(--ink); font-weight: 650; }
.field-bar i { margin-right: 6px; border-radius: 1px; }
.field-tag, .hud-title span { color: #a4aa98; font: 10px var(--mono); letter-spacing: .11em; }
.field-tools { gap: 12px; }
.look-lock { min-width: auto; padding: 4px 8px; }
.look-hint { color: var(--amber); font-size: 11px; }
.stage { position: relative; isolation: isolate; overflow: hidden; aspect-ratio: 3 / 2; background: #171c19; }
.stage[data-mode='playing'] { cursor: crosshair; }
.stage[data-locked='true'] { cursor: none; }
.stage:focus-visible { outline-offset: -3px; }
canvas { display: block; width: 100%; height: 100%; }
.level-notice { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 12px; width: max-content; max-width: calc(100% - 20px); border: 1px solid #746444; border-radius: 4px; background: #171913eb; color: var(--amber); font-size: 12px; font-weight: 700; text-align: center; pointer-events: none; }
.stage[data-view='split'] .level-notice { top: 38px; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; background: radial-gradient(ellipse at 50% 48%, #101410f5 5%, #111510eb 30%, #11141075 69%, #11141030 100%); }
.overlay-content { position: relative; }
.overline { margin: 0 0 13px; color: var(--amber); font-size: 12px; font-weight: 750; letter-spacing: .24em; }
.overlay h1 { margin: 0; font-size: clamp(38px, 7vw, 94px); font-weight: 900; letter-spacing: .055em; line-height: 1.08; text-shadow: 0 6px 28px #0009; }
.overlay h1 span { color: var(--accent); }
.overlay[data-mode='won'] h1 { color: #bce5a1; }
.brief { margin: 18px 0 24px; color: #d7d9ce; font-size: clamp(12px, 1.55vw, 16px); }
.action { display: inline-flex; gap: 33px; align-items: center; justify-content: space-between; border: 1px solid #ff886b; padding: 11px 16px; min-height: 44px; background: var(--accent); color: #171612; }
.action:hover { background: #ff8a70; }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.secondary { border: 1px solid #777d6e; padding: 10px 12px; background: #242820; color: var(--ink); }
.secondary:hover { background: #30382c; }
.choose-mode { margin-top: 9px; padding: 4px 8px; border: 0; background: transparent; color: var(--muted); font-size: 12px; }
.choose-mode:hover { color: var(--ink); }
.hud-title { height: 40px; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); }
.hud-title strong { font-size: 13px; }
.vital, .level-hud, .elapsed { padding: 16px; border-bottom: 1px solid var(--border); }
.section-label { justify-content: space-between; gap: 6px; }
.section-label h2, .elapsed span { margin: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.section-label span, .elapsed time { font: 12px var(--mono); }
.health { height: 8px; border-radius: 2px; margin-top: 11px; background: #363930; overflow: hidden; }
.health-fill { width: 100%; height: 100%; background: repeating-linear-gradient(90deg, transparent 0 19px, #1a1d194d 19px 21px), var(--accent); transition: width .18s ease; }
.partner-vital { margin-top: 12px; }
.partner-fill { background-color: var(--blue); }
.player-one { color: var(--amber); }
.player-two, .partner-vital h2 { color: var(--blue); }
.level-track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; margin-top: 11px; }
.level-track i { height: 5px; background: #3b4037; border-radius: 1px; }
.level-track .current { background: var(--accent); }
.level-track .done { background: #acd390; }
.level-hud p { min-height: 1.45em; margin: 11px 0 0; color: var(--muted); font-size: 11px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.stats > div { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.stats > div + div { border-left: 1px solid var(--border); }
.stats dt { color: var(--muted); font-size: 12px; }
.stats dd { margin: 5px 0 0; font: 700 23px var(--mono); }
.elapsed { border-bottom: 0; justify-content: space-between; }
.wallet { padding: 14px 16px; border-top: 1px solid var(--border); }
.wallet strong { color: var(--amber); font-size: 14px; }
.wallet-points { margin: 9px 0 11px; color: var(--muted); }
.wallet-points > :first-child, .wallet p { font-family: inherit; font-size: 11px; }
.exchange { width: 100%; }
.exchange:not(:disabled) { border-color: #79643d; color: var(--amber); }
.exchange[data-unlocked='true'] { border-color: #506044; color: #bce5a1; }
.wallet p { margin: 8px 0 0; color: var(--muted); }
.controls { gap: 17px; padding: 13px 0; font-size: 12px; color: var(--muted); }
.controls strong { color: var(--ink); }
.desktop-controls { display: flex; gap: 17px; flex-wrap: wrap; }
.desktop-controls > span { display: flex; gap: 4px; align-items: center; }
kbd { display: inline-block; min-width: 19px; padding: 2px 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--panel); color: #e2e4d9; text-align: center; font: 11px var(--mono); }
.key-alt { padding: 0 1px; }

@media (max-width: 900px) {
  .shell { --content-width: calc(100% - 32px); padding-top: 18px; }
  .layout { grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; }
  .stats dd { font-size: 20px; }
}
@media (max-width: 650px) {
  .look-hint { display: none; }
  .shell { --content-width: calc(100% - 20px); padding-top: 12px; }
  .shell[data-fullscreen='true'] { padding-inline: 10px; }
  .masthead { margin-bottom: 12px; }
  .overlay-actions { gap: 5px; }
  .overlay-actions .button { min-height: 32px; padding: 6px 8px; font-size: 12px; }
  .overlay-actions .action { gap: 9px; }
  .header-tools { gap: 6px; }
  .header-tools .quiet { min-width: auto; padding-inline: 8px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .field-bar, .hud-title { height: 32px; }
  .hud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hud-title, .elapsed, .wallet { grid-column: span 2; }
  .vital, .level-hud, .elapsed, .wallet, .stats > div { padding: 11px 12px; }
  .level-hud { border-left: 1px solid var(--border); }
  .stats { grid-column: span 2; }
  .brief { margin: 10px 0 13px; }
  .overline { margin-bottom: 8px; font-size: 10px; }
  .controls { align-items: flex-start; }
}
@media (max-width: 400px) { .header-tools .signal { display: none; } }
@media (prefers-reduced-motion: reduce) { .health-fill { transition: none; } }
