:root {
  color-scheme: light;
  --forest: #173e34;
  --forest-deep: #0a2822;
  --forest-mid: #2e604e;
  --leaf: #608353;
  --leaf-light: #91a96b;
  --paper: #f4edcf;
  --paper-light: #fffbed;
  --sun: #f3c85d;
  --sun-light: #fff5ad;
  --sun-deep: #dc9937;
  --ink: #17382f;
  --ink-soft: #5a7167;
  --line: rgba(23, 56, 47, 0.22);
  --cat: #a86742;
  --cat-light: #d8955b;
  --cat-dark: #53382b;
  font-family: "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  background: var(--forest-deep);
  color: var(--ink);
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--forest-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 85% 8%, rgba(244, 204, 91, 0.16), transparent 25rem),
    radial-gradient(circle at 12% 45%, rgba(128, 166, 99, 0.18), transparent 31rem),
    linear-gradient(153deg, #12372e 0%, #1d4b3d 49%, #0d2b25 100%);
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    radial-gradient(circle, rgba(255, 252, 224, 0.9) 0 0.6px, transparent 0.8px),
    radial-gradient(circle, rgba(7, 30, 25, 0.9) 0 0.7px, transparent 0.9px);
  background-position: 0 0, 8px 10px;
  background-size: 15px 15px, 19px 19px;
  content: "";
}

button,
a { -webkit-tap-highlight-color: transparent; }

button { font: inherit; }

button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid #fff19a;
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding-bottom: 44px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(246, 239, 207, 0.24);
  color: var(--paper);
}

.back-link {
  color: inherit;
  text-decoration: none;
  font: 750 0.68rem/1.2 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.12em;
}

.back-link span {
  display: inline-block;
  margin-right: 8px;
  transition: transform 160ms ease;
}

.back-link:hover span { transform: translateX(-4px); }

.run-stats {
  display: flex;
  align-items: stretch;
  border: 1px solid rgba(246, 239, 207, 0.2);
}

.run-stats > span {
  min-width: 84px;
  padding: 9px 12px;
  display: grid;
  gap: 4px;
  text-align: right;
}

.run-stats > span + span { border-left: 1px solid rgba(246, 239, 207, 0.2); }

.run-stats small,
.result-stats small {
  color: rgba(246, 239, 207, 0.62);
  font: 700 0.52rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.11em;
}

