/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   MONORAIL SIMULATOR v2 - Styles
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
  background: #0a0a1a;
  color: #fff;
  -webkit-font-smoothing: antialiased;
}

#container { width: 100vw; height: 100vh; position: fixed; top: 0; left: 0; }
#container canvas { display: block; width: 100% !important; height: 100% !important; }

/* ── Loading ── */
#loading-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(135deg, #0a0a2e 0%, #1a1a3e 50%, #0d0d28 100%);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.8s ease, visibility 0.8s ease;
}
#loading-overlay.fade-out { opacity: 0; visibility: hidden; }
.loader-content { text-align: center; }
.loader-spinner {
  width: 48px; height: 48px;
  border: 3px solid rgba(0,212,255,0.15); border-top-color: #00d4ff;
  border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text {
  font-size: 24px; font-weight: 700; letter-spacing: 2px;
  background: linear-gradient(90deg, #00d4ff, #00ff88, #00d4ff);
  background-size: 200% 100%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; animation: shimmer 2s linear infinite;
}
.loader-sub { font-size: 13px; color: rgba(255,255,255,0.4); margin-top: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Glass ── */
.glass {
  background: rgba(8, 12, 28, 0.75);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* ── Mode Toggle ── */
#mode-toggle {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 3px; padding: 5px; z-index: 20;
}
#mode-toggle button {
  padding: 10px 28px; background: transparent; border: none;
  color: rgba(255,255,255,0.4); font-family: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; border-radius: 10px;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1); position: relative; overflow: hidden;
}
#mode-toggle button::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(0,255,136,0.08));
  opacity: 0; transition: opacity 0.35s; border-radius: 10px;
}
#mode-toggle button.active { color: #00d4ff; text-shadow: 0 0 20px rgba(0,212,255,0.3); }
#mode-toggle button.active::before { opacity: 1; }
#mode-toggle button:hover:not(.active) { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.04); }
.btn-icon { margin-right: 4px; }

