:root {
  --bg: #050713;
  --panel: rgba(9, 14, 34, 0.76);
  --panel-strong: rgba(7, 10, 25, 0.92);
  --white: #f8fbff;
  --muted: #9ca9c7;
  --blue: #006bff;
  --cyan: #38bdf8;
  --purple: #a855f7;
  --violet: #6d28d9;
  --dark: #02040d;
  --danger: #ff4278;
  --good: #54f0b0;
  --border: rgba(112, 166, 255, 0.25);
  --shadow: 0 26px 90px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow-x: hidden;
  color: var(--white);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

.scene-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 107, 255, .42), transparent 26%),
    radial-gradient(circle at 84% 18%, rgba(168, 85, 247, .34), transparent 26%),
    radial-gradient(circle at 50% 94%, rgba(56, 189, 248, .22), transparent 28%),
    linear-gradient(145deg, #030510 0%, #080a1b 48%, #050817 100%);
  z-index: -3;
}
.grid {
  position: absolute;
  inset: 0;
  opacity: .18;
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(650px) rotateX(58deg) translateY(-180px) scale(1.35);
  transform-origin: top center;
  animation: gridMove 14s linear infinite;
}
.orb {
  position: absolute;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(42px);
  opacity: .45;
  animation: float 8s ease-in-out infinite;
}
.orb-blue { left: -90px; top: 18%; background: var(--blue); }
.orb-purple { right: -100px; top: 8%; background: var(--purple); animation-delay: -2s; }
.orb-cyan { left: 42%; bottom: -160px; background: var(--cyan); animation-delay: -4s; }
.sparks span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255,255,255,.75);
  box-shadow: 0 0 18px rgba(87, 190, 255, .9);
  animation: spark 3s ease-in-out infinite;
}

