:root {
  --bg: #111;
  --panel: #1c1c1c;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --line: #333;
  --accent: #6fb38a;
  --k-futsu: #f2f2f2;
  --k-red: #e0494a;
  --k-green: #3fae6a;
  --k-blue: #5b7fe0;
  --k-blank: #6c6c6c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif; }
body { overscroll-behavior: none; }
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---- stage: the car side (#body, drawn on top with a hole) over the sign film (#sign) */
#stage { position: relative; background: #000; overflow: hidden; height: 60vh;
  user-select: none; -webkit-user-select: none; touch-action: none; }
#sign { position: absolute; display: block; }
#body { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #bbb; font-size: 14px; background: #000; }
#hint { position: absolute; left: 0; right: 0; bottom: 10px; text-align: center; font-size: 12px; color: #888;
  opacity: 0; transition: opacity .6s; pointer-events: none; }

/* ---- panel */
#panel { flex: 1; background: var(--panel); border-top: 1px solid var(--line); padding: 10px 16px 24px; }
#bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#now { display: flex; align-items: baseline; gap: 10px; font-size: 18px; min-height: 28px; }
#nowNo { font-family: ui-monospace, Consolas, monospace; color: var(--accent); font-size: 20px; min-width: 2.2em; }
#controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; }
#controls label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
select, button { font: inherit; color: var(--text); background: #2a2a2a; border: 1px solid #444; border-radius: 6px;
  padding: 6px 10px; cursor: pointer; }
button.tog.on { background: #2f4a3a; border-color: var(--accent); }
#vol { width: 90px; accent-color: var(--accent); }
#btnClose { display: none; }

#grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.koma { display: flex; gap: 6px; align-items: center; text-align: left; padding: 7px 8px; background: #262626;
  border: 1px solid #383838; border-radius: 6px; min-height: 40px; }
.koma .no { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); min-width: 1.6em; }
.koma .lb { font-size: 14px; font-weight: 600; line-height: 1.2; }
.koma.blank .lb { color: var(--k-blank); font-weight: 400; font-size: 12px; }
.koma.k-普通 .lb, .koma.k-回送 .lb { color: var(--k-futsu); }
.koma.k-急行 .lb, .koma.k-臨時 .lb, .koma.k-臨時急行 .lb, .koma.k-特急 .lb { color: var(--k-red); }
.koma.k-区急 .lb { color: var(--k-green); }
.koma.k-準急 .lb { color: var(--k-blue); }
.koma.target { border-color: #8a7a3a; background: #2e2a1c; }
.koma.current { border-color: var(--accent); background: #22382b; }

/* ---- immersive (fullscreen) mode */
#app.immersive #stage { position: fixed; inset: 0; height: auto; z-index: 1; }
#app.immersive #panel { position: fixed; left: 0; right: 0; bottom: 0; max-height: 70%; overflow: auto; z-index: 2;
  background: rgba(24, 24, 24, .94); transform: translateY(100%); transition: transform .25s ease; }
#app.immersive.menu #panel { transform: none; }
#app.immersive #btnClose { display: inline-block; }
#app.immersive #hint.show { opacity: 1; }

@media (max-width: 600px) {
  #grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .koma .lb { font-size: 13px; }
}
