:root {
  color-scheme: dark;
  --bg: #090b0f;
  --panel: #141820;
  --panel-strong: #1d2430;
  --line: #334155;
  --text: #f5f7fb;
  --muted: #aeb8c7;
  --cyan: #40d9ff;
  --amber: #ffb84d;
  --green: #69d391;
  --red: #ff6b6b;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 15% 10%, rgba(64, 217, 255, 0.12), transparent 30rem),
    radial-gradient(circle at 88% 18%, rgba(255, 184, 77, 0.1), transparent 26rem),
    linear-gradient(135deg, #080a0e 0%, #111721 54%, #080a0e 100%);
  color: var(--text);
}

button {
  min-height: 44px;
  border: 1px solid rgba(245, 247, 251, 0.18);
  border-radius: 8px;
  background: #1c2532;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--cyan);
  outline: 2px solid rgba(64, 217, 255, 0.24);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  min-height: 100vh;
}

.loading-view,
.error-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.error-view p {
  max-width: 680px;
  color: var(--muted);
}

.intro-view {
  display: grid;
  min-height: 100vh;
  grid-template-rows: auto 1fr auto;
}

.topbar,
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid rgba(245, 247, 251, 0.12);
  background: rgba(9, 11, 15, 0.78);
  backdrop-filter: blur(14px);
}

.brand-mark {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.brand-mark strong {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand-mark span,
.page-count,
.kicker,
.meta,
.resource-kind,
.event-tags,
.log-entry,
.empty-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.intro-stage {
  display: grid;
  align-items: center;
  justify-items: center;
  min-height: 0;
  padding: clamp(12px, 2vw, 24px);
}

.comic-frame {
  position: relative;
  width: min(100%, 1500px);
  max-height: calc(100vh - 148px);
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(245, 247, 251, 0.16);
  border-radius: 8px;
  overflow: hidden;
  background: #05070a;
  box-shadow: var(--shadow);
}

.comic-frame picture,
.comic-frame img {
  display: block;
  width: 100%;
  height: 100%;
}

.comic-frame img {
  object-fit: contain;
}

.overlay-stack {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.comic-overlay {
  position: absolute;
  max-width: min(36rem, 45%);
  padding: 12px 14px;
  border: 1px solid rgba(245, 247, 251, 0.22);
  border-radius: 8px;
  background: rgba(10, 14, 20, 0.84);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.32);
  color: var(--text);
  line-height: 1.35;
}

.comic-overlay[data-kind="radio"],
.comic-overlay[data-kind="ai"] {
  border-color: rgba(64, 217, 255, 0.48);
}

.comic-overlay[data-place="top-left"] {
  top: 5%;
  left: 5%;
}

.comic-overlay[data-place="top-right"] {
  top: 5%;
  right: 5%;
}

.comic-overlay[data-place="bottom-left"] {
  bottom: 6%;
  left: 5%;
}

.comic-overlay[data-place="bottom-right"] {
  right: 5%;
  bottom: 6%;
}

.comic-overlay[data-place="center"] {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.intro-controls,
.game-actions,
.choice-list,
.build-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.intro-controls {
  align-items: center;
  justify-content: center;
  padding: 14px clamp(16px, 3vw, 34px) 18px;
  border-top: 1px solid rgba(245, 247, 251, 0.12);
  background: rgba(9, 11, 15, 0.78);
}

.primary {
  border-color: rgba(64, 217, 255, 0.55);
  background: linear-gradient(180deg, #1c6d83, #124354);
}

.quiet {
  background: transparent;
}

.game-view {
  min-height: 100vh;
}

.game-header h1,
.game-header p {
  margin: 0;
}

.game-header h1 {
  font-size: clamp(1.3rem, 2vw, 2rem);
}

.game-main {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 18px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
}

.panel {
  border: 1px solid rgba(245, 247, 251, 0.14);
  border-radius: 8px;
  background: rgba(20, 24, 32, 0.86);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(245, 247, 251, 0.1);
}

.panel-header h2,
.event-copy h2,
.card h3 {
  margin: 0;
}

.panel-body {
  padding: 16px;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.resource-tile,
.card,
.event-card {
  border: 1px solid rgba(245, 247, 251, 0.12);
  border-radius: 8px;
  background: rgba(29, 36, 48, 0.78);
}

.resource-tile {
  display: grid;
  gap: 8px;
  min-height: 104px;
  padding: 12px;
}

.resource-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.resource-value {
  font-size: 1.4rem;
  font-weight: 800;
}

.meter {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(245, 247, 251, 0.12);
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.resource-tile.is-warning .meter > span {
  background: var(--amber);
}

.resource-tile.is-critical .meter > span {
  background: var(--red);
}

.event-card {
  display: grid;
  grid-template-columns: minmax(160px, 34%) minmax(0, 1fr);
  overflow: hidden;
}

.event-card img,
.asset-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.event-copy {
  display: grid;
  gap: 12px;
  padding: 16px;
}

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

.effect-list li,
.log-entry {
  border-left: 3px solid rgba(64, 217, 255, 0.58);
  padding: 8px 10px;
  background: rgba(9, 11, 15, 0.35);
}

.choice-list button,
.build-list button {
  flex: 1 1 220px;
  padding: 10px 12px;
  text-align: left;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.card {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  min-height: 94px;
  overflow: hidden;
}

.card-content {
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
}

.side-column {
  display: grid;
  align-content: start;
  gap: 18px;
}

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

  .event-card {
    grid-template-columns: 1fr;
  }

  .event-card img {
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 699px) {
  .topbar,
  .game-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .comic-frame {
    max-height: calc(100vh - 190px);
    aspect-ratio: 9 / 16;
  }

  .comic-overlay {
    right: 5%;
    left: 5%;
    max-width: none;
    font-size: 0.88rem;
  }

  .comic-overlay[data-place-mobile="top"] {
    top: 4%;
    bottom: auto;
    transform: none;
  }

  .comic-overlay[data-place-mobile="middle"] {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }

  .comic-overlay[data-place-mobile="bottom"] {
    top: auto;
    bottom: 5%;
    transform: none;
  }

  .intro-controls button,
  .game-actions button {
    flex: 1 1 130px;
  }
}
