:root {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #183b42;
  background: #e8f7ed;
  font-synthesis: none;
  --ink: #183b42;
  --teal: #176f78;
  --deep: #0e505e;
  --coral: #f06f58;
  --yellow: #ffd85c;
  --paper: #fffdf4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 12%, #ffe873 0 3.5%, transparent 3.8%),
    radial-gradient(circle at 94% 14%, #b7e4f0 0 7%, transparent 7.3%),
    linear-gradient(155deg, #efffe8 0%, #d9f4ee 50%, #d7eef7 100%);
}

button { font: inherit; }
button:focus-visible, [role="gridcell"]:focus-visible { outline: 4px solid #ffae35; outline-offset: 2px; }

.topbar {
  min-height: 58px;
  padding: 7px max(16px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #8fcdb9;
  background: #ffffffed;
  position: relative;
  z-index: 20;
}

.brand { color: #164854; text-decoration: none; font-weight: 1000; letter-spacing: .07em; }
.brand b { color: var(--coral); }
.top-actions { display: flex; align-items: center; gap: 7px; }

.round-button, .sound-button {
  min-height: 40px;
  border: 2px solid #6eb4a5;
  border-radius: 999px;
  background: #fff;
  color: #135f68;
  font-weight: 900;
  cursor: pointer;
}
.round-button { width: 40px; padding: 0; font-size: 1.15rem; }
.sound-button { padding: 7px 12px; }

main {
  width: min(1180px, 100%);
  margin: auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(270px, .92fr) minmax(430px, 580px);
  gap: 34px;
  align-items: center;
}

.eyebrow, .panel-kicker {
  display: inline-block;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-size: .86rem;
  font-weight: 1000;
  letter-spacing: .08em;
}

.intro h1 {
  margin: 12px 0 16px;
  color: #174b55;
  font-size: clamp(2.65rem, 5.4vw, 4.8rem);
  line-height: .96;
  letter-spacing: -.05em;
  text-shadow: 0 5px 0 #fff;
}
.intro h1 span { color: #e8624f; }
.lead { max-width: 580px; font-size: 1.08rem; line-height: 1.8; font-weight: 800; }
.lead span { color: #d95747; }

.learning-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.learning-cards article {
  min-height: 116px;
  padding: 12px 8px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  border: 2px solid #b7ded2;
  border-radius: 18px;
  background: #fffef8;
  text-align: center;
  box-shadow: 0 8px 22px #225c4a15;
}
.learning-cards span { font-size: 1.65rem; }
.learning-cards b { color: #155b64; font-size: .87rem; }
.learning-cards small { color: #557278; font-size: .68rem; font-weight: 700; line-height: 1.45; }

.records {
  width: max-content;
  max-width: 100%;
  margin-top: 16px;
  padding: 11px 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  border-radius: 17px;
  background: #123f49;
  color: #fff;
  font-weight: 900;
}
.records strong { color: var(--yellow); font-size: 1.15rem; }

.game-shell {
  position: relative;
  width: 100%;
  padding: 10px;
  border: 5px solid #fff;
  border-radius: 29px;
  background: #fff;
  box-shadow: 0 26px 65px #164b4733;
  overflow: hidden;
}

.hud { margin-bottom: 8px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.hud div { padding: 6px 2px; border-radius: 12px; background: #e7f6ef; text-align: center; }
.hud small { display: block; color: #5d7f7a; font-size: .61rem; font-weight: 900; }
.hud b { color: #174f58; font-size: .96rem; }

.game-window {
  min-height: 670px;
  padding: 14px;
  border-radius: 22px;
  background:
    linear-gradient(#ffffff12 1px, transparent 1px),
    linear-gradient(90deg, #ffffff12 1px, transparent 1px),
    linear-gradient(155deg, #1c7580, #155963 56%, #154853);
  background-size: 24px 24px, 24px 24px, auto;
  color: #fff;
}

.district-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.district-row small { color: #bdebdc; font-size: .7rem; font-weight: 900; }
.district-row h2 { margin: 1px 0 7px; font-size: 1.25rem; }
.request-progress { padding: 7px 11px; border-radius: 999px; background: #fff; color: #13555e; font-size: .78rem; font-weight: 1000; }

.request-card {
  min-height: 77px;
  margin-bottom: 10px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: 10px;
  border: 3px solid #f7cf60;
  border-radius: 18px;
  background: #fffbed;
  color: #28494d;
  box-shadow: 0 8px 0 #093b4245;
}
.request-person { width: 49px; height: 49px; display: grid; place-items: center; border-radius: 50%; background: #d9f5e7; font-size: 1.8rem; }
.request-card small { color: #b4533d; font-size: .67rem; font-weight: 1000; }
.request-card p { margin: 2px 0 0; font-size: .82rem; font-weight: 900; line-height: 1.45; }

.map-wrap { padding: 8px; border: 2px solid #7bbba9; border-radius: 18px; background: #0b3d46; box-shadow: inset 0 0 30px #061f2588; }
.town-map {
  --size: 7;
  width: min(100%, 460px);
  aspect-ratio: 1;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 3px;
  touch-action: none;
}

.map-tile {
  position: relative;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: #a8d9bd;
  color: #163d43;
  font-size: clamp(.96rem, 4.4vw, 1.7rem);
  overflow: hidden;
  cursor: default;
  transition: transform .15s, filter .18s, background .18s;
}
.map-tile::after { content: ""; position: absolute; inset: 0; border: 1px solid #ffffff42; border-radius: inherit; pointer-events: none; }
.map-tile.road { background: #d4cfb4; }
.map-tile.road::before { content: ""; position: absolute; inset: 44% 0; border-top: 1px dashed #fff9; }
.map-tile.park { background: #70bd83; }
.map-tile.blocked { background: #4c806a; }
.map-tile.blocked::before { content: "🌳"; opacity: .7; filter: saturate(.7); }
.map-tile.facility { background: #ffebb1; box-shadow: inset 0 0 0 2px #dbad4a; }
.map-tile.citizen { background: #a9e5e5; }
.map-tile.fog {
  background: #6d8f91;
  filter: saturate(.4);
}
.map-tile.fog::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 35% 35%, #dce9e2a8, #567579 70%); }
.map-tile.fog .tile-content { opacity: 0; }
.map-tile.player { z-index: 3; background: #fff3ad; box-shadow: 0 0 0 3px #ffca43, 0 0 15px #fff08a; transform: scale(1.04); }
.map-tile.reachable { cursor: pointer; animation: reachable-pulse 1.25s infinite; }
.map-tile.reachable:hover { transform: scale(1.08); filter: brightness(1.1); }
.tile-content { position: relative; z-index: 2; line-height: 1; }
.facility-mark { width: 70%; aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; background: #164f59; color: #fff; font-weight: 1000; }
.map-legend { padding: 7px 3px 0; display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; color: #c7ede3; font-size: .63rem; font-weight: 800; }

.game-message { min-height: 2.8em; margin: 9px 5px 6px; color: #e8fff8; font-size: .76rem; font-weight: 800; line-height: 1.45; }
.game-message.good { color: #fff29c; }
.game-message.warn { color: #ffc1af; }

.controls { display: grid; grid-template-columns: 170px 1fr; gap: 12px; align-items: center; }
.dpad { width: 152px; margin: auto; display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(3, 41px); gap: 3px; }
.dpad button {
  border: 0;
  border-radius: 12px;
  background: #fff;
  color: #165c65;
  font-weight: 1000;
  cursor: pointer;
  box-shadow: 0 4px 0 #9fc9bd;
}
.dpad button:active { transform: translateY(3px); box-shadow: 0 1px 0 #9fc9bd; }
.dpad button:disabled { opacity: .35; cursor: not-allowed; }
.dpad button small { display: block; margin-top: -3px; font-size: .5rem; }
.dpad [data-move="up"] { grid-column: 2; grid-row: 1; }
.dpad [data-move="left"] { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; display: grid; place-items: center; border-radius: 50%; background: #124651; font-size: 1.2rem; }
.dpad [data-move="right"] { grid-column: 3; grid-row: 2; }
.dpad [data-move="down"] { grid-column: 2; grid-row: 3; }
.found-list { min-width: 0; }
.found-list > small { color: #bce7db; font-size: .65rem; font-weight: 900; }
.found-icons { min-height: 55px; margin-top: 5px; padding: 7px; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; border-radius: 13px; background: #0b3d46a8; }
.found-chip { width: 36px; height: 36px; display: grid; place-items: center; border: 2px solid #ffffff45; border-radius: 10px; background: #fff6d0; font-size: 1.25rem; }
.found-chip.unknown { background: #315e64; color: #9bbbbb; font-size: .9rem; }

.overlay-panel {
  position: absolute;
  inset: 78px 10px 10px;
  z-index: 10;
  padding: 25px;
  display: grid;
  place-items: center;
  align-content: center;
  overflow-y: auto;
  border-radius: 22px;
  background:
    radial-gradient(circle at 8% 8%, #ffe474 0 4%, transparent 4.3%),
    radial-gradient(circle at 92% 12%, #bcead8 0 9%, transparent 9.3%),
    linear-gradient(155deg, #fffef4, #e9f8ec);
  color: var(--ink);
  text-align: center;
}
.overlay-panel[hidden] { display: none; }
.start-panel .mascot { font-size: 4.2rem; filter: drop-shadow(0 8px 2px #4f82752c); }
.overlay-panel h2 { margin: 10px 0 8px; color: #154f59; font-size: clamp(1.7rem, 5vw, 2.4rem); }
.overlay-panel > p { max-width: 470px; line-height: 1.7; font-weight: 750; }
.start-panel ul { max-width: 450px; padding: 14px 18px 14px 38px; border-radius: 16px; background: #fff; text-align: left; font-size: .85rem; font-weight: 800; line-height: 1.7; }

.primary-button {
  min-width: min(330px, 92%);
  min-height: 54px;
  margin-top: 8px;
  padding: 12px 22px;
  border: 0;
  border-radius: 17px;
  background: linear-gradient(#f68264, #dc5849);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 1000;
  cursor: pointer;
  box-shadow: 0 7px 0 #a63e35, 0 13px 20px #7b44312d;
}
.primary-button:hover { filter: brightness(1.07); }
.primary-button:active { transform: translateY(5px); box-shadow: 0 2px 0 #a63e35; }

.discovery-icon { width: 92px; height: 92px; display: grid; place-items: center; border: 5px solid #fff; border-radius: 28px; background: #ffe590; font-size: 3.5rem; box-shadow: 0 9px 28px #284a3530; }
.role-text { margin: 3px 0; font-size: .98rem; }
.fact-box { margin: 8px 0; padding: 12px 15px; border-left: 5px solid #27a195; border-radius: 11px; background: #fff; color: #315359; font-size: .82rem; text-align: left; }
.score-breakdown { margin: 8px 0; color: #c94f3f; font-weight: 1000; }

.final-score { margin: 10px 0; display: flex; align-items: baseline; justify-content: center; gap: 4px; color: #d45542; }
.final-score small { color: #46666a; font-weight: 900; }
.final-score strong { font-size: clamp(3rem, 9vw, 4.8rem); line-height: 1; }
.final-score span { font-weight: 1000; }
.result-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; width: min(450px, 100%); }
.result-stats div { padding: 9px 5px; border-radius: 12px; background: #fff; font-size: .72rem; font-weight: 800; }
.result-stats b { display: block; color: #176f78; font-size: 1.1rem; }
.result-message { margin: 9px 0 2px; }
.new-stamps { min-height: 42px; display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.new-stamps span { padding: 7px 10px; border: 2px solid #efc252; border-radius: 12px; background: #fff6c8; font-size: .78rem; font-weight: 900; }
.ranking-area { width: min(480px, 100%); margin-top: 18px; padding-top: 12px; border-top: 2px dashed #92bdb0; text-align: left; }
.ranking-area h3 { text-align: center; color: #155761; }
.ranking-area .itc-ranking__tabs { justify-content: center; }
.ranking-area table { font-size: .78rem; }

dialog { width: min(560px, calc(100% - 30px)); padding: 25px; border: 0; border-radius: 22px; color: var(--ink); box-shadow: 0 25px 80px #103f4755; }
dialog::backdrop { background: #0b2932aa; backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; color: #155d66; }
dialog ol { padding-left: 1.5em; line-height: 1.8; }
dialog p { line-height: 1.7; }
.dialog-close { float: right; width: 38px; height: 38px; border: 0; border-radius: 50%; background: #e6f3ee; color: #155d66; font-size: 1.4rem; cursor: pointer; }
.key-help { padding: 10px; border-radius: 10px; background: #edf8f2; font-size: .85rem; }

@keyframes reachable-pulse { 50% { box-shadow: inset 0 0 0 3px #fff59a; } }
@keyframes found-pop { 0% { transform: scale(.7) rotate(-8deg); } 70% { transform: scale(1.13) rotate(3deg); } }
.found-pop { animation: found-pop .45s; }

@media (max-width: 880px) {
  main { max-width: 650px; padding: 18px; grid-template-columns: 1fr; gap: 22px; }
  .intro { text-align: center; }
  .intro h1 { font-size: clamp(2.5rem, 11vw, 4.5rem); }
  .lead { margin-inline: auto; }
  .records { margin-inline: auto; }
}

@media (max-width: 560px) {
  .topbar { min-height: 52px; }
  .sound-button { font-size: .73rem; }
  main { padding: 10px; }
  .intro h1 { margin-top: 8px; }
  .learning-cards article { min-height: 103px; }
  .game-shell { padding: 7px; border-width: 3px; border-radius: 22px; }
  .game-window { min-height: 620px; padding: 10px; border-radius: 17px; }
  .hud { gap: 3px; }
  .hud small { font-size: .53rem; }
  .hud b { font-size: .82rem; }
  .request-card { min-height: 72px; grid-template-columns: 42px 1fr; padding: 7px 9px; }
  .request-person { width: 40px; height: 40px; font-size: 1.45rem; }
  .request-card p { font-size: .74rem; }
  .map-wrap { padding: 5px; }
  .town-map { gap: 2px; }
  .map-tile { border-radius: 5px; font-size: clamp(.85rem, 5.8vw, 1.55rem); }
  .controls { grid-template-columns: 155px 1fr; gap: 6px; }
  .dpad { width: 140px; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 38px); }
  .found-chip { width: 31px; height: 31px; font-size: 1.05rem; }
  .overlay-panel { inset: 68px 7px 7px; padding: 18px 14px; }
  .start-panel ul { font-size: .76rem; }
  .result-panel { justify-content: start; align-content: start; padding-top: 30px; }
}

@media (max-width: 390px) {
  .learning-cards small { display: none; }
  .learning-cards article { min-height: 80px; }
  .controls { grid-template-columns: 144px 1fr; }
  .dpad { width: 137px; }
  .found-icons { padding: 5px; gap: 3px; }
  .found-chip { width: 28px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
