/* ============================================================
   東京ライン・タイピング  —  styles (map version)
   ============================================================ */
:root {
  --bg:        #0b0e13;
  --bg-2:      #10151d;
  --panel:     rgba(18, 24, 33, 0.82);
  --panel-solid: #141a23;
  --line:      rgba(255, 255, 255, 0.10);
  --line-soft: rgba(255, 255, 255, 0.06);
  --text:      #eaf0f6;
  --text-mid:  #aab4c0;
  --text-dim:  #6c7885;
  --accent:    #4fc3f7;   /* UIアクセント（路線色とは別のニュートラル系） */
  --warn:      #ff6b6b;
  --warn-soft: rgba(255, 107, 107, 0.18);
  --r-card: 18px;
  --r-pill: 999px;
  --font-jp: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
             "Yu Gothic", "YuGothic", "Meiryo", system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code",
               "Roboto Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font-jp); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
.app { position: relative; height: 100dvh; width: 100%; }

.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; transition: opacity 0.45s var(--ease); }
.screen.is-active { opacity: 1; visibility: visible; }
.screen--select, .screen--result { display: flex; align-items: center; justify-content: center; padding: clamp(20px, 4vw, 56px); overflow-y: auto; }
@media (prefers-reduced-motion: reduce) { .screen { transition: none; } }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-jp); font-size: 1rem; font-weight: 700;
  display: inline-flex; align-items: center; gap: 0.6em; padding: 0.9em 1.6em;
  border: 1px solid transparent; border-radius: var(--r-pill); cursor: pointer; white-space: nowrap;
  transition: transform 0.12s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn--primary { color: #04121c; background: linear-gradient(180deg, #7fd6fb, var(--accent)); box-shadow: 0 10px 30px -12px rgba(79, 195, 247, 0.6); }
.btn--ghost { color: var(--text-mid); background: var(--panel-solid); border-color: var(--line); }
.btn--ghost:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
.btn kbd { font-family: var(--font-mono); font-size: 0.72em; font-weight: 600; padding: 0.25em 0.55em; border-radius: 7px; background: rgba(4, 18, 28, 0.25); color: #05202e; }

/* ============ SELECT ============ */
.select__inner { max-width: 760px; width: 100%; }
.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.brand__dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.brand__label { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.26em; color: var(--text-dim); font-weight: 600; }
.select__title { font-size: clamp(2.3rem, 7vw, 3.8rem); line-height: 1.04; letter-spacing: -0.02em; font-weight: 800; }
.select__title .accent { color: var(--accent); text-shadow: 0 0 36px rgba(79, 195, 247, 0.4); }
.select__lead { margin-top: 18px; max-width: 40em; color: var(--text-mid); font-size: clamp(0.96rem, 2.2vw, 1.08rem); line-height: 1.7; }

/* mode buttons (quiz / profile) */
.modes { margin-top: 30px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modebtn {
  text-align: left; cursor: pointer; font-family: inherit; color: inherit;
  background: linear-gradient(120deg, rgba(79,195,247,0.10), var(--panel-solid));
  border: 1px solid rgba(79,195,247,0.28); border-radius: 14px; padding: 16px 20px;
  transition: transform 0.14s var(--ease), border-color 0.2s, box-shadow 0.2s;
}
.modebtn:hover { transform: translateY(-3px); border-color: rgba(79,195,247,0.5); box-shadow: 0 16px 40px -20px rgba(0,0,0,0.8); }
.modebtn:active { transform: translateY(-1px); }
.modebtn__title { display: block; font-size: 1.2rem; font-weight: 800; }
.modebtn__desc { display: block; margin-top: 3px; font-size: 0.8rem; color: var(--text-mid); }

.lines__label { margin-top: 28px; font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.2em; color: var(--text-dim); text-transform: uppercase; }
.lines { margin-top: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.linecard {
  position: relative; text-align: left; cursor: pointer;
  background: linear-gradient(180deg, var(--panel-solid), var(--bg-2));
  border: 1px solid var(--line); border-left: 5px solid var(--lc, #888);
  border-radius: 14px; padding: 18px 20px;
  transition: transform 0.14s var(--ease), border-color 0.2s, box-shadow 0.2s;
  font-family: inherit; color: inherit;
}
.linecard:hover { transform: translateY(-3px); border-color: rgba(255, 255, 255, 0.2); box-shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.8); }
.linecard:active { transform: translateY(-1px); }
.linecard__name { font-size: 1.35rem; font-weight: 800; display: flex; align-items: center; gap: 9px; }
.linecard__badge { width: 12px; height: 12px; border-radius: 50%; background: var(--lc); box-shadow: 0 0 10px var(--lc); flex: none; }
.linecard__en { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); margin-top: 4px; letter-spacing: 0.02em; }
.linecard__meta { margin-top: 12px; font-size: 0.82rem; color: var(--text-mid); }
.select__note { margin-top: 26px; color: var(--text-dim); font-size: 0.82rem; line-height: 1.6; }

/* ============ PLAY (map) ============ */
.map { position: absolute; inset: 0; background: var(--bg); z-index: 1; }
/* ダークタイルが暗すぎるので明るく持ち上げる（社長要望 2026-07-15） */
.leaflet-tile-pane { filter: brightness(1.85) contrast(0.92); }
.overlay { position: absolute; inset: 0; z-index: 2; pointer-events: none; display: flex; flex-direction: column; }
.overlay > * { pointer-events: auto; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px clamp(14px, 3vw, 26px);
  background: linear-gradient(180deg, rgba(11, 14, 19, 0.92), rgba(11, 14, 19, 0));
}
.iconbtn { font-family: inherit; font-size: 0.9rem; font-weight: 700; color: var(--text-mid); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 0.55em 1em; cursor: pointer; backdrop-filter: blur(8px); transition: color 0.2s, border-color 0.2s; }
.iconbtn:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.22); }
.topbar__line { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.02rem; }
.topbar__line .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--tbc, #9acd32); box-shadow: 0 0 10px var(--tbc, #9acd32); }
.topbar__stats { margin-left: auto; display: flex; gap: clamp(8px, 2vw, 18px); }
.tstat { font-family: var(--font-mono); font-size: 0.82rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.tstat b { color: var(--text); font-size: 1.05rem; font-weight: 700; }
.tstat--prog b { color: var(--accent); }

/* speedometer (Rail Typer style) */
.speedo {
  position: absolute; top: clamp(64px, 12vh, 104px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: baseline; gap: 6px; pointer-events: none;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.9);
}
.speedo__val {
  font-family: var(--font-mono); font-weight: 800; font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 12vw, 5.2rem); line-height: 1; letter-spacing: -0.03em;
  color: #fff; transition: color 0.25s, text-shadow 0.25s;
}
.speedo.fast .speedo__val { color: var(--lc2, #9acd32); text-shadow: 0 0 30px var(--lc2, #9acd32); }
.speedo__unit { font-family: var(--font-mono); font-size: clamp(0.9rem, 2.4vw, 1.15rem); font-weight: 700; color: var(--text-mid); }
.combo {
  margin-left: 12px; font-family: var(--font-mono); font-size: 0.95rem; color: var(--accent);
  opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s;
  align-self: center;
}
.combo[data-on="true"] { opacity: 1; transform: none; }
.combo b { font-size: 1.5rem; font-weight: 800; }
.combo__x { margin-left: 4px; color: var(--text-dim); font-size: 0.72rem; letter-spacing: 0.08em; }
@media (prefers-reduced-motion: reduce) { .speedo__val, .combo { transition: none; } }

/* typing card, bottom-center floating */
.typecard {
  margin: auto auto clamp(20px, 5vh, 46px); width: min(560px, calc(100% - 28px));
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: clamp(18px, 3.5vw, 28px); backdrop-filter: blur(16px) saturate(1.2);
  box-shadow: 0 24px 70px -30px rgba(0, 0, 0, 0.95), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.typecard__head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.typecard__kanji { font-size: clamp(1.9rem, 6vw, 2.8rem); font-weight: 800; line-height: 1.05; }
.typecard__kana { font-size: clamp(0.85rem, 2.2vw, 1rem); color: var(--text-dim); letter-spacing: 0.06em; }
.typecard__romaji { margin-top: 16px; font-family: var(--font-mono); font-weight: 600; font-size: clamp(1.5rem, 5vw, 2.3rem); letter-spacing: 0.02em; word-break: break-all; line-height: 1.35; min-height: 1.4em; }
.typecard__romaji .ch { color: var(--text-dim); transition: color 0.08s; }
.typecard__romaji .ch.done { color: var(--lc2, #9acd32); }
.typecard__romaji .ch.cur { color: var(--text); border-bottom: 3px solid var(--lc2, #9acd32); border-radius: 2px; animation: caret 1.1s steps(1) infinite; }
.typecard__romaji .ch.err { color: var(--warn); background: var(--warn-soft); border-radius: 4px; }
@keyframes caret { 50% { border-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .typecard__romaji .ch.cur { animation: none; } }
.typecard.shake { animation: shake 0.24s var(--ease); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) { .typecard.shake { animation: none; } }
.typecard__next { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); display: flex; align-items: center; gap: 11px; color: var(--text-mid); font-size: 0.92rem; }
.next-cap { font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.2em; color: var(--text-dim); border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; }

/* ---- leaflet marker: station dots & train ---- */
.stn-dot { border-radius: 50%; background: #0b0e13; border: 2px solid var(--text-dim); box-sizing: border-box; }
.stn-dot.done { background: var(--lc3, #9acd32); border-color: #fff; }
.train-marker { border-radius: 50%; background: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.25), 0 0 18px 4px var(--tc, #9acd32); border: 2px solid var(--tc, #9acd32); }
.stn-label { font-family: var(--font-jp); font-size: 11px; font-weight: 700; color: #dfe7ef; text-shadow: 0 1px 3px #000, 0 0 6px #000; white-space: nowrap; pointer-events: none; }

/* Leaflet attribution: keep readable on dark */
.leaflet-control-attribution { background: rgba(11, 14, 19, 0.7) !important; color: #7b8794 !important; }
.leaflet-control-attribution a { color: #9aa6b2 !important; }

/* ============ RESULT ============ */
.result__inner { max-width: 560px; width: 100%; text-align: center; }
.result__eyebrow { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.24em; color: var(--accent); margin-bottom: 12px; }
.result__time { font-size: clamp(3.6rem, 15vw, 6.4rem); font-weight: 800; line-height: 0.9; letter-spacing: -0.03em; font-family: var(--font-mono); }
.result__time .u { font-size: 0.28em; color: var(--text-dim); margin-left: 0.2em; font-family: var(--font-jp); font-weight: 700; }
.result__speed { margin-top: 14px; font-size: 1.15rem; color: var(--text-mid); }
.result__speed b { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.result__speed .u2 { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text-dim); }
.result__speed-best { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--text-dim); }
.result__sub { margin-top: 12px; color: var(--text-mid); font-size: 0.98rem; }
.result__grid { margin: 32px 0 26px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.rcell { display: flex; flex-direction: column; gap: 6px; padding: 16px 8px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; }
.rcell--best { border-color: rgba(79, 195, 247, 0.32); background: rgba(79, 195, 247, 0.06); }
.rfig { font-family: var(--font-mono); font-size: clamp(1.25rem, 5vw, 1.8rem); font-weight: 700; font-variant-numeric: tabular-nums; }
.rfig small { font-size: 0.5em; color: var(--text-dim); }
.rcell--best .rfig { color: var(--accent); }
.rlbl { font-size: 0.72rem; color: var(--text-dim); }
.result__actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.result__share { display: inline-block; margin-top: 16px; color: var(--text-dim); font-size: 0.86rem; background: none; border: none; border-bottom: 1px solid transparent; cursor: pointer; font-family: inherit; transition: color 0.2s, border-color 0.2s; }
.result__share:hover { color: var(--text); border-color: var(--text-dim); }
.result.is-new-best .rcell--best { animation: pulseBest 1.6s var(--ease) infinite; }
@keyframes pulseBest { 0%, 100% { box-shadow: 0 0 0 0 rgba(79, 195, 247, 0); } 50% { box-shadow: 0 0 0 4px rgba(79, 195, 247, 0.18); } }
@media (prefers-reduced-motion: reduce) { .result.is-new-best .rcell--best { animation: none; } }

/* ============ QUIZ ============ */
.screen--quiz { display: flex; align-items: stretch; justify-content: stretch; padding: 0; }
.quiz { width: 100%; display: flex; flex-direction: column; }
.quiz__hud { display: flex; align-items: center; gap: 14px; padding: 16px clamp(14px,3vw,26px); border-bottom: 1px solid var(--line-soft); }
.quiz__stats { margin-left: auto; display: flex; gap: clamp(10px,2vw,20px); }
.quiz__body { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; }
.quiz__hint { font-family: var(--font-mono); font-size: 0.85rem; letter-spacing: 0.06em; color: var(--accent); }
.quiz__kanji { font-size: clamp(3.4rem, 14vw, 7rem); font-weight: 800; letter-spacing: 0.04em; line-height: 1.05; }
.quiz__romaji { font-family: var(--font-mono); font-weight: 600; font-size: clamp(1.6rem, 6vw, 2.6rem); letter-spacing: 0.04em; min-height: 1.4em; }
.quiz__romaji .ch { color: var(--text-dim); transition: color 0.08s; }
.quiz__romaji .ch.done { color: var(--accent); }
.quiz__romaji .ch.cur { color: var(--text); border-bottom: 3px solid var(--accent); border-radius: 2px; animation: caret 1.1s steps(1) infinite; }
.quiz__romaji .ch.err { color: var(--warn); background: var(--warn-soft); border-radius: 4px; }
.quiz__reveal { min-height: 1.4em; font-size: 1.05rem; color: var(--text-mid); }
.quiz__reveal.show { color: #7fe0a8; }
.quiz.shake .quiz__romaji { animation: shake 0.24s var(--ease); }
@media (prefers-reduced-motion: reduce) { .quiz__romaji .ch.cur, .quiz.shake .quiz__romaji { animation: none; } }
.quiz__end { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; padding: 24px; }
.quiz__end-eyebrow { font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.22em; color: var(--accent); }
.quiz__end-score { font-family: var(--font-mono); font-size: clamp(3.6rem, 15vw, 6rem); font-weight: 800; line-height: 0.9; }
.quiz__end-score .u { font-size: 0.32em; color: var(--text-dim); }
.quiz__end-sub { color: var(--text-mid); }
.quiz__end-actions { margin-top: 14px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* ============ PROFILE ============ */
.profile { max-width: 760px; width: 100%; margin: 0 auto; }
.profile__head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.profile__title { font-size: 1.6rem; font-weight: 800; }
.profile__summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 20px; }
.psum { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 14px; padding: 16px; text-align: center; }
.psum b { display: block; font-family: var(--font-mono); font-size: 1.7rem; font-weight: 800; color: var(--accent); }
.psum span { font-size: 0.74rem; color: var(--text-dim); }
.profile__table { display: flex; flex-direction: column; gap: 8px; }
.prow { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 16px; background: var(--panel-solid); border: 1px solid var(--line); border-left: 5px solid var(--pc,#888); border-radius: 12px; }
.prow__name { font-weight: 700; }
.prow__stat { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text-mid); font-variant-numeric: tabular-nums; }
.prow__stat b { color: var(--text); }
.profile__empty { color: var(--text-dim); text-align: center; padding: 40px 0; }

@media (max-width: 640px) {
  .modes { grid-template-columns: 1fr; }
  .profile__summary { grid-template-columns: 1fr 1fr; }
  .prow { grid-template-columns: 1fr auto; }
  .topbar { flex-wrap: wrap; }
  .topbar__stats { width: 100%; margin-left: 0; justify-content: space-between; order: 3; }
  .result__grid { grid-template-columns: repeat(2, 1fr); }
}
