:root {
  --bg: #090d1a;
  --bg2: #101735;
  --card: rgba(255, 255, 255, 0.075);
  --card2: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.16);
  --text: #f7f8ff;
  --muted: #aeb8d6;
  --accent: #7c5cff;
  --accent2: #19d3da;
  --good: #33d17a;
  --warn: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, .38);
  --radius: 28px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(124, 92, 255, .38), transparent 28%),
    radial-gradient(circle at 88% 22%, rgba(25, 211, 218, .24), transparent 30%),
    linear-gradient(135deg, var(--bg), var(--bg2) 58%, #060814);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), transparent 88%);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 54px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: .16em;
  font-weight: 800;
  font-size: .74rem;
}

h1, h2, h3, p { margin-top: 0; }
h1 {
  margin-bottom: 10px;
  font-size: clamp(2.45rem, 6vw, 5.6rem);
  letter-spacing: -0.08em;
  line-height: .9;
}
h2 { margin-bottom: 8px; font-size: clamp(1.55rem, 3vw, 2.3rem); letter-spacing: -0.04em; }
.subtitle { max-width: 760px; color: var(--muted); font-size: 1.06rem; line-height: 1.55; margin-bottom: 0; }
.hero-card, .screen {
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, var(--card), rgba(255,255,255,.045));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}
.hero-card {
  border-radius: var(--radius);
  padding: 22px 26px;
  min-width: 160px;
  text-align: center;
}
.hero-number { display: block; font-weight: 900; font-size: 3.2rem; letter-spacing: -0.08em; color: white; }
.hero-card span:last-child { color: var(--muted); font-weight: 700; }

.screen { border-radius: var(--radius); padding: clamp(20px, 4vw, 34px); }
.hidden { display: none !important; }
.section-head { margin-bottom: 22px; }
.section-head p { color: var(--muted); margin-bottom: 0; }
.center { text-align: center; }

.control-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.control-row label { color: var(--muted); font-weight: 800; }
select, input {
  color: var(--text);
  background: rgba(4, 7, 18, .68);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 14px 16px;
  outline: none;
}
select:focus, input:focus { border-color: rgba(25, 211, 218, .85); box-shadow: 0 0 0 4px rgba(25, 211, 218, .13); }
.team-inputs { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.team-field label { display: block; color: var(--muted); font-size: .86rem; font-weight: 800; margin: 0 0 6px 4px; }
.team-field input { width: 100%; }
.setup-actions, .topbar-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.center-actions { justify-content: center; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 13px 18px;
  font-weight: 900;
  color: var(--text);
  transition: transform .16s ease, filter .16s ease, background .16s ease;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.btn-secondary { background: rgba(255,255,255,.12); border: 1px solid var(--stroke); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.18); color: var(--muted); }

.history-preview { margin-top: 18px; color: var(--muted); line-height: 1.5; }

.game-topbar { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin-bottom: 18px; }
.scoreboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.team-score {
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.08);
  border-radius: 22px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.team-score::after {
  content: "";
  position: absolute;
  inset: auto -20% -70% 20%;
  height: 120px;
  background: radial-gradient(circle, rgba(25,211,218,.23), transparent 68%);
}
.team-name { color: var(--muted); font-weight: 900; margin-bottom: 6px; overflow-wrap: anywhere; }
.team-points { font-size: 2rem; font-weight: 900; letter-spacing: -0.05em; }

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.category, .cell {
  min-height: 86px;
  border-radius: 22px;
  border: 1px solid var(--stroke);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 14px;
}
.category {
  background: rgba(255,255,255,.12);
  color: white;
  font-weight: 900;
  line-height: 1.12;
  font-size: .98rem;
}
.cell {
  color: white;
  background: linear-gradient(145deg, rgba(124,92,255,.75), rgba(25,211,218,.34));
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.05em;
  box-shadow: 0 14px 32px rgba(0,0,0,.24);
}
.cell.used {
  background: rgba(255,255,255,.055);
  color: rgba(255,255,255,.34);
  box-shadow: none;
  cursor: not-allowed;
}

.modal {
  width: min(860px, calc(100% - 28px));
  border: 0;
  border-radius: 34px;
  padding: 0;
  background: transparent;
  color: var(--text);
}
.modal::backdrop { background: rgba(2, 4, 12, .72); backdrop-filter: blur(12px); }
.modal-card {
  background: linear-gradient(180deg, rgba(19,26,57,.98), rgba(10,14,31,.98));
  border: 1px solid var(--stroke);
  border-radius: 34px;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: var(--shadow);
}
.modal-top { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 16px; }
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: white;
  font-size: 2rem;
  line-height: 1;
}
.question-text {
  font-size: clamp(1.5rem, 3.2vw, 2.45rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.04em;
  margin: 22px 0;
}
.answer-box {
  border: 1px solid rgba(51,209,122,.38);
  background: rgba(51,209,122,.105);
  color: #dfffea;
  border-radius: 24px;
  padding: 18px;
  line-height: 1.5;
  margin-bottom: 18px;
}
.answer-box strong { color: white; }
.modal-actions, .award-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.award-buttons .btn { background: rgba(255,255,255,.12); border: 1px solid var(--stroke); }

.final-ranking { display: grid; gap: 12px; max-width: 680px; margin: 0 auto 22px; }
.rank-row {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--stroke);
  background: rgba(255,255,255,.08);
  border-radius: 22px;
  padding: 14px 16px;
}
.rank-pos { font-size: 1.7rem; font-weight: 900; }
.rank-name { font-weight: 900; overflow-wrap: anywhere; }
.rank-score { font-weight: 900; color: var(--accent2); }

@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; }
  .hero-card { display: none; }
  .team-inputs { grid-template-columns: 1fr; }
  .game-topbar { flex-direction: column; }
  .board { gap: 8px; }
  .category { min-height: 74px; font-size: .72rem; border-radius: 16px; padding: 8px; }
  .cell { min-height: 70px; border-radius: 16px; font-size: 1.25rem; }
  .scoreboard { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
