/* StraightUpQuest — Zombie Ridder Stellar Outpost.
   Modern dark sci-fi: amber emergency warmth over deep space blue. Not retro. */

:root {
  --bg: #0a0e18;
  --bg-deep: #060912;
  --panel: #101828;
  --panel-2: #0d1424;
  --line: #223052;
  --line-soft: #1a2540;
  --text: #dbe4f5;
  --muted: #8fa0c0;
  --amber: #f2b25c;
  --amber-strong: #ffd08a;
  --teal: #6fe3c8;
  --red: #e2604f;
  --green: #7ed491;
  --shadow: 0 18px 50px rgb(0 0 0 / 45%);
  --radius: 16px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --mono: ui-monospace, 'Cascadia Code', 'SF Mono', Menlo, Consolas, monospace;
  --sans: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 700px at 75% -10%, #14213d 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 110%, #101b33 0%, transparent 55%), var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
}

/* One screen, no page scroll: only the log (and long cutscene text) scroll. */
.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px clamp(10px, 2.5vw, 24px) 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100dvh;
  min-height: 520px;
}

.main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1 1 0;
  min-height: 0;
}

/* ── update banner ─────────────────────────────────────────── */

.header,
.statusbar,
.footer {
  flex: 0 0 auto;
}

.update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(90deg, #1a2440, #14203a);
}

.update-banner[hidden] {
  display: none;
}

/* ── header ────────────────────────────────────────────────── */

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  border-radius: 10px;
  box-shadow: 0 4px 18px rgb(111 227 200 / 15%);
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ── buttons ───────────────────────────────────────────────── */

.btn {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s,
    transform 0.05s;
}

.btn:hover {
  border-color: var(--amber);
  background: #16213a;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background: linear-gradient(180deg, #f7c274, #eaa64e);
  border-color: #f2b25c;
  color: #241708;
  font-weight: 650;
}

.btn.primary:hover {
  background: linear-gradient(180deg, #ffd08a, #f2b25c);
}

.btn.icon {
  padding: 8px 10px;
  font-size: 1.05rem;
  line-height: 1;
}

/* ── scene ─────────────────────────────────────────────────── */

.scene-card {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-deep);
  box-shadow: var(--shadow);
  /* Wide screens must not let the art eat the whole viewport: the log needs room. */
  max-width: min(100%, calc(44dvh * 16 / 9));
  margin-inline: auto;
  width: 100%;
  flex: 0 0 auto;
}

#scene,
.intro-art {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Cutscenes take over the whole viewport: art on top, text and continue below. */
.cutscene {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(4, 6, 12, 0.96);
  backdrop-filter: blur(8px);
  z-index: 40;
  padding: 4dvh 6vw 3dvh;
}

.cutscene[hidden] {
  display: none;
}

#cutscene-art {
  display: block;
  width: min(100%, calc(54dvh * 16 / 9));
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #04060c;
  object-fit: contain;
}

.cutscene-body {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cutscene-text {
  flex: 1 1 auto;
  min-height: 4em;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 1.04rem;
  line-height: 1.65;
  white-space: pre-line;
  padding-right: 6px;
}

.cutscene-body .btn {
  align-self: center;
}

/* ── status bar ────────────────────────────────────────────── */

.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel-2);
  font-size: 0.92rem;
}

.room-name {
  font-weight: 650;
  color: var(--amber-strong);
}

.area-badge {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  border: 1px solid #245a4e;
  background: #0d1f1c;
  padding: 2px 8px;
  border-radius: 999px;
}

.status-right {
  margin-left: auto;
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ── inventory strip ───────────────────────────────────────── */

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel-2);
  flex: 0 0 auto;
  max-height: 96px;
  overflow-y: auto;
}

.inventory[hidden] {
  display: none;
}

.slot {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--panel);
  cursor: help;
}

.slot canvas {
  width: 40px;
  height: 40px;
  display: block;
}

.slot .slot-label {
  font-size: 0.85rem;
  color: var(--text);
}

