:root {
  color-scheme: light;
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #696b72;
  --line: #d8d5ca;
  --green: #2f7d63;
  --red: #b54a3f;
  --blue: #356da8;
  --gold: #a66f22;
  --violet: #6a5fa8;
  --shadow: 0 14px 40px rgba(38, 35, 27, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.link-button {
  border: 1px solid #1f2d2a;
  background: #1f2d2a;
  color: #fff;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

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

.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

h2 {
  margin-bottom: 12px;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 22px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 241, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-actions,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.wrap {
  flex-wrap: wrap;
}

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

.muted {
  color: var(--muted);
}

main {
  padding: 24px clamp(16px, 4vw, 48px) 42px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 18px;
  max-width: 920px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

form.panel {
  display: grid;
  gap: 16px;
}

.screen {
  max-width: 980px;
}

.lobby-panel {
  display: grid;
  gap: 16px;
}

.lobby-list {
  display: grid;
  gap: 10px;
}

.lobby-player,
.score-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 112px;
}

.main-stage {
  display: grid;
  gap: 16px;
}

.global-board,
.resource-row {
  display: grid;
  gap: 10px;
}

.stat,
.resource,
.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fbfaf7;
}

.stat b,
.resource b,
.mini-stat b {
  font-size: 1.05rem;
}

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

.player-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
}

.player-card.is-active {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(47, 125, 99, 0.15);
}

.player-card.is-self {
  border-color: var(--blue);
}

.player-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.badge {
  border-radius: 99px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  background: #edf2ef;
  color: #24493d;
}

.badge.ai {
  background: #f2eee0;
  color: #76551e;
}

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

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

.region {
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 0.75rem;
}

.region.on {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

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

.mission {
  max-width: 360px;
  color: var(--muted);
  font-size: 0.88rem;
}

.actions-panel {
  display: grid;
  gap: 16px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 16px;
}

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

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

.project-card {
  display: grid;
  gap: 10px;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #fff;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tag {
  font-size: 0.68rem;
  border-radius: 99px;
  padding: 3px 7px;
  font-weight: 800;
  background: #eef1f2;
  color: #394246;
}

.card-cost {
  color: var(--gold);
  font-weight: 800;
}

.card-text {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.card-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.log {
  display: grid;
  gap: 8px;
  max-height: 340px;
  overflow: auto;
  color: var(--muted);
  font-size: 0.86rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #202124;
  color: #fff;
  padding: 12px 16px;
  border-radius: 7px;
  box-shadow: var(--shadow);
  z-index: 30;
}

.scores {
  display: grid;
  gap: 12px;
}

.score-row strong {
  font-size: 1.2rem;
}

@media (max-width: 900px) {
  .home-grid,
  .game-shell,
  .cards-layout,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
