:root {
  --bg-void: #090611;
  --bg-deep: #130d1f;
  --panel: rgba(27, 18, 40, 0.94);
  --ink: #f3e9d2;
  --ink-soft: #cfbfd5;
  --gold: #d7b15f;
  --gold-bright: #f0d68d;
  --emerald: #2dd0a8;
  --ruby: #9f223d;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  font-family: "Cormorant SC", serif;
  background:
    radial-gradient(circle at top, rgba(134, 69, 170, 0.22), transparent 28%),
    radial-gradient(circle at 15% 80%, rgba(8, 168, 135, 0.1), transparent 20%),
    linear-gradient(180deg, #1c132c 0%, #100a1a 42%, #06040a 100%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.014) 0 2px,
    transparent 2px 4px
  );
  mix-blend-mode: soft-light;
  opacity: 0.45;
}

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

code {
  font-family: "Press Start 2P", monospace;
  font-size: 0.68em;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100dvh;
  padding: 14px;
  display: grid;
  place-items: center;
  position: relative;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, 0.05), transparent 16%),
    radial-gradient(circle at 87% 12%, rgba(90, 39, 136, 0.24), transparent 18%),
    repeating-linear-gradient(
      135deg,
      transparent 0 22px,
      rgba(255, 255, 255, 0.015) 22px 24px
    );
}

.title-screen,
.game-layout,
.scroll {
  width: min(calc(100vw - 28px), 1600px);
}

.title-screen {
  padding: 30px 24px 36px;
  text-align: center;
  border: 3px solid rgba(215, 177, 95, 0.72);
  background:
    linear-gradient(180deg, rgba(41, 22, 57, 0.95), rgba(17, 11, 27, 0.98)),
    var(--panel);
  box-shadow:
    0 22px 60px rgba(0, 0, 0, 0.48),
    inset 0 0 0 2px rgba(240, 214, 141, 0.1);
}

.sigil {
  width: 108px;
  height: 108px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 2px solid rgba(240, 214, 141, 0.62);
  background:
    radial-gradient(circle, rgba(45, 208, 168, 0.34), transparent 42%),
    conic-gradient(from 180deg, #2d102a, #35ddb3, #7b2cbf, #d7b15f, #2d102a);
  box-shadow:
    0 0 24px rgba(45, 208, 168, 0.18),
    inset 0 0 22px rgba(255, 255, 255, 0.12);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 0.62rem;
  line-height: 1.8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: #715529;
}

h1,
h2 {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
}

h1 {
  font-size: clamp(2.4rem, 7vw, 5rem);
  line-height: 0.95;
}

h2 {
  font-size: 2rem;
}

.lead,
.scroll p,
.panel p,
.hint {
  line-height: 1.45;
}

.lead {
  max-width: 40rem;
  margin: 16px auto 22px;
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.boot-seal {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 12px;
  border: 1px solid rgba(45, 208, 168, 0.45);
  background: rgba(8, 23, 24, 0.45);
  color: #96f5dd;
  font-family: "Press Start 2P", monospace;
  font-size: 0.54rem;
  line-height: 1.8;
  text-transform: uppercase;
}

.microcopy,
.hint {
  color: #b9a8c2;
}

.microcopy {
  margin: 14px 0 0;
  font-size: 1.02rem;
}

.primary-button,
.secondary-button,
.control-button {
  border: 1px solid rgba(240, 214, 141, 0.7);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 8px 20px rgba(0, 0, 0, 0.28);
}

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 12px 22px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.72rem;
  line-height: 1.5;
}

.primary-button {
  border-radius: 999px;
  background: linear-gradient(180deg, #7d2257 0%, #4b1740 52%, #26112b 100%);
}

.secondary-button {
  width: 100%;
  border-radius: 14px;
  background: linear-gradient(180deg, #26445e 0%, #1d2f45 52%, #111f31 100%);
}

.primary-button:active,
.secondary-button:active,
.control-button:active {
  transform: translateY(1px);
}

.game-layout {
  display: flex;
  gap: 16px;
  align-items: stretch;
  height: calc(100dvh - 28px);
  max-height: calc(100dvh - 28px);
  overflow: hidden;
}

.viewport-frame,
.panel,
.scroll,
.battle-panel {
  border: 2px solid rgba(215, 177, 95, 0.72);
  background: linear-gradient(180deg, rgba(40, 24, 56, 0.95), rgba(15, 10, 23, 0.98));
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.36);
}

.sidebar {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  flex: 0 0 300px;
}

.stage-column {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  gap: 14px;
}

.panel {
  padding: 14px 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.stat-card {
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid rgba(240, 214, 141, 0.18);
  background: rgba(255, 255, 255, 0.04);
}

.stat-card.wide {
  grid-column: span 2;
}

.effect-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(240, 214, 141, 0.18);
}

.effect-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.effect-list li {
  padding: 6px 8px;
  border: 1px solid rgba(45, 208, 168, 0.18);
  background: rgba(45, 208, 168, 0.08);
  color: #cff7eb;
  font-size: 0.94rem;
}

.stat-label {
  display: block;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  line-height: 1.7;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-size: 1.25rem;
  line-height: 1.05;
}

.stat-value.tiny {
  font-size: 0.8rem;
  line-height: 1.45;
  word-break: break-word;
}

.artifact-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.artifact-chip {
  padding: 6px 10px;
  border: 1px solid rgba(240, 214, 141, 0.25);
  background: rgba(255, 255, 255, 0.04);
  color: #dbc898;
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  line-height: 1.6;
  opacity: 0.45;
}

.artifact-chip.found {
  opacity: 1;
  color: #99f4de;
  border-color: rgba(45, 208, 168, 0.65);
  background: rgba(45, 208, 168, 0.12);
}

.viewport-frame {
  position: relative;
  min-height: 0;
  min-width: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(111, 53, 154, 0.34), transparent 24%),
    radial-gradient(circle at 18% 70%, rgba(45, 208, 168, 0.12), transparent 20%),
    linear-gradient(180deg, rgba(28, 17, 43, 0.96), rgba(8, 6, 14, 0.98));
}

.viewport-frame::before,
.viewport-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.viewport-frame::before {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 240, 198, 0.12), transparent 18%),
    linear-gradient(90deg, rgba(8, 5, 14, 0.94), transparent 10%, transparent 90%, rgba(8, 5, 14, 0.94)),
    linear-gradient(180deg, rgba(8, 5, 14, 0.56), transparent 10%, transparent 86%, rgba(8, 5, 14, 0.8));
}

