:root {
  color-scheme: light;
  --paper: #fffaf0;
  --paper-deep: #f7e7c6;
  --ink: #2b251d;
  --muted: #736651;
  --line: #dfc895;
  --shelf: #fff4d9;
  --green: #4f8f63;
  --green-deep: #2f6844;
  --red: #c65b4a;
  --shadow: 0 18px 44px rgba(101, 75, 32, 0.14);
  --radius: 8px;
  --hud: #102326;
  --hud-deep: #173f36;
  --game-cyan: #74e4dc;
  --game-cyan-soft: rgba(116, 228, 220, 0.14);
  --game-red: #ff7c83;
  --game-red-soft: rgba(255, 124, 131, 0.18);
  --game-amber: #f5c56a;
  --game-ink: #e7fff2;
  --game-muted: rgba(231, 255, 242, 0.72);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html,
body {
  min-width: 0;
  overflow-x: hidden;
}

html { scroll-behavior: smooth; }

body {
  background:
    linear-gradient(180deg, rgba(79, 143, 99, 0.14), transparent 340px),
    repeating-linear-gradient(90deg, rgba(223, 200, 149, 0.18) 0 1px, transparent 1px 76px),
    var(--paper);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  line-height: 1.7;
  margin: 0;
}

button,
input { font: inherit; }

a { color: inherit; }

.site-header {
  background: rgba(255, 250, 240, 0.94);
  border-bottom: 1px solid rgba(115, 102, 81, 0.2);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner,
.footer-inner {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1560px;
  padding: 14px 24px;
}

.brand { display: inline-grid; text-decoration: none; }
.brand strong { font-size: 18px; }
.brand span { color: var(--muted); font-size: 12px; }

.nav,
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.nav a,
.button {
  align-items: center;
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  letter-spacing: 0;
  min-height: 40px;
  padding: 8px 12px;
  text-decoration: none;
}

button.button { cursor: pointer; }

.nav a:hover,
.nav a:focus-visible,
.button:hover,
.button:focus-visible {
  border-color: var(--green);
}

.button.primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.page-shell {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(110px, 150px) minmax(0, 1fr) minmax(110px, 150px);
  margin: 0 auto;
  max-width: 1560px;
  padding: 22px 24px 44px;
}

.page-shell > main { grid-column: 2; }

main { display: grid; gap: 24px; min-width: 0; }
.ad-rail { min-width: 0; }

.ad-box {
  align-items: center;
  background: rgba(255, 253, 250, 0.75);
  border: 1px dashed rgba(115, 102, 81, 0.28);
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: center;
  min-height: 240px;
  position: sticky;
  text-align: center;
  top: 76px;
}

.hero,
.panel {
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(115, 102, 81, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.hero { padding: clamp(28px, 5vw, 56px); }
.panel { padding: clamp(20px, 3vw, 30px); }

.eyebrow {
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 900;
  margin: 0 0 8px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p { letter-spacing: 0; margin-top: 0; overflow-wrap: anywhere; }

h1 { font-size: clamp(30px, 4vw, 38px); line-height: 1.12; margin-bottom: 10px; }
h2 { font-size: clamp(22px, 3vw, 31px); line-height: 1.25; margin-bottom: 8px; }
h3 { font-size: 18px; line-height: 1.35; margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 16px; max-width: 820px; }

.device-note {
  background: var(--shelf);
  border: 1px dashed rgba(115, 102, 81, 0.32);
  border-radius: var(--radius);
  color: var(--muted);
  display: inline-block;
  font-size: 13px;
  margin: 4px 0 0;
  max-width: 100%;
  padding: 6px 10px;
}

.game-board {
  background: linear-gradient(150deg, var(--hud), var(--hud-deep));
  border: 1px solid rgba(79, 143, 99, 0.45);
  border-radius: var(--radius);
  color: var(--game-ink);
  min-width: 0;
  overflow: hidden;
  padding: clamp(18px, 3vw, 28px);
}

.game-board .eyebrow,
.game-board .section-label {
  color: #a6f0c0;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-board h2,
.game-board h3 { color: var(--game-ink); }

.panel-heading {
  align-items: start;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.panel-heading h2 { margin-bottom: 0; }

.stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(86px, 1fr));
  min-width: min(100%, 340px);
}

.stats div,
.instrument {
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(231, 255, 242, 0.18);
  border-radius: var(--radius);
  min-width: 0;
  padding: 8px 10px;
}

.stats span { color: var(--game-muted); display: block; font-size: 12px; }
.stats strong { color: var(--game-ink); display: block; font-size: 17px; overflow-wrap: anywhere; }

.status-line {
  background: var(--game-cyan-soft);
  border-left: 3px solid var(--game-cyan);
  color: var(--game-ink);
  min-height: 2.1em;
  margin: 24px 0 16px;
  padding: 10px 14px;
}

.status-line.is-alert,
.alarm-panel.is-alert {
  background: var(--game-red-soft);
  border-color: var(--game-red);
}

.status-line.is-ended { border-color: var(--game-amber); }

.instrument-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.instrument { padding: 14px; }

.instrument-heading,
.section-heading,
.input-row,
.result-main,
.related-links {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.instrument-heading h3 { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.08em; margin: 0; }
.meter-state { color: var(--game-muted); font-size: 12px; }
.instrument.is-alert .meter-state { color: var(--game-red); font-weight: 900; }

.instrument-value { align-items: baseline; display: flex; gap: 5px; margin: 10px 0 8px; }
.instrument-value strong { font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: clamp(28px, 5vw, 42px); line-height: 1; }
.instrument-value span { color: var(--game-muted); font-size: 12px; }

.meter-track { background: rgba(0, 0, 0, 0.3); border-radius: 99px; height: 8px; overflow: hidden; }
.meter-fill { background: var(--game-cyan); border-radius: inherit; display: block; height: 100%; transition: width 120ms linear, background 120ms linear; width: 42%; }
.instrument.is-alert .meter-fill { background: var(--game-amber); }
.instrument.is-danger .meter-fill { background: var(--game-red); }
.instrument-note { color: var(--game-muted); font-size: 12px; margin: 8px 0 0; min-height: 1.7em; }

.alarm-panel {
  align-items: center;
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(231, 255, 242, 0.18);
  border-left: 3px solid var(--game-cyan);
  border-radius: var(--radius);
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 13px;
}

.alarm-light { background: var(--game-cyan); border-radius: 50%; flex: 0 0 10px; height: 10px; width: 10px; }
.alarm-panel.is-alert .alarm-light { background: var(--game-red); }
.alarm-panel strong,
.alarm-panel span { display: block; }
.alarm-panel strong { font-size: 14px; }
.alarm-panel div span { color: var(--game-muted); font-size: 12px; }

.incident-panel,
.command-panel { margin-top: 18px; }
.section-heading { color: var(--game-muted); font-size: 12px; }
.section-heading h3 { font-size: 16px; margin: 0; }
.incident-log { list-style: none; margin: 8px 0 0; max-height: 142px; overflow: auto; padding: 0; }
.incident-log li { border-bottom: 1px solid rgba(231, 255, 242, 0.12); color: var(--game-muted); font-size: 12px; padding: 6px 0; }
.incident-log li strong { color: var(--game-ink); margin-right: 8px; }
.incident-log .empty-log { border-bottom: 0; }

.reference-note,
.help-text { color: var(--game-muted); font-size: 12px; }
.reference-note { margin: 8px 0 10px; }

.command-table-wrap { overflow-x: auto; }
.command-table { border-collapse: collapse; font-size: 12px; table-layout: fixed; width: 100%; }
.command-table th,
.command-table td { border-bottom: 1px solid rgba(231, 255, 242, 0.15); padding: 8px 6px; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.command-table th:first-child { width: 16%; }
.command-table th:nth-child(2) { width: 34%; }
.command-table th { color: var(--game-muted); font-weight: 700; }
.command-table code,
.help-text code { color: var(--game-cyan); font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-weight: 900; }

.command-form { margin-top: 20px; }
.command-form label { color: var(--game-ink); display: block; font-size: 14px; font-weight: 800; margin-bottom: 7px; }
.input-row { justify-content: flex-start; position: relative; }
.input-row input {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(231, 255, 242, 0.34);
  border-radius: var(--radius);
  color: var(--game-ink);
  min-height: 46px;
  min-width: 0;
  outline: none;
  padding: 8px 78px 8px 12px;
  width: 100%;
}
.input-row input:focus { border-color: var(--game-cyan); box-shadow: 0 0 0 3px rgba(116, 228, 220, 0.16); }
.input-row input:disabled { cursor: not-allowed; opacity: 0.58; }
.enter-hint { color: var(--game-muted); font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: 11px; pointer-events: none; position: absolute; right: 13px; }
.help-text { margin: 8px 0 0; }

.action-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.game-board .button { background: rgba(255, 255, 255, 0.06); border-color: rgba(231, 255, 242, 0.28); color: var(--game-ink); }
.game-board .button:hover,
.game-board .button:focus-visible { background: var(--game-cyan-soft); border-color: var(--game-cyan); }
.game-board .button.primary { background: var(--game-cyan); border-color: var(--game-cyan); color: #061115; }
.game-board .button.primary:hover,
.game-board .button.primary:focus-visible { background: #9af3ec; }

.result-panel,
.how-to,
.related-modes { padding: clamp(20px, 3vw, 30px); }
.result-panel { border-color: rgba(79, 143, 99, 0.35); }
.result-main { align-items: baseline; color: var(--muted); justify-content: flex-start; margin: 18px 0 22px; }
.result-main strong { color: var(--green-deep); font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace; font-size: clamp(36px, 7vw, 56px); line-height: 1; }
.result-grid { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.result-grid div { background: var(--shelf); border: 1px solid rgba(115, 102, 81, 0.18); border-radius: var(--radius); min-width: 0; padding: 12px; }
.result-grid dt { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.result-grid dd { font-size: 17px; font-weight: 800; margin: 4px 0 0; overflow-wrap: anywhere; }
.result-note { color: var(--muted); margin: 18px 0 0; }
.how-to ol { margin: 8px 0 0; padding-left: 1.4em; }
.how-to li + li { margin-top: 5px; }
.related-modes p { color: var(--muted); }
.related-links { flex-wrap: wrap; justify-content: flex-start; }

.site-footer { background: transparent; border-top: 1px solid rgba(115, 102, 81, 0.18); color: var(--ink); }
.footer-links { justify-content: flex-start; }
.footer-links a { text-underline-offset: 3px; }
.footer-note { font-size: 13px; margin: 0; }

@media (max-width: 1100px) {
  .page-shell { grid-template-columns: 1fr; }
  .page-shell > main { grid-column: 1; }
  .ad-rail { display: none; }
}

@media (max-width: 720px) {
  h1, h2, h3, p { line-break: anywhere; word-break: break-word; }
  .header-inner, .footer-inner, .panel-heading { align-items: stretch; flex-direction: column; }
  .nav { justify-content: flex-start; width: 100%; }
  .nav a { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .page-shell { padding: 14px 12px 32px; width: 100%; }
  .hero, .panel { max-width: 100%; padding: 18px; width: 100%; }
  .game-board { padding: 18px; }
  .stats { margin-top: 18px; min-width: 0; }
  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .header-inner, .footer-inner { padding: 12px; }
  .page-shell { padding: 12px 10px 32px; }
  .nav a { width: auto; }
  .button { width: 100%; }
  .hero, .panel { padding: 18px 14px; }
  .game-board { padding: 14px; }
  .stats { gap: 5px; }
  .stats div { padding: 7px 5px; }
  .stats strong { font-size: 14px; }
  .instrument { padding: 10px; }
  .instrument-value strong { font-size: 27px; }
  .instrument-note { font-size: 11px; }
  .command-table { font-size: 11px; }
  .command-table th, .command-table td { padding: 7px 4px; }
  .result-grid { gap: 7px; }
  .result-grid div { padding: 9px; }
  .result-grid dd { font-size: 15px; }
}

@media (max-width: 360px) {
  .instrument-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
