/* Orbit Explorer 3D - Styles */

/* ============================================
   CSS Variables & Theme
   ============================================ */
:root {
  color-scheme: dark;
  --bg: #0a0a1a;
  --bg-soft: #12122a;
  --bg-panel: rgba(15, 15, 35, 0.95);
  --ink: #e8e8ff;
  --ink-muted: #8888aa;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #00ff88;
  --accent-glow: rgba(0, 255, 136, 0.4);
  --accent-2: #4488ff;
  --danger: #ff4466;
  --danger-glow: rgba(255, 68, 102, 0.4);
  --warning: #ffaa00;
  --hud-btn-bg: rgba(40, 60, 100, 0.8);
  --hud-btn-hover: rgba(60, 90, 140, 0.9);
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

select {
  font-family: inherit;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden, [hidden] {
  display: none !important;
}

/* ============================================
   Entry Screen
   ============================================ */
.entry-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a3a 0%, #0a0a1a 100%);
  padding: 20px;
  z-index: 100;
}

.entry-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.entry-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.entry-logo {
  font-size: 48px;
  line-height: 1;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

.entry-brand h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.entry-slogan {
  font-size: 14px;
  color: var(--ink-muted);
  margin-top: 4px;
}

.entry-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-label {
  font-size: 14px;
  color: var(--ink-muted);
}

.field-row select {
  flex: 1;
  max-width: 200px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}

.field-row select:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgba(68, 136, 255, 0.2);
}

.entry-instructions {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.entry-instructions h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent-2);
}

.entry-instructions ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entry-instructions li {
  font-size: 13px;
  color: var(--ink-muted);
  padding-left: 4px;
}

.btn-start {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  color: var(--bg);
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.btn-start:active {
  transform: translateY(0);
}

/* ============================================
   Game Container
   ============================================ */
.app {
  position: fixed;
  inset: 0;
  background: var(--bg);
}

.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ============================================
   HUD - Top
   ============================================ */
.top-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  z-index: 10;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  font-size: 13px;
  backdrop-filter: blur(10px);
}

.pill .label {
  color: var(--ink-muted);
}

.pill strong {
  color: var(--ink);
  font-weight: 600;
}

.level-pill strong {
  color: var(--accent-2);
}

.speed-pill strong {
  color: var(--warning);
}

.status-pill strong {
  color: var(--accent);
}

.status-pill.warning strong {
  color: var(--warning);
}

.status-pill.danger strong {
  color: var(--danger);
}

/* ============================================
   Hint Text
   ============================================ */
.hint-text {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
  backdrop-filter: blur(10px);
  z-index: 10;
  max-width: 90%;
  transition: opacity 0.3s;
}

/* ============================================
   HUD - Bottom
   ============================================ */
.bottom-hud {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  z-index: 10;
}

.cards {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 20px;
  background: var(--hud-btn-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  transition: background 0.2s, transform 0.1s;
  backdrop-filter: blur(10px);
}

.action-card:hover {
  background: var(--hud-btn-hover);
}

.action-card:active {
  transform: scale(0.95);
}

.action-card .icon {
  font-size: 20px;
}

.action-card .txt {
  font-size: 12px;
  color: var(--ink-muted);
}

/* ============================================
   Result Overlay
   ============================================ */
.result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 26, 0.85);
  backdrop-filter: blur(8px);
  z-index: 50;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.result-card {
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px 40px;
  text-align: center;
  max-width: 320px;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.result-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.result-card h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.result-card p {
  font-size: 14px;
  color: var(--ink-muted);
  margin-bottom: 24px;
}

.result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-secondary {
  padding: 12px 24px;
  background: var(--hud-btn-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: var(--hud-btn-hover);
}

.btn-primary {
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  border-radius: var(--radius);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.result-overlay.failure .result-icon {
  filter: none;
}

.result-overlay.failure h2 {
  color: var(--danger);
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 12px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink);
  backdrop-filter: blur(10px);
  z-index: 60;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .entry-brand h1 {
    font-size: 22px;
  }

  .entry-logo {
    font-size: 36px;
  }

  .pill {
    padding: 6px 10px;
    font-size: 12px;
  }

  .hint-text {
    font-size: 13px;
    padding: 10px 16px;
    bottom: 70px;
  }

  .action-card {
    padding: 10px 16px;
  }

  .action-card .icon {
    font-size: 18px;
  }

  .result-card {
    padding: 24px;
    margin: 16px;
  }

  .result-card h2 {
    font-size: 20px;
  }
}

@media (max-width: 480px) {
  .top-hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 8px;
  }

  .pill {
    padding: 5px 8px;
    font-size: 11px;
  }

  .bottom-hud {
    bottom: 8px;
    left: 8px;
    right: 8px;
  }

  .cards {
    gap: 8px;
  }

  .action-card {
    padding: 8px 12px;
  }

  .hint-text {
    bottom: 60px;
    font-size: 12px;
  }
}

/* ============================================
   Tutorial Overlay
   ============================================ */

.tutorial-overlay {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.9);
  backdrop-filter: blur(10px);
}

