:root {
  --bg: #f6f3ff;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #f3e8ff;
  --line: rgba(124, 58, 237, 0.2);
  --text: #211432;
  --muted: #665779;
  --purple: #7c3aed;
  --purple-light: #6d28d9;
  --gold: #9a6700;
  --danger: #c32152;
  --success: #117a4a;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font: 500 17px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 8%, rgba(192, 132, 252, 0.35), transparent 29rem),
    radial-gradient(circle at 90% 95%, rgba(233, 213, 255, 0.9), transparent 30rem),
    linear-gradient(180deg, #fcfaff, #e9d5ff);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .23;
  background-image: radial-gradient(rgba(124,58,237,.42) .65px, transparent .65px);
  background-size: 24px 24px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.page-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 42px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 18px; font-weight: 800; letter-spacing: .025em; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(124,58,237,.35); border-radius: 12px; color: var(--purple); background: #f3e8ff; font-size: 22px; }
.eyebrow { margin: 0 0 8px; color: var(--purple-light); font-size: 13px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.panel { border: 1px solid var(--line); border-radius: 24px; background: var(--panel); box-shadow: 0 18px 48px rgba(124,58,237,.14); backdrop-filter: blur(16px); }
.button, button, .tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 12px 18px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 10px 25px rgba(124, 58, 237, .22);
  font-weight: 800;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.button:hover, button:hover, .tile:hover { transform: translateY(-2px); filter: brightness(1.07); box-shadow: 0 14px 28px rgba(139, 75, 235, .36); }
.button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
button:disabled { cursor: not-allowed; opacity: .55; transform: none; filter: none; }

.lang-select { min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 30px 9px 12px; color: var(--text); background: #fff; font-size: 16px; }
.lang-select option { color: var(--text); }
.form-page { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.form-card { width: min(100%, 460px); padding: 38px; text-align: center; }
.game-emblem { display: grid; width: 76px; height: 76px; margin: 0 auto 24px; place-items: center; border: 1px solid rgba(124,58,237,.32); border-radius: 24px; color: var(--purple); background: linear-gradient(145deg, #f3e8ff, #e9d5ff); font-size: 38px; box-shadow: inset 0 1px rgba(255,255,255,.8); }
h1 { margin: 0; font-size: clamp(30px, 6vw, 44px); line-height: 1.05; letter-spacing: -.04em; }
.lead { margin: 14px 0 28px; color: var(--muted); font-size: 18px; }
.field { width: 100%; min-height: 56px; border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px; color: var(--text); background: rgba(255,255,255,.86); outline: 0; font-size: 18px; }
.field::placeholder { color: #89779d; }
.form-stack { display: grid; gap: 12px; }
.form-stack button { width: 100%; }
.error { min-height: 24px; margin: 13px 0 0; color: var(--danger); font-size: 15px; }

.lobby { padding-top: clamp(44px, 10vh, 110px); }
.lobby-intro { max-width: 630px; }
.lobby-intro h1 { font-size: clamp(38px, 7vw, 64px); }
.lobby-intro .lead { max-width: 500px; font-size: 18px; }
.lobby-grid { display: grid; grid-template-columns: .9fr 1.6fr; gap: 22px; margin-top: 38px; align-items: start; }
.create-card { padding: 28px; }
.create-card h2, .rooms-card h2 { margin: 0 0 8px; font-size: 25px; }
.create-card p { margin: 0 0 22px; color: var(--muted); }
.create-card .tile { width: 100%; color: #fff; background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.rooms-card { min-height: 240px; padding: 28px; }
.rooms-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.rooms-list .tile { justify-content: flex-start; width: 100%; color: var(--text); border-color: var(--line); background: #faf7ff; box-shadow: none; font-weight: 700; }
.empty-state { margin: 36px 0 0; color: var(--muted); text-align: center; }

.room-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 16px; margin-top: 18px; align-items: start; }
.game-stage, .log-panel { padding: 20px; }
.room-meta { margin: 6px 0 0; color: var(--muted); word-break: break-word; }
.section-title { margin: 0; font-size: 21px; }
.players-list { display: grid; gap: 9px; margin-top: 18px; }
.player-item { display: flex; justify-content: space-between; gap: 8px; padding: 12px 14px; border: 1px solid rgba(124,58,237,.13); border-radius: 10px; background: #faf7ff; }
.player-item::before { content: "♦"; color: var(--gold); }
.timer { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 0; padding: 12px; border-radius: 12px; color: var(--purple); background: #f3e8ff; font-weight: 800; }
#startBtn { width: 100%; margin-top: 12px; }
.game-stage { display: flex; min-height: 0; flex-direction: column; }
.stage-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.stage-heading h1 { font-size: clamp(26px, 4vw, 36px); }
.round-timer { display: none; margin-bottom: 22px; color: var(--gold); font-size: 20px; font-weight: 800; }
.choice-caption { margin: 26px 0 14px; color: var(--muted); font-size: 18px; }
.choices { display: none; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px; max-width: 700px; }
.choice-btn { min-width: 0; min-height: 56px; padding: 8px; border: 1px solid rgba(124,58,237,.2); border-radius: 12px; color: var(--text); background: #faf7ff; box-shadow: none; font-size: 17px; }
.choice-btn:hover { border-color: var(--purple); color: #fff; background: var(--purple); box-shadow: none; }
.log-panel { min-height: 400px; }
.round-log { display: grid; gap: 12px; max-height: 580px; margin-top: 18px; overflow-y: auto; }
.round-log > div { padding: 14px; border-left: 3px solid var(--purple); border-radius: 0 12px 12px 0; background: #faf7ff; }
.winner { color: var(--success); font-weight: 800; }
.loser { color: var(--danger); }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; display: none; max-width: min(380px, calc(100% - 44px)); padding: 14px 18px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: #fff; box-shadow: 0 15px 40px rgba(76,29,149,.22); }

@media (max-width: 760px) {
  body { font-size: 18px; }
  .page-shell { width: min(100% - 24px, 1120px); padding-top: 12px; }
  .lobby { padding-top: 56px; }
  .lobby-grid, .room-layout { grid-template-columns: 1fr; }
  .game-stage { min-height: 420px; padding: 18px; }
  .log-panel { min-height: 0; padding: 18px; }
  .form-card { padding: 28px 20px; }
  .topbar { align-items: flex-start; }
  .game-stage { min-height: 0; }
  .choices { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
  .choice-btn { min-height: 60px; font-size: 18px; }
  .timer { font-size: 18px; }
}
