:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --felt: #123c2d;
  --felt-dark: #08271d;
  --panel: rgba(7, 29, 22, 0.92);
  --panel-soft: rgba(255, 255, 255, 0.07);
  --cream: #fff7df;
  --ink: #1c211d;
  --gold: #e2b85f;
  --muted: #b8c8c0;
  --danger: #ff8b8b;
  --success: #8ee3b2;
  --border: rgba(255, 255, 255, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,255,255,0.07), transparent 35%),
    linear-gradient(150deg, var(--felt), var(--felt-dark));
  color: white;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.brand {
  text-align: center;
  margin: 8px 0 24px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.brand p { color: var(--muted); margin: 12px auto 0; max-width: 680px; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.sidebar { grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.75fr); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,0.22);
}

.panel h2, .panel h3 { margin-top: 0; }

label {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 6px;
}

input, select {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.24);
  color: white;
  border-radius: 11px;
  padding: 12px 13px;
  outline: none;
}

input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(226,184,95,0.16); }

.form-row { margin-bottom: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.btn {
  border: 0;
  border-radius: 11px;
  padding: 11px 16px;
  background: var(--gold);
  color: #1d1708;
  font-weight: 800;
}

.btn.secondary { background: rgba(255,255,255,0.12); color: white; border: 1px solid var(--border); }
.btn.danger { background: #7f2727; color: white; }
.btn.small { padding: 7px 10px; border-radius: 9px; font-size: 0.85rem; }

.notice, .error, .success {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 14px 0;
}
.notice { background: rgba(226,184,95,0.13); border: 1px solid rgba(226,184,95,0.35); }
.error { background: rgba(255,70,70,0.14); border: 1px solid rgba(255,139,139,0.4); color: #ffd5d5; }
.success { background: rgba(62,180,115,0.14); border: 1px solid rgba(142,227,178,0.4); color: #d8ffea; }

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--cream);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: 13px;
  margin-bottom: 16px;
}

.game-code { font-weight: 950; font-size: clamp(1.8rem, 7vw, 3.4rem); letter-spacing: 0.12em; }

.player-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
}
.player-name { font-weight: 800; }
.player-meta { color: var(--muted); font-size: 0.86rem; }

.table-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.status-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { background: rgba(255,255,255,0.1); border: 1px solid var(--border); padding: 7px 10px; border-radius: 999px; font-size: 0.88rem; }
.pill.gold { color: #ffe3a3; border-color: rgba(226,184,95,0.5); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px; }
.card {
  min-height: 170px;
  border-radius: 15px;
  padding: 14px;
  background: var(--cream);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 3px solid rgba(0,0,0,0.13);
  box-shadow: 0 9px 22px rgba(0,0,0,0.2);
}
.card.face-down {
  color: white;
  background: repeating-linear-gradient(45deg, #193f56, #193f56 10px, #24546f 10px, #24546f 20px);
  border-color: rgba(255,255,255,0.28);
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}
.card-topic { font-size: 1.15rem; font-weight: 950; line-height: 1.05; }
.card-difficulty { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-weight: 800; }
.card-icon { font-size: 2rem; }

.seat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; }
.seat { background: rgba(255,255,255,0.07); border: 1px solid var(--border); border-radius: 12px; padding: 11px; }
.seat.current { border-color: var(--gold); }
.seat-badges { min-height: 24px; display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.badge { font-size: 0.74rem; border-radius: 999px; padding: 3px 7px; background: rgba(255,255,255,0.11); }

.muted { color: var(--muted); }
.hidden { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

.loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 30px;
}
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: var(--muted); margin-top: 30px; font-size: 0.85rem; }

@media (max-width: 760px) {
  .grid.two, .grid.sidebar { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .code-box { align-items: flex-start; flex-direction: column; }
  .game-code { font-size: 2.35rem; }
}
