:root {
  --bg: #101827;
  --panel: rgba(20, 29, 47, 0.84);
  --panel-solid: #172033;
  --panel-2: #202d46;
  --ink: #f8fafc;
  --muted: #96a3b8;
  --line: rgba(226, 232, 240, 0.14);
  --primary: #4f7cff;
  --cyan: #23d3ee;
  --green: #3ddc84;
  --amber: #ffbd4a;
  --pink: #ff5da2;
  --purple: #a78bfa;
  --danger: #fb7185;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 10%, rgba(79, 124, 255, 0.28), transparent 27%),
    radial-gradient(circle at 84% 0%, rgba(35, 211, 238, 0.18), transparent 25%),
    linear-gradient(145deg, #101827 0%, #111827 45%, #121a2b 100%);
  font-family: Poppins, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.game-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.command-deck {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  padding: 16px;
  border-right: 1px solid var(--line);
  background: rgba(10, 16, 28, 0.78);
  backdrop-filter: blur(24px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  text-decoration: none;
}

.brand-mark, .avatar, .district-icon, .nova-mark {
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  font-weight: 800;
}

.brand-mark {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
}

.brand strong, .player-card strong { display: block; font-size: 0.96rem; font-weight: 720; }
.brand small, .player-card small { color: var(--muted); font-size: 0.74rem; }

.nav-list { display: grid; gap: 6px; }

.nav-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: #cbd5e1;
  text-decoration: none;
}

.nav-link span:first-child {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: rgba(148, 163, 184, 0.11);
  color: var(--cyan);
  font-size: 0.82rem;
  font-weight: 800;
}

.nav-link:hover, .nav-link.active {
  border-color: rgba(79, 124, 255, 0.48);
  background: rgba(79, 124, 255, 0.15);
  color: #fff;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--amber), var(--pink));
  font-size: 0.86rem;
}

.game-main {
  min-width: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px;
}

.hud {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

.hud h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.4vw, 2.8rem);
  line-height: 1;
}

.hud-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.hud-strip span {
  display: grid;
  min-width: 108px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

.hud-strip b { font-size: 1rem; }
.hud-strip small { color: var(--muted); font-size: 0.68rem; }

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

.panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

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

.panel h2 { margin: 0; font-size: 1.05rem; }
.muted { color: var(--muted); }

.city-board {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 8% 88%, rgba(54, 211, 153, 0.3), transparent 18%),
    radial-gradient(circle at 92% 76%, rgba(96, 165, 250, 0.28), transparent 21%),
    linear-gradient(180deg, rgba(125, 211, 252, 0.2), transparent 38%),
    linear-gradient(180deg, #1d3352, #18304d 40%, #172640);
}

#cityCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.weather-rain .city-board::after,
.weather-night .city-board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.weather-rain .city-board::after {
  background: repeating-linear-gradient(110deg, rgba(255,255,255,0.16) 0 1px, transparent 1px 13px);
  animation: rain 1s linear infinite;
}

.weather-night .city-board::after {
  background: rgba(4, 8, 20, 0.36);
}

@keyframes rain {
  from { background-position: 0 0; }
  to { background-position: -40px 80px; }
}

.sun {
  position: absolute;
  right: 48px;
  top: 38px;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff7b1 0 22%, #ffd166 23% 62%, transparent 64%);
}

.game-banner {
  position: absolute;
  z-index: 2;
  left: 16px;
  top: 16px;
  display: grid;
  gap: 2px;
  max-width: min(320px, calc(100% - 32px));
  padding: 10px 13px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.78), rgba(30, 64, 175, 0.58));
}

.game-banner strong {
  font-size: 1.15rem;
  line-height: 1;
}

.game-banner span {
  color: #dbeafe;
  font-size: 0.78rem;
}

.commander-card {
  position: absolute;
  z-index: 2;
  right: 16px;
  top: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 16px;
  background: rgba(9, 17, 31, 0.68);
}

.commander-card > span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--amber), var(--pink));
  color: #fff;
  font-weight: 900;
}

.commander-card strong,
.commander-card small {
  display: block;
}

.commander-card small {
  color: var(--muted);
}

.city-controls {
  position: absolute;
  z-index: 3;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
}

.round-control {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255,255,255,0.7);
  border-radius: 50%;
  color: #0f172a;
  background: linear-gradient(180deg, #fff, #bfdbfe);
  font-weight: 900;
}

.city-plane {
  position: absolute;
  left: 50%;
  bottom: -120px;
  width: 840px;
  height: 620px;
  transform: translateX(-50%) rotateX(58deg) rotateZ(45deg);
  transform-style: preserve-3d;
  border-radius: 22px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.12) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,0.12) 1px, transparent 1px),
    linear-gradient(135deg, #54c88b, #2e8e72 55%, #29795f);
  background-size: 70px 70px, 70px 70px, auto;
}

