:root {
  color-scheme: dark;
  --bg: #071126;
  --panel: rgba(10, 24, 50, .9);
  --panel-2: rgba(7, 17, 36, .82);
  --line: rgba(255, 220, 134, .36);
  --cream: #fff4cf;
  --muted: #aab8d4;
  --gold: #ffd76a;
  --orange: #f17f4d;
  --blue: #132d58;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(220, 93, 72, .2), transparent 42%),
    linear-gradient(180deg, #061023 0%, #091734 52%, #030714 100%);
  color: var(--cream);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #1d3d73, #0f2348);
  color: var(--cream);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 8px 20px rgba(0, 0, 0, .22);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

a {
  color: var(--cream);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.topbar nav {
  display: flex;
  gap: 12px;
  font-size: 14px;
}

.topbar button {
  padding: 0 14px;
}

.game {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 12px;
}

.stage-panel,
.side-panel,
dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}

.stage-panel {
  padding: 12px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: .16em;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(22px, 5vw, 34px);
}

h2 {
  margin-bottom: 10px;
  font-size: 18px;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 7px;
  font-size: 14px;
}

.stats span {
  padding: 6px 9px;
  border: 1px solid rgba(255, 220, 134, .28);
  border-radius: 999px;
  background: rgba(0, 0, 0, .18);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px solid rgba(255, 220, 134, .28);
  border-radius: 12px;
  background: #071126;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-wrap {
  position: relative;
}

.canvas-memory {
  position: absolute;
  left: 50%;
  top: 73%;
  width: min(72%, 360px);
  transform: translate(-50%, -50%);
  background: rgba(10, 24, 50, .72);
  border-color: rgba(255, 244, 207, .52);
  backdrop-filter: blur(3px);
}

.canvas-memory::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 18px;
  background: radial-gradient(circle, rgba(255, 215, 106, .2), transparent 68%);
  pointer-events: none;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.primary {
  min-height: 58px;
  font-size: 18px;
}

.night {
  min-height: 52px;
  background: linear-gradient(180deg, #51305e, #142752);
}

.status {
  min-height: 1.5em;
  margin: 10px 2px 0;
  color: var(--muted);
}

.upgrade-list {
  display: grid;
  gap: 8px;
}

.upgrade {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255, 220, 134, .2);
  border-radius: 12px;
  background: var(--panel-2);
}

.upgrade strong {
  display: block;
}

.upgrade small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.35;
}

.upgrade button {
  padding: 0 10px;
}

.progress-box ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.75;
}

.progress-box li.done {
  color: var(--gold);
}

dialog {
  width: min(760px, calc(100% - 24px));
  color: var(--cream);
  padding: 14px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, .68);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.album-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.album-card {
  padding: 10px;
  border: 1px solid rgba(255, 220, 134, .22);
  border-radius: 12px;
  background: rgba(0, 0, 0, .18);
}

.album-card canvas {
  margin-top: 8px;
}

.album-card img {
  display: block;
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(255, 220, 134, .2);
  border-radius: 10px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.album-card button {
  width: 100%;
  margin-top: 8px;
}

.album-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 820px) {
  .shell {
    padding: 8px;
  }

  .game {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 8px 0;
    background: rgba(7, 17, 38, .92);
    backdrop-filter: blur(8px);
  }

  .title-row {
    display: block;
  }

  .stats {
    justify-content: start;
    margin-top: 8px;
  }

  .side-panel {
    padding-bottom: env(safe-area-inset-bottom);
  }
}