@keyframes gridMove { to { background-position: 0 44px, 44px 0; } }
@keyframes float { 50% { transform: translate3d(24px, -30px, 0) scale(1.08); } }
@keyframes spark { 0%, 100% { opacity: .1; transform: translateY(0) scale(.6); } 50% { opacity: .9; transform: translateY(-22px) scale(1.2); } }
@keyframes popIn { from { opacity: 0; transform: translateY(18px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes cardEnter { from { opacity: 0; transform: translateY(22px) rotate(-1deg); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { box-shadow: 0 0 32px rgba(0, 107, 255, .45); } }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}
.screen { display: none; animation: popIn .38s ease both; }
.screen.active { display: block; }

.hero-card {
  display: grid;
  grid-template-columns: 320px 1fr;
  align-items: center;
  gap: 34px;
  padding: 28px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: 34px;
  background: linear-gradient(135deg, rgba(8,12,31,.88), rgba(12,17,43,.64));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  inset: -2px;
  pointer-events: none;
  background: linear-gradient(120deg, transparent, rgba(0,107,255,.18), rgba(168,85,247,.2), transparent);
  mask: linear-gradient(#000, transparent 70%);
}
.main-logo {
  width: 100%;
  filter: drop-shadow(0 24px 34px rgba(0, 0, 0, .6)) drop-shadow(0 0 18px rgba(0, 107, 255, .35));
  animation: pulse 4s ease-in-out infinite;
}
.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 12px;
  font-weight: 900;
}
h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 12px;
  font-family: Anton, Inter, sans-serif;
  font-size: clamp(42px, 7vw, 92px);
  line-height: .93;
  text-transform: uppercase;
  letter-spacing: .02em;
  text-shadow: 0 7px 0 #02040d, 0 0 32px rgba(0, 107, 255, .35);
}
.lead {
  max-width: 680px;
  color: #dbe8ff;
  font-size: 18px;
  line-height: 1.65;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1.25fr .75fr;
  gap: 22px;
}
.panel, .players-card, .table-card, .topbar {
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.panel { padding: 24px; }
.panel h2 { font-size: 26px; margin-bottom: 18px; }
label {
  display: block;
  margin: 14px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}
input {
  width: 100%;
  border: 1px solid rgba(118, 171, 255, .24);
  border-radius: 18px;
  padding: 16px 18px;
  outline: none;
  background: rgba(0,0,0,.28);
  color: var(--white);
  font: inherit;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03);
}
input:focus { border-color: rgba(56, 189, 248, .85); box-shadow: 0 0 0 4px rgba(56, 189, 248, .11); }
.code-input { text-transform: uppercase; letter-spacing: .25em; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.preset {
  cursor: pointer;
  min-height: 112px;
  padding: 16px;
  border: 1px solid rgba(118, 171, 255, .23);
  border-radius: 20px;
  color: var(--white);
  text-align: left;
  background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.025));
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.preset:hover { transform: translateY(-3px); border-color: rgba(56, 189, 248, .72); }
.preset.active { background: linear-gradient(145deg, rgba(0,107,255,.38), rgba(168,85,247,.22)); border-color: rgba(56, 189, 248, .9); }
.preset strong { display: block; font-size: 16px; margin-bottom: 8px; }
.preset span { display: block; color: #b9c7e9; font-size: 12px; line-height: 1.35; }

.btn, .copy-btn {
  border: 0;
  cursor: pointer;
  border-radius: 18px;
  color: var(--white);
  font: inherit;
  font-weight: 950;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}
.btn {
  width: 100%;
  margin-top: 18px;
  padding: 16px 22px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.btn:hover, .copy-btn:hover { transform: translateY(-2px); filter: brightness(1.12); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary { background: linear-gradient(135deg, var(--blue), var(--purple)); box-shadow: 0 16px 38px rgba(0,107,255,.28); }
.secondary { background: linear-gradient(135deg, #18284f, #5030b4); box-shadow: 0 16px 38px rgba(168,85,247,.22); }
.copy-btn { padding: 10px 14px; background: rgba(56,189,248,.16); border: 1px solid rgba(56,189,248,.35); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  margin-bottom: 22px;
}
.room-code-row { display: flex; align-items: center; gap: 12px; }
.room-code-row h2 { margin: 0; font-size: 34px; letter-spacing: .16em; }
.status-pill {
  padding: 12px 18px;
  border-radius: 999px;
  background: rgba(84, 240, 176, .12);
  color: var(--good);
  border: 1px solid rgba(84, 240, 176, .25);
  font-weight: 900;
}
.game-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
}
.players-card { padding: 20px; align-self: start; }
.aside-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.aside-head h3 { margin: 0; }
.aside-head span { color: var(--cyan); font-weight: 900; }
.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.player-row:last-child { border-bottom: 0; }
.player-name { font-weight: 900; }
.player-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag {
  display: inline-flex;
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  background: rgba(255,255,255,.08);
  color: #cfe0ff;
}
.tag.host { color: #ffe8a8; background: rgba(255, 207, 89, .13); }
.tag.judge { color: #dfc8ff; background: rgba(168, 85, 247, .17); }
.tag.ready { color: #b9ffe4; background: rgba(84, 240, 176, .12); }
.score { font-family: Anton, Inter, sans-serif; font-size: 28px; color: var(--cyan); }
.table-card { min-height: 620px; padding: 24px; position: relative; overflow: hidden; }
.table-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(0,107,255,.18), transparent 38%);
  pointer-events: none;
}
.lobby-view, .game-view { position: relative; z-index: 1; }
.lobby-view {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 560px;
}
.lobby-view h2 { font-size: clamp(34px, 5vw, 60px); margin-bottom: 8px; }
.lobby-view p { max-width: 580px; color: var(--muted); line-height: 1.65; }
.room-big-code {
  margin: 20px 0 8px;
  padding: 18px 26px;
  border-radius: 24px;
  background: rgba(0,0,0,.33);
  border: 1px dashed rgba(56,189,248,.5);
  font-size: clamp(38px, 7vw, 86px);
  font-weight: 1000;
  letter-spacing: .18em;
  text-shadow: 0 0 25px rgba(56,189,248,.4);
}
.round-meta { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; color: var(--muted); font-weight: 900; }
.black-card {
  min-height: 180px;
  display: flex;
  align-items: flex-end;
  padding: 24px;
  border-radius: 28px;
  color: white;
  background:
    linear-gradient(145deg, rgba(0,0,0,.92), rgba(10,14,34,.96)),
    radial-gradient(circle at top right, rgba(0,107,255,.28), transparent 40%);
  border: 1px solid rgba(255,255,255,.13);
  box-shadow: 0 18px 50px rgba(0,0,0,.45);
  font-size: clamp(25px, 4vw, 48px);
  font-weight: 1000;
  line-height: 1.06;
  animation: cardEnter .32s ease both;
}
.hint { margin: 18px 2px; color: #c2d4ff; font-weight: 800; }
.answers-zone {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.answer-card {
  min-height: 140px;
  border: 1px solid rgba(118, 171, 255, .22);
  border-radius: 22px;
  padding: 16px;
  color: #09101f;
  background: linear-gradient(145deg, #ffffff, #dbeaff);
  box-shadow: 0 18px 32px rgba(0,0,0,.25);
  font-weight: 950;
  text-align: left;
  cursor: pointer;
  animation: cardEnter .32s ease both;
}
.answer-card:hover { transform: translateY(-5px) rotate(.4deg); box-shadow: 0 22px 50px rgba(0,107,255,.22); }
.answer-card.disabled { cursor: default; opacity: .85; }
.answer-card.disabled:hover { transform: none; }
.answer-card.winner { background: linear-gradient(145deg, #c5ffec, #ffffff); border-color: rgba(84,240,176,.8); }
.answer-owner { margin-top: 18px; color: #33527e; font-size: 12px; font-weight: 1000; text-transform: uppercase; }
.hidden { display: none !important; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(7, 10, 25, .92);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 900;
  transition: .2s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .hero-card, .menu-grid, .game-layout { grid-template-columns: 1fr; }
  .main-logo { max-width: 360px; margin: 0 auto; }
  .preset-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; gap: 14px; flex-direction: column; }
}
@media (max-width: 560px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 12px; }
  .hero-card, .panel, .players-card, .table-card, .topbar { border-radius: 22px; padding: 16px; }
  .room-code-row h2 { font-size: 26px; }
  .answers-zone { grid-template-columns: 1fr; }
  .lobby-view { min-height: 420px; }
}