.road {
  position: absolute;
  background: rgba(29, 39, 56, 0.72);
  border: 1px solid rgba(255,255,255,0.12);
}

.road.r1 { left: 0; top: 274px; width: 840px; height: 42px; }
.road.r2 { left: 398px; top: 0; width: 42px; height: 620px; }
.road.r3 { left: 112px; top: 112px; width: 42px; height: 430px; }

.plot {
  position: absolute;
  width: 110px;
  height: 110px;
  transform-style: preserve-3d;
}

.plot::before {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.16);
}

.building {
  position: absolute;
  left: 31px;
  bottom: 26px;
  width: 48px;
  height: var(--height);
  transform: translateZ(calc(var(--height) / 2));
  transform-style: preserve-3d;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--color), #fff 16%), var(--color));
}

.building::after {
  content: "";
  position: absolute;
  inset: 8px 10px;
  border-radius: 4px;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,0.75) 0 4px, transparent 4px 11px);
  opacity: 0.68;
}

.plot.locked .building {
  filter: grayscale(1);
  opacity: 0.42;
}

.plot.active .building {
  animation: pulse 1.3s ease-in-out infinite alternate;
}

@keyframes pulse {
  to { filter: brightness(1.22); }
}

.city-tags {
  position: absolute;
  left: 14px;
  right: 150px;
  bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  background: rgba(10, 16, 28, 0.64);
  color: #e5eefb;
  font-size: 0.78rem;
  white-space: nowrap;
}

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

.action-card, .mission, .reward, .district-card, .log-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.action-card {
  display: grid;
  gap: 8px;
  min-height: 118px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
}

.action-card b { font-size: 0.92rem; }
.action-card small { color: var(--muted); }
.action-card strong { color: var(--amber); }

.mission-list, .district-list, .reward-list, .log-list {
  display: grid;
  gap: 9px;
}

.mission {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
}

.mission input { width: 18px; height: 18px; accent-color: var(--green); }
.mission strong, .reward strong, .district-card strong { display: block; margin-bottom: 3px; }
.mission small, .reward small, .district-card small { color: var(--muted); }
.gp { color: var(--amber); font-weight: 800; }

.district-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 11px;
}

.district-icon {
  width: 42px;
  height: 42px;
  background: var(--color);
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
}

.bar span {
  display: block;
  width: var(--w);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color), color-mix(in srgb, var(--color), #fff 28%));
}

.stat-large {
  display: grid;
  gap: 8px;
  min-height: 146px;
}

.stat-large strong { font-size: clamp(2rem, 4.6vw, 4.5rem); line-height: 0.95; }
.stat-large span { color: var(--muted); }

.level-track {
  display: grid;
  gap: 9px;
}

.level-track .bar { height: 12px; }

.reward {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
}

.buy-button, .secondary-button {
  min-height: 34px;
  border: 0;
  border-radius: 10px;
  padding: 0 12px;
  color: #08111f;
  font-weight: 800;
  background: var(--amber);
}

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

.secondary-button {
  color: #fff;
  background: rgba(79, 124, 255, 0.28);
  border: 1px solid rgba(79, 124, 255, 0.44);
}

.chart {
  display: flex;
  align-items: end;
  gap: 9px;
  min-height: 170px;
  padding-top: 12px;
}

.chart span {
  flex: 1;
  min-width: 14px;
  height: var(--h);
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--color, var(--primary)), var(--cyan));
}

.nova-panel {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.nova-mark {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: conic-gradient(from 120deg, var(--purple), var(--primary), var(--cyan), var(--purple));
}

.nova-input {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.nova-input input {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.log-item {
  padding: 10px;
  color: #dbeafe;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  max-width: min(420px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #09111f;
  transition: 180ms ease;
}

.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .game-shell { grid-template-columns: 1fr; }
  .command-deck {
    height: auto;
    z-index: 5;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav-link { flex: 0 0 auto; min-width: 128px; }
  .player-card { display: none; }
  .game-main { height: auto; min-height: 100vh; padding: 14px; }
  .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-12 { grid-column: span 12; }
}

@media (max-width: 720px) {
  .hud { align-items: stretch; flex-direction: column; }
  .hud-strip span { min-width: 96px; }
  .city-board { min-height: 430px; }
  .commander-card { display: none; }
  .game-banner { max-width: calc(100% - 32px); }
  .city-tags { right: 14px; bottom: 68px; }
  .city-plane {
    width: 650px;
    height: 500px;
    bottom: -110px;
  }
  .actions-grid { grid-template-columns: 1fr; }
  .mission { grid-template-columns: 22px minmax(0, 1fr); }
  .mission .gp { grid-column: 2; }
  .nova-input { flex-direction: column; }
}

