:root {
  --navy: #183153;
  --ink: #203149;
  --cream: #fff9e9;
  --paper: #ffffff;
  --yellow: #ffd45a;
  --orange: #ff8b5c;
  --coral: #ff6b6b;
  --mint: #55d6be;
  --sky: #82d7f7;
  --blue: #3979d8;
  --line: rgba(24,49,83,.14);
  --shadow: 0 18px 45px rgba(24,49,83,.16);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: #dff6ff; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 12% 11%, rgba(255,255,255,.9) 0 3%, transparent 3.2%),
    radial-gradient(circle at 84% 22%, rgba(255,255,255,.76) 0 4%, transparent 4.2%),
    linear-gradient(165deg, #b9edff 0%, #eafaff 44%, #fff3c8 100%);
  touch-action: manipulation;
  overscroll-behavior: none;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid rgba(57,121,216,.35); outline-offset: 3px; }

.sky-decor { position: fixed; z-index: 0; color: rgba(255,255,255,.7); font-size: 8rem; pointer-events: none; }
.sky-decor--one { left: -2rem; top: 12vh; transform: rotate(-18deg); }
.sky-decor--two { right: -1rem; bottom: 8vh; transform: rotate(12deg); }

.app-shell { position: relative; z-index: 1; width: min(100%, 1040px); min-height: 100vh; margin: 0 auto; padding: 16px clamp(12px, 3vw, 28px) 42px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--navy); font-weight: 900; font-size: clamp(.78rem, 2vw, .95rem); letter-spacing: .08em; text-decoration: none; }
.brand__flag { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 13px; background: white; box-shadow: 0 7px 18px rgba(24,49,83,.12); font-size: 1.2rem; }
.icon-button { border: 2px solid rgba(24,49,83,.18); border-radius: 999px; color: var(--navy); background: rgba(255,255,255,.75); padding: 9px 13px; font-weight: 800; cursor: pointer; }
.screen { animation: screen-in .35s ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(9px); } }

