:root {
  --bg: #070707;
  --fg: #efefef;
  --muted: rgba(239, 239, 239, 0.48);
  --line: rgba(239, 239, 239, 0.14);
  --pill-bg: rgba(16, 16, 16, 0.72);
  --pill-hover: rgba(239, 239, 239, 0.12);
  --pill-active-bg: #efefef;
  --pill-active-fg: #070707;
}

body.light-theme {
  --bg: #f2ede2;
  --fg: #181614;
  --muted: rgba(24, 22, 20, 0.52);
  --line: rgba(24, 22, 20, 0.16);
  --pill-bg: rgba(242, 237, 226, 0.78);
  --pill-hover: rgba(24, 22, 20, 0.08);
  --pill-active-bg: #181614;
  --pill-active-fg: #f2ede2;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "IBM Plex Mono", "SFMono-Regular", ui-monospace, Menlo, Monaco, Consolas, monospace;
  overflow: hidden;
  transition: background-color 0.28s ease, color 0.28s ease;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  pointer-events: none;
}

.topbar a, .topbar .meta {
  pointer-events: auto;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  text-decoration: none;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: var(--pill-bg);
  backdrop-filter: blur(8px);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.back-link:hover {
  background: var(--pill-hover);
  border-color: var(--fg);
}

.meta {
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.meta .title {
  color: var(--fg);
  font-weight: 600;
}

.meta .sub {
  color: var(--muted);
  margin-top: 2px;
  font-size: 10px;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 20px 76px;
}

.stage canvas {
  display: block;
  max-width: min(84vmin, 800px);
  max-height: min(84vmin, 800px);
  width: auto !important;
  height: auto !important;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.controls {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: calc(100vw - 32px);
}

.ctrl-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--pill-bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 11px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ctrl-btn kbd {
  font-family: inherit;
  font-size: 10px;
  opacity: 0.55;
  border: 1px solid currentColor;
  padding: 0 4px;
  line-height: 1.4;
}

.ctrl-btn:hover {
  background: var(--pill-hover);
  border-color: var(--fg);
}

.ctrl-btn.active {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg);
  border-color: var(--pill-active-bg);
}

@media (max-width: 600px) {
  .topbar {
    padding: 12px 14px;
  }
  .controls {
    bottom: 12px;
    gap: 6px;
  }
  .ctrl-btn {
    padding: 6px 9px;
    font-size: 10px;
  }
  .ctrl-btn kbd {
    display: none;
  }
}
