:root {
  --bg: #0e1218;
  --panel: #171d25;
  --panel-alt: #202a36;
  --text: #edf2f7;
  --muted: #9fb0c2;
  --accent: #f2bf66;
  --accent-strong: #ffd990;
  --line: rgba(255, 255, 255, 0.08);
  --danger: #f58f8f;
  --shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(242, 191, 102, 0.1), transparent 35%),
    linear-gradient(180deg, #10151c, #0b0f14 65%);
  color: var(--text);
}

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

.panel {
  background: rgba(23, 29, 37, 0.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel-start {
  margin-top: 10vh;
  padding: 40px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  font-size: 0.72rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4rem);
  max-width: 10ch;
}

.lede {
  max-width: 42rem;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
}

.subtle {
  color: var(--muted);
  line-height: 1.6;
}

.primary-button,
.ghost-button,
.choice-button {
  border: 0;
  border-radius: 14px;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 120ms ease;
}

.primary-button {
  margin-top: 12px;
  padding: 14px 22px;
  background: var(--accent);
  color: #151311;
  font-weight: 700;
}

.preference-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: 18px;
  color: var(--text);
  cursor: pointer;
}

.preference-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.preference-note {
  margin-top: 8px;
}

.ghost-button {
  padding: 10px 14px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.primary-button:hover,
.ghost-button:hover,
.choice-button:hover {
  transform: translateY(-1px);
}

.hidden {
  display: none !important;
}

#game-screen {
  padding: 28px;
}

.game-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 20px;
  padding: 22px;
}

.side-section + .side-section {
  margin-top: 22px;
}

.game-panel {
  padding: 28px;
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 0;
}

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.endings-list {
  display: grid;
  gap: 10px;
}

.ending-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.ending-chip.locked {
  color: var(--muted);
}

.ending-icon {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.ending-chip.unlocked .ending-icon {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(242, 191, 102, 0.08);
}

.ending-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ending-name {
  font-size: 0.95rem;
}

.ending-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.inventory-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(242, 191, 102, 0.12);
  border: 1px solid rgba(242, 191, 102, 0.18);
  color: var(--accent-strong);
  font-size: 0.92rem;
}

.status-text {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.transcript-panel,
.choice-panel,
.ending-panel {
  padding: 20px;
  border-radius: 18px;
  background: var(--panel-alt);
  border: 1px solid var(--line);
}

.transcript-panel {
  min-height: 300px;
  margin-top: 6px;
}

.panel-label {
  margin: 0 0 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}

.transcript {
  display: grid;
  gap: 12px;
}

.line {
  padding-left: 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
  opacity: 0.92;
  min-height: 24px;
  transition: border-color 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

.line.pending {
  display: none;
}

.line.active {
  border-left-color: rgba(242, 191, 102, 0.55);
  background: rgba(242, 191, 102, 0.05);
  opacity: 1;
}

.line-speaker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-strong);
  font-size: 0.85rem;
}

.line-body {
  white-space: pre-wrap;
}

.choices {
  display: grid;
  gap: 18px;
}

.choice-button {
  text-align: left;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--line);
}

.choice-button.pulse {
  animation: pulse 1s ease-in-out infinite;
}

.choice-button.warning {
  border-color: rgba(242, 191, 102, 0.45);
  box-shadow: 0 0 0 6px rgba(242, 191, 102, 0.06);
}

.choice-button.danger {
  border-color: rgba(245, 143, 143, 0.5);
  box-shadow: 0 0 0 8px rgba(245, 143, 143, 0.08);
}

.choice-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.ending-panel {
  margin-top: 26px;
}

.choice-panel {
  margin-top: 28px;
}

.secondary-button {
  width: 100%;
  margin-top: 0;
}

.feedback-modal {
  width: min(720px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 0;
  background: rgba(17, 21, 28, 0.98);
  color: var(--text);
  box-shadow: var(--shadow);
}

.feedback-modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.feedback-form {
  padding: 28px;
}

.feedback-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field textarea {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  padding: 12px 14px;
}

.feedback-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(242, 191, 102, 0.28);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(242, 191, 102, 0.04);
  }
}

@media (max-width: 960px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .header-actions {
    flex-direction: column;
    align-items: flex-end;
  }
}