.hero-card {
  min-height: 300px;
  display: grid;
  grid-template-columns: 1.35fr .8fr;
  align-items: center;
  gap: 24px;
  overflow: hidden;
  padding: clamp(26px, 6vw, 58px);
  border: 3px solid rgba(255,255,255,.8);
  border-radius: 38px;
  color: white;
  background:
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.19) 0 7%, transparent 7.3%),
    linear-gradient(135deg, #1a4670, #276ca3 55%, #3f9ac1);
  box-shadow: var(--shadow);
}
.eyebrow { margin: 0 0 8px; color: var(--coral); font-weight: 1000; letter-spacing: .13em; font-size: .8rem; text-transform: uppercase; }
.hero-card .eyebrow { color: var(--yellow); }
.hero-card h1 { margin: 0; font-size: clamp(2.3rem, 6.5vw, 4.5rem); line-height: .98; letter-spacing: -.06em; text-shadow: 0 4px 0 rgba(10,37,66,.2); }
.hero-card h1 span { color: var(--yellow); font-size: .66em; letter-spacing: -.04em; }
.hero-card__lead { margin: 20px 0 0; font-weight: 700; line-height: 1.8; }
.passport-art { position: relative; width: min(100%, 260px); aspect-ratio: 4 / 3; justify-self: center; transform: rotate(6deg); }
.passport-art__cover { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 8px solid #f6c84a; border-radius: 22px; color: #ffe982; background: #d65353; box-shadow: 0 18px 0 rgba(8,33,59,.18); font-weight: 900; letter-spacing: .18em; }
.passport-art__cover strong { font-size: clamp(1.5rem, 4vw, 2.2rem); }
.passport-art__cover span { font-size: 3.2rem; }
.passport-art__stamp { position: absolute; right: -15px; top: -15px; display: grid; place-items: center; width: 86px; height: 86px; border: 6px double white; border-radius: 50%; color: white; background: var(--mint); font: 1000 1.35rem/1 sans-serif; transform: rotate(-12deg); box-shadow: 0 8px 16px rgba(0,0,0,.14); }

.start-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 14px; margin: 15px 0; }
.panel { border: 2px solid rgba(255,255,255,.9); border-radius: 24px; background: rgba(255,255,255,.9); box-shadow: 0 12px 30px rgba(24,49,83,.1); }
.name-panel, .record-panel { padding: 20px; }
.panel h2 { margin: 0 0 6px; font-size: 1.05rem; }
.panel h2 > span { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 6px; border-radius: 50%; color: white; background: var(--blue); }
.panel p { margin: 5px 0 15px; line-height: 1.6; }
.alias-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.alias-button { border: 2px solid var(--line); border-radius: 14px; padding: 12px 5px; color: var(--navy); background: white; font-weight: 900; cursor: pointer; }
.alias-button.is-selected { border-color: var(--blue); color: white; background: var(--blue); box-shadow: 0 5px 0 #245598; transform: translateY(-2px); }
.record-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.record-row div { padding: 15px 8px; text-align: center; border-radius: 16px; background: var(--cream); }
.record-row strong { display: block; color: var(--blue); font-size: 1.55rem; }
.record-row small { font-weight: 800; }

.primary-button, .secondary-button { border: 0; border-radius: 17px; padding: 15px 24px; font-weight: 1000; cursor: pointer; }
.primary-button { color: var(--navy); background: var(--yellow); box-shadow: 0 6px 0 #dcae2e, 0 12px 22px rgba(24,49,83,.15); }
.primary-button:active { transform: translateY(4px); box-shadow: 0 2px 0 #dcae2e; }
.primary-button--large { width: 100%; min-height: 58px; font-size: 1.12rem; }
.secondary-button { color: var(--navy); background: white; border: 2px solid var(--line); }
.howto-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 15px; }
.howto-strip div { display: grid; grid-template-columns: auto 1fr; column-gap: 9px; align-items: center; padding: 12px; border-radius: 18px; background: rgba(255,255,255,.65); }
.howto-strip span { grid-row: 1 / 3; font-size: 1.7rem; }
.howto-strip strong, .howto-strip small { display: block; }
.howto-strip small { opacity: .75; }

.hud { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-bottom: 9px; }
.hud div { padding: 9px 5px; text-align: center; border-radius: 15px; background: rgba(255,255,255,.9); box-shadow: 0 6px 18px rgba(24,49,83,.08); }
.hud small { display: block; color: #6e7d91; font-size: .65rem; font-weight: 900; letter-spacing: .08em; }
.hud strong { color: var(--navy); font-size: clamp(.9rem, 3vw, 1.15rem); }
#heartHud { color: var(--coral); letter-spacing: .08em; }
.route-bar, .countdown { overflow: hidden; height: 9px; border-radius: 999px; background: rgba(24,49,83,.12); }
.route-bar { margin-bottom: 9px; }
.route-bar span, .countdown span { display: block; height: 100%; border-radius: inherit; transition: width .25s linear; }
.route-bar span { width: 10%; background: linear-gradient(90deg, var(--mint), var(--blue)); }

.encounter-card { padding: 15px; border-radius: 25px 25px 12px 12px; background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,249,233,.95)); box-shadow: 0 10px 30px rgba(24,49,83,.12); }
.scene-label { display: inline-flex; gap: 7px; align-items: center; padding: 6px 11px; border-radius: 999px; color: var(--blue); background: #eaf4ff; font-size: .8rem; font-weight: 900; }
.visitor-zone { display: grid; grid-template-columns: 108px 1fr; gap: 16px; align-items: center; max-width: 660px; margin: 9px auto 4px; }
.visitor-avatar { display: grid; place-items: center; width: 108px; height: 108px; border: 5px solid white; border-radius: 50%; background: linear-gradient(145deg, #fce59b, #ffb894); box-shadow: 0 8px 18px rgba(24,49,83,.14); font-size: 4rem; }
.speech-card { position: relative; padding: 14px 18px; border: 3px solid var(--navy); border-radius: 20px; color: var(--navy); background: white; }
.speech-card::before { content: ""; position: absolute; left: -16px; top: 40%; width: 26px; height: 26px; border-left: 3px solid var(--navy); border-bottom: 3px solid var(--navy); background: white; transform: rotate(45deg); }
.speech-card small, .speech-card strong { position: relative; z-index: 1; display: block; }
.speech-card small { font-weight: 800; opacity: .72; }
.speech-card strong { margin: 5px 0 8px; font-size: clamp(1.5rem, 5vw, 2.45rem); }
.listen-button { position: relative; z-index: 1; border: 0; border-radius: 999px; padding: 7px 11px; color: white; background: var(--blue); font-weight: 800; cursor: pointer; }
.mission-copy { margin: 8px 0 0; text-align: center; font-size: .9rem; }

.catch-field { position: relative; overflow: hidden; min-height: 235px; padding: 11px 10px 0; border: 3px solid rgba(255,255,255,.85); border-radius: 12px 12px 25px 25px; background: linear-gradient(#8bdcf4 0 22%, #fff0b9 22% 100%); box-shadow: 0 12px 32px rgba(24,49,83,.13); }
.countdown { height: 8px; background: rgba(255,255,255,.7); }
.countdown span { width: 100%; background: linear-gradient(90deg, var(--coral), var(--yellow), var(--mint)); }
.lane-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 14px 0 56px; }
.lane-card { position: relative; min-height: 105px; display: flex; align-items: center; justify-content: center; padding: 12px 5px; border: 3px solid transparent; border-radius: 18px; color: var(--navy); background: white; box-shadow: 0 7px 0 rgba(24,49,83,.16); font-weight: 1000; font-size: clamp(.78rem, 2.8vw, 1.05rem); cursor: pointer; transform: translateY(var(--drop, 0px)); transition: border-color .12s, background .12s, transform .1s linear; }
.lane-card::before { content: "✉"; position: absolute; top: 8px; right: 9px; color: var(--orange); font-size: .9rem; }
.lane-card.is-selected { border-color: var(--blue); background: #eef7ff; }
.runner-row { position: absolute; left: 10px; right: 10px; bottom: 6px; height: 45px; border-top: 3px dashed rgba(24,49,83,.23); }
.runner { position: absolute; left: calc((var(--lane, 1) * 33.333%) + 16.666%); top: -5px; transform: translateX(-50%); font-size: 2.5rem; transition: left .15s ease; filter: drop-shadow(0 5px 3px rgba(24,49,83,.22)); }
.controls { display: grid; grid-template-columns: 72px 1fr 72px; gap: 9px; margin-top: 11px; }
.move-button, .catch-button { min-height: 54px; border: 0; border-radius: 17px; font-weight: 1000; cursor: pointer; }
.move-button { color: white; background: var(--navy); font-size: 1.5rem; box-shadow: 0 5px 0 #0d2039; }
.catch-button { color: var(--navy); background: var(--yellow); font-size: 1.15rem; box-shadow: 0 5px 0 #d9a928; }
.move-button:active, .catch-button:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(13,32,57,.8); }
.catch-button:disabled { cursor: wait; opacity: .58; transform: none; box-shadow: 0 5px 0 #d9a928; }
.keyboard-note { margin: 9px 0 0; text-align: center; opacity: .68; font-size: .75rem; font-weight: 700; }

.center-screen { min-height: calc(100vh - 96px); display: grid; place-items: center; }
.feedback-card, .quiz-card { width: min(100%, 620px); padding: clamp(25px, 6vw, 48px); text-align: center; border: 3px solid white; border-radius: 32px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); }
.feedback-burst, .quiz-flag { font-size: 3.3rem; animation: bounce .65s ease both; }
@keyframes bounce { 50% { transform: translateY(-12px) scale(1.08); } }
.feedback-card h2, .quiz-card h2 { margin: 5px 0 12px; color: var(--navy); font-size: clamp(1.55rem, 5vw, 2.2rem); }
.earned-sticker { width: 118px; height: 118px; display: grid; place-items: center; margin: 12px auto; border: 7px double var(--blue); border-radius: 50%; background: var(--cream); box-shadow: 0 8px 0 rgba(24,49,83,.12); font-size: 4rem; transform: rotate(-4deg); }
.feedback-text { min-height: 3em; line-height: 1.7; }
.score-gain { margin: 12px 0 22px; color: var(--coral); font-size: 1.3rem; font-weight: 1000; }
.quiz-choices { display: grid; gap: 9px; margin: 20px 0; }
.quiz-choice { min-height: 52px; border: 2px solid var(--line); border-radius: 15px; color: var(--navy); background: white; font-weight: 900; cursor: pointer; }
.quiz-choice:hover, .quiz-choice:focus-visible { border-color: var(--blue); background: #edf6ff; }
.quiz-choice.is-correct { border-color: #269c7d; color: #176c58; background: #e3fff5; }
.quiz-choice.is-wrong { border-color: var(--coral); color: #a43737; background: #fff0f0; }
.quiz-choice:disabled { cursor: default; opacity: 1; }
.quiz-explanation { padding: 13px; border-radius: 14px; text-align: left; line-height: 1.65; background: var(--cream); }

.result-hero { padding: clamp(28px, 7vw, 60px) 20px; text-align: center; border: 3px solid white; border-radius: 35px; color: white; background: linear-gradient(135deg, #183153, #2877a9); box-shadow: var(--shadow); }
.result-hero .eyebrow { color: var(--yellow); }
.result-hero h2 { margin: 0 0 12px; font-size: clamp(1.8rem, 5vw, 3rem); }
.result-score small { display: block; font-weight: 900; letter-spacing: .12em; opacity: .78; }
.result-score strong { color: var(--yellow); font-size: clamp(3.2rem, 11vw, 6rem); line-height: 1; }
.result-score span { font-weight: 900; }
.rank-badge { display: inline-block; margin: 12px auto; padding: 7px 17px; border-radius: 999px; color: var(--navy); background: var(--yellow); font-weight: 1000; }
.result-stats { width: min(100%, 550px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px auto 0; }
.result-stats div { padding: 13px 5px; border-radius: 16px; background: rgba(255,255,255,.12); }
.result-stats strong, .result-stats small { display: block; }
.result-stats strong { font-size: 1.35rem; }
.result-stats small { opacity: .78; }
.collection-panel { margin-top: 15px; padding: clamp(18px, 4vw, 28px); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-heading h3 { margin: 0; color: var(--navy); font-size: 1.35rem; }
.section-heading > strong { color: var(--blue); font-size: 1.25rem; }
.collection-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 9px; margin-top: 18px; }
.collection-item { position: relative; min-height: 112px; display: flex; flex-direction: column; justify-content: center; align-items: center; border: 2px dashed rgba(24,49,83,.2); border-radius: 18px; background: #edf1f5; }
.collection-item.is-owned { border-style: solid; border-color: #f2ca51; background: var(--cream); box-shadow: 0 5px 0 rgba(218,170,41,.25); }
.collection-item.is-new::after { content: "NEW"; position: absolute; right: -5px; top: -6px; padding: 3px 6px; border-radius: 999px; color: white; background: var(--coral); font-size: .58rem; font-weight: 1000; }
.collection-item__avatar { font-size: 2.2rem; filter: grayscale(1); opacity: .22; }
.collection-item.is-owned .collection-item__avatar { filter: none; opacity: 1; }
.collection-item strong { margin-top: 4px; font-size: .76rem; }
.collection-item small { font-size: .62rem; opacity: .7; }
.collection-note { margin-bottom: 0 !important; font-size: .82rem; }
.result-actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin: 15px 0; }
.ranking-panel { padding: 18px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 700px) {
  .app-shell { padding-top: max(10px, env(safe-area-inset-top)); }
  .hero-card { min-height: auto; grid-template-columns: 1fr; padding: 28px 23px; border-radius: 27px; }
  .hero-card__lead { font-size: .88rem; }
  .passport-art { width: 165px; position: absolute; right: -35px; bottom: -22px; opacity: .2; }
  .hero-card__copy { position: relative; z-index: 1; }
  .start-grid { grid-template-columns: 1fr; }
  .howto-strip { grid-template-columns: 1fr; }
  .howto-strip div { grid-template-columns: auto auto 1fr; }
  .howto-strip span { grid-row: auto; }
  .visitor-zone { grid-template-columns: 78px 1fr; gap: 11px; }
  .visitor-avatar { width: 78px; height: 78px; font-size: 3rem; }
  .speech-card { padding: 11px 13px; }
  .speech-card strong { font-size: 1.42rem; }
  .catch-field { min-height: 220px; }
  .lane-card { min-height: 100px; }
  .collection-grid { grid-template-columns: repeat(3, 1fr); }
  .result-actions { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .brand span:last-child { display: none; }
  .alias-choices { grid-template-columns: repeat(2, 1fr); }
  .hud { gap: 4px; }
  .hud div { padding-inline: 2px; }
  .mission-copy { font-size: .78rem; }
  .controls { grid-template-columns: 58px 1fr 58px; }
}

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