/* ==========================================================================
   METREAL VOL.2 — route3d.css  (「歩いてみる」 three.js lane runner, mounted by route.js into .rt-g3)
   Square corners, flat colours. Labels in Noto Sans JP (--font-body), numerals in --font-display.
   Overlays over the canvas: fork labels (.r3-sign), station display (.r3-train), title / finish (.r3-over).
   ========================================================================== */
.r3 { display: grid; gap: 14px; }

/* ---------- HUD ---------- */
.r3-hud { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px 18px; align-items: end; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.r3-hud-item { display: grid; gap: 2px; min-width: 0; }
.r3-k { font-family: var(--font-body); font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.r3-hud-item b { font-family: var(--font-display); font-weight: 900; font-size: 22px; line-height: 1; letter-spacing: -.02em; color: var(--white); font-variant-numeric: tabular-nums; white-space: nowrap; }
.r3-hud-clock b { font-size: clamp(32px, 4vw, 44px); color: var(--cyan); }
.r3-seg { font-family: var(--font-body) !important; font-weight: 900 !important; font-size: 16px !important; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 480px) {
  .r3-hud { grid-template-columns: 1fr 1fr; gap: 6px 14px; padding-bottom: 10px; }
  .r3-hud-item b { font-size: 20px; }
  .r3-hud-clock b { font-size: 30px; }
}

/* ---------- screen ---------- */
.r3-screen { position: relative; background: var(--bg-2); border: 1px solid var(--line-soft); overflow: hidden; }
.r3-view { position: relative; width: 100%; line-height: 0; }
.r3-canvas { display: block; width: 100%; touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; background: #0c0d1a; cursor: pointer; outline: none; }
.r3.is-run .r3-canvas { touch-action: none; }
.r3-canvas:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

/* feedback: one short flash (correct = cyan, mistake = red) */
.r3-flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.r3-flash.is-cyan { background: var(--cyan); animation: r3-flash .4s steps(2, end) 1; }
.r3-flash.is-red { background: var(--red); animation: r3-flash .4s steps(2, end) 1; }
@keyframes r3-flash { 0% { opacity: .5; } 50% { opacity: 0; } 75% { opacity: .35; } 100% { opacity: 0; } }

.r3-msg { position: absolute; left: 50%; top: 10%; transform: translate(-50%, 0); padding: 8px 14px; background: var(--red); color: #fff; font-family: var(--font-body); font-weight: 900; font-size: clamp(16px, 2.2vw, 22px); line-height: 1.2; white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity .15s var(--ease), visibility .15s; pointer-events: none; }
.r3-msg.is-cyan { background: var(--cyan); color: #000; }
.r3-msg.is-show { opacity: 1; visibility: visible; }

.r3-fade { position: absolute; inset: 0; background: var(--bg); opacity: 0; pointer-events: none; transition: opacity .22s linear; }
.r3-fade.is-on { opacity: 1; }

/* ---------- fork labels: one per branch, the lane you are in is lit ---------- */
.r3-sign { position: absolute; left: 0; right: 0; bottom: 14%; display: flex; justify-content: space-between; gap: 8px; padding: 0 10px; pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s; }
.r3-sign.is-show { opacity: 1; visibility: visible; }
.r3-sign-l, .r3-sign-r { display: inline-flex; align-items: center; gap: 10px; max-width: 48%; min-height: 56px; padding: 8px 14px; background: rgba(11, 12, 20, .9); color: var(--white); border: 2px solid var(--white); font-family: var(--font-body); font-weight: 900; font-size: clamp(15px, 4vw, 28px); line-height: 1.15; letter-spacing: .01em; transform: translateY(10px); transition: transform .25s var(--ease-out), background .15s var(--ease), color .15s var(--ease); }
.r3-sign-l { text-align: left; } .r3-sign-r { text-align: right; }
.r3-sign.is-show .r3-sign-l, .r3-sign.is-show .r3-sign-r { transform: none; }
.r3-sign i { font-style: normal; font-family: var(--font-display); font-weight: 900; font-size: 1.15em; }
.r3-sign b { font-weight: 900; }
.r3-sign-l.is-on, .r3-sign-r.is-on { background: var(--white); color: #000; border-color: var(--white); }

/* ---------- 大江戸線 station display ---------- */
.r3-train { position: absolute; left: 0; right: 0; top: 0; display: grid; gap: 6px; padding: 10px 12px 8px; background: rgba(11, 12, 20, .92); border-bottom: 2px solid var(--rt-oedo, #c4007a); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .2s var(--ease), visibility .2s; }
.r3-train.is-show { opacity: 1; visibility: visible; }
.r3-train-row { display: flex; align-items: baseline; gap: 12px; min-height: 1em; }
.r3-train-k { font-family: var(--font-body); font-weight: 700; font-size: clamp(14px, 2.2vw, 18px); color: var(--muted); }
.r3-train-k:empty { display: none; }
.r3-train-n { font-family: var(--font-body); font-weight: 900; font-size: clamp(36px, 8.5vw, 56px); line-height: 1; color: var(--white); letter-spacing: .02em; }
.r3-train.is-goal .r3-train-n { color: var(--red); }
.r3-train-dots { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; position: relative; padding-top: 10px; }
.r3-train-dots::before { content: ''; position: absolute; left: 10%; right: 10%; top: 14px; height: 2px; background: var(--rt-oedo, #c4007a); }
.r3-train-dots li { position: relative; display: grid; justify-items: center; gap: 4px; font-family: var(--font-body); font-weight: 700; font-size: clamp(10px, 2.4vw, 13px); line-height: 1.2; color: var(--muted); text-align: center; }
.r3-train-dots li i { display: block; width: 10px; height: 10px; background: var(--bg); border: 2px solid var(--rt-oedo, #c4007a); }
.r3-train-dots li.is-past i { background: var(--rt-oedo, #c4007a); }
.r3-train-dots li.is-cur { color: var(--white); }
.r3-train-dots li.is-cur i { background: var(--white); border-color: var(--white); width: 14px; height: 14px; margin-top: -2px; }
.r3-train-dots li.is-goal { color: var(--red); }
.r3-train-dots li.is-goal i { border-color: var(--red); }
.r3-train-dots li.is-goal.is-cur i { background: var(--red); border-color: var(--red); }
.r3-train-off { position: absolute; right: 12px; top: calc(100% + 14px); padding: 8px 14px; background: var(--white); color: #000; font-family: var(--font-body); font-weight: 900; font-size: clamp(16px, 3.6vw, 22px); line-height: 1; opacity: 0; visibility: hidden; transition: opacity .15s var(--ease), visibility .15s; }
.r3-train-off i { font-style: normal; font-family: var(--font-display); font-weight: 900; }
.r3-train-off.is-show { opacity: 1; visibility: visible; }
.r3-train.is-goal .r3-train-off { background: var(--red); color: #fff; }

/* ---------- overlays: title / finish ---------- */
.r3-over { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(7, 8, 12, .8); }
.r3-over.is-show { display: flex; }
.r3-title { display: grid; justify-items: center; gap: 10px; text-align: center; }
.r3-title-h { font-family: var(--font-body); font-weight: 900; font-size: clamp(28px, 5vw, 44px); line-height: 1; color: var(--white); }
.r3-title-s { font-family: var(--font-body); font-weight: 700; font-size: 14px; color: var(--muted); }
.r3-title-arrows { display: inline-flex; gap: 18px; margin: 6px 0 2px; }
.r3-title-arrows i { display: grid; place-items: center; width: 64px; height: 64px; border: 2px solid var(--white); font-style: normal; font-family: var(--font-display); font-weight: 900; font-size: 34px; line-height: 1; color: var(--white); }
.r3-title-best { display: inline-flex; align-items: baseline; gap: 8px; }
.r3-title-best b { font-family: var(--font-display); font-weight: 900; font-size: 24px; line-height: 1; color: var(--white); }
.r3-title-best i { font-style: normal; font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--cyan); }
.r3-btn { min-height: 48px; min-width: 96px; padding: 0 18px; background: var(--bg); color: var(--white); border: 2px solid var(--white); border-radius: 0; font-family: var(--font-body); font-weight: 700; font-size: 16px; letter-spacing: .02em; line-height: 1; cursor: pointer; transition: background .15s var(--ease), color .15s var(--ease); }
.r3-btn:hover, .r3-btn:focus-visible { background: var(--white); color: #000; }
.r3-btn--start { margin-top: 6px; min-width: 160px; background: var(--red); border-color: var(--red); color: #fff; }
.r3-btn--start:hover, .r3-btn--start:focus-visible { background: #fff; border-color: #fff; color: var(--red); }

.r3-fin { width: 100%; max-width: 560px; display: grid; gap: 14px; }
.r3-fin-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 14px; }
.r3-fin-grid > div { display: grid; gap: 2px; border-top: 1px solid var(--line); padding-top: 6px; min-width: 0; }
.r3-fin-grid b { font-family: var(--font-display); font-weight: 900; font-size: clamp(24px, 4vw, 40px); line-height: 1; letter-spacing: -.03em; color: var(--white); font-variant-numeric: tabular-nums; }
.r3-fin-grid b small { font-family: var(--font-body); font-weight: 700; font-size: .4em; letter-spacing: 0; margin-left: 2px; color: var(--muted); }
.r3-fin-score { grid-column: 1 / 3; border-top-width: 2px !important; border-top-color: var(--white) !important; position: relative; }
.r3-fin-score b { font-size: clamp(48px, 8vw, 80px); color: var(--white); }
.r3-fin-rank { border-top-width: 2px !important; border-top-color: var(--white) !important; }
.r3-fin-rank b { font-size: clamp(48px, 8vw, 80px); }
.r3-fin-new { position: absolute; right: 0; top: 8px; font-style: normal; font-family: var(--font-body); font-weight: 700; font-size: 13px; color: #000; background: var(--cyan); padding: 2px 8px; }
.r3-fin-rank b.is-S { color: var(--red); }
.r3-fin-rank b.is-A { color: var(--cyan); }
.r3-fin-rank b.is-B, .r3-fin-rank b.is-C { color: var(--white); }
.r3-fin-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.r3-fin-acts .btn { min-height: 44px; }
@media (max-width: 420px) {
  .r3-fin-grid b { font-size: 22px; }
  .r3-fin-score b, .r3-fin-rank b { font-size: 40px; }
  .r3-over { padding: 10px; align-items: flex-start; overflow: auto; }
  .r3-title-arrows i { width: 56px; height: 56px; font-size: 30px; }
}