/* ── Side Panel ── */
.side-panel {
  position: fixed; top: 85px; left: 20px; width: 230px; padding: 18px; z-index: 20;
  transition: opacity 0.3s, transform 0.3s;
}
.side-panel h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255,255,255,0.35);
  margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.info-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 13px; padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.6);
}
.info-value { color: #00d4ff; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Type Toggle ── */
.type-toggle {
  display: flex; gap: 2px; margin-bottom: 14px;
  background: rgba(255,255,255,0.03); border-radius: 8px; padding: 3px;
}
.type-btn {
  flex: 1; padding: 7px 0; background: transparent; border: none;
  color: rgba(255,255,255,0.4); font-family: inherit; font-size: 12px;
  font-weight: 600; cursor: pointer; border-radius: 6px; transition: all 0.25s;
}
.type-btn.active { background: rgba(0,212,255,0.12); color: #00d4ff; }
.type-btn:hover:not(.active) { color: rgba(255,255,255,0.6); }

/* ── Build Mode Buttons ── */
.build-mode-btns { display: flex; gap: 4px; margin: 12px 0; }
.build-mode-btns .btn { flex: 1; font-size: 12px; padding: 8px 6px; }
.build-mode-btns .btn.build-sub.active {
  background: rgba(0,212,255,0.1); border-color: rgba(0,212,255,0.25); color: #00d4ff;
}

/* ── Buttons ── */
.btn-group { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.btn {
  width: 100%; padding: 10px 14px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; color: rgba(255,255,255,0.75);
  font-family: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  display: flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.15); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-danger:hover { background: rgba(255,60,60,0.12); border-color: rgba(255,60,60,0.25); color: #ff7777; }

.height-hint { margin-top: 14px; padding: 8px 10px; background: rgba(0,212,255,0.06); border-radius: 8px; border: 1px solid rgba(0,212,255,0.1); }
.height-hint small { font-size: 11px; color: rgba(0,212,255,0.6); }

/* ── Station Info ── */
.station-info {
  padding: 10px 12px; background: rgba(0,200,100,0.06);
  border: 1px solid rgba(0,200,100,0.12); border-radius: 8px; margin-bottom: 14px;
}
.station-label { font-size: 10px; font-weight: 700; text-transform: uppercase; color: rgba(255,255,255,0.3); letter-spacing: 1px; }
.station-name { font-size: 15px; font-weight: 700; color: #00ff88; margin: 4px 0; }
.station-dist { font-size: 12px; color: rgba(255,255,255,0.45); font-variant-numeric: tabular-nums; }

/* ── Camera Buttons ── */
.cam-section { margin-bottom: 16px; }
.cam-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: rgba(255,255,255,0.3); margin-bottom: 8px; }
.cam-btns { display: flex; flex-direction: column; gap: 4px; }
.cam-btn {
  padding: 9px 12px; background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 8px;
  color: rgba(255,255,255,0.45); font-family: inherit; font-size: 12px;
  font-weight: 500; cursor: pointer; transition: all 0.25s; text-align: left;
}
.cam-btn.active { background: rgba(0,212,255,0.1); border-color: rgba(0,212,255,0.25); color: #00d4ff; box-shadow: 0 0 12px rgba(0,212,255,0.1); }
.cam-btn:hover:not(.active) { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); }

.controls-help { margin-top: 4px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.06); }
.controls-help .info-row { padding: 5px 0; }
.key {
  display: inline-block; padding: 2px 8px; background: rgba(255,255,255,0.08);
  border-radius: 5px; font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,0.7); font-family: 'Inter', monospace;
  letter-spacing: 0.5px; border: 1px solid rgba(255,255,255,0.06);
}

/* ── Speed Display ── */
#speed-display {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  width: 320px; padding: 18px 22px 14px; text-align: center; z-index: 20;
}
.speed-inner { display: flex; align-items: baseline; justify-content: center; gap: 4px; }
.speed-number {
  font-size: 56px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums;
  background: linear-gradient(180deg, #ffffff 0%, rgba(255,255,255,0.7) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.speed-unit { font-size: 14px; font-weight: 500; color: rgba(255,255,255,0.35); }
.speed-bar-track { width: 100%; height: 4px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 12px; overflow: hidden; }
.speed-bar-fill { height: 100%; background: linear-gradient(90deg, #00d4ff, #00ff88); border-radius: 2px; width: 0%; transition: width 0.15s ease-out; box-shadow: 0 0 8px rgba(0,212,255,0.4); }

/* ── Notch Indicator ── */
.notch-indicator { display: flex; justify-content: center; gap: 3px; margin-top: 12px; }
.notch-item {
  padding: 4px 0; font-size: 10px; font-weight: 700; border-radius: 4px;
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.2);
  text-align: center; min-width: 26px; transition: all 0.15s; user-select: none;
}
.notch-item.active.brake { background: rgba(255,60,60,0.25); color: #ff6666; box-shadow: 0 0 8px rgba(255,60,60,0.2); }
.notch-item.active.neutral { background: rgba(255,200,0,0.15); color: #ffcc00; box-shadow: 0 0 6px rgba(255,200,0,0.15); }
.notch-item.active.power { background: rgba(0,212,255,0.2); color: #00d4ff; box-shadow: 0 0 8px rgba(0,212,255,0.2); }

/* ── Boost Gauge ── */
.boost-section { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.boost-label { font-size: 10px; font-weight: 600; color: rgba(255,255,255,0.25); white-space: nowrap; }
.boost-bar-track { flex: 1; height: 3px; background: rgba(255,255,255,0.06); border-radius: 1.5px; overflow: hidden; }
.boost-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ff8800, #ff2200); border-radius: 1.5px; transition: width 0.15s; }
.boost-status { font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.2); min-width: 28px; text-align: right; transition: color 0.2s; }
.boost-status.on { color: #ff8800; text-shadow: 0 0 8px rgba(255,136,0,0.4); }
.boost-status.cooldown { color: #ff4444; }

/* ── Help Panel ── */
#help-panel { position: fixed; top: 20px; right: 20px; width: 210px; padding: 14px 16px; z-index: 20; }
.help-title { font-size: 12px; font-weight: 700; color: rgba(255,255,255,0.6); margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.help-item { font-size: 11px; line-height: 2; color: rgba(255,255,255,0.4); }

/* ── Height Label ── */
.height-label {
  position: fixed; z-index: 30; padding: 4px 10px;
  background: rgba(0,0,0,0.8); color: #00d4ff; font-size: 12px; font-weight: 600;
  border-radius: 6px; pointer-events: none; white-space: nowrap;
  border: 1px solid rgba(0,212,255,0.3);
  font-variant-numeric: tabular-nums;
}

/* ── Camera Toast ── */
.cam-toast {
  position: fixed; top: 75px; left: 50%; transform: translateX(-50%) translateY(-10px);
  padding: 8px 20px; background: rgba(0,212,255,0.15); border: 1px solid rgba(0,212,255,0.2);
  border-radius: 8px; font-size: 13px; font-weight: 600; color: #00d4ff;
  z-index: 25; opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.cam-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Stop Indicator ── */
.stop-indicator {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  padding: 14px 28px; background: rgba(0,200,100,0.15);
  border: 1px solid rgba(0,200,100,0.25); border-radius: 14px;
  font-size: 20px; font-weight: 700; color: #00ff88; z-index: 25;
  animation: stopPulse 2s ease-in-out infinite; pointer-events: none;
}
@keyframes stopPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Mobile Controls ── */
.btn-mobile-toggle { margin-top: 10px; background: rgba(0,212,255,0.1); border-color: rgba(0,212,255,0.25); color: #00d4ff; }
.btn-mobile-toggle.active { background: rgba(255,100,100,0.15); border-color: rgba(255,100,100,0.3); color: #ff8888; }
#mobile-controls {
  position: fixed; bottom: 120px; right: 20px; z-index: 25;
  display: flex; gap: 12px; padding: 12px;
}
.mobile-btn-col { display: flex; flex-direction: column; gap: 12px; justify-content: flex-end; }
.m-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05); color: #fff; font-family: inherit; font-weight: 700;
  font-size: 24px; cursor: pointer; user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.1);
  transition: transform 0.1s, background 0.1s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.m-btn small { font-size: 10px; font-weight: 500; opacity: 0.7; }
.m-btn:active { transform: scale(0.92); }
.m-btn-up { background: rgba(0,212,255,0.15); border-color: rgba(0,212,255,0.3); color: #00d4ff; }
.m-btn-down { background: rgba(255,255,255,0.08); }
.m-btn-red { background: rgba(255,60,60,0.15); border-color: rgba(255,60,60,0.3); color: #ff6666; font-size: 18px; width: 56px; height: 56px; }
.m-btn-orange { background: rgba(255,136,0,0.15); border-color: rgba(255,136,0,0.3); color: #ff8800; font-size: 14px; width: 56px; height: 56px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .side-panel { width: 200px; padding: 14px; }
  #speed-display { width: 260px; padding: 14px 18px 12px; }
  .speed-number { font-size: 42px; }
  #help-panel { display: none; }
  #mobile-controls { bottom: 100px; right: 10px; transform: scale(0.9); transform-origin: bottom right; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
