* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --ink: #2d261f;
  --muted: #766b5d;
  --line: rgba(63, 46, 30, 0.16);
  --paper: rgba(255, 250, 238, 0.9);
  --deep: #17251f;
  --accent: #8f1f1f;
  --gold: #b9822d;
  --foot-control-size: clamp(64px, 11svh, 82px);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  background:
    radial-gradient(circle at 14% 10%, rgba(185, 130, 45, 0.22), transparent 22rem),
    radial-gradient(circle at 86% 12%, rgba(85, 127, 130, 0.18), transparent 26rem),
    linear-gradient(135deg, #f5ead2 0%, #fffaf0 48%, #e8dcc6 100%);
}

button, a { -webkit-tap-highlight-color: transparent; }

.stepper-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar, .hero, .map-panel, .stats, .controls, .challenge, .next-links { width: 100%; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
}

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

.top-links a,
.ghost-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--deep);
  background: rgba(255, 255, 255, 0.58);
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.top-links a { padding: 8px 10px; }

.ghost-button {
  padding: 8px 12px;
  cursor: pointer;
}

.hero { padding-top: 0; }

.kicker {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--deep);
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.05;
  letter-spacing: 0;
}

.lead {
  max-width: 21rem;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.map-panel, .stats > div, .record-card, .challenge, .next-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(48, 35, 23, 0.1);
  backdrop-filter: blur(12px);
}

.map-panel { padding: 10px; }

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.eyebrow, .stats span, .next-card span {
  display: block;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.map-header strong {
  display: block;
  margin-top: 3px;
  font-size: 18px;
}

.country-name {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.map-wrap {
  position: relative;
  min-height: clamp(460px, calc(100svh - 230px), 620px);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255,255,255,0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.28) 1px, transparent 1px),
    radial-gradient(circle at 50% 16%, rgba(85, 127, 130, 0.15), transparent 26rem),
    #eee2c7;
  background-size: 26px 26px, 26px 26px, auto, auto;
}

.map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(68, 46, 24, 0.12));
}

#mapSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.route-shadow, .route-path, .route-done {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-shadow {
  stroke: rgba(49, 37, 26, 0.18);
  stroke-width: 8;
  filter: url(#inkBleed);
}

.route-path {
  stroke: rgba(45, 38, 31, 0.45);
  stroke-width: 3;
  stroke-dasharray: 2 7;
}

.route-done {
  stroke: var(--accent);
  stroke-width: 5;
}

.traveler-dot {
  fill: var(--accent);
  stroke: #fff8e8;
  stroke-width: 3;
}

.surveyor {
  position: absolute;
  z-index: 2;
  width: clamp(28px, 5.5vw, 38px);
  height: auto;
  transform: translate(-50%, -86%) rotate(var(--heading, 0deg));
  filter: drop-shadow(0 8px 10px rgba(44, 33, 23, 0.18));
  pointer-events: none;
  transform-origin: 50% 86%;
}

.surveyor.is-walking { animation: surveyor-step 120ms steps(2, end); }

@keyframes surveyor-step {
  0% { transform: translate(-50%, -86%) rotate(calc(var(--heading, 0deg) - 3deg)); }
  50% { transform: translate(-50%, -92%) rotate(calc(var(--heading, 0deg) + 3deg)); }
  100% { transform: translate(-50%, -86%) rotate(calc(var(--heading, 0deg) - 2deg)); }
}

.message-bubble {
  position: absolute;
  left: 28px;
  top: 142px;
  z-index: 3;
  width: min(250px, 46%);
  height: 72px;
  margin: 0;
  padding: 10px 12px;
  border: 2px solid rgba(45, 38, 31, 0.28);
  border-radius: 18px;
  color: var(--deep);
  background: rgb(255, 250, 238);
  box-shadow: 0 8px 18px rgba(48, 35, 23, 0.08);
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 900;
  line-height: 1.45;
  opacity: 0.82;
}

.message-bubble::before {
  content: "";
  position: absolute;
  right: -8px;
  top: 50%;
  width: 16px;
  height: 16px;
  border-top: 2px solid rgba(45, 38, 31, 0.28);
  border-right: 2px solid rgba(45, 38, 31, 0.28);
  background: inherit;
  transform: translateY(-50%) rotate(45deg);
}

.message-bubble::after {
  content: "";
  position: absolute;
  right: 0;
  top: calc(50% - 14px);
  width: 14px;
  height: 28px;
  background: inherit;
}

.seal {
  position: absolute;
  right: 78px;
  bottom: calc(var(--foot-control-size) + 30px);
  z-index: 3;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(143, 31, 31, 0.78);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  text-align: center;
  transform: rotate(-7deg);
  background: rgba(255, 250, 238, 0.5);
}

html[lang="en"] .seal {
  width: 62px;
  height: 44px;
  font-size: 10px;
}

