:root {
  --bg: #12100d;
  --panel: #1c1813;
  --panel-2: #241f18;
  --line: #3b3327;
  --ink: #efe6d4;
  --muted: #a99d86;
  --gold: #d9a441;
  --gold-2: #f0c46a;
  --red: #b54a3a;
  --green: #4d8f5a;
  --blue: #4f7fa8;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 80% -10%, #3a2a18 0%, transparent 60%),
    radial-gradient(900px 500px at 0% 100%, #1d2a22 0%, transparent 55%),
    var(--bg);
  min-height: 100vh;
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 16, 13, .86);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: .02em;
  text-decoration: none;
  font-size: 18px;
}

.brand-icon { font-size: 24px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  font-size: 13px;
}

.user-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold); }

.center-card {
  min-height: calc(100vh - 62px);
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.parchment {
  width: min(560px, 100%);
  padding: 40px 34px;
  border-radius: 24px;
  border: 1px solid #5b4a2e;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), transparent 40%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .015) 0 1px, transparent 1px 4px),
    #211b13;
  box-shadow: var(--shadow);
  text-align: center;
}

h1 {
  margin: 6px 0 12px;
  font-size: clamp(38px, 7vw, 56px);
  letter-spacing: -.03em;
  line-height: 1;
}

h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
h3 { margin: 0 0 8px; font-size: 16px; }

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}

.lead { color: var(--muted); line-height: 1.6; margin: 0 0 24px; font-size: 15px; }
.hint { color: #8d826d; font-size: 12.5px; line-height: 1.5; margin: 16px 0 0; }
.muted { color: var(--muted); font-size: 13.5px; line-height: 1.55; }
.error { color: #ff9c8a; font-size: 13px; margin: 14px 0 0; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--ink);
  background: var(--panel-2);
  transition: transform .12s ease, border-color .12s ease, opacity .12s ease;
}

.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: #6b5a3d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  border-color: #8a6a2f;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #241a09;
}

.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 9px; }

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 45%), var(--panel);
  padding: 18px;
  min-width: 0;
}

.panel-wide { grid-column: 1 / -1; }
.panel.compact { padding: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.players, .friends { display: grid; gap: 8px; }

.player-row, .friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .02);
}

.player-row .name, .friend-row .name { font-weight: 700; font-size: 13.5px; }
.player-row .meta, .friend-row .meta { color: var(--muted); font-size: 11.5px; }
.player-row .grow, .friend-row .grow { flex: 1; min-width: 0; }
.player-row .name, .friend-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); display: inline-block; }
.offline-dot { width: 7px; height: 7px; border-radius: 50%; background: #5b5347; display: inline-block; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
  font-size: 12.5px;
  color: var(--muted);
  padding-right: 4px;
}

.log div { padding-bottom: 5px; border-bottom: 1px solid rgba(255, 255, 255, .04); }

.notice {
  max-width: 1100px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border: 1px solid #6b4b2a;
  border-radius: 12px;
  background: #2a2116;
  color: #e8c99a;
  font-size: 13.5px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  max-width: 1460px;
  margin: 0 auto;
  padding: 16px;
}

.map-panel { min-width: 0; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.stat {
  flex: 1 1 120px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  padding: 9px 12px;
}

.stat .label { color: var(--muted); font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.stat .value { font-size: 18px; font-weight: 800; margin-top: 2px; }

.map-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(600px 300px at 30% 20%, rgba(217, 164, 65, .08), transparent 60%),
    #17140f;
  padding: 8px;
  overflow: auto;
}

#map { width: 100%; height: auto; display: block; min-width: 600px; }
.map-cell { cursor: pointer; transition: filter .15s ease, stroke .15s ease; }
.map-cell:hover { filter: brightness(1.12); }
.map-cell.selected { stroke: var(--gold-2); stroke-width: 4; }
.map-cell.adjacent { stroke: #8b7a58; stroke-width: 2; stroke-dasharray: 6 5; }
.province-label { fill: #f7eeda; font-size: 15px; font-weight: 800; pointer-events: none; text-anchor: middle; }
.province-army { fill: #f7eeda; font-size: 12px; font-weight: 700; pointer-events: none; text-anchor: middle; opacity: .9; }
.province-yield { fill: rgba(247, 238, 218, .65); font-size: 10px; pointer-events: none; text-anchor: middle; }

.sidebar { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.sidebar .panel { padding: 13px; }
.sidebar h3 { font-size: 13.5px; letter-spacing: .02em; }
.sidebar .muted, .sidebar .log { font-size: 12px; }

.province-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.province-actions .btn { flex: 1 1 45%; }

.neighbors { display: grid; gap: 6px; margin-top: 10px; }

.timer { color: var(--gold-2); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  border: 1px solid #6b5a3d;
  background: #2a2319;
  color: var(--ink);
  font-size: 13px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .layout-two { grid-template-columns: 1fr; }
  .game-layout { grid-template-columns: 1fr; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; }
  .sidebar .panel:first-child { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .parchment { padding: 28px 20px; }
  .topbar { padding: 10px 12px; }
  .brand span:last-child { font-size: 16px; }
  .sidebar { grid-template-columns: 1fr; }
  .game-layout { padding: 10px; }
}
