:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #10151b;
  --panel-2: #161d25;
  --line: #2c3741;
  --text: #f4efe5;
  --muted: #aeb8bd;
  --gold: #f0bb50;
  --green: #6fd391;
  --rose: #e57a7a;
  --cyan: #72c8d7;
  --ink: #07090d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(111, 211, 145, 0.16), transparent 28rem),
    radial-gradient(circle at 84% 24%, rgba(240, 187, 80, 0.14), transparent 26rem),
    linear-gradient(145deg, #07090d 0%, #111821 48%, #090c11 100%);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1d2630;
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--gold);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.primary {
  border-color: rgba(240, 187, 80, 0.75);
  background: linear-gradient(180deg, #f5ca6c, #d4972f);
  color: var(--ink);
  font-weight: 700;
}

.shell {
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  min-height: 100vh;
}

.status-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 12, 17, 0.82);
  backdrop-filter: blur(14px);
}

.ship-badge {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.85rem;
  align-items: center;
}

.ship-badge img {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.25rem;
  line-height: 1.15;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.stat-grid div,
.manifest {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(22, 29, 37, 0.74);
  padding: 0.8rem;
}

.stat-grid div > span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.stat-grid strong {
  display: block;
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

.stat-grid div:first-child strong {
  white-space: normal;
}

.meter {
  height: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: #222b34;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 220ms ease;
}

.meter.small {
  height: 0.55rem;
}

.manifest h2 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.manifest dl {
  display: grid;
  gap: 0.65rem;
  margin: 0;
}

.manifest div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}

.manifest dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.game-panel {
  display: grid;
  grid-template-rows: minmax(18rem, 52vh) auto;
  min-width: 0;
}

.scene-media {
  position: relative;
  min-height: 18rem;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.scene-media img {
  width: 100%;
  height: 100%;
  min-height: 18rem;
  display: block;
  object-fit: cover;
}

.scene-media.contain img {
  object-fit: contain;
  background:
    radial-gradient(circle at 50% 34%, rgba(240, 187, 80, 0.22), transparent 24rem),
    linear-gradient(135deg, #10151b, #07090d);
}

.scene-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 9, 13, 0.05), rgba(7, 9, 13, 0.76));
}

.scene-overlay {
  position: absolute;
  left: clamp(1rem, 4vw, 3rem);
  right: clamp(1rem, 4vw, 3rem);
  bottom: clamp(1rem, 4vw, 2.4rem);
  z-index: 1;
}

.scene-overlay h2 {
  max-width: 52rem;
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3.4vw, 3rem);
  line-height: 1.08;
  text-shadow: 0 0.2rem 1rem rgba(0, 0, 0, 0.6);
}

.story-panel {
  width: min(64rem, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem);
}

#storyText {
  color: #e9e1d3;
  font-size: 1.05rem;
  line-height: 1.62;
  white-space: pre-line;
}

.setup-form,
.challenge-box {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.2rem;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(16, 21, 27, 0.82);
}

.setup-form label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b10;
  color: var(--text);
  padding: 0.7rem 0.85rem;
}

.word-entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}

.choice-card {
  display: grid;
  grid-template-rows: 13rem auto;
  min-height: 22rem;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background: var(--panel-2);
}

.choice-card img {
  width: 100%;
  height: 13rem;
  object-fit: contain;
  object-position: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(114, 200, 215, 0.18), transparent 12rem),
    linear-gradient(145deg, #080b10, #17202a);
}

.choice-card div {
  padding: 0.8rem;
}

.choice-card strong {
  display: block;
  margin-bottom: 0.3rem;
}

.choice-card span {
  display: block;
  color: var(--gold);
  font-size: 0.86rem;
  font-weight: 800;
}

.choice-card p {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.choice-card.done {
  border-color: var(--green);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.actions button {
  min-width: 8rem;
  padding-inline: 1rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 840px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .status-panel {
    position: static;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .game-panel {
    grid-template-rows: minmax(16rem, 42vh) auto;
  }
}

@media (max-width: 560px) {
  .stat-grid,
  .word-entry {
    grid-template-columns: 1fr;
  }

  .manifest div {
    display: grid;
    gap: 0.25rem;
  }

  .manifest dd {
    text-align: left;
  }

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

  .actions button {
    min-width: 0;
    flex: 1;
  }
}

/* ── Builder link in status panel ─── */
.builder-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: auto;
  padding: 0.65rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: none;
  color: var(--muted);
  font-size: 0.82rem;
  text-decoration: none;
  transition: border-color 160ms, color 160ms;
}
.builder-link:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ── End-of-scene branch choices ─── */
.branch-prompt {
  grid-column: 1 / -1;
  margin: 0.25rem 0 0;
  color: var(--cyan);
  font-weight: 700;
  font-size: 1.02rem;
}
.branch-btn {
  min-height: 3.25rem;
  padding: 0.7rem 1rem;
  border-color: rgba(196, 181, 253, 0.55);
  background: rgba(196, 181, 253, 0.08);
  font-weight: 700;
  text-align: left;
}
.branch-btn:hover {
  border-color: var(--gold);
  background: rgba(240, 187, 80, 0.1);
}

/* ── NaNoWriMo hint in setup form ─── */
.goal-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}