.run-stats strong {
  font: 850 0.94rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.title-block {
  padding: clamp(46px, 6vw, 76px) 0 clamp(32px, 4vw, 48px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.68fr);
  align-items: end;
  gap: 42px;
  color: var(--paper);
}

.eyebrow,
.section-label {
  margin: 0;
  font: 800 0.62rem/1.3 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.16em;
}

.eyebrow { color: #f4d875; }
.section-label { color: var(--ink-soft); }

.title-block h1 {
  margin: 15px 0 0;
  font-size: clamp(3.6rem, 9vw, 7.2rem);
  line-height: 0.85;
  letter-spacing: -0.09em;
}

.title-block h1 span {
  display: block;
  margin-bottom: 0.18em;
  color: #d8e8ad;
  font-size: 0.42em;
  letter-spacing: 0.1em;
}

.lead {
  margin: 0 0 3px;
  color: rgba(246, 239, 207, 0.8);
  font-weight: 650;
  line-height: 1.9;
}

.play-panel {
  padding: clamp(16px, 3.2vw, 34px);
  border: 1px solid rgba(246, 239, 207, 0.55);
  background:
    linear-gradient(rgba(246, 239, 207, 0.97), rgba(250, 245, 222, 0.98)),
    repeating-linear-gradient(7deg, transparent 0 8px, rgba(106, 83, 42, 0.08) 9px 10px);
  box-shadow: 18px 18px 0 rgba(4, 25, 21, 0.26);
}

.panel-heading {
  margin-bottom: 22px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.panel-heading h2 {
  margin: 7px 0 0;
  font-size: clamp(1.45rem, 3.6vw, 2.25rem);
  letter-spacing: -0.05em;
}

.text-button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 800;
}

.text-button:hover { background: rgba(23, 53, 46, 0.08); }

.scene {
  position: relative;
  overflow: hidden;
  border: 2px solid rgba(23, 53, 46, 0.42);
  background: #6d9361;
  box-shadow:
    inset 0 0 0 7px rgba(255, 252, 233, 0.14),
    0 12px 28px rgba(23, 53, 46, 0.15);
  isolation: isolate;
}

#game-canvas {
  position: relative;
  z-index: 1;
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 2;
  display: block;
  cursor: default;
  touch-action: none;
  user-select: none;
}

.scene[data-phase="running"] #game-canvas { cursor: crosshair; }
.scene.is-pressed #game-canvas { cursor: grabbing; }

.scene-hud,
.scene-legend {
  position: absolute;
  z-index: 4;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.scene-hud { top: 16px; }
.scene-legend { bottom: 16px; justify-content: flex-start; }

.pressure-chip,
.scene-legend span {
  min-height: 34px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 251, 223, 0.45);
  background: rgba(18, 52, 44, 0.75);
  color: rgba(255, 253, 226, 0.94);
  backdrop-filter: blur(4px);
}

.pressure-chip small {
  color: rgba(255, 253, 226, 0.62);
  font: 750 0.48rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.1em;
}

.pressure-chip strong,
.scene-legend span {
  font: 800 0.58rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.06em;
}

.forecast-mark {
  width: 16px;
  height: 16px;
  border: 2px dashed var(--sun-light);
  border-radius: 50%;
}

.pulse-mark {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 4px rgba(255, 237, 147, 0.24);
  animation: pulseMark 620ms ease-in-out infinite;
}

@keyframes pulseMark {
  50% { box-shadow: 0 0 0 9px rgba(255, 237, 147, 0.05); }
}

.cicada {
  color: rgba(255, 253, 226, 0.84);
  font: 750 0.6rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 4px rgba(15, 47, 39, 0.7);
  animation: cicadaPulse 2.8s ease-in-out infinite;
}

@keyframes cicadaPulse {
  0%, 100% { opacity: 0.34; }
  48% { opacity: 0.92; }
}

.scene-overlay {
  position: absolute;
  z-index: 10;
  inset: 0;
  padding: 14px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(7, 32, 27, 0.72);
  backdrop-filter: blur(7px);
}

.overlay-card {
  width: min(530px, 100%);
  padding: clamp(18px, 2.8vw, 28px);
  border: 1px solid rgba(23, 56, 47, 0.24);
  background: var(--paper-light);
  box-shadow: 11px 11px 0 rgba(7, 28, 24, 0.24);
  text-align: center;
}

.overlay-card h2 {
  margin: 8px 0 10px;
  font-size: clamp(1.85rem, 4.5vw, 3rem);
  line-height: 0.98;
  letter-spacing: -0.07em;
}

.overlay-card > p:not(.eyebrow) {
  max-width: 430px;
  margin: 0 auto;
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.58;
}

.intro-forecast {
  position: relative;
  width: min(360px, 90%);
  height: 82px;
  margin: 8px auto 10px;
  overflow: hidden;
  border: 1px solid rgba(23, 56, 47, 0.2);
  background: linear-gradient(155deg, #4f7856, #75965e);
}

.intro-ring {
  position: absolute;
  border: 2px dashed rgba(255, 247, 181, 0.9);
  border-radius: 50%;
}

.intro-ring i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--sun-light);
  box-shadow: 0 0 20px rgba(255, 238, 137, 0.8);
  transform: translate(-50%, -50%);
  animation: introGrow 1.6s ease-in-out infinite;
}

.intro-ring-one {
  left: 18px;
  top: 12px;
  width: 106px;
  height: 106px;
}

.intro-ring-one i { animation-duration: 1s; }

.intro-ring-two {
  right: 16px;
  top: 16px;
  width: 68px;
  height: 68px;
}

.intro-ring-two i { animation-duration: 2s; }

@keyframes introGrow {
  0%, 100% { transform: translate(-50%, -50%) scale(0.55); opacity: 0.75; }
  55% { transform: translate(-50%, -50%) scale(1.7); opacity: 1; }
}

.intro-cat {
  position: absolute;
  z-index: 2;
  left: 49%;
  bottom: 18px;
  width: 58px;
  height: 30px;
  border: 2px solid var(--cat-dark);
  border-radius: 55% 48% 45% 52%;
  background: var(--cat-light);
  transform: translateX(-50%);
}

.intro-cat::before,
.intro-cat::after {
  position: absolute;
  top: -9px;
  width: 15px;
  height: 15px;
  background: var(--cat-light);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  content: "";
}

.intro-cat::before { left: 7px; transform: rotate(-14deg); }
.intro-cat::after { right: 7px; transform: rotate(14deg); }

.intro-cat i {
  position: absolute;
  right: -24px;
  bottom: 0;
  width: 30px;
  height: 18px;
  border: 4px solid var(--cat);
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 30px 0 0;
}

