:root {
  --bg-top: #0f1a1c;
  --bg-bottom: #141e20;
  --panel: rgba(18, 26, 28, 0.96);
  --dock: rgba(22, 32, 34, 0.94);
  --border: rgba(80, 130, 120, 0.22);
  --ink: #d8eae8;
  --muted: #7eaaa6;
  --teal-900: #1a8a7a;
  --teal-700: #22a090;
  --focus: #4db8ff;
  --focus-glow: #ffd166;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

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

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(ellipse at 30% 0%, rgba(180, 100, 20, 0.18), transparent 40%),
    radial-gradient(ellipse at 80% 100%, rgba(10, 60, 70, 0.35), transparent 45%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--ink);
  font-family: Roboto, Arial, sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-glow);
}

#sim-app {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

#stage-panel {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

#canvas-frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at 50% 2%, rgba(220, 140, 40, 0.38), transparent 28%),
    radial-gradient(ellipse at 50% 100%, rgba(20, 40, 50, 0.55), transparent 38%),
    linear-gradient(180deg, #1a2830 0%, #0e1d20 60%, #0a1510 100%);
  box-shadow: inset 0 0 0 1px rgba(60, 110, 100, 0.18);
}

#canvas-frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(200, 130, 40, 0.06), transparent 18%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.14), transparent 20%);
}

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

#time-chip {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 14px;
  background: rgba(10, 20, 24, 0.72);
  border: 1px solid rgba(80, 140, 130, 0.22);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
}

.hud-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud-value {
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
}

.hud-value--sm {
  font-size: 17px;
}

/* Instructional interaction hints */
.interaction-hint {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(10, 20, 24, 0.64);
  border: 1px solid rgba(100, 200, 190, 0.28);
  backdrop-filter: blur(8px);
  color: rgba(180, 230, 225, 0.90);
  font-size: 12px;
  font-weight: 600;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 10;
}

.interaction-hint--vertical {
  flex-direction: column;
  padding: 10px 8px;
  gap: 4px;
}

.interaction-hint.hint-hidden {
  opacity: 0;
  pointer-events: none;
}

.interaction-hint.hint-used {
  opacity: 0;
}

/* hint-visible must come after hint-used so hover overrides it */
.interaction-hint.hint-visible {
  opacity: 1;
}

.hint-arrow {
  font-size: 14px;
  line-height: 1;
}

.hint-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

#orbit-hint {
  /* positioned dynamically via JS */
  transform: translateX(-50%);
}

#lamp-hint {
  /* positioned dynamically via JS */
  transform: translate(-100%, -50%);
}

#lid-hint {
  /* positioned dynamically via JS */
  transform: translateX(-50%);
}

/* Controls dock: vegetation + speed */

#controls-dock {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.control-card {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(93, 133, 144, 0.16);
  background: var(--dock);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.slider-row {
  display: grid;
  gap: 8px;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slider-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.slider-inline-value {
  min-width: 52px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(80, 140, 130, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}

.slider-track-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.track-end-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

input[type='range'] {
  width: 100%;
  min-width: 0;
  margin: 0;
  height: 4px;
  accent-color: var(--teal-900);
}

.speed-card {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
}

.speed-btns {
  display: flex;
  gap: 4px;
}

.speed-btn {
  flex: 1;
  min-height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(80, 140, 130, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  transition: background 0.15s, color 0.15s;
}

.speed-btn.active,
.speed-btn[aria-pressed="true"] {
  background: var(--teal-900);
  color: #ffffff;
  border-color: var(--teal-700);
}

.speed-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
}

#info-dialog {
  width: min(600px, calc(100vw - 32px));
  max-width: 600px;
  max-height: calc(100vh - 56px);
  padding: 0;
  border: none;
  border-radius: 16px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.32);
  overflow: hidden;
}

#info-dialog::backdrop {
  background: rgba(15, 23, 42, 0.4);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #004445;
  color: #ffffff;
}

.dialog-header h2 {
  margin: 0;
  font-size: 16px;
  color: inherit;
}

#dialog-close-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: #004445;
  color: #ffffff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dialog-close-btn:hover {
  background: rgba(0, 68, 69, 0.80);
}

.dialog-tabs {
  display: flex;
  border-bottom: 2px solid #e5eae9;
  background: #f8fbfb;
}

.tab-btn {
  flex: 1;
  min-height: 44px;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.tab-btn.active {
  color: #004445;
  border-bottom-color: #004445;
}

.tab-btn:hover {
  color: #004445;
}

[role="tabpanel"] {
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding: 16px 20px;
  font-size: 14px;
  line-height: 1.6;
  color: #1a2a2a;
}

[role="tabpanel"] h3 {
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #004445;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[role="tabpanel"] h3:first-child {
  margin-top: 0;
}

[role="tabpanel"] p,
[role="tabpanel"] ul {
  margin: 0 0 8px;
}

[role="tabpanel"] ul {
  padding-left: 18px;
}

[role="tabpanel"] li {
  font-size: 14px;
  line-height: 1.6;
  color: #1a2a2a;
  margin-bottom: 3px;
}

[role="tabpanel"] code {
  font-family: monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 20px;
  background: #f8fbfb;
  border-top: 1px solid #e5eae9;
}

.dialog-close-footer {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: #004445;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
}

.dialog-close-footer:hover {
  background: #006667;
}

@media (max-width: 560px) {
  #sim-app {
    padding: 8px;
  }

  #stage-panel {
    gap: 8px;
    padding: 8px;
  }

  #canvas-frame {
    min-height: 250px;
    border-radius: 18px;
  }

  #time-chip {
    padding: 6px 10px;
    top: 10px;
    left: 10px;
  }

  .hud-label {
    font-size: 9px;
  }

  .hud-value {
    font-size: 18px;
  }

  .hud-value--sm {
    font-size: 12px;
  }

  .control-card {
    padding: 8px 10px;
    border-radius: 16px;
  }

  .slider-row {
    gap: 6px;
  }

  .slider-label {
    font-size: 11px;
  }

  .slider-inline-value {
    min-width: 48px;
    font-size: 10px;
    padding: 2px 7px;
  }

  .slider-track-row {
    gap: 6px;
  }

  .track-end-label {
    font-size: 9px;
  }

  input[type='range'] {
    height: 3px;
  }
}
