:root {
  color-scheme: dark;
  --bg: #101014;
  --panel: #191a21;
  --panel-strong: #242631;
  --ink: #f4f0dc;
  --muted: #b7b1a2;
  --green: #6df2a8;
  --pink: #ff6b9a;
  --gold: #ffd166;
  --cyan: #60d5ff;
  --purple: #9b7bff;
  --danger: #ff8b6e;
  --shadow: rgba(0, 0, 0, 0.45);
  --font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(180deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(180deg, #101014 0%, #18151c 46%, #11151b 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.stage {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(500px, 1.12fr);
  gap: 20px;
  align-items: start;
  min-height: min(900px, calc(100vh - 64px));
}

.pixel-scene,
.game-panel,
.gallery,
.final-card,
.debug-panel {
  border: 4px solid #07080c;
  box-shadow: 0 24px 0 #07080c, 0 30px 40px var(--shadow);
}

.pixel-scene {
  position: sticky;
  top: 32px;
  display: grid;
  place-items: center;
  align-self: start;
  aspect-ratio: 1448 / 1086;
  min-height: 0;
  background: #11151b;
  overflow: hidden;
}

.workshop-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}

.floating-hearts span {
  position: absolute;
  width: 28px;
  height: 24px;
  background:
    linear-gradient(var(--pink), var(--pink)) 4px 0 / 8px 4px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 16px 0 / 8px 4px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 0 4px / 28px 12px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 4px 16px / 20px 4px no-repeat,
    linear-gradient(var(--pink), var(--pink)) 8px 20px / 12px 4px no-repeat;
  filter: drop-shadow(0 0 8px rgba(255, 107, 154, 0.55));
  animation: float-heart 3.6s steps(5, end) infinite;
}

.floating-hearts span:nth-child(1) {
  left: 18px;
  bottom: 22px;
}

.floating-hearts span:nth-child(2) {
  right: 34px;
  bottom: 36px;
  animation-delay: 0.8s;
}

.floating-hearts span:nth-child(3) {
  left: 22%;
  top: 28px;
  animation-delay: 1.6s;
}

.game-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
  height: clamp(680px, calc(100vh - 64px), 900px);
  min-height: 0;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(255, 107, 154, 0.1), transparent 34%),
    rgba(25, 26, 33, 0.96);
}

.topbar,
.gallery-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1,
h2 {
  margin-bottom: 0;
  font-size: 2.4rem;
  line-height: 1;
}

.subtitle {
  max-width: 42rem;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.toolbar {
  display: flex;
  gap: 10px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--ink);
  background: var(--panel-strong);
  border: 3px solid #07080c;
  box-shadow: 0 5px 0 #07080c;
}

.icon-button:hover,
.icon-button:focus-visible,
.suggestions button:hover,
.suggestions button:focus-visible {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #07080c;
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.icon-button.is-active {
  background: var(--pink);
  color: #07080c;
}

.status-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.status-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: max-content;
  padding: 4px 7px;
  background: #11151b;
  border: 2px solid #07080c;
}

.status-item span {
  color: var(--muted);
  font-size: 0.64rem;
}

.status-item strong {
  color: var(--green);
  font-size: 0.86rem;
}

.terminal-wrap {
  height: 100%;
  min-height: 520px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #090b0f;
  border: 4px solid #07080c;
  overflow: hidden;
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  background: #2e3440;
  border-bottom: 4px solid #07080c;
}

.terminal-titlebar span {
  width: 12px;
  height: 12px;
  background: var(--pink);
  border: 2px solid #07080c;
}

.terminal-titlebar span:nth-child(2) {
  background: var(--gold);
}

.terminal-titlebar span:nth-child(3) {
  background: var(--green);
}

.terminal-titlebar p {
  margin: 0 0 0 auto;
  color: var(--muted);
  font-size: 0.78rem;
}

.terminal-output {
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--green);
  text-shadow: 0 0 8px rgba(109, 242, 168, 0.28);
  scrollbar-color: var(--pink) #10141b;
  scrollbar-width: thin;
}

