:root {
  color-scheme: light;
  --ink: #15333d;
  --muted: #60747a;
  --paper: #fffdf7;
  --line: #dce8e7;
  --primary: #176b87;
  --primary-dark: #0f5067;
  --step1: #f6b73c;
  --step2: #d6a719;
  --danger: #d85040;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #d9f3ef 0, transparent 30rem),
    #f7f4e9;
  font-size: 18px;
}

button { font: inherit; }

.hero {
  padding: 30px 20px 38px;
  color: white;
  background: linear-gradient(135deg, #0f5067, #23899a);
}

.hero__inner, main {
  width: min(1100px, 100%);
  margin: auto;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 24px; font-size: clamp(2rem, 7vw, 3.8rem); line-height: 1.12; }
h2 { margin-bottom: 12px; font-size: clamp(1.4rem, 4vw, 2rem); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stats div {
  min-width: 0;
  padding: 12px;
  text-align: center;
  background: rgb(255 255 255 / 14%);
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 14px;
}

.stats span { display: block; font-size: clamp(1.5rem, 5vw, 2.2rem); font-weight: 900; }
.stats small { display: block; font-size: .68rem; font-weight: 700; }

main { padding: 24px 16px 60px; }

.guide, .message-panel {
  margin-bottom: 24px;
  padding: 20px;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgb(30 70 70 / 8%);
}

.guide ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: play-step;
}

.guide li {
  padding: 13px;
  background: #eef8f6;
  border-radius: 12px;
  counter-increment: play-step;
}

.guide li::before {
  content: counter(play-step);
  display: inline-grid;
  width: 28px;
  height: 28px;
  margin-right: 7px;
  place-items: center;
  color: white;
  background: var(--primary);
  border-radius: 50%;
  font-weight: 900;
}

.message-panel {
  text-align: center;
  border-color: var(--step1);
  background: #fff8dc;
}

.message-panel__actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.game-mode-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
  margin-bottom: 24px;
  padding: 24px;
  color: white;
  background:
    radial-gradient(circle at 88% 20%, rgb(255 225 92 / 38%), transparent 22%),
    linear-gradient(135deg, #172d52, #6b245f);
  border: 3px solid #f5c94b;
  border-radius: 20px;
  box-shadow: 0 9px 25px rgb(44 25 76 / 20%);
}
.game-mode-card h2 { margin-bottom: 8px; }
.game-mode-card p { margin-bottom: 8px; }
.game-mode-high-score { color: #ffe36d; font-weight: 900; }
.game-mode-high-score strong { font-size: 1.5rem; }
.button--shooting { background: #ef9b24; box-shadow: 0 5px 0 #9b5712; }

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.section-note { margin-bottom: 0; color: var(--muted); font-weight: 700; }
.quiz-launcher {
  display: grid;
  grid-template-columns: auto minmax(160px, 260px) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  background: white;
  border: 2px solid var(--line);
  border-radius: 14px;
}
.quiz-launcher label { font-weight: 900; }
.quiz-launcher select {
  min-height: 48px;
  padding: 8px 12px;
  color: var(--ink);
  background: white;
  border: 2px solid #99bdc3;
  border-radius: 10px;
  font: inherit;
  font-weight: 800;
}
.legend { display: flex; gap: 12px; flex-wrap: wrap; color: var(--muted); font-size: .75rem; font-weight: 700; }
.dot { display: inline-block; width: 13px; height: 13px; margin-right: 4px; border-radius: 50%; vertical-align: -1px; }
.dot--none { background: #c6d0d0; }
.dot--step1 { background: #36a269; }
.dot--step2 { background: var(--step2); }
.dot--mistake { background: white; border: 3px solid var(--danger); }

.svg-map-shell {
  padding: 12px;
  background: linear-gradient(145deg, #dff3f5, #eff8ee);
  border: 2px solid #b8dcdf;
  border-radius: 22px;
}

.map-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-bottom: 8px;
}

.map-toolbar button {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 12px;
  color: white;
  background: var(--primary);
  border: 0;
  border-radius: 10px;
  font-weight: 900;
  cursor: pointer;
}

.svg-map-viewport {
  position: relative;
  height: min(72dvh, 720px);
  overflow: hidden;
  touch-action: none;
  background: #cfeef4;
  border: 2px solid #8fc5cf;
  border-radius: 16px;
  cursor: grab;
}

.svg-map-viewport:active { cursor: grabbing; }
.svg-map-canvas { width: 100%; height: 100%; }
.svg-map-canvas, .svg-map-canvas svg, .svg-map-canvas .prefecture {
  pointer-events: auto;
}
.svg-map-canvas svg {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  will-change: transform;
}

.svg-map-canvas .prefecture {
  fill: #aeb9bc !important;
  stroke: #fff !important;
  stroke-width: 2.2 !important;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition: fill .18s, filter .18s, stroke .18s;
}
.svg-map-canvas .prefecture.is-pressed {
  filter: brightness(1.22);
}
.svg-map-canvas .prefecture .prefecture-hit-area {
  fill: transparent !important;
  stroke: transparent !important;
  stroke-width: 18 !important;
  vector-effect: non-scaling-stroke;
  pointer-events: all;
  cursor: pointer;
}

.svg-map-canvas .prefecture.status-1 { fill: #36a269 !important; }
.svg-map-canvas .prefecture.status-2 { fill: #d6a719 !important; }
.svg-map-canvas .prefecture.has-mistake {
  stroke: var(--danger) !important;
  stroke-width: 5 !important;
}
.svg-map-canvas .prefecture:hover,
.svg-map-canvas .prefecture:focus-visible {
  fill: #4b93ac !important;
  filter: brightness(1.1);
  outline: none;
}
.svg-map-shell--static .prefecture { cursor: default; }
.svg-map-shell--static .prefecture:hover {
  filter: none;
}
.svg-map-shell--static .prefecture.status-0:hover { fill: #aeb9bc !important; }
.svg-map-shell--static .prefecture.status-1:hover { fill: #36a269 !important; }
.svg-map-shell--static .prefecture.status-2:hover { fill: #d6a719 !important; }
.svg-map-canvas .prefecture.is-revealed {
  fill: #ffdf47 !important;
  stroke: #ff4d35 !important;
  stroke-width: 7 !important;
  filter: drop-shadow(0 0 10px #ffed5f);
  animation: map-flash .75s ease-in-out infinite alternate;
}

.map-help, .map-credit {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}
.map-debug-status {
  margin-top: 10px;
  padding: 10px 14px;
  color: var(--muted);
  background: #eef4f3;
  border: 2px solid transparent;
  border-radius: 10px;
  font-size: .82rem;
  font-weight: 800;
  text-align: center;
}
.map-debug-status.is-active {
  color: var(--primary-dark);
  background: #fff6cc;
  border-color: var(--step2);
}
.map-debug-status.has-error {
  color: #8b2016;
  background: #fff0ed;
  border-color: var(--danger);
}
.map-credit a { color: var(--primary-dark); }
.map-reveal-label {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 3;
  padding: 8px 18px;
  color: white;
  background: rgb(16 64 77 / 92%);
  border-radius: 999px;
  font-size: 1.1rem;
  font-weight: 900;
  transform: translateX(-50%);
}
.svg-map-shell--compact { padding: 8px; }
.svg-map-shell--compact .svg-map-viewport { height: min(52dvh, 470px); }
.svg-map-shell--compact .map-help { display: none; }
.svg-map-shell--compact .map-toolbar button { min-height: 40px; }

@keyframes map-flash {
  from { opacity: .65; }
  to { opacity: 1; }
}

.quiz-dialog {
  width: min(780px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 20px 70px rgb(0 0 0 / 30%);
}

.quiz-dialog::backdrop { background: rgb(8 31 37 / 70%); }
.quiz-dialog form { position: absolute; top: 10px; right: 10px; z-index: 2; }
.close-button { width: 42px; height: 42px; border: 0; border-radius: 50%; color: var(--ink); background: #edf2f1; font-size: 1.5rem; cursor: pointer; }
.quiz-card { padding: 28px 22px 24px; text-align: center; }
.quiz-card--map { padding-inline: 14px; }
.quiz-step { margin-bottom: 8px; color: var(--primary); font-size: .8rem; font-weight: 900; letter-spacing: .08em; }
.quiz-question { margin-bottom: 22px; font-size: clamp(1.35rem, 5vw, 1.8rem); }
.quiz-clue { margin: -10px 0 20px; color: var(--muted); font-weight: 700; }
.answer-list { display: grid; gap: 10px; }

.answer-map { margin: 14px 0; }

.answer-button, .button {
  min-height: 52px;
  padding: 12px 18px;
  color: white;
  background: var(--primary);
  border: 0;
  border-radius: 12px;
  font-weight: 900;
  cursor: pointer;
}

.answer-button:hover, .answer-button:focus-visible, .button:hover { background: var(--primary-dark); }
.answer-button:disabled { cursor: wait; opacity: .65; }
.button--accent { background: #d57a00; }
.feedback { padding: 34px 22px; text-align: center; }
.feedback__mark { margin-bottom: 8px; font-size: 4rem; line-height: 1; }
.feedback--correct .feedback__mark { color: var(--step2); }
.feedback--wrong .feedback__mark { color: var(--danger); }
.feedback p { color: var(--muted); font-weight: 700; }

.shooting-dialog {
  width: min(820px, calc(100% - 16px));
  max-height: calc(100dvh - 16px);
  padding: 0;
  overflow: auto;
  color: white;
  background: #101a38;
  border: 3px solid #58dcff;
  border-radius: 22px;
  box-shadow: 0 0 50px rgb(65 210 255 / 40%);
}
.shooting-dialog::backdrop { background: rgb(5 8 25 / 88%); }
.shooting-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
}
.shooting-ready, .shooting-result {
  min-height: 540px;
  padding: 55px 24px 30px;
  text-align: center;
  background:
    linear-gradient(rgb(16 26 56 / 76%), rgb(16 26 56 / 95%)),
    repeating-linear-gradient(90deg, transparent 0 39px, rgb(69 198 255 / 12%) 40px),
    repeating-linear-gradient(0deg, transparent 0 39px, rgb(69 198 255 / 12%) 40px);
}
.shooting-kicker { color: #67e3ff; font-size: .78rem; font-weight: 900; letter-spacing: .15em; }
.shooting-ready h2, .shooting-result h2 {
  color: white;
  font-size: clamp(2rem, 7vw, 3.2rem);
  text-shadow: 0 0 18px #5ddfff;
}
.shooting-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 560px;
  margin: 25px auto;
}
.shooting-rules div { padding: 13px; background: rgb(255 255 255 / 10%); border-radius: 12px; }
.shooting-rules small { display: block; color: #90eaff; font-size: .7rem; font-weight: 800; }
.shooting-rules strong { display: block; margin-top: 4px; font-size: 1.5rem; }
.shooting-start { min-width: 220px; background: #e99b21; }
.shooting-game {
  position: relative;
  min-height: 650px;
  padding: 18px 16px 24px;
  overflow: hidden;
  background: radial-gradient(circle at center, #273b70, #101a38 65%);
}
.shooting-hud { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shooting-hud div {
  padding: 8px;
  text-align: center;
  background: rgb(0 0 0 / 30%);
  border: 1px solid #4782ac;
  border-radius: 10px;
}
.shooting-hud span { display: block; color: #fff36a; font-size: 1.5rem; font-weight: 900; }
.shooting-hud small { color: #9feaff; font-size: .65rem; font-weight: 800; }
.shooting-combo {
  min-height: 36px;
  padding-top: 7px;
  color: #ffdc50;
  font-size: 1.3rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 0 12px #ff8c00;
}
.shooting-prompt { margin-bottom: 6px; color: #b9f2ff; text-align: center; font-weight: 900; }
.shooting-silhouette {
  width: min(320px, 72vw);
  height: 290px;
  margin: auto;
  filter: drop-shadow(0 0 18px rgb(103 227 255 / 75%));
}
.shooting-silhouette svg { width: 100%; height: 100%; overflow: visible; }
.shooting-silhouette .shooting-shape {
  fill: #07101d !important;
  stroke: #6ee7ff !important;
  stroke-width: 3 !important;
  vector-effect: non-scaling-stroke;
}
.shooting-lanes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 115px;
  align-items: center;
}
.shooting-target {
  min-height: 74px;
  padding: 12px 8px;
  color: white;
  background: linear-gradient(#36598b, #1d355e);
  border: 3px solid #67ddff;
  border-radius: 16px;
  box-shadow: 0 0 15px rgb(77 210 255 / 35%);
  font-size: clamp(1rem, 4vw, 1.4rem);
  font-weight: 900;
  cursor: crosshair;
  animation: target-float 2.2s ease-in-out infinite alternate;
}
.shooting-target--left { animation: target-in-left .55s, target-float 2.2s .55s infinite alternate; }
.shooting-target--right { animation: target-in-right .55s, target-float 2.2s .55s infinite alternate; }
.shooting-target.is-hit { color: #1a2c23; background: #ffdf53; animation: target-destroy .55s forwards; }
.shooting-target.is-miss { background: #a4293a; animation: target-shake .4s; }
.shooting-target.is-correct { border-color: #ffdf53; box-shadow: 0 0 25px #ffdf53; }
.shooting-help { margin: 5px 0 0; color: #96bccc; font-size: .72rem; text-align: center; }
.shooting-impact {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  font-size: 2.8rem;
  font-weight: 900;
  transform: translate(-50%, -50%);
  animation: impact-pop .6s forwards;
  pointer-events: none;
}
.shooting-impact--hit { color: #fff35c; text-shadow: 0 0 25px #ff6400; }
.shooting-impact--miss { color: #ff7885; text-shadow: 0 0 20px #85000d; }
.shooting-final-score { margin: 22px 0; color: #fff36a; font-size: 4.5rem; font-weight: 900; }
.shooting-final-score small { font-size: 1rem; }
.shooting-new-record { color: #fff36a; font-size: 1.5rem; font-weight: 900; }
.shooting-result-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

@keyframes target-in-left { from { transform: translateX(-130%); } to { transform: translateX(0); } }
@keyframes target-in-right { from { transform: translateX(130%); } to { transform: translateX(0); } }
@keyframes target-float { from { translate: 0 -4px; } to { translate: 0 5px; } }
@keyframes target-destroy { to { opacity: 0; transform: scale(1.6) rotate(8deg); filter: blur(8px); } }
@keyframes target-shake { 25% { translate: -8px; } 75% { translate: 8px; } }
@keyframes impact-pop { from { opacity: 0; transform: translate(-50%, -50%) scale(.4); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } }

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  color: white;
  background: #263b42;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .2s;
}

.toast.is-visible { opacity: 1; transform: none; }
.loading { padding: 40px; text-align: center; color: var(--muted); font-weight: 800; }
.mobile-only { display: none; }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding-top: 24px; }
  .mobile-only { display: initial; }
  .guide ol { grid-template-columns: 1fr; }
  .section-heading { align-items: start; flex-direction: column; gap: 4px; }
  .quiz-dialog { width: calc(100% - 12px); max-height: calc(100dvh - 12px); }
  .svg-map-shell { padding: 7px; }
  .svg-map-viewport { height: 66dvh; min-height: 470px; }
  .svg-map-shell--compact .svg-map-viewport { height: 55dvh; min-height: 390px; }
  .map-toolbar { justify-content: center; }
  .map-toolbar button { flex: 1; }
  .quiz-launcher { grid-template-columns: 1fr; }
  .quiz-launcher select, .quiz-launcher .button { width: 100%; }
  .game-mode-card { grid-template-columns: 1fr; text-align: center; }
  .shooting-ready, .shooting-result { min-height: 520px; padding-inline: 16px; }
  .shooting-game { min-height: 620px; padding-inline: 8px; }
  .shooting-silhouette { width: min(290px, 78vw); height: 270px; }
  .shooting-lanes { gap: 8px; }
  .shooting-target { min-height: 82px; padding: 10px 5px; }
}

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