:root {
  --bg: #050505;
  --bg-soft: #050505;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f5f5;
  --muted: rgba(245, 245, 245, 0.64);
  --accent: #ffffff;
  --accent-inverse: #050505;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  --glow: rgba(255, 255, 255, 0.05);
  --grid-line: rgba(255, 255, 255, 0.03);
}

body.light {
  --bg: #eeeeee;
  --bg-soft: #eeeeee;
  --surface: rgba(255, 255, 255, 0.4);
  --surface-strong: rgba(255, 255, 255, 0.7);
  --line: rgba(0, 0, 0, 0.12);
  --line-strong: rgba(0, 0, 0, 0.2);
  --text: #050505;
  --muted: rgba(5, 5, 5, 0.62);
  --accent: #050505;
  --accent-inverse: #ffffff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.08);
  --glow: rgba(0, 0, 0, 0.04);
  --grid-line: rgba(0, 0, 0, 0.025);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  font-family: "VT323", monospace;
  letter-spacing: 0.03em;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.38;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 48%, var(--glow), transparent 36%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  padding: 18px 18px 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.topbar__brand {
  min-width: 0;
}

.brand-kicker {
  margin: 0 0 6px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.45;
  text-transform: uppercase;
}

.brand-subline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 20px;
  line-height: 1.05;
}

.topbar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stage {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 8px 0;
}

#logoCanvas {
  width: min(88vmin, 860px);
  height: min(88vmin, 860px);
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 0 18px rgba(255,255,255,0.03));
}

body.light #logoCanvas {
  filter: drop-shadow(0 0 18px rgba(0,0,0,0.03));
}

.pixel-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 11px 12px 9px;
  cursor: pointer;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  line-height: 1.3;
  text-transform: uppercase;
  transition: transform 120ms steps(2), background 120ms steps(2), opacity 120ms steps(2);
}

.pixel-btn:hover {
  transform: translateY(-1px);
}

.pixel-btn--primary {
  background: var(--accent);
  color: var(--accent-inverse);
}

.pixel-select {
  appearance: none;
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 8px 10px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  text-transform: uppercase;
}

body.light .pixel-select option {
  color: #050505;
}

.pixel-select option {
  background: var(--bg);
  color: var(--text);
}

.bottom-bar {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.bottom-bar__meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.bottom-bar__controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 9px 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.4;
  text-transform: uppercase;
}

.bar-control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.bar-control span {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: var(--muted);
  text-transform: uppercase;
}

.bar-control input[type="range"] {
  width: 100%;
  margin: 0;
}

.bar-control--timeline {
  grid-column: span 1;
}

.mobile-drawer {
  display: none;
}

.mobile-drawer__toggle {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  padding: 13px 14px 11px;
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-transform: uppercase;
}

.mobile-drawer__panel {
  display: grid;
  gap: 12px;
  padding: 12px 0 0;
}

.mobile-meta,
.mobile-actions,
.mobile-controls {
  display: grid;
  gap: 10px;
}

.mobile-actions {
  grid-template-columns: 1fr;
}

@media (max-width: 980px) {
  .bottom-bar__controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
  }

  .topbar__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .app {
    grid-template-rows: 1fr auto;
    gap: 10px;
    padding: 10px 10px 12px;
  }

  .topbar {
    display: none;
  }

  .bottom-bar {
    display: none;
  }

  .mobile-drawer {
    display: grid;
    position: sticky;
    bottom: 0;
    z-index: 10;
    border: 1px solid var(--line);
    background: rgba(8, 8, 8, 0.82);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow);
    padding: 10px;
  }

  body.light .mobile-drawer {
    background: rgba(255, 255, 255, 0.84);
  }

  .mobile-drawer:not(.is-open) .mobile-drawer__panel {
    display: none;
  }

  .stage {
    padding: 0;
  }

  #logoCanvas {
    width: min(96vw, 96vh);
    height: min(96vw, 96vh);
  }

  .meta-pill {
    font-size: 7px;
  }

  .brand-subline {
    font-size: 16px;
  }
}

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