:root {
  --bg: #070b12;
  --panel: rgba(9, 16, 29, 0.86);
  --panel-strong: rgba(12, 23, 41, 0.96);
  --border: rgba(148, 163, 184, 0.22);
  --text: #e5edf8;
  --muted: #94a3b8;
  --gold: #facc15;
  --blue: #38bdf8;
  --red: #f87171;
  --green: #34d399;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font: Inter, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(circle at 15% 15%, rgba(56, 189, 248, 0.15), transparent 34rem),
    radial-gradient(circle at 85% 5%, rgba(250, 204, 21, 0.12), transparent 28rem),
    linear-gradient(135deg, #030712, #0f172a 62%, #111827);
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
  min-height: 100dvh;
}

.shell-screen {
  display: grid;
  place-items: center;
  padding: 24px;
}

.card,
.side-panel,
.modal-box {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-card {
  width: min(94vw, 460px);
  padding: 38px;
}

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

h1 {
  margin-bottom: 10px;
  color: #fff;
  font-size: clamp(2.6rem, 8vw, 4.8rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

h2,
h3 {
  margin-bottom: 12px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

.message {
  min-height: 1.4em;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 24px 0 16px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.26);
}

.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.tab.active {
  color: #06111f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #fb923c);
}

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

input,
select,
textarea {
  width: 100%;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  color: var(--text);
  background: rgba(2, 6, 23, 0.72);
  outline: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.16);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  color: var(--text);
  font-weight: 800;
  background: rgba(15, 23, 42, 0.78);
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  color: #06111f;
  border: 0;
  background: linear-gradient(135deg, var(--gold), #fb923c);
}

.btn.secondary {
  border-color: rgba(56, 189, 248, 0.36);
  background: rgba(14, 116, 144, 0.42);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.05);
}

.btn.tiny {
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 0.84rem;
}

.dashboard {
  width: min(1180px, 96vw);
}

.topbar,
.section-header,
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(2, 6, 23, 0.52);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 18px;
}

.dashboard-grid .card {
  padding: 24px;
}

.dashboard-grid .card:nth-child(3) {
  grid-column: 1 / -1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.checkbox-row {
  align-content: center;
  grid-template-columns: auto 1fr;
  gap: 10px;
  min-height: 70px;
}

.checkbox-row input {
  width: auto;
  margin: 0;
}

.join-row,
.chat-form {
  display: flex;
  gap: 10px;
}

.join-row input,
.chat-form input {
  margin: 0;
}

.list {
  display: grid;
  gap: 12px;
  max-height: 410px;
  overflow: auto;
}

.game-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.58);
}

.game-card strong {
  color: #fff;
}

.game-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.game-layout {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 320px;
  min-height: 100vh;
}

.side-panel {
  position: relative;
  z-index: 2;
  margin: 14px;
  padding: 18px;
  border-radius: 22px;
  background: var(--panel-strong);
  overflow: auto;
}

.board-wrap {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at center, rgba(51, 65, 85, 0.38), transparent 38rem),
    linear-gradient(180deg, rgba(15, 23, 42, 0.5), rgba(2, 6, 23, 0.7));
}

#board-canvas,
#labels-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#labels-layer {
  pointer-events: none;
}

.territory-label {
  position: absolute;
  min-width: 76px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  background: rgba(2, 6, 23, 0.78);
  transform: translate(-50%, -50%);
}

.board-help {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(2, 6, 23, 0.7);
}

.status-pill {
  display: inline-flex;
  padding: 6px 10px;
  border-radius: 999px;
  color: #06111f;
  font-weight: 900;
  background: var(--gold);
}

.players,
.actions {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.player-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.log,
.chat {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
}

.log-entry,
.chat-entry {
  padding: 9px;
  border-radius: 12px;
  color: #dbeafe;
  font-size: 0.86rem;
  background: rgba(2, 6, 23, 0.54);
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat {
  flex: 1;
  min-height: 240px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 23, 0.72);
}

.modal-box {
  width: min(760px, 96vw);
  max-height: 88vh;
  padding: 24px;
  overflow: auto;
}

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

.stat {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.stat strong {
  display: block;
  color: #fff;
  font-size: 1.6rem;
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 280px 1fr;
  }

  .chat-panel {
    grid-column: 1 / -1;
    min-height: 340px;
  }
}

@media (max-width: 760px) {
  .dashboard-grid,
  .form-grid,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .board-wrap {
    min-height: 70vh;
  }
}
