:root {
  --bg-start: #0b0f1a;
  --bg-end: #101836;
  --accent: #00e5ff;
  --accent-strong: #00ffff;
  --danger: #ff6b3d;
  --text: #d7e8ff;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Orbitron', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 50% 40%, var(--bg-end), var(--bg-start));
  overflow: hidden;
}
.bg { position: relative; }
.stars .layer { position: absolute; inset: 0; pointer-events: none; }
.layer-far { background-image: radial-gradient(#ffffff10 1px, transparent 1px); background-size: 2px 2px; opacity: 0.2; transform: translate3d(0,0,0); }
.layer-mid { background-image: radial-gradient(#ffffff20 1px, transparent 1px); background-size: 3px 3px; opacity: 0.3; transform: translate3d(0,0,0); }
.site-header { position: fixed; top: 0; left: 0; right: 0; padding: 16px 24px; display: flex; justify-content: center; z-index: 10; }
.nav { display: inline-flex; gap: 16px; background: #0f1430cc; backdrop-filter: blur(6px); padding: 8px 12px; border-radius: 12px; }
.nav-link { color: var(--text); text-decoration: none; opacity: 0.85; transition: opacity .2s ease; }
.nav-link:hover { opacity: 1; }
.nav-link.active { color: var(--accent); }
.nav-toggle { position: fixed; top: 16px; left: 16px; padding: 10px 14px; border-radius: 12px; background: #0f1430cc; color: var(--text); border: 1px solid #1a2048; cursor: pointer; z-index: 20; }
.nav-overlay { position: fixed; inset: 0; background: #00000080; z-index: 19; }
.nav-drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; background: #0f1430; box-shadow: 0 0 24px #00ffff33; transform: translateX(-100%); transition: transform .2s ease; z-index: 20; padding: 16px; }
.nav-title { font-size: 18px; margin-bottom: 10px; color: var(--accent); letter-spacing: 1px; }
.nav-item { display: block; padding: 10px 8px; color: var(--text); text-decoration: none; border-radius: 10px; opacity: 0.85; }
.nav-item:hover { opacity: 1; background: #12183b; }
.nav-sep { height: 1px; background: #1a2048; margin: 8px 0; }
.hidden { display: none; }
body.menu-open .nav-drawer { transform: translateX(0); }
.hero { height: 100vh; display: grid; place-items: center; text-align: center; }
.hero-img { width: min(90vw, 980px); height: auto; border-radius: 16px; box-shadow: 0 0 32px #00ffff22; }
.title { font-size: 56px; letter-spacing: 3px; }
.title.small { font-size: 32px; }
.subtitle { margin-top: 8px; opacity: 0.8; }
.cta { margin-top: 24px; display: inline-flex; gap: 12px; }
.btn {
  appearance: none;
  border: none;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform .12s ease, opacity .2s ease, box-shadow .2s ease;
}
.btn-primary { background: linear-gradient(180deg, var(--accent-strong), var(--accent)); color: #001b25; }
.btn-ghost { background: #0f1430cc; color: var(--text); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.glow { text-shadow: 0 0 12px #00ffff66, 0 0 32px #00ffff44; box-shadow: 0 0 24px #00ffff33; }
.footer-text { text-align: center; opacity: 0.6; margin: 16px 0 24px; }
.play-wrap { padding-top: 72px; display: grid; place-items: center; gap: 16px; }
.stage { position: relative; width: 90vw; height: 80vh; }
.scene { width: 100%; height: 100%; border-radius: 16px; background: #0f1430aa; backdrop-filter: blur(4px); position: relative; z-index: 25; }
.hud { position: absolute; top: 12px; left: 12px; display: flex; gap: 16px; z-index: 12; background: #0f1430cc; padding: 8px 12px; border-radius: 12px; }
.hud-item { color: var(--text); }
.hud-bottom { width: 90vw; margin: 6px auto 0; display: flex; gap: 16px; background: #0f1430cc; padding: 8px 12px; border-radius: 12px; justify-content: center; }
.objective { position: absolute; top: 12px; right: 12px; padding: 6px 12px; border-radius: 999px; background: #0f1430cc; backdrop-filter: blur(6px); opacity: 0.9; z-index: 12; }
.hud-time { position: absolute; top: 10px; left: 10px; font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 13px; letter-spacing: 0.03em; text-transform: uppercase; color: rgba(255, 255, 255, 0.85); text-shadow: 0 0 4px rgba(0, 0, 0, 0.8); pointer-events: none; z-index: 12; }
.toast { position: fixed; top: 140px; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: #0f1430ee; backdrop-filter: blur(6px); font-size: 12px; letter-spacing: 1px; text-transform: uppercase; box-shadow: 0 0 24px #00ffff33; z-index: 15; }
.toast span { color: var(--accent); }
.controls { display: none; }
.site-footer { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; z-index: 14; }
.game-controls { display: flex; gap: 12px; }
.key-controls { display: flex; gap: 8px; align-items: center; background: #0f1430cc; padding: 8px 12px; border-radius: 12px; }
.key { min-width: 28px; height: 24px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; background: #0b1028; border: 1px solid #1a2048; color: var(--text); font-size: 12px; }
.key.wide { min-width: 60px; }
.key-label { font-size: 12px; opacity: 0.85; margin-left: 4px; color: var(--accent); }
.fs .site-footer { display: none; }
.fs .nav-toggle { display: inline-block; }
.boost-overlay { position: absolute; bottom: 12px; right: 12px; z-index: 14; display: flex; align-items: center; gap: 8px; }
.boost-label { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.85; }
.boost-bar { width: 120px; height: 8px; background: #0b1028; border-radius: 6px; overflow: hidden; border: 1px solid #1a2048; }
#boost-fill { height: 100%; width: 0%; background: linear-gradient(180deg, var(--accent-strong), var(--accent)); transition: width .2s ease; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: #00000066; backdrop-filter: blur(6px); z-index: 40; }
.hidden { display: none; }
.modal-card { position: relative; width: 320px; background: linear-gradient(180deg, rgba(18,26,44,0.45), rgba(8,12,22,0.35)); border: 1px solid rgba(150,200,255,0.18); border-radius: 16px; padding: 16px; overflow: hidden; backdrop-filter: blur(10px) saturate(130%) brightness(1.1); box-shadow: 0 12px 32px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(150,200,255,0.14); }
.modal-card::after { content: ""; position: absolute; inset: 0; border-radius: 16px; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18), inset 0 0 24px rgba(120,180,255,0.12); opacity: 0.06; background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><circle cx="4" cy="8" r="1" fill="white" opacity="0.5"/><circle cx="80" cy="40" r="1" fill="white" opacity="0.6"/><circle cx="40" cy="100" r="1" fill="white" opacity="0.4"/></svg>'); animation: dashNoise 18s linear infinite; }
.modal-title { margin: 0; font-size: 22px; }
.modal-text { opacity: 0.85; }
.modal-info { margin-top: 6px; opacity: 0.9; color: var(--accent); }
.input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid #1a2048; background: #0b1028; color: var(--text); outline: none; }
.modal-actions { margin-top: 12px; display: flex; gap: 10px; justify-content: flex-end; }
.board-wrap { padding-top: 88px; display: grid; place-items: center; gap: 12px; }
.board { width: min(720px, 90vw); background: #0f1430aa; border-radius: 16px; padding: 16px; box-shadow: 0 0 24px #00ffff22; }
.board-table { width: 100%; border-collapse: collapse; }
.board-table th, .board-table td { padding: 10px 8px; border-bottom: 1px solid #182050; text-align: left; }
.board-table th { color: var(--accent); font-weight: 600; letter-spacing: 1px; }
.board-table tr:last-child td { border-bottom: none; }
.board-table .col-rank { width: 64px; }
.board-table .col-score { width: 120px; text-align: right; }
.site-footer { position: fixed; bottom: 0; left: 0; right: 0; }
.invert { filter: invert(0.2); }
.tier-progress { position: absolute; bottom: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 12; }
.boost-bar { width: 100px; height: 6px; border-radius: 999px; background: #1a2048; overflow: hidden; margin-top: 4px; }
#boost-fill { width: 100%; height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transform-origin: left center; transition: width 0.15s ease-out; }
.fact { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f1430ee; backdrop-filter: blur(6px); padding: 8px 14px; border-radius: 12px; box-shadow: 0 0 24px #00ffff22; color: var(--text); font-size: 12px; letter-spacing: 1px; z-index: 16; }
.modal-info { margin: 0 0 6px; font-size: 13px; opacity: 0.85; }
.modal-codex { margin-top: 10px; padding-top: 8px; border-top: 1px solid #182050; max-height: 160px; overflow-y: auto; font-size: 12px; }
.modal-codex h3 { margin: 6px 0; font-size: 14px; color: var(--accent); }
.modal-codex ul { list-style: none; padding: 0; margin: 0; }
.modal-codex li { margin: 4px 0; opacity: 0.9; }
.codex-link { color: var(--accent); text-decoration: none; opacity: 0.85; margin-left: 6px; }
.codex-link:hover { opacity: 1; text-decoration: underline; }
body.invert .scene { filter: invert(1) hue-rotate(180deg); transition: filter 0.35s ease; }
.tier-progress { position: absolute; bottom: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 12; }
/* Win Theme */
.modal.win { background: linear-gradient(180deg, rgba(0,0,0,0.75), rgba(0,0,0,0.55)); }
.modal.win .modal-card { width: 360px; background: linear-gradient(180deg, rgba(24,18,10,0.45), rgba(18,14,8,0.35)); border: 1px solid rgba(255,211,122,0.28); border-radius: 16px; padding: 18px; box-shadow: 0 12px 32px rgba(0,0,0,0.35), 0 0 28px #ffd37a33, inset 0 0 0 1px rgba(255,211,122,0.22); }
.modal.win .modal-title { color: #ffd37a; letter-spacing: 0.6px; }
.modal.win .modal-info { color: #ffd37a; opacity: 0.9; }
.modal.win .btn.glow { box-shadow: 0 0 20px #ffd37a44; }
.tier-item { display: flex; align-items: center; gap: 8px; }
.tier-label { width: 90px; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; opacity: 0.7; }
.tier-bar { width: 120px; height: 6px; border-radius: 999px; background: #1a2048; overflow: hidden; }
.tier-fill { width: 0%; height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transition: width 0.2s ease-out; }
.tier-item.completed .tier-fill { width: 100%; }
.intro { position: fixed; inset: 0; display: grid; place-items: center; background: transparent; z-index: 30; opacity: 1; transition: opacity .6s ease; }
.intro.fade-out { opacity: 0; pointer-events: none; }
.intro-text { font-size: 24px; letter-spacing: 2px; color: #ffffff; opacity: 0; transition: opacity .6s ease; }
.intro-text.show { opacity: 1; }
.intro-text.fade-out { opacity: 0; }
.intro-text.god-fly { animation: godFly 1.6s ease-out forwards; }
@keyframes godFly {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  60% { transform: translateY(-40px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-80px) scale(1.25); opacity: 0; }
}
.intro-text.paused { font-size: 32px; letter-spacing: 4px; }
.fact { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f1430ee; backdrop-filter: blur(6px); padding: 8px 14px; border-radius: 12px; box-shadow: 0 0 24px #00ffff22; color: var(--text); font-size: 12px; letter-spacing: 1px; z-index: 16; }
.fact.hidden { display: none; }
#touch-layer { position: absolute; inset: 0; pointer-events: auto; }
#joystick-base { position: absolute; width: 120px; height: 120px; border-radius: 50%; border: 2px solid #00e5ff; background: #0b1020aa; transform: translate(-50%, -50%); opacity: 0; transition: opacity 0.12s; pointer-events: none; z-index: 18; }
#joystick-nub { position: absolute; left: 50%; top: 50%; width: 60px; height: 60px; border-radius: 50%; background: #00e5ff; transform: translate(-50%, -50%); opacity: 0.9; }
#touch-boost { position: absolute; right: 20px; bottom: 20px; width: 80px; height: 80px; border-radius: 50%; border: none; font-size: 14px; font-weight: 600; background: #ff6b3d; color: #fff; box-shadow: 0 0 18px #ff6b3d88; pointer-events: auto; z-index: 18; }
#touch-fullscreen { position: absolute; right: 20px; top: 20px; width: 52px; height: 52px; border-radius: 12px; border: 1px solid #1a2048; font-size: 11px; font-weight: 600; background: #0f1430cc; color: var(--text); box-shadow: 0 0 18px #00ffff22; pointer-events: auto; z-index: 18; }
:root { --btn: 36px; --gap: 8px; --pad-x: 10px; --pad-y: 8px; --border: 1px; }
/* Compact glass HUD panel */
.dashboard {
  position: absolute;
  bottom: 10px;
  left: 10px;
  margin-bottom: 8px;
  width: calc(8*var(--btn) + 7*var(--gap) + 2*var(--pad-x) + 2*var(--border));
  max-width: calc(8*var(--btn) + 7*var(--gap) + 2*var(--pad-x) + 2*var(--border));
  box-sizing: border-box;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 26;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(18,26,44,0.45), rgba(8,12,22,0.35));
  border-radius: 16px;
  border: 1px solid rgba(150,200,255,0.18);
  overflow: hidden;
  backdrop-filter: blur(10px) saturate(130%) brightness(1.1);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(150,200,255,0.14);
  opacity: 0;
  transition: opacity .35s ease;
}
.dashboard.dash-show { opacity: 1; pointer-events: auto; }
.dashboard::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255,255,255,0.10), rgba(255,255,255,0.02) 30%, rgba(0,0,0,0.0) 60%);
  mix-blend-mode: screen;
}
.dashboard::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 16px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18), inset 0 0 24px rgba(120,180,255,0.12);
  opacity: 0.06;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><circle cx="4" cy="8" r="1" fill="white" opacity="0.5"/><circle cx="80" cy="40" r="1" fill="white" opacity="0.6"/><circle cx="40" cy="100" r="1" fill="white" opacity="0.4"/></svg>');
  animation: dashNoise 18s linear infinite;
}
@keyframes dashNoise { from { background-position: 0 0; } to { background-position: 400px 0; } }
.hud-top { display: flex; flex-direction: column; gap: 2px; font-size: 11px; opacity: 0.95; align-items: center; text-align: center; width: 100%; }
#objective { font-weight: 600; letter-spacing: 0.5px; }
.dashboard #hud-time { position: static; top: auto; left: auto; opacity: 0.85; font-size: 10px; text-align: center; }
.hud-age { font-size: 10px; opacity: 0.8; margin-top: 2px; }
.hud-gauges { position: relative; display: grid; grid-template-columns: repeat(2, calc(4*var(--btn) + 3*var(--gap))); column-gap: var(--gap); row-gap: 6px; }
.gauge-col { width: calc(4*var(--btn) + 3*var(--gap)); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge-readout { width: 140px; height: 24px; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: linear-gradient(180deg, #0b1028, #0a1428); border: 1px solid rgba(140,190,255,0.28); color: #cfe7ff; box-shadow: inset 0 0 12px rgba(0,255,255,0.08), 0 2px 8px rgba(0,0,0,0.35); font-family: 'Orbitron', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; letter-spacing: 0.6px; font-size: 11px; }
.gauge-readout span { opacity: 0.92; }
.hud-stats { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; font-size: 11px; opacity: 0.9; }
.hud-metrics { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.hud-pill { padding: 2px 6px; border-radius: 999px; background: rgba(8,14,26,0.7); border: 1px solid rgba(140,190,255,0.25); white-space: normal; font-size: 10px; max-width: 180px; }
.hud-controls { width: 100%; display: grid; grid-template-columns: repeat(8, var(--btn)); column-gap: var(--gap); align-items: center; justify-content: start; }
.key-pill { padding: 2px 6px; border-radius: 999px; background: rgba(8,14,26,0.7); border: 1px solid rgba(140,190,255,0.25); white-space: nowrap; font-size: 10px; }
.dash-actions { display: flex; gap: 8px; justify-content: flex-end; }
.icon-btn { box-sizing: border-box; width: var(--btn); height: var(--btn); display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; border: 1px solid rgba(120,160,220,0.25); background: rgba(10,16,28,0.35); box-shadow: 0 0 12px rgba(0,0,0,0.25); cursor: pointer; }
.icon-btn:hover { box-shadow: 0 0 16px rgba(0,255,255,0.25); background: rgba(12,18,30,0.45); }
.icon-btn.danger { border-color: rgba(255,120,80,0.35); }
.icon-btn.key.active { background: rgba(255,255,255,0.14); box-shadow: 0 0 12px rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.45); }
.icon-btn.key.active svg { stroke: #ffffff; }
.icon-btn.active { background: rgba(255,255,255,0.14); box-shadow: 0 0 12px rgba(255,255,255,0.35); border-color: rgba(255,255,255,0.45); }
.icon-btn.active svg { stroke: #ffffff; }
.gauge { background: transparent; width: 100%; height: 90px; }
.gauge { filter: drop-shadow(0 6px 14px rgba(0,0,0,0.45)) drop-shadow(0 0 8px rgba(0,255,255,0.12)); }
.gauge { animation: hudPulse 6s ease-in-out infinite; }
@keyframes hudPulse {
  0%, 100% { transform: perspective(600px) scaleY(0.94) scale(1.00); }
  50% { transform: perspective(600px) scaleY(0.94) scale(1.02); }
}
.gauge text { font-family: 'Orbitron', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; text-transform: uppercase; letter-spacing: 1px; fill: rgba(255,255,255,0.9); }
.gauge #gauge-progress-pointer, .gauge #gauge-boost-pointer { transition: transform 0.2s ease-in-out; transform-origin: 100px 100px; transform-box: view-box; }
.tick-major { stroke: #bfcde6; stroke-width: 1.2; opacity: 0.8; }
.tick-minor { stroke: #60708d; stroke-width: 0.8; opacity: 0.45; }
/* warmer glow on boost gauge */
#gauge-boost { filter: drop-shadow(0 0 12px rgba(255,150,80,0.25)); }
.gauge-readout { width: 100%; height: 24px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border-radius: 8px; background: linear-gradient(180deg, rgba(11,16,40,0.55), rgba(10,20,40,0.45)); border: 1px solid rgba(140,190,255,0.22); color: #cfe7ff; box-shadow: inset 0 0 12px rgba(0,255,255,0.06), 0 2px 8px rgba(0,0,0,0.30); font-family: 'Orbitron', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; letter-spacing: 0.4px; font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gauge-readout span { opacity: 0.92; }
/* Drag handle */
.dash-handle { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 26px; height: 26px; border-radius: 999px; border: 1px solid rgba(200,220,255,0.65); background: radial-gradient(circle at 50% 50%, #0b1028, #0a1428); box-shadow: 0 2px 10px rgba(0,0,0,0.40); cursor: move; display: grid; place-items: center; }
.dash-handle svg { stroke: #ffffff; opacity: 0.95; }
.dash-handle.active { box-shadow: 0 0 20px #ffffff55, 0 0 16px #00ffff44; border-color: #ffffffaa; }
