:root {
  --bg: #0d1117;
  --panel: rgba(18, 22, 30, 0.92);
  --fg: #e8ecf1;
  --dim: #9aa4b2;
  --accent: #2fb7c9;
  --gold: #f2b33d;
  --danger: #ff6b6b;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
button { font: inherit; color: var(--fg); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; }
button:hover { background: rgba(255,255,255,0.16); }
button.primary { background: var(--accent); color: #041014; border: none; font-weight: 600; padding: 10px 28px; font-size: 1.05rem; }
.small { font-size: 0.85rem; color: var(--dim); }
.error { color: var(--danger); white-space: pre-wrap; }
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 30;
  background: radial-gradient(ellipse at center, #1a2230 0%, #07090d 75%); }
.loading-card { text-align: center; max-width: 440px; padding: 24px; }
.loading-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.loading-card .sub { color: var(--dim); margin: 0 0 20px; }
.bar { height: 6px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
#load-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud input, #hud select, #hud label { pointer-events: auto; }
#topbar { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 6px; align-items: center; }
#topbar .spacer { flex: 1; }
.pill { background: var(--panel); padding: 5px 10px; border-radius: 20px; font-size: 0.9rem; }
.pill.dim { color: var(--dim); }
#discovered::before { content: "★ "; color: var(--gold); }
button.icon { width: 38px; height: 38px; padding: 0; font-size: 1.1rem; background: var(--panel); }
button.icon.on { border-color: var(--accent); color: var(--accent); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255,255,255,0.7); box-shadow: 0 0 2px #000; }
#prompt { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); background: var(--panel);
  padding: 8px 14px; border-radius: 20px; border: 1px solid var(--gold); pointer-events: auto; cursor: pointer; }
#toast { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); background: var(--panel);
  padding: 10px 18px; border-radius: var(--radius); border-left: 4px solid var(--gold); max-width: 80vw; }
#minimap-wrap { position: absolute; right: 10px; bottom: 10px; border-radius: var(--radius); overflow: hidden;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.15); pointer-events: auto; }
#minimap { display: block; width: 220px; height: 220px; cursor: pointer; }
#pano-bar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center;
  background: var(--panel); padding: 8px 12px; border-radius: var(--radius); }
#pano-label { font-weight: 600; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.panel { position: fixed; z-index: 20; top: 60px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 90px); overflow: auto; background: var(--panel); border-radius: var(--radius);
  padding: 18px 20px; border: 1px solid rgba(255,255,255,0.12); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.panel h2 { margin: 0 0 10px; font-size: 1.2rem; padding-right: 30px; }
.panel .close { position: absolute; right: 10px; top: 10px; width: 30px; height: 30px; padding: 0; }
.panel .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 10px 0; }
#info-desc { line-height: 1.45; color: #d4dae2; }
#info-media img { width: 100%; border-radius: 8px; margin-top: 10px; display: block; }
#info-media .cap { font-size: 0.8rem; color: var(--dim); margin-top: 2px; }
#station-list { list-style: none; padding: 0; margin: 0 0 12px; }
#station-list li { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; }
#station-list li:hover { background: rgba(255,255,255,0.08); }
#station-list li .chk { width: 20px; text-align: center; color: var(--dim); }
#station-list li.done .chk { color: var(--gold); }
.small-btn { font-size: 0.8rem; }
table.keys { border-collapse: collapse; width: 100%; }
table.keys td { padding: 4px 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
table.keys td:first-child { white-space: nowrap; color: var(--accent); font-family: ui-monospace, monospace; width: 40%; }
#bigmap { flex-direction: column; background: rgba(5,7,10,0.9); }
#bigmap-canvas { max-width: 94vw; max-height: 84vh; border-radius: var(--radius); cursor: crosshair; }

#joystick { position: absolute; left: 24px; bottom: 24px; width: 130px; height: 130px; border-radius: 50%;
  background: rgba(255,255,255,0.08); border: 2px solid rgba(255,255,255,0.2); pointer-events: auto; touch-action: none; }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%;
  background: rgba(255,255,255,0.35); }

@media (max-width: 640px) {
  #minimap, #minimap-wrap canvas { width: 140px; height: 140px; }
  #minimap-wrap { top: 58px; bottom: auto; }
  #pano-bar { flex-wrap: wrap; width: calc(100vw - 32px); justify-content: center; bottom: 170px; }
}

