:root {
  --bg: #07121b;
  --ink: #eef4f8;
  --muted: rgba(223, 233, 240, 0.72);
  --soft: rgba(223, 233, 240, 0.54);
  --line: rgba(255, 255, 255, 0.1);
  --panel: rgba(5, 12, 18, 0.66);
  --panel-strong: rgba(8, 15, 22, 0.84);
  --ember: #ff8550;
  --tide: #63d5ff;
  --frost: #dff8ff;
  --gold: #d6a06a;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 133, 80, 0.16), transparent 24%),
    radial-gradient(circle at 83% 10%, rgba(99, 213, 255, 0.14), transparent 23%),
    linear-gradient(180deg, #0a1824 0%, #061019 36%, #04090e 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 49.6%, rgba(255, 255, 255, 0.018) 50%, transparent 50.4%),
    linear-gradient(transparent 0 49.6%, rgba(255, 255, 255, 0.016) 50%, transparent 50.4%);
  background-size: 180px 180px;
  opacity: 0.6;
  mask-image: radial-gradient(circle at center, black, transparent 82%);
}

.app-shell {
  min-height: 100vh;
  padding: 18px 16px 24px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.85fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 22px;
}

.brand-column {
  max-width: 820px;
}

.eyebrow,
.label,
.stage-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: rgba(242, 216, 190, 0.76);
}

h1 {
  margin: 0;
  font-family: "Baskerville", "Palatino Linotype", serif;
  font-size: clamp(3.4rem, 7vw, 6rem);
  line-height: 0.9;
  letter-spacing: 0.015em;
}

.deck-copy {
  max-width: 52ch;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 1.02rem;
}

.command-column {
  display: grid;
  gap: 16px;
  justify-items: start;
}

.rule-strip,
.command-actions,
.stage-markers,
.status-actions,
.tutorial-nav,
.tutorial-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.rule-strip span,
.stage-markers span {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.primary-action,
.secondary-action {
  border-radius: 999px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.primary-action:hover,
.secondary-action:hover {
  transform: translateY(-1px);
}

.primary-action {
  padding: 14px 24px;
  color: #130d08;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, rgba(255, 133, 80, 0.96), rgba(214, 160, 106, 0.96));
  box-shadow: 0 18px 42px rgba(255, 133, 80, 0.24);
}

.secondary-action {
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  color: rgba(241, 245, 248, 0.9);
}

.secondary-action:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.battle-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 210px;
  gap: 14px;
  align-items: start;
}

.rail {
  display: grid;
  gap: 14px;
}

.rail-block,
.stage-shell {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.rail-block {
  border-radius: 24px;
  padding: 18px 18px 16px;
}

.rail-copy,
.summary-line,
.signature-line,
.enemy-read-line,
.intel-list,
.battle-log,
.status-line,
.stage-note,
.tutorial-progress,
.tutorial-body,
.tutorial-tip {
  color: var(--muted);
}

.summary-line,
.signature-line,
.enemy-read-line,
.rail-copy,
.status-line,
.tutorial-body,
.tutorial-tip {
  line-height: 1.55;
}

.signature-line {
  min-height: 72px;
}

.enemy-read-line {
  min-height: 68px;
}

.enemy-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.enemy-count-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(241, 245, 248, 0.9);
  font-size: 0.84rem;
}

.enemy-count-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.intel-list,
.battle-log {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  line-height: 1.5;
}

.stage-column {
  min-width: 0;
}

.stage-shell {
  border-radius: 32px;
  padding: 16px;
  box-shadow: var(--shadow);
  background:
    linear-gradient(180deg, rgba(10, 18, 27, 0.92), rgba(7, 13, 19, 0.82)),
    radial-gradient(circle at top center, rgba(255, 255, 255, 0.04), transparent 46%);
}

.stage-header,
.status-band {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.stage-header {
  padding: 4px 4px 14px;
}

.stage-note {
  margin: 0;
  font-size: 0.92rem;
}

.stage-frame {
  position: relative;
  border-radius: 26px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(8, 17, 25, 0.62), rgba(8, 15, 22, 0.82));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

canvas {
  display: block;
  width: 100%;
  max-width: 960px;
  height: auto;
  border-radius: 26px;
  background: linear-gradient(180deg, #102333 0%, #08131d 100%);
}

.status-band {
  padding: 16px 4px 4px;
  align-items: end;
}

.status-copy {
  min-width: 0;
}

.status-copy .label {
  margin-bottom: 6px;
}

.status-line {
  margin: 0;
  max-width: 48ch;
  font-size: 1rem;
}

.tutorial-overlay {
  position: absolute;
  inset: 18px;
  display: grid;
  align-content: end;
  justify-items: start;
  pointer-events: none;
}

.tutorial-overlay.is-hidden {
  display: none;
}

.tutorial-panel {
  width: min(410px, calc(100% - 8px));
  padding: 18px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(4, 10, 16, 0.84);
  backdrop-filter: blur(18px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.tutorial-progress {
  margin-bottom: 10px;
  font-size: 0.84rem;
}

.tutorial-title {
  margin: 0 0 10px;
  font-family: "Baskerville", "Palatino Linotype", serif;
  font-size: clamp(1.9rem, 3vw, 2.4rem);
  line-height: 0.98;
}

.tutorial-tip {
  margin-top: 10px;
  color: rgba(255, 224, 192, 0.84);
  font-size: 0.94rem;
}

.tutorial-actions {
  justify-content: space-between;
  margin-top: 16px;
}

.tutorial-next {
  min-width: 136px;
}

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

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

@media (max-width: 820px) {
  .app-shell {
    padding: 18px 14px 28px;
  }

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

  .rail,
  .status-band {
    grid-template-columns: 1fr;
  }

  .stage-header,
  .status-band {
    flex-direction: column;
    align-items: start;
  }

  .tutorial-overlay {
    inset: 12px;
  }

  .tutorial-panel {
    width: 100%;
  }
}