.viewport-frame::after {
  inset: 10px;
  border: 1px solid rgba(240, 214, 141, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 0 42px rgba(115, 52, 164, 0.18);
}

.campaign-log-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 16px 20px 18px;
  background:
    linear-gradient(180deg, rgba(51, 30, 69, 0.97), rgba(15, 11, 22, 0.99)),
    rgba(27, 18, 40, 0.94);
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.campaign-log-panel.feed-expanded {
  transform: translateY(-6px);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.4),
    inset 0 0 0 1px rgba(125, 255, 229, 0.08);
}

.campaign-log-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.log-badge {
  min-width: 154px;
  padding: 8px 10px;
  border: 1px solid rgba(45, 208, 168, 0.36);
  background: rgba(13, 42, 40, 0.56);
  color: #9cf6e1;
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  line-height: 1.7;
  text-transform: uppercase;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
}

.log-badge:hover,
.log-badge[aria-pressed="true"] {
  background: rgba(28, 75, 70, 0.86);
  border-color: rgba(111, 242, 214, 0.8);
  color: #e2fff7;
}

.log-badge[aria-pressed="true"] {
  transform: translateY(-1px);
}

#game-root {
  position: absolute;
  inset: 0;
  z-index: 1;
}

#game-root canvas {
  width: 100% !important;
  height: 100% !important;
  image-rendering: pixelated;
}

#log {
  margin: 0;
  padding: 14px 16px;
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
  scrollbar-width: thin;
  border: 1px solid rgba(240, 214, 141, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.08)),
    rgba(255, 255, 255, 0.03);
  color: #f5ecd8;
  font-size: 1.32rem;
  line-height: 1.4;
  letter-spacing: 0.01em;
  overflow-y: auto;
  transition:
    background 180ms ease,
    box-shadow 180ms ease;
}

.campaign-log-panel.feed-expanded #log {
  background:
    linear-gradient(180deg, rgba(45, 208, 168, 0.08), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 0 0 1px rgba(45, 208, 168, 0.08);
}

.log-entry {
  padding: 10px 12px;
  border-left: 3px solid rgba(215, 177, 95, 0.5);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  animation: log-entry-rise 220ms ease;
}

.log-entry.latest {
  border-left-color: rgba(45, 208, 168, 0.8);
  background:
    linear-gradient(90deg, rgba(45, 208, 168, 0.14), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.02);
}

.log-entry-day {
  display: block;
  margin-bottom: 5px;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  line-height: 1.6;
}

.log-entry-text {
  display: block;
}

@keyframes log-entry-rise {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.event-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.event-list li {
  padding: 8px 10px;
  border: 1px solid rgba(240, 214, 141, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-soft);
  line-height: 1.35;
}

.event-type {
  display: block;
  margin-bottom: 4px;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  line-height: 1.7;
}

.controls .panel-title {
  margin-bottom: 10px;
}

.dpad {
  width: min(100%, 280px);
  margin: 14px auto 0;
  display: grid;
  gap: 8px;
}

.middle-row {
  display: grid;
  grid-template-columns: 1fr 1.45fr 1fr;
  gap: 8px;
}

.control-button {
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(180deg, #3d2857 0%, #28173b 58%, #171121 100%);
  font-size: 1.05rem;
}

.control-button.accent {
  background: linear-gradient(180deg, #175651 0%, #123d3e 52%, #0d2324 100%);
  font-family: "Press Start 2P", monospace;
  font-size: 0.62rem;
  line-height: 1.5;
}

.scroll-screen,
.battle-screen {
  position: fixed;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(5, 3, 10, 0.8);
  backdrop-filter: blur(8px);
  z-index: 40;
}

.scroll {
  max-width: 720px;
  padding: 28px 22px 30px;
  text-align: center;
  color: #3c251a;
  background:
    radial-gradient(circle at top, rgba(255, 248, 222, 0.6), transparent 18%),
    linear-gradient(180deg, #eadcb8 0%, #d7c291 18%, #caaa76 100%);
}

.battle-panel {
  width: min(100%, 720px);
  padding: 24px 20px;
  text-align: center;
  position: relative;
  z-index: 41;
}

.battle-stats,
.battle-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.battle-stats {
  margin: 18px 0 12px;
}

.battle-card {
  padding: 10px 12px;
  border: 1px solid rgba(240, 214, 141, 0.2);
  background: rgba(255, 255, 255, 0.04);
}

.battle-value {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
}

.battle-log {
  min-height: 52px;
  margin: 0 0 14px;
  font-size: 1.08rem;
  line-height: 1.45;
}

.battle-intent {
  margin: 10px 0 12px;
  color: var(--gold-bright);
  font-family: "Press Start 2P", monospace;
  font-size: 0.58rem;
  line-height: 1.8;
}

@media (max-width: 1400px) {
  .game-layout {
    gap: 12px;
  }

  .sidebar {
    flex-basis: 260px;
  }

  .stage-column {
    grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  }

  #log {
    font-size: 1.18rem;
  }
}
