/* Tesla Roadster Flight Launch — SpaceX Rocket Package
 * Yuj's Game World — Game 08
 * High-tech SpaceX / Tesla Proving Grounds Aesthetic
 */

:root {
  --bg-dark: #0a0c12;
  --panel-bg: rgba(14, 18, 27, 0.88);
  --panel-border: rgba(255, 255, 255, 0.12);
  --accent-red: #e82127; /* Tesla Red */
  --accent-spacex: #0077ff; /* SpaceX Blue / Thruster Cyan */
  --accent-cyan: #00f0ff;
  --accent-gold: #ffbe3b;
  --accent-green: #00e676;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-sans);
  color: var(--text-primary);
}

main {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- HEADER BAR --- */
.game-header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(10, 12, 18, 0.9) 0%, rgba(10, 12, 18, 0) 100%);
  z-index: 20;
  pointer-events: none;
}

.game-header > * {
  pointer-events: auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: all 0.2s ease;
}

.back-link:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  transform: translateX(-2px);
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.game-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent-red);
  text-transform: uppercase;
}

.header-center h1 {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.sub-tag {
  font-size: 10px;
  color: var(--text-secondary);
  letter-spacing: 1px;
  font-weight: 600;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 15px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* --- CANVAS & STAGE --- */
.game-stage {
  position: relative;
  width: 100%;
  height: 100%;
  flex: 1;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* --- TOP IN-GAME TELEMETRY BAR --- */
.telemetry-bar {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 15;
  pointer-events: none;
  max-width: 95vw;
}

.telemetry-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.telemetry-chip small {
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 600;
}

.speed-chip {
  border-left: 3px solid var(--accent-red);
}

.speed-chip .value {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  min-width: 48px;
  text-align: right;
}

.psi-chip {
  border-left: 3px solid var(--accent-cyan);
}

.psi-chip .value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  color: var(--accent-cyan);
}

.psi-bar-mini {
  width: 50px;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.psi-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #0077ff, #00f0ff);
  transition: width 0.1s linear;
}

.launch-trap-chip {
  border-left: 3px solid var(--accent-gold);
  color: var(--accent-gold);
}

.launch-trap-chip .value {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.score-chip {
  border-left: 3px solid var(--accent-green);
}

/* --- CENTER ANNOUNCER / TOAST --- */
.hud-announcer {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}

.hud-announcer.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.announcer-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 20px rgba(232, 33, 39, 0.8), 0 2px 4px rgba(0, 0, 0, 0.9);
}

.announcer-sub {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-top: 4px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
}

/* --- CHRISTMAS TREE LAUNCH LIGHTS --- */
.launch-tree {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: rgba(10, 12, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7);
  z-index: 16;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.launch-tree.active {
  opacity: 1;
}

.tree-row {
  display: flex;
  gap: 12px;
}

.tree-light {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #222;
  border: 2px solid #444;
  transition: background 0.1s, box-shadow 0.1s;
}

.tree-light.staged.on {
  background: #00f0ff;
  box-shadow: 0 0 12px #00f0ff;
}

.tree-light.yellow.on {
  background: #ffcc00;
  box-shadow: 0 0 16px #ffcc00;
}

.tree-light.green.on {
  background: #00e676;
  box-shadow: 0 0 20px #00e676;
}

.tree-label {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #fff;
  text-transform: uppercase;
}

/* --- COLLAPSIBLE BOTTOM DOCK (Three.js Skill standard) --- */
.bottom-dock-container {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: min(960px, 96vw);
  width: 100%;
  pointer-events: none;
}

.bottom-dock-container.collapsed {
  transform: translateX(-50%) translateY(calc(100% - 32px));
}

.dock-toggle-btn {
  pointer-events: auto;
  background: rgba(14, 18, 27, 0.9);
  border: 1px solid var(--panel-border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 6px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

.dock-toggle-btn:hover {
  background: rgba(25, 32, 48, 0.95);
  color: #fff;
}

.dock-panel {
  pointer-events: auto;
  width: 100%;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 18px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dock-row-primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

/* Main Flight / Thruster Controls */
.action-buttons-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.5px;
  border: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

.hero-action-btn:active {
  transform: scale(0.96);
}

.hero-action-btn kbd {
  font-size: 10px;
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: 0;
}

.btn-launch {
  background: linear-gradient(135deg, #ff2a2a, #b30000);
  color: #ffffff;
  border: 1px solid rgba(255, 100, 100, 0.5);
  box-shadow: 0 4px 20px rgba(232, 33, 39, 0.5);
}

.btn-launch:hover {
  filter: brightness(1.15);
}

.btn-fly {
  background: linear-gradient(135deg, #0088ff, #0055b3);
  color: #ffffff;
  border: 1px solid rgba(100, 180, 255, 0.5);
  box-shadow: 0 4px 20px rgba(0, 136, 255, 0.4);
}

.btn-fly:hover {
  filter: brightness(1.15);
}

.btn-flip {
  background: linear-gradient(135deg, #ffaa00, #d47b00);
  color: #ffffff;
  border: 1px solid rgba(255, 200, 100, 0.5);
}

.btn-brake {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-brake:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Color & Paint Swatches */
.paint-selector-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.paint-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.paint-swatches {
  display: flex;
  gap: 6px;
}

.swatch-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

.swatch-btn:hover {
  transform: scale(1.15);
}

.swatch-btn.active {
  border-color: #fff;
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

.swatch-red { background: linear-gradient(135deg, #e82127, #8b0000); }
.swatch-white { background: linear-gradient(135deg, #f0f4f8, #c4cbd4); }
.swatch-cherry { background: linear-gradient(135deg, #581825, #2b060d); }
.swatch-carbon { background: linear-gradient(135deg, #2a2c30, #111215); }
.swatch-silver { background: linear-gradient(135deg, #d8dee9, #8892b0); }

/* Second Dock Row: Mission Tabs & Quick Toggles */
.dock-row-secondary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 10px;
}

.mission-tabs {
  display: flex;
  gap: 6px;
}

.mission-tab {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mission-tab:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.mission-tab.active {
  background: rgba(255, 255, 255, 0.22);
  border-color: var(--accent-cyan);
  color: #fff;
}

.dock-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s;
}

.quick-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* --- ON-SCREEN TOUCH CONTROLS (Mobile / Tablet) --- */
.touch-controls {
  position: absolute;
  bottom: 120px;
  left: 0;
  width: 100%;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 18;
}

.touch-cluster-left,
.touch-cluster-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.touch-dpad-row {
  display: flex;
  gap: 10px;
}

.touch-btn {
  pointer-events: auto;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: rgba(14, 18, 27, 0.75);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  touch-action: manipulation;
}

.touch-btn small {
  font-size: 8px;
  letter-spacing: 0.5px;
  opacity: 0.8;
  margin-top: -2px;
}

.touch-btn:active {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(0.92);
}

.touch-btn-launch {
  border-color: var(--accent-red);
  background: rgba(232, 33, 39, 0.4);
}

.touch-btn-fly {
  border-color: var(--accent-cyan);
  background: rgba(0, 119, 255, 0.4);
}

@media (min-width: 900px) {
  .touch-controls {
    display: none; /* Hide on desktop when keyboard is available */
  }
}

/* --- OVERLAY MODALS & RESULTS --- */
.game-overlay-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  padding: 24px 32px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.8);
  text-align: center;
  z-index: 30;
  max-width: 460px;
  width: 90%;
  display: none;
}

.game-overlay-modal.active {
  display: block;
}

.modal-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent-red);
  background: rgba(232, 33, 39, 0.15);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.modal-title {
  font-size: 24px;
  font-weight: 900;
  margin-bottom: 6px;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 20px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px;
  border-radius: 10px;
}

.stat-item span {
  display: block;
  font-size: 10px;
  color: var(--text-secondary);
  font-weight: 700;
}

.stat-item strong {
  display: block;
  font-size: 18px;
  font-family: var(--font-mono);
  color: #fff;
  margin-top: 2px;
}

.modal-btn {
  background: linear-gradient(135deg, var(--accent-red), #b30000);
  border: none;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 12px 28px;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(232, 33, 39, 0.5);
  transition: transform 0.15s;
}

.modal-btn:hover {
  transform: scale(1.04);
}

.launch-prompt-cue {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(14, 18, 27, 0.92);
  border: 1.5px solid rgba(232, 33, 39, 0.7);
  border-radius: 999px;
  padding: 12px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(232, 33, 39, 0.5), 0 0 24px rgba(0, 0, 0, 0.9);
  z-index: 22;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.launch-prompt-cue.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -36%);
}

.launch-prompt-cue span {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  color: #ffffff;
  text-transform: uppercase;
}

.launch-prompt-cue kbd {
  background: rgba(255, 255, 255, 0.22);
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
}
