:root {
  --bg: #1c1027;
  --panel: rgba(30, 18, 44, 0.88);
  --panel-border: rgba(255, 255, 255, 0.14);
  --sand-1: #f3d59c;
  --sand-2: #d9b265;
  --purple: #a56cff;
  --text: #f9f4ff;
  --muted: #c7b7d6;
  --success: #56d58f;
  --danger: #ff7a90;
  --shadow: 0 14px 40px rgba(0,0,0,0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at top, #301746, var(--bg) 52%); color: var(--text); font-family: Inter, system-ui, sans-serif; }
body { overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; position: relative; z-index: 5;
}
.topbar h1 { margin: 0; font-family: 'Baloo 2', sans-serif; font-size: clamp(2rem, 4vw, 3rem); line-height: 0.95; }
.tagline { margin: 4px 0 0; color: var(--muted); }
.layout { flex: 1; position: relative; }
.hero {
  display: grid; grid-template-columns: minmax(320px, 560px) minmax(280px, 420px);
  gap: 24px; padding: 24px; align-items: start;
}
.hero-card {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 28px; box-shadow: var(--shadow);
  padding: 24px;
}
.hero-card h2 { margin: 0 0 16px; font-family: 'Baloo 2', sans-serif; font-size: 2rem; line-height: 1; }
.hero-card ul { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.6; }
.eyebrow { margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; font-weight: 700; color: #d6b8ff; }
.eyebrow.small { margin-bottom: 2px; }
.stacked-form { display: grid; gap: 16px; }
.stacked-form.compact { gap: 14px; }
label { display: grid; gap: 8px; font-weight: 600; }
input, select {
  width: 100%; border: 1px solid rgba(255,255,255,0.14); border-radius: 16px; background: rgba(255,255,255,0.06); color: var(--text);
  padding: 12px 14px; outline: none;
}
input:focus, select:focus { border-color: rgba(165,108,255,0.8); box-shadow: 0 0 0 3px rgba(165,108,255,0.18); }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; align-items: center; }
.actions.wrap { flex-wrap: wrap; }
.primary, .ghost, .icon-btn {
  border: 0; border-radius: 999px; padding: 12px 18px; transition: transform .15s ease, opacity .15s ease;
}
.primary:hover, .ghost:hover, .icon-btn:hover { transform: translateY(-1px); }
.primary { background: linear-gradient(135deg, #b870ff, #864bff); color: white; font-weight: 700; }
.ghost { background: rgba(255,255,255,0.08); color: var(--text); }
.icon-btn { width: 40px; height: 40px; padding: 0; background: rgba(255,255,255,0.08); color: white; font-size: 1.4rem; }
.color-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.color-chip {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; box-shadow: inset 0 0 0 2px rgba(255,255,255,0.22);
}
.color-chip.selected { border-color: white; transform: scale(1.07); }
.color-chip.taken { opacity: 0.28; filter: grayscale(0.7); cursor: not-allowed; }
.game-wrap { position: absolute; inset: 0; overflow: hidden; }
#gameCanvas { width: 100%; height: calc(100vh - 86px); display: block; }
.panel {
  position: absolute; right: 18px; bottom: 18px; width: min(370px, calc(100vw - 24px));
  background: rgba(20, 10, 28, 0.86); backdrop-filter: blur(14px); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; z-index: 6;
}
.panel-handle {
  padding: 8px 14px; background: rgba(255,255,255,0.05); color: #d9c5ef; font-size: 0.82rem; cursor: grab; user-select: none;
}
.panel-header { display: flex; justify-content: space-between; align-items: start; padding: 16px 16px 10px; }
.panel-header h3 { margin: 0; font-family: 'Baloo 2', sans-serif; font-size: 1.7rem; line-height: 1; }
.panel-section { padding: 0 16px 16px; }
.status-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pill { background: rgba(86, 213, 143, 0.16); color: #8ff0b6; border-radius: 999px; padding: 6px 10px; font-size: 0.82rem; font-weight: 700; }
.players-block, .help-block {
  margin-top: 16px; padding: 14px; border-radius: 18px; background: rgba(255,255,255,0.045);
}
.players-block h4, .help-block h4 { margin: 0 0 10px; }
.players-list { display: grid; gap: 10px; }
.player-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; background: rgba(255,255,255,0.05); border-radius: 16px; padding: 10px 12px;
}
.player-color { width: 14px; height: 14px; border-radius: 50%; }
.player-meta small { color: var(--muted); display: block; }
.badge { font-size: 0.75rem; font-weight: 700; border-radius: 999px; padding: 5px 8px; background: rgba(255,255,255,0.08); }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; z-index: 7;
  background: radial-gradient(circle, rgba(15,10,20,0.18), rgba(15,10,20,0.48));
  font-family: 'Baloo 2', sans-serif; font-size: clamp(3rem, 10vw, 8rem); text-shadow: 0 10px 24px rgba(0,0,0,0.4);
}
.winner-banner {
  position: absolute; left: 50%; top: 28px; transform: translateX(-50%); z-index: 8;
  background: rgba(58, 34, 82, 0.92); border: 1px solid rgba(255,255,255,0.15); border-radius: 999px; padding: 14px 22px;
  font-family: 'Baloo 2', sans-serif; font-size: clamp(1.25rem, 2.4vw, 2rem); box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .hero { grid-template-columns: 1fr; }
  .game-wrap { position: relative; }
  #gameCanvas { height: 72vh; }
  .panel { width: calc(100vw - 20px); right: 10px; bottom: 10px; }
}