/* ── story log ─────────────────────────────────────────────── */

.log {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: var(--panel-2);
  padding: 14px 18px;
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 120px;
  font-family: var(--serif);
  font-size: 1.02rem;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: #2a3a61 transparent;
}

.log p {
  margin: 0 0 0.65em;
  overflow-wrap: break-word;
}

.log p:last-child {
  margin-bottom: 0;
}

.log .cmd {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--amber);
  margin-top: 1em;
}

.log .cmd::before {
  content: '> ';
  color: var(--muted);
}

.log .system {
  color: var(--muted);
  font-style: italic;
}

/* ── input row ─────────────────────────────────────────────── */

.inputrow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  flex: 0 0 auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(13, 20, 36, 0.96);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 35%);
}

.prompt {
  font-family: var(--mono);
  color: var(--amber);
  font-size: 1.1rem;
  padding: 0 2px;
}

#input {
  flex: 1 1 220px;
  min-width: 0;
  font: var(--mono);
  font-size: 1rem;
  font-family: var(--mono);
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
}

#input:focus-visible {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgb(242 178 92 / 20%);
}

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

.chip {
  font: inherit;
  font-size: 0.88rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 13px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.chip:hover {
  border-color: var(--teal);
  background: #12233a;
}

/* ── footer ────────────────────────────────────────────────── */

.footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.8rem;
}

.version-line {
  font-variant-numeric: tabular-nums;
}

/* ── dialogs ───────────────────────────────────────────────── */

.dialog {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  max-width: min(620px, calc(100vw - 32px));
  width: 92vw;
  box-shadow: var(--shadow);
}

.dialog::backdrop {
  background: rgb(4 6 12 / 70%);
  backdrop-filter: blur(3px);
}

.dialog h2 {
  margin: 0;
  padding: 16px 22px 0;
  font-size: 1.2rem;
}

.dialog.wide {
  max-width: min(860px, calc(100vw - 32px));
}

.intro-art {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 1px solid var(--line);
}

.intro-text,
.end-text {
  font-family: var(--serif);
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-line;
  overflow-y: auto;
  max-height: 40vh;
  padding: 14px 22px;
}

.end-text {
  max-height: 30vh;
  color: var(--text);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 22px 18px;
}

#intro .dialog-actions,
#intro h2 {
  padding-left: 22px;
}

.whats-new {
  margin: 0;
  padding: 12px 22px;
  overflow-y: auto;
  max-height: 40vh;
}

.whats-new li {
  margin: 0.4em 0;
}

.dialog .version-line {
  padding: 0 22px;
  color: var(--muted);
  font-size: 0.8rem;
}

.dialog form {
  padding: 0 22px 18px;
  display: flex;
  justify-content: flex-end;
}

/* ── toast ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #182338;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
}

.toast[hidden] {
  display: none;
}

/* ── small screens ─────────────────────────────────────────── */

@media (max-width: 720px) {
  .app {
    gap: 8px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .tagline {
    display: none;
  }

  .brand h1 {
    font-size: 0.98rem;
  }

  .log {
    font-size: 0.97rem;
    min-height: 110px;
  }

  .status-right {
    gap: 8px;
    font-size: 0.85rem;
  }

  .slot .slot-label {
    display: none;
  }

  .inputrow {
    gap: 6px;
  }

  .chips {
    width: 100%;
    order: 3;
  }

  .chip {
    flex: 1;
    text-align: center;
    padding: 7px 8px;
  }
}

@media (max-height: 760px) {
  .scene-card {
    max-width: min(100%, calc(32dvh * 16 / 9));
  }

  .app {
    gap: 7px;
    padding-bottom: 8px;
  }

  .log {
    min-height: 84px;
  }

  .inventory {
    max-height: 64px;
    padding: 6px 8px;
  }

  #cutscene-art {
    width: min(100%, calc(46dvh * 16 / 9));
  }

  .footer {
    font-size: 0.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* Music toggle off-state (the icon stays, dimmed). */
.btn.icon.off {
  opacity: 0.45;
}
