:root {
  color-scheme: dark;
  --ink: #f7efe5;
  --muted: #c8b8a6;
  --panel: #181412;
  --panel-soft: #231d19;
  --line: #5b4a3f;
  --accent: #f1b24a;
  --rose: #b85463;
  --green: #7aa36f;
  --blue: #72a6b8;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: #10100f;
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100vw - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: center;
  padding: 18px 0;
}

.stage-panel {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid #3a3029;
  border-radius: 8px;
  background: #17120f;
  box-shadow: 0 24px 70px var(--shadow);
  aspect-ratio: 16 / 9;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.screen-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, 0.55);
}

.hud-panel {
  min-width: 0;
  min-height: min(720px, calc(100vh - 36px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chapter-card,
.dialogue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, #32271f);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.18);
}

.chapter-card {
  padding: 16px;
}

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

h1 {
  margin: 0 0 10px;
  color: #fff9ef;
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  line-height: 1.08;
  letter-spacing: 0;
}

#objective {
  min-height: 3.6em;
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.35;
}

.dialogue-card {
  min-height: 210px;
  padding: 16px;
}

.speaker {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dialogue {
  margin: 0;
  color: #f6eadc;
  font-size: 1.04rem;
  line-height: 1.45;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.icon-button,
.mobile-pad button {
  min-height: 50px;
  border: 1px solid #665144;
  border-radius: 8px;
  background: var(--panel-soft);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.icon-button {
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}

.icon-button:hover,
.mobile-pad button:hover {
  border-color: var(--accent);
  background: #2d241e;
}

.icon-button:active,
.mobile-pad button:active {
  transform: translateY(1px);
}

.mobile-pad {
  display: none;
  grid-template-columns: repeat(3, 54px);
  grid-template-areas:
    ". up ."
    "left down right";
  gap: 8px;
  justify-content: center;
  margin-top: auto;
}

.mobile-pad [data-dir="up"] {
  grid-area: up;
}

.mobile-pad [data-dir="left"] {
  grid-area: left;
}

.mobile-pad [data-dir="down"] {
  grid-area: down;
}

.mobile-pad [data-dir="right"] {
  grid-area: right;
}

.dream-image-overlay {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  background: rgba(16, 12, 10, 0.85);
  border: 2px solid var(--accent);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  transition: opacity 300ms ease, transform 300ms cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform: scale(0.92);
  pointer-events: none;
}

.dream-image-overlay.active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.dream-image-overlay img {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px var(--shadow);
  object-fit: contain;
}

@media (max-width: 920px) {
  .game-shell {
    width: min(100vw - 20px, 760px);
    grid-template-columns: 1fr;
    align-content: start;
    padding: 10px 0 18px;
  }

  .hud-panel {
    min-height: auto;
  }

  .dialogue-card {
    min-height: 150px;
  }

  .mobile-pad {
    display: grid;
  }
}

@media (max-width: 560px) {
  .game-shell {
    width: 100%;
    padding: 0 0 12px;
    gap: 10px;
  }

  .stage-panel {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  .hud-panel {
    padding: 0 10px;
  }

  .chapter-card,
  .dialogue-card,
  .icon-button,
  .mobile-pad button {
    border-radius: 6px;
  }
}
