:root {
  color-scheme: only light;
  --bg-top: #d9d0b8;
  --bg-mid: #7b8a78;
  --bg-bottom: #40525a;
  --panel: rgba(15, 21, 31, 0.76);
  --panel-edge: rgba(204, 170, 99, 0.3);
  --text: #f7efdf;
  --muted: rgba(237, 228, 211, 0.72);
  --gold: #d0ae67;
  --green: #5f8f78;
  --red: #9b5f4b;
  --shadow: rgba(5, 8, 14, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  font-family: "Avenir Next", "Trebuchet MS", "Gill Sans", sans-serif;
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 243, 211, 0.42), transparent 26%),
    radial-gradient(circle at 78% 18%, rgba(255, 234, 201, 0.18), transparent 30%),
    linear-gradient(180deg, var(--bg-top), var(--bg-mid) 48%, var(--bg-bottom));
}

body {
  color: var(--text);
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.viewport {
  position: absolute;
  inset: 0;
}

.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

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

.panel {
  border: 1px solid var(--panel-edge);
  background:
    linear-gradient(180deg, rgba(34, 43, 59, 0.88), rgba(13, 18, 26, 0.72)),
    linear-gradient(135deg, rgba(255, 245, 212, 0.08), transparent 42%);
  box-shadow:
    0 20px 42px var(--shadow),
    inset 0 1px 0 rgba(255, 250, 235, 0.08);
  backdrop-filter: blur(10px);
}

.topbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: grid;
  grid-template-columns: minmax(250px, 300px) 1fr minmax(210px, 250px);
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 18px;
}

.brand-block h1,
.sidebar-head h2,
.menu-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.03em;
}

.brand-block h1 {
  font-size: clamp(1.25rem, 1.7vw, 1.78rem);
}

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

.subline,
.enemy-line,
.faint {
  margin: 2px 0 0;
  color: var(--muted);
}

.resource-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
}

.resource-pill {
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 247, 230, 0.08);
}

.resource-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 1.12rem;
}

.enemy-block {
  text-align: right;
}

.selection-drawer,
.empire-panel {
  position: absolute;
  top: 80px;
  bottom: 78px;
  width: min(21vw, 300px);
  padding: 14px;
  border-radius: 22px;
  overflow-x: hidden;
  overflow-y: auto;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-gutter: stable;
}

.selection-drawer {
  left: 10px;
  transform: translateX(0);
  opacity: 1;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.selection-drawer.collapsed {
  transform: translateX(calc(-100% - 28px));
  opacity: 0;
  pointer-events: none;
}

.empire-panel {
  right: 10px;
}

.sidebar-head {
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.section-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-block h3 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.selection-panel {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.selection-portrait {
  aspect-ratio: 1 / 1;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 247, 227, 0.08), rgba(29, 22, 16, 0.18)),
    rgba(255, 248, 233, 0.03);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  clip-path: polygon(50% 4%, 92% 26%, 92% 74%, 50% 96%, 8% 74%, 8% 26%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.selection-portrait.empty {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(22, 17, 12, 0.55);
}

.selection-title {
  font-size: 1.35rem;
  font-family: Georgia, "Times New Roman", serif;
  color: #fff6e6;
}

.selection-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  font-size: 0.86rem;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empire-grid {
  max-height: 132px;
  overflow: auto;
  padding-right: 4px;
}

.actions-block {
  min-height: 0;
  flex: 1;
}

.action-btn,
.primary-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: #fff7e8;
  cursor: pointer;
  transition:
    transform 140ms ease,
    filter 140ms ease,
    border-color 140ms ease;
}

.action-btn {
  min-height: 60px;
  padding: 10px 11px;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(139, 112, 65, 0.86), rgba(89, 69, 41, 0.76));
}

.action-btn strong,
.primary-btn strong {
  display: block;
  font-size: 0.97rem;
  letter-spacing: 0.03em;
}

.action-btn span {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: rgba(255, 247, 232, 0.74);
}

.action-btn[data-tone="build"] {
  background:
    linear-gradient(135deg, rgba(53, 101, 88, 0.94), rgba(30, 67, 61, 0.82));
}

.action-btn[data-tone="research"] {
  background:
    linear-gradient(135deg, rgba(52, 81, 118, 0.94), rgba(31, 49, 82, 0.84));
}

.action-btn:disabled {
  opacity: 0.42;
  cursor: default;
  filter: grayscale(0.2);
}

.action-btn:not(:disabled):hover,
.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
  border-color: rgba(244, 226, 190, 0.28);
}

.messages-block {
  min-height: 0;
  flex: 1;
}

.messages-block .message-list {
  min-height: 132px;
}

.empire-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.empire-card {
  padding: 10px 12px;
  border-radius: 18px;
  background: rgba(255, 247, 232, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.empire-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  color: #fff7e8;
}

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.message-item {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  line-height: 1.35;
}

.command-ribbon {
  position: absolute;
  left: calc(min(21vw, 300px) + 20px);
  right: calc(min(21vw, 300px) + 20px);
  bottom: 10px;
  padding: 10px 14px;
  border-radius: 16px;
}

.mode-line {
  margin-bottom: 8px;
  color: #fff7e8;
}

.controls-line {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 0.88rem;
}

.menu-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(8, 7, 5, 0.28), rgba(8, 7, 5, 0.7)),
    linear-gradient(180deg, rgba(231, 212, 169, 0.16), rgba(55, 61, 54, 0.38));
  backdrop-filter: blur(4px);
}

.world-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.world-banner {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 122px;
  padding: 6px 10px;
  border: 1px solid color-mix(in srgb, var(--banner) 62%, #f1d49a);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(15, 24, 39, 0.92), rgba(8, 12, 22, 0.84));
  box-shadow: 0 10px 20px rgba(3, 6, 10, 0.26);
  text-align: center;
}

.world-banner strong,
.world-banner span {
  display: block;
  white-space: nowrap;
}

.world-banner strong {
  color: #fff6df;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.world-banner span {
  margin-top: 2px;
  color: rgba(240, 234, 219, 0.82);
  font-size: 0.72rem;
}

.city-banner::after,
.unit-banner::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 10px;
  height: 10px;
  background: rgba(9, 14, 22, 0.88);
  border-right: 1px solid color-mix(in srgb, var(--banner) 62%, #f1d49a);
  border-bottom: 1px solid color-mix(in srgb, var(--banner) 62%, #f1d49a);
  transform: translateX(-50%) rotate(45deg);
}

.hidden {
  display: none !important;
}

.menu-card {
  width: min(760px, calc(100vw - 40px));
  padding: 34px;
  border-radius: 34px;
  transform: translateY(-12px);
}

.menu-card h2 {
  font-size: clamp(3rem, 8vw, 4.8rem);
}

.menu-copy {
  max-width: 40rem;
  font-size: 1.06rem;
  line-height: 1.6;
  color: var(--muted);
}

.menu-bullets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 28px;
}

.menu-bullets span {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: #fff5e3;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.primary-btn {
  padding: 14px 20px;
  background:
    linear-gradient(135deg, rgba(182, 128, 62, 0.96), rgba(124, 82, 35, 0.88));
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

  .enemy-block {
    text-align: left;
  }

  .selection-drawer,
  .empire-panel {
    top: auto;
    bottom: 18px;
    left: 18px;
    right: 18px;
    width: auto;
    height: min(33vh, 320px);
  }

  .selection-drawer {
    bottom: calc(33vh + 32px);
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }

  .command-ribbon {
    display: none;
  }
}

@media (max-width: 760px) {
  .resource-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .menu-card {
    padding: 24px;
  }
}