.terminal-output::-webkit-scrollbar {
  width: 12px;
}

.terminal-output::-webkit-scrollbar-track {
  background: #10141b;
  border-left: 3px solid #07080c;
}

.terminal-output::-webkit-scrollbar-thumb {
  background: var(--pink);
  border: 3px solid #07080c;
}

.terminal-output p {
  margin: 0 0 7px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.output-block {
  margin-bottom: 12px;
}

.output-block.warn {
  color: var(--danger);
}

.output-block.success {
  color: var(--cyan);
}

.output-block.secret {
  color: var(--pink);
}

.command-line {
  color: var(--gold);
}

.terminal-input-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-top: 4px solid #07080c;
  background: #10141b;
}

.prompt {
  color: var(--gold);
  white-space: nowrap;
}

.terminal-input-row input {
  min-width: 0;
  color: var(--ink);
  background: #090b0f;
  border: 3px solid #303746;
  padding: 8px 10px;
  outline: none;
}

.terminal-input-row input:focus {
  border-color: var(--gold);
}

.suggestions button {
  color: #07080c;
  background: var(--gold);
  border: 3px solid #07080c;
  box-shadow: 0 5px 0 #07080c;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.suggestions button {
  min-height: 28px;
  padding: 4px 8px;
  color: var(--muted);
  background: transparent;
  border: 2px solid #303746;
  box-shadow: none;
  font-size: 0.72rem;
  overflow-wrap: anywhere;
}

.suggestions button:hover,
.suggestions button:focus-visible {
  color: var(--gold);
  background: #151923;
  box-shadow: none;
  transform: none;
}

.gallery {
  margin-top: 48px;
  padding: 20px;
  background: #171820;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.memory-card,
.final-card {
  background: #222530;
  border: 4px solid #07080c;
}

.memory-card {
  min-height: 190px;
  padding: 16px;
  animation: rise 420ms steps(4, end) both;
  animation-delay: var(--delay);
}

.memory-badge {
  display: inline-block;
  margin-bottom: 12px;
  padding: 5px 8px;
  color: #07080c;
  background: var(--pink);
  border: 3px solid #07080c;
  box-shadow: 0 4px 0 #07080c;
  font-size: 0.72rem;
}

.memory-card p {
  color: var(--muted);
  line-height: 1.5;
}

.memory-card code {
  display: inline-block;
  max-width: 100%;
  color: var(--green);
  overflow-wrap: anywhere;
}

.final-card {
  margin-top: 16px;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 107, 154, 0.18), transparent 36%),
    #242631;
}

.final-card p:last-child {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 1.05rem;
  line-height: 1.6;
}

.debug-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  width: min(360px, calc(100vw - 36px));
  padding: 14px;
  background: #242631;
}

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

.debug-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.debug-panel code {
  color: var(--green);
}

@keyframes blink {
  50% {
    opacity: 0.25;
  }
}

@keyframes pulse {
  50% {
    transform: scale(1.08);
  }
}

@keyframes float-heart {
  50% {
    transform: translateY(-16px);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .stage {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .pixel-scene {
    position: relative;
    top: auto;
    width: min(100%, 720px);
    margin: 0 auto;
  }

  .memory-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding: 10px 0 30px;
  }

  .stage {
    min-height: auto;
    gap: 14px;
  }

  .game-panel {
    height: auto;
    min-height: auto;
    padding: 12px;
  }

  .terminal-wrap {
    height: 540px;
    min-height: 0;
  }

  .topbar,
  .gallery-heading {
    align-items: flex-start;
  }

  h1,
  h2 {
    font-size: 1.8rem;
  }

  .status-grid,
  .suggestions,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .terminal-input-row {
    grid-template-columns: 1fr;
  }

  .prompt {
    grid-column: 1 / -1;
  }

  .pixel-scene {
    width: 100%;
  }

}

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