.primary-button {
  min-height: 52px;
  padding: 0 24px;
  border: 0;
  background: var(--forest);
  color: var(--paper-light);
  cursor: pointer;
  font-weight: 850;
  letter-spacing: 0.04em;
  box-shadow: 5px 5px 0 rgba(23, 53, 46, 0.2);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.overlay-card .primary-button {
  width: 100%;
  margin-top: 12px;
}

.primary-button:hover {
  background: #245848;
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 rgba(23, 53, 46, 0.18);
}

.primary-button:active {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(23, 53, 46, 0.18);
}

.result-cat {
  position: relative;
  width: 110px;
  height: 60px;
  margin: 12px auto 4px;
}

.result-cat span {
  position: absolute;
  left: 12px;
  bottom: 6px;
  width: 74px;
  height: 39px;
  border: 3px solid var(--cat-dark);
  border-radius: 55% 45% 48% 52%;
  background: var(--cat-light);
  transform: rotate(-9deg);
}

.result-cat span::before,
.result-cat span::after {
  position: absolute;
  top: -12px;
  width: 19px;
  height: 19px;
  background: var(--cat-light);
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
  content: "";
}

.result-cat span::before { left: 9px; }
.result-cat span::after { right: 9px; }

.result-cat i {
  position: absolute;
  right: 8px;
  top: 2px;
  color: var(--sun-deep);
  font: 900 1.7rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.result-stats {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
}

.result-stats span {
  min-height: 64px;
  display: grid;
  place-content: center;
  gap: 7px;
}

.result-stats span + span { border-left: 1px solid var(--line); }

.result-stats small { color: var(--ink-soft); }
.result-stats strong { font: 850 1.05rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }

.control-strip {
  min-height: 112px;
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.7fr);
  align-items: center;
  gap: 28px;
  border: 1px solid var(--line);
  border-top: 0;
  background: rgba(255, 251, 229, 0.76);
}

.control-strip > div {
  display: grid;
  gap: 5px;
}

.control-strip strong { font-size: 0.95rem; }

.control-strip p:not(.section-label),
.status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.65;
}

.status {
  min-height: 54px;
  padding: 11px 13px;
  display: grid;
  align-content: center;
  border-left: 3px solid var(--sun-deep);
  background: rgba(220, 236, 203, 0.65);
}

.rule-cards {
  margin-top: 34px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  color: var(--paper);
}

.rule-cards article {
  min-height: 210px;
  padding: 28px;
  border: 1px solid rgba(246, 239, 207, 0.28);
}

.rule-cards article + article { border-left: 0; }

.rule-cards article > span {
  color: #f4d875;
  font: 800 0.6rem/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.rule-cards h2 {
  margin: 30px 0 12px;
  font-size: 1.3rem;
}

.rule-cards p {
  margin: 0;
  color: rgba(246, 239, 207, 0.72);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.8;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 760px) {
  .game-shell { width: min(100% - 24px, 1120px); }

  .topbar {
    min-height: 64px;
    align-items: flex-start;
    padding: 12px 0;
    flex-direction: column;
    gap: 10px;
  }

  .run-stats { width: 100%; }
  .run-stats > span { min-width: 0; flex: 1; text-align: left; }

  .title-block {
    padding: 40px 0 30px;
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .title-block h1 { font-size: clamp(3.5rem, 20vw, 5.4rem); }
  .lead { max-width: 34rem; }
  .play-panel { box-shadow: 9px 9px 0 rgba(4, 25, 21, 0.26); }

  .panel-heading { align-items: flex-start; }
  .panel-heading .text-button { flex: 0 0 auto; }

  .scene-hud,
  .scene-legend { left: 9px; right: 9px; }
  .scene-hud { top: 9px; }
  .scene-legend { bottom: 9px; gap: 5px; }
  .scene-legend span { padding: 6px 7px; font-size: 0.49rem; }
  .cicada { display: none; }

  .scene-overlay {
    position: fixed;
    z-index: 100;
    padding: 18px;
    background: rgba(7, 32, 27, 0.9);
  }

  .overlay-card {
    max-height: calc(100dvh - 36px);
    overflow: auto;
  }

  .control-strip {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .rule-cards { grid-template-columns: 1fr; }
  .rule-cards article { min-height: 0; }
  .rule-cards article + article { border-left: 1px solid rgba(246, 239, 207, 0.28); border-top: 0; }
  .rule-cards h2 { margin-top: 18px; }
}

@media (max-width: 430px) {
  .game-shell { width: min(100% - 16px, 1120px); }
  .back-link { font-size: 0.59rem; }
  .run-stats > span { padding: 8px; }
  .play-panel { padding: 10px; }
  .panel-heading { margin: 7px 4px 16px; }
  .panel-heading h2 { font-size: 1.3rem; }
  .panel-heading .section-label { max-width: 190px; }
  .text-button { padding: 0 10px; }
  .scene-legend span:last-child { display: none; }
  .control-strip { padding: 16px 14px; }
  .overlay-card { padding: 22px 18px; }
  .overlay-card h2 { font-size: 2.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