.stats {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 10px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stats > div {
  min-width: 0;
  padding: 0 3px;
  text-align: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
  text-shadow:
    0 1px 0 rgba(255, 250, 238, 0.95),
    0 0 10px rgba(255, 250, 238, 0.82);
}

.stats strong {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Hiragino Sans", sans-serif;
  font-size: clamp(26px, 7vw, 42px);
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.stats strong > span {
  font-size: 1em;
  letter-spacing: -0.02em;
}

.stats strong small {
  color: rgba(45, 38, 31, 0.76);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: .24em;
  font-weight: 900;
}

.stats strong.is-ticking {
  animation: tick-pop 120ms ease;
}

@keyframes tick-pop {
  50% { transform: translateY(-2px) scale(1.04); color: var(--accent); }
}

.record-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  text-align: center;
}

.record-card span {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.record-card strong {
  color: var(--deep);
  font-size: clamp(18px, 5vw, 26px);
  line-height: 1.35;
}

.record-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.controls {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: auto;
  pointer-events: none;
}

.foot-button {
  width: var(--foot-control-size);
  height: var(--foot-control-size);
  min-height: 0;
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  color: #fffaf0;
  background: rgba(255, 250, 238, 0.66);
  border: 1px solid rgba(63, 46, 30, 0.18);
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.16), 0 10px 18px rgba(29, 51, 45, 0.18);
  backdrop-filter: blur(8px);
  cursor: pointer;
  pointer-events: auto;
  transition: transform 90ms ease, box-shadow 90ms ease;
}

.foot-button:nth-child(2) {
  background: rgba(255, 244, 221, 0.68);
}

.foot-button:active,
.foot-button.is-hit {
  transform: translateY(5px) scale(0.99);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2), 0 8px 15px rgba(29, 51, 45, 0.15);
}

.foot-button img {
  display: none;
}

.foot-button::before {
  content: "";
  width: 56%;
  height: 72%;
  display: block;
  background: url("foot-left.png") center / contain no-repeat;
  filter: drop-shadow(0 6px 6px rgba(44, 33, 23, 0.18));
}

.foot-button:first-child::before {
  transform: rotate(-6deg);
}

.foot-button:nth-child(2)::before {
  background-image: url("foot-right.png");
  transform: rotate(6deg);
}

.challenge {
  position: absolute;
  left: 50%;
  right: auto;
  bottom: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(160px, calc(100% - (var(--foot-control-size) * 2) - 52px));
  padding: 7px 8px;
  background: rgba(255, 250, 238, 0.68);
  border: 1px solid rgba(63, 46, 30, 0.12);
  border-radius: 999px;
  box-shadow: 0 8px 16px rgba(48, 35, 23, 0.09);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
}

.timer-pill {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  color: var(--accent);
  background: rgba(143, 31, 31, 0.08);
  font: inherit;
  font-family: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Hiragino Sans", sans-serif;
  font-size: 14px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

.timer-pill.is-running {
  color: #fffaf0;
  background: var(--accent);
  animation: tick-pop 1s ease infinite;
}

.timer-pill.is-finished {
  color: #fffaf0;
  background: linear-gradient(135deg, var(--accent), #4d1717);
}

.next-links {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 6px;
}

.next-card {
  display: grid;
  gap: 4px;
  padding: 13px 14px;
  color: var(--ink);
  text-decoration: none;
}

.next-card-primary {
  background: linear-gradient(135deg, rgba(143, 31, 31, 0.1), rgba(185, 130, 45, 0.16));
}

.next-card strong {
  font-size: 16px;
  line-height: 1.35;
}

.next-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 5;
  max-width: min(92vw, 440px);
  padding: 10px 14px;
  border-radius: 8px;
  color: #fffaf0;
  font-weight: 900;
  background: rgba(23, 37, 31, 0.92);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 700px) {
  .stepper-shell { padding: 24px; }
  .next-links { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .stats {
    grid-template-columns: .9fr 1.15fr 1.05fr;
  }
  .stats > div:nth-child(4) {
    display: none;
  }
  .stats strong {
    font-size: clamp(24px, 7.6vw, 36px);
  }
}

@media (max-width: 420px) {
  .hero {
    display: block;
  }
  .lead {
    max-width: none;
    margin-top: 5px;
  }
  .top-links a { padding: 7px 8px; }
  .map-header strong { font-size: 16px; }
  .stats span { font-size: 10px; }
  .stats strong { font-size: clamp(22px, 7vw, 32px); }
  .message-bubble {
    left: 18px;
    top: 128px;
    width: min(220px, 44%);
    height: 68px;
    padding: 8px 10px;
    font-size: 11px;
  }
  .challenge {
    width: min(130px, calc(100% - (var(--foot-control-size) * 2) - 44px));
  }
  .timer-pill {
    padding: 6px 8px;
    font-size: 12px;
  }
}
