:root {
  --text: #f3f6ff;
  --ok: #18cc87;
  --bad: #ff5d73;
  --warn: #ffd166;
  --accent: #35c2ff;
  --panel: #111831;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, #133467 0%, transparent 40%),
    radial-gradient(circle at 80% 0%, #1d1a4e 0%, transparent 36%),
    linear-gradient(170deg, #060a14, #0d1428 64%, #121a32);
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 14px;
}

.game {
  width: min(1180px, 98vw);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border: 1px solid rgba(255,255,255,0.11);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  position: relative;
}

.title {
  margin: 0 0 14px;
  font-size: clamp(1.4rem, 2.9vw, 2rem);
}

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

.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.stat-label {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  opacity: 0.78;
  text-transform: uppercase;
}

.stat-value {
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.1;
}

.stat-value.inline {
  font-size: 1.15rem;
}

.timer-urgent {
  color: #ff8a9b;
  text-shadow: 0 0 12px rgba(255, 93, 115, 0.35);
}

.question-panel {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.1);
}

.avatar.sm {
  width: 24px;
  height: 24px;
}

.ghost-btn {
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0.85;
}

.lives {
  color: var(--warn);
}

#lives {
  transition: transform 0.2s ease;
  display: inline-block;
}

#lives.hit {
  transform: scale(1.15);
}

#question {
  font-size: clamp(1.08rem, 2.2vw, 1.34rem);
  margin: 0 0 16px;
  line-height: 1.42;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.option {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 12px;
  text-align: left;
  padding: 12px 14px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.13s ease, border-color 0.2s ease, background 0.2s ease;
}

.option:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: rgba(53,194,255,0.12);
}

.option:disabled { opacity: 0.62; cursor: not-allowed; }

.feedback {
  min-height: 24px;
  margin-top: 16px;
  font-weight: 700;
}

.ok { color: var(--ok); }
.bad { color: var(--bad); }

.start-overlay,
.wrong-popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: grid;
  place-items: center;
  z-index: 50;
}

.card {
  width: min(520px, 92%);
  background: #171432;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 36px rgba(0,0,0,0.55);
}

.card h2 { margin-top: 0; }

.intro-screen {
  text-align: center;
}

.intro-screen p {
  margin: 0 0 18px;
  font-size: clamp(1.1rem, 2.4vw, 1.4rem);
  font-weight: 800;
  line-height: 1.4;
}

.account-screen {
  display: none;
}

.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

label {
  font-size: 0.9rem;
  opacity: 0.9;
}

input[type="text"],
input[type="password"],
input[type="file"] {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  outline: none;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 800;
  background: var(--accent);
  color: #02111b;
}

.btn.secondary {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}

.auth-msg {
  min-height: 20px;
  margin-top: 8px;
  font-weight: 700;
}

.logged-panel {
  display: none;
  margin-top: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.05);
}

.logged-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 700;
}

.wrong-popup {
  display: none;
  z-index: 60;
}

.wrong-card {
  width: min(980px, 96vw);
  background: #1b1328;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 16px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0,0,0,0.55);
}

.wrong-card img {
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  display: block;
  background: rgba(0, 0, 0, 0.45);
}

.wrong-card p {
  margin: 10px 14px 16px;
  font-size: 1.24rem;
  font-weight: 800;
}

.answer-burst {
  position: fixed;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -20px) scale(0.88);
  opacity: 0;
  z-index: 70;
  pointer-events: none;
  border-radius: 16px;
  padding: 14px 18px;
  font-size: clamp(1.1rem, 2.5vw, 1.7rem);
  font-weight: 900;
  border: 1px solid transparent;
  background: rgba(0,0,0,0.65);
  transition: opacity 0.18s ease, transform 0.25s ease;
}

.answer-burst.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.answer-burst.ok {
  color: #c9ffe8;
  border-color: rgba(24,204,135,0.55);
  box-shadow: 0 0 32px rgba(24,204,135,0.34);
}

.answer-burst.bad {
  color: #ffe1e7;
  border-color: rgba(255,93,115,0.56);
  box-shadow: 0 0 30px rgba(255,93,115,0.34);
}

.gameover,
.ranking {
  display: none;
  margin-top: 18px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.15);
  padding: 14px;
}

.gameover { background: rgba(255, 93, 115, 0.13); }
.ranking { background: rgba(53,194,255,0.11); }

.gameover-title {
  margin: 0;
  font-size: clamp(2.2rem, 7vw, 4.8rem);
  letter-spacing: 0.18em;
  line-height: 0.95;
  text-align: center;
  color: #ffe3e8;
  text-shadow:
    0 0 18px rgba(255, 93, 115, 0.45),
    0 0 38px rgba(255, 93, 115, 0.22);
}

.gameover-copy {
  margin-top: 10px;
  text-align: center;
  font-weight: 700;
}

.gameover img {
  width: 100%;
  margin-top: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  max-height: 60vh;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.35);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding: 8px 4px;
  text-align: left;
  vertical-align: middle;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .options {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .game { padding: 16px; }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .option { font-size: 0.95rem; }
  .wrong-card p { font-size: 1.05rem; }
  .btn-row { flex-direction: column; }
  .btn-row button { width: 100%; }
}