:root {
  --bg: #050505;
  --panel: rgba(8, 8, 8, 0.8);
  --fg: #f5f1e8;
  --muted: #9c9385;
  --accent: #f2dbc1;
  --glow: rgba(255, 243, 221, 0.18);
  --frame: rgba(255, 244, 229, 0.12);
  --theme-flash: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 236, 214, 0.08), transparent 40%),
    radial-gradient(circle at bottom right, rgba(255, 190, 120, 0.06), transparent 32%),
    linear-gradient(180deg, #090909 0%, #030303 100%);
  color: var(--fg);
  font-family: "Consolas", "Menlo", "Monaco", monospace;
  transition:
    color 320ms ease,
    background 420ms ease;
}

body {
  min-height: 100vh;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 28%, var(--theme-flash), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.03), transparent 60%);
  opacity: 0;
  transform: scale(0.985);
  transition:
    opacity 420ms ease,
    transform 520ms ease;
  z-index: 5;
}

body.theme-transition::before {
  opacity: 0.95;
  transform: scale(1.035);
}

body.stage-expanded {
  overflow: hidden;
}

body.stage-expanded .topbar,
body.stage-expanded .footer-note {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-12px);
}

.app-shell {
  width: min(2200px, 100%);
  margin: 0 auto;
}

.topbar,
.footer-note,
.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--frame);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  transition:
    background 320ms ease,
    border-color 320ms ease,
    box-shadow 420ms ease,
    color 320ms ease;
}

.topbar {
  position: relative;
  z-index: 80;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 20px 22px;
  border-radius: 18px;
  transition: opacity 180ms ease, transform 180ms ease;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 11px;
}

h1 {
  margin: 0;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1;
  max-width: 10ch;
  text-wrap: balance;
}

.terminal-heading {
  display: grid;
  gap: 4px;
  line-height: 0.95;
  max-width: 12ch;
}

.terminal-heading > span {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.prompt-mark {
  opacity: 0.22;
  font-size: 0.62em;
  transform: translateY(-0.08em);
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  border: 1px solid var(--frame);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  padding: 12px 16px;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 260ms ease,
    background 260ms ease,
    color 260ms ease,
    box-shadow 320ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

button.is-accent {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

button.is-accent:hover {
  border-color: color-mix(in srgb, var(--accent) 85%, transparent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.settings-menu {
  position: relative;
  z-index: 120;
}

.settings-menu summary {
  list-style: none;
  border: 1px solid var(--frame);
  background: rgba(255, 255, 255, 0.04);
  color: var(--fg);
  padding: 12px 16px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

.settings-menu summary::-webkit-details-marker {
  display: none;
}

.settings-menu[open] summary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}

.settings-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--frame);
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  z-index: 140;
}

.setting-row {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row-inline {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.setting-row input[type="range"] {
  width: 100%;
}

.setting-row input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--frame);
  border-radius: 10px;
  background: transparent;
}

.setting-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.settings-reset {
  width: 100%;
  margin-top: 6px;
}

.stage-wrap {
  position: relative;
  z-index: 20;
  margin-top: 18px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--frame);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 30px 80px rgba(0, 0, 0, 0.45);
}

.stage-wrap.is-expanded {
  position: fixed;
  inset: 18px;
  z-index: 40;
  margin-top: 0;
  border-radius: 28px;
  background: rgba(0, 0, 0, 0.18);
}

.stage-wrap.is-expanded #asciiCanvas {
  height: 100%;
}

.stage-wrap.is-expanded .overlay {
  inset: 18px;
}

#asciiCanvas {
  width: 100%;
  height: min(82vh, 1400px);
  display: block;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.03), transparent 58%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 30%),
    #060606;
}

.overlay {
  position: absolute;
  inset: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.panel {
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 12px;
  color: var(--muted);
}

.panel-right {
  text-align: right;
}

.footer-note {
  margin-top: 14px;
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 13px;
  transition: opacity 180ms ease, transform 180ms ease;
}

body.theme-amber {
  --bg: #120a02;
  --panel: rgba(20, 10, 2, 0.78);
  --fg: #ffd49d;
  --muted: #be9566;
  --accent: #ffb24b;
  --glow: rgba(255, 166, 66, 0.18);
  --frame: rgba(255, 193, 111, 0.18);
  --theme-flash: rgba(255, 167, 71, 0.2);
}

body.theme-blood {
  --bg: #100405;
  --panel: rgba(18, 4, 5, 0.78);
  --fg: #ffd7d8;
  --muted: #d48b8f;
  --accent: #ff6d72;
  --glow: rgba(255, 109, 114, 0.18);
  --frame: rgba(255, 146, 150, 0.16);
  --theme-flash: rgba(255, 90, 98, 0.22);
}

body.theme-mint {
  --bg: #04100d;
  --panel: rgba(4, 17, 13, 0.8);
  --fg: #d7fff3;
  --muted: #83c9b5;
  --accent: #42f2c8;
  --glow: rgba(66, 242, 200, 0.18);
  --frame: rgba(116, 255, 222, 0.16);
  --theme-flash: rgba(66, 242, 200, 0.2);
}

body.theme-cobalt {
  --bg: #040813;
  --panel: rgba(7, 12, 28, 0.82);
  --fg: #d9e6ff;
  --muted: #8da5d6;
  --accent: #6ea3ff;
  --glow: rgba(110, 163, 255, 0.18);
  --frame: rgba(148, 188, 255, 0.16);
  --theme-flash: rgba(110, 163, 255, 0.2);
}

body.theme-violet {
  --bg: #0d0612;
  --panel: rgba(16, 8, 20, 0.82);
  --fg: #f1dcff;
  --muted: #c09cd8;
  --accent: #d890ff;
  --glow: rgba(216, 144, 255, 0.18);
  --frame: rgba(230, 176, 255, 0.16);
  --theme-flash: rgba(216, 144, 255, 0.2);
}

body.theme-ice {
  --bg: #051015;
  --panel: rgba(7, 17, 23, 0.82);
  --fg: #dcf8ff;
  --muted: #8cb9c7;
  --accent: #7cecff;
  --glow: rgba(124, 236, 255, 0.18);
  --frame: rgba(160, 244, 255, 0.16);
  --theme-flash: rgba(124, 236, 255, 0.2);
}

@media (max-width: 900px) {
  body {
    padding: 12px;
  }

  .stage-wrap.is-expanded {
    inset: 12px;
    border-radius: 20px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .settings-panel {
    right: auto;
    left: 0;
  }

  .overlay {
    inset: 10px;
    flex-direction: column;
    gap: 8px;
  }

  .panel-right {
    text-align: left;
  }
}