.tutorial-card {
  position: relative;
  background: linear-gradient(145deg, #1a1a3a 0%, #0d0d1f 100%);
  border: 1px solid rgba(100, 150, 255, 0.3);
  border-radius: 20px;
  padding: 0;
  max-width: 420px;
  width: 90%;
  box-shadow: 
    0 0 60px rgba(68, 136, 255, 0.2),
    0 20px 40px rgba(0, 0, 0, 0.5);
  animation: tutorialSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tutorialSlideIn {
  from { 
    transform: translateY(30px) scale(0.95);
    opacity: 0;
  }
  to { 
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.tutorial-header {
  padding: 20px 24px 0;
}

.tutorial-progress {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.tutorial-progress span {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink-muted);
  transition: all 0.3s ease;
}

.tutorial-progress .tutorial-step-active {
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  color: var(--bg);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.4);
}

.tutorial-content {
  padding: 24px;
  min-height: 280px;
}

.tutorial-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.tutorial-panel.active {
  display: block;
}

.tutorial-icon {
  font-size: 48px;
  text-align: center;
  margin-bottom: 16px;
}

.tutorial-panel h2 {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 12px;
  background: linear-gradient(135deg, var(--ink) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tutorial-panel p {
  font-size: 14px;
  color: var(--ink-muted);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 20px;
}

.tutorial-panel strong {
  color: var(--ink);
}

.tutorial-visual {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.tutorial-visual-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  font-size: 13px;
  color: var(--ink);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tutorial-visual-item:last-child {
  border-bottom: none;
}

.tutorial-visual-item.track-blue { color: #88ccff; }
.tutorial-visual-item.track-green { color: #00ff88; }
.tutorial-visual-item.track-red { color: #ff4466; }

.tutorial-tip {
  background: rgba(0, 255, 136, 0.1);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--accent);
  text-align: center;
  margin-top: 16px;
}

.tutorial-footer {
  padding: 16px 24px 24px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-tutorial-skip {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-tutorial-skip:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.btn-tutorial-secondary {
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tutorial-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-tutorial-secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-tutorial-primary {
  padding: 12px 32px;
  background: linear-gradient(135deg, var(--accent-2) 0%, var(--accent) 100%);
  border: none;
  border-radius: 10px;
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tutorial-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(0, 255, 136, 0.4);
}

/* Highlight elements during tutorial */
.tutorial-highlight {
  position: relative;
  z-index: 101;
  animation: tutorialPulse 1.5s ease-in-out infinite;
}

@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(0, 255, 136, 0); }
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .tutorial-card {
    margin: 16px;
    max-width: calc(100% - 32px);
  }

  .tutorial-content {
    padding: 16px;
    min-height: 240px;
  }

  .tutorial-panel h2 {
    font-size: 18px;
  }

  .tutorial-icon {
    font-size: 36px;
  }

  .tutorial-progress span {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}
