:root {
  color-scheme: dark;
  --bg: #030612;
  --bg-2: #071327;
  --panel: rgba(5, 12, 28, 0.78);
  --panel-strong: rgba(8, 18, 38, 0.92);
  --line: rgba(185, 220, 255, 0.2);
  --text: #f6edd3;
  --muted: #aeb9cb;
  --cyan: #8fe8ff;
  --gold: #f5c15a;
  --danger: #ff6978;
  --shadow: 0 18px 54px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 22% 18%, rgba(23, 76, 111, 0.28), transparent 28%),
    radial-gradient(circle at 78% 70%, rgba(105, 55, 94, 0.2), transparent 30%),
    linear-gradient(150deg, #020410 0%, #061020 55%, #02050c 100%);
}

#orbitCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100dvh;
  touch-action: none;
  user-select: none;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 5;
  display: grid;
  gap: 6px;
  max-width: min(360px, calc(100vw - 88px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(4, 10, 24, 0.52);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hud__key {
  font-size: clamp(14px, 1.8vw, 18px);
  font-weight: 720;
}

.hud__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.hud__meta span {
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.panel-toggle {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 7;
  min-width: 68px;
  padding: 0 14px;
  background: rgba(12, 26, 53, 0.72);
  backdrop-filter: blur(12px);
}

.entry {
  position: absolute;
  right: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: max(14px, env(safe-area-inset-left));
  z-index: 6;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  width: min(300px, calc(100vw - 28px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(5, 14, 31, 0.78), rgba(5, 12, 25, 0.62));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.entry.is-hidden {
  pointer-events: none;
  opacity: 0;
  transform: translateY(16px);
}

.entry__copy {
  display: grid;
  gap: 6px;
}

.eyebrow {
  margin: 0;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.95;
  letter-spacing: 0;
}

.entry__copy p:not(.eyebrow),
.entry__status {
  color: var(--muted);
  font-size: 15px;
}

.entry__actions {
  display: grid;
  gap: 10px;
  justify-items: stretch;
  min-width: 0;
}

.launch-button {
  width: 100%;
  min-width: 0;
  padding: 0 22px;
  border-color: rgba(245, 193, 90, 0.66);
  color: #111723;
  font-weight: 800;
  background: linear-gradient(180deg, #ffe6a1, var(--gold));
}

.load-meter {
  overflow: hidden;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.load-meter__bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  transition: width 140ms ease;
}

.settings {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 8;
  display: grid;
  align-content: start;
  gap: 16px;
  width: min(360px, calc(100vw - 28px));
  height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) 18px;
  border-left: 1px solid var(--line);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  transform: translateX(102%);
  transition: transform 220ms ease;
  overflow: auto;
}

.settings.is-open {
  transform: translateX(0);
}

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

.settings h2 {
  font-size: 20px;
  letter-spacing: 0;
}

.settings h3 {
  color: #dfefff;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: uppercase;
}

.plain-button {
  min-width: 72px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.06);
}

.control-group {
  display: grid;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.control-row {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--muted);
  font-size: 14px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented button[aria-pressed="true"] {
  border-color: rgba(143, 232, 255, 0.6);
  background: rgba(143, 232, 255, 0.16);
}

.play-toggle {
  width: 100%;
  font-weight: 680;
}

.play-toggle[aria-pressed="true"] {
  border-color: rgba(245, 193, 90, 0.66);
  background: rgba(245, 193, 90, 0.16);
}

select#sleepTimer {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

/* #mediaSink is used only when the audio engine chooses the media-element sink
   for non-Android controls/background behavior. Android and iframes use direct
   Web Audio output for the most stable foreground playback. */

.about {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

@media (max-width: 720px) {
  .hud {
    right: max(88px, env(safe-area-inset-right));
    max-width: none;
  }

  .entry {
    grid-template-columns: 1fr;
    align-items: stretch;
    right: max(14px, env(safe-area-inset-right));
    width: auto;
    padding: 14px;
  }

  h1 {
    font-size: clamp(32px, 13vw, 56px);
  }

  .launch-button {
    width: 100%;
    min-width: 0;
  }

  .settings {
    top: auto;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: min(78dvh, 620px);
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 8px 8px 0 0;
    transform: translateY(102%);
  }

  .settings.is-open {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
}