/* ---- start screen ---- */
.overlay.start { background: #07090d; overflow: hidden; }
.start-bg { position: absolute; inset: -4%; background-size: cover; background-position: 50% 55%; opacity: 0;
  filter: saturate(0.9) brightness(0.55) blur(1.5px); transform: scale(1.04); transition: opacity 1.2s ease;
  animation: startpan 60s linear infinite alternate; }
.start-bg.on { opacity: 1; }
@keyframes startpan { from { background-position: 30% 55%; } to { background-position: 70% 55%; } }
.overlay.start::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(7,9,13,0.25) 0%, rgba(7,9,13,0.85) 80%); }
.overlay.start .loading-card { position: relative; z-index: 1; max-width: 560px; background: rgba(10, 14, 20, 0.62);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 28px 30px; backdrop-filter: blur(6px); }
.kicker { margin: 0 0 6px; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.75rem; color: var(--accent); }
.overlay.start h1 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 6px; }
.features { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; display: inline-block; }
.features li { margin: 4px 0; color: #d4dae2; }
.features li::before { content: "◆"; color: var(--accent); margin-right: 8px; font-size: 0.8em; }
.features li.violet::before { color: #c48cff; }
.start-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 10px 0 8px; }
.controls-hint { margin: 6px 0; }
.lang-switch { margin: 4px 0; font-size: 0.85rem; color: var(--dim); }
button.link { background: none; border: none; padding: 0 2px; color: var(--dim); text-decoration: underline; cursor: pointer; }
button.link.on { color: var(--fg); text-decoration: none; font-weight: 600; }
.credits { font-size: 0.72rem; color: #7d8794; margin: 12px 0 0; line-height: 1.35; }

/* ---- intro ---- */
#intro-bar { position: fixed; z-index: 25; left: 50%; bottom: 6%; transform: translateX(-50%); display: flex; gap: 14px;
  align-items: center; background: rgba(10, 14, 20, 0.72); padding: 10px 14px 10px 18px; border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.14); font-size: 1.05rem; max-width: calc(100vw - 32px); }
#intro-caption { transition: opacity 0.4s; }

/* ---- HUD extras ---- */
button#discovered { font: inherit; font-size: 0.9rem; border: 1px solid rgba(255,255,255,0.12); cursor: pointer; color: var(--fg); }
#pano-note { color: var(--gold); max-width: 30vw; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 10px; }
.badge { font-size: 0.72rem; padding: 2px 8px; border-radius: 10px; background: rgba(255,255,255,0.08); color: var(--fg); white-space: nowrap; }
.badge.gold { background: rgba(242,179,61,0.18); color: var(--gold); }
.badge.violet { background: rgba(196,140,255,0.2); color: #d8b4ff; }
.badge.dim { color: var(--dim); }
.progress { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.progress .bar { flex: 1; height: 8px; margin: 0; }
.progress .bar > div { height: 100%; width: 0; background: var(--gold); transition: width 0.4s; }
#station-list li.group-h { cursor: default; padding: 10px 8px 4px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
#station-list li.group-h:hover { background: none; }
#station-list li .name { flex: 1; }
#info-pano { margin-top: 4px; }

/* ---- finalize: mobile fixes (review web-and-video F8-F10) ---- */
.overlay.start .loading-card { max-height: calc(100dvh - 16px); overflow-y: auto; }
@media (max-height: 520px) {
  .overlay.start .loading-card { padding: 12px 18px; }
  .overlay.start h1 { font-size: 1.25rem; }
  .overlay.start .sub, .overlay.start .features, .overlay.start .kicker { display: none; }
  .credits { margin-top: 6px; }
}
#discovered { white-space: nowrap; }
body.touch #minimap, body.touch #minimap-wrap canvas { width: 110px; height: 110px; }
body.touch #minimap-wrap { top: 58px; bottom: auto; right: 8px; }
body.touch #toast { top: 58px; max-width: calc(100vw - 150px); left: 12px; transform: none; }
body.touch #pano-label { max-width: 52vw; }
body.touch #pano-bar { bottom: 12px; width: auto; max-width: calc(100vw - 24px); flex-wrap: wrap; }
body.mode-pano #joystick { display: none !important; }
