/* A single grayscale toolbar and a full-viewport article. */
:root { color-scheme: light dark; --bg: #fff; --panel: #f5f5f5; --text: #202020; --muted: #666; --line: #d6d6d6; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }
:root[data-theme="dark"] { color-scheme: dark; --bg: #181818; --panel: #222; --text: #eee; --muted: #aaa; --line: #444; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) { :root:not([data-theme]) { --bg: #181818; --panel: #222; --text: #eee; --muted: #aaa; --line: #444; } }
* { box-sizing: border-box; }
body { margin: 0; overflow: hidden; }
button, select { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 7px 10px; cursor: pointer; }
button:hover:enabled, select:hover { background: var(--panel); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
[hidden] { display: none !important; }
.app, .game { height: 100dvh; width: 100%; min-width: 0; }
.game { display: flex; flex-direction: column; }
.game-bar { position: relative; z-index: 2; flex-shrink: 0; display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; }
.target-line { flex: 1; min-width: 0; font-size: 17px; overflow-wrap: anywhere; }
.target-line strong { font-weight: 650; }
.stats { display: flex; gap: 20px; }
.stat { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.bar-controls { display: flex; align-items: center; gap: 12px; }
#theme-button { width: 34px; height: 34px; padding: 7px; display: grid; place-items: center; }
#theme-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#back-button { white-space: nowrap; }
#help-button { width: 32px; padding-inline: 0; }
.chaos-status { position: absolute; top: calc(100% + 10px); right: 18px; padding: 7px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 4px; color: var(--text); font-size: 12px; pointer-events: none; }
.article-stage { position: relative; flex: 1; min-height: 0; background: var(--bg); overflow: hidden; }
iframe { display: block; width: 100%; height: 100%; border: 0; background: var(--bg); }
.loading { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); padding: 24px; }
.loading h2 { font-size: 22px; color: var(--text); margin: 20px 0 6px; }
.loading p { font-size: 13px; margin: 0; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--text); border-radius: 50%; display: inline-block; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-card { position: absolute; top: 16px; left: 20px; right: 20px; display: flex; align-items: center; gap: 14px; z-index: 3; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 17px; font-size: 13px; box-shadow: 0 5px 20px #0002; }
.error-card > span { font-size: 24px; }
.error-card p { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 5px 0 0; }
.error-card button { margin-left: auto; white-space: nowrap; }
dialog.victory { position: fixed; inset: 0; width: 100%; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; display: flex; align-items: center; justify-content: center; background: transparent; box-shadow: none; padding: 24px; }
dialog.victory::backdrop { background: #0008; backdrop-filter: blur(4px); }
.victory-card { position: relative; padding: 40px 45px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 60px #0004; max-width: 500px; }
.victory-star { display: block; font-size: 70px; line-height: 1; margin-bottom: 20px; }
.eyebrow { font-size: 10px; letter-spacing: 1.2px; color: var(--muted); }
.victory-card h2 { font-size: 32px; line-height: 1.15; margin: 12px 0; }
.victory-card p { font-size: 14px; line-height: 1.6; color: var(--muted); margin-bottom: 24px; }
.next-round { display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 11px; }
.next-round .spinner { width: 13px; height: 13px; }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 8; }
dialog { color: var(--text); background: var(--bg); max-width: 520px; width: calc(100% - 32px); padding: 32px; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 20px 100px #0005; }
dialog::backdrop { background: #0008; backdrop-filter: blur(3px); }
dialog h2 { font-size: 26px; line-height: 1.15; margin: 0 0 23px; }
dialog p { font-size: 13px; line-height: 1.8; color: var(--muted); }
.close-dialog { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 27px; padding: 0 5px; }
.credits { margin-top: 25px; padding-top: 21px; border-top: 1px solid var(--line); }
.credits > strong, .credits p { font-size: 11px; }
.credits a { color: inherit; }
@media (max-width: 800px) { .game-bar { gap: 14px; padding: 10px 14px; } .stats { gap: 12px; } .stat { flex-direction: column; gap: 2px; } }
@media (max-width: 600px) {
  .game-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px 12px; padding: 10px 12px; }
  #back-button { grid-row: 1; grid-column: 1; }
  .target-line { grid-row: 1; grid-column: 2 / 4; font-size: 16px; }
  .stats { grid-row: 2; grid-column: 1 / 3; gap: 14px; }
  .stat { flex-direction: row; gap: 5px; }
  .bar-controls { grid-row: 2; grid-column: 3; gap: 8px; }
  #help-button { width: 28px; }
  .error-card { left: 10px; right: 10px; padding: 12px; flex-wrap: wrap; }
  .error-card > div { flex: 1; }
  .victory-card { position: relative; padding: 28px 20px; }
  .victory-card h2 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
