* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }

:root {
  --p1: #a855f7;       /* purple */
  --p1-dark: #6b21a8;
  --p1-glow: rgba(168, 85, 247, 0.5);
  --p2: #f97316;       /* orange */
  --p2-dark: #9a3412;
  --p2-glow: rgba(249, 115, 22, 0.5);
  --bg: #0b0018;
  --card: rgba(255,255,255,0.06);
  --text: #f4f0ff;
  --dim: #a89cc0;
  --good: #22c55e;
  --bad: #ef4444;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "Heebo", sans-serif;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  background:
    radial-gradient(circle at 30% 20%, rgba(168,85,247,0.15), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(249,115,22,0.15), transparent 50%),
    var(--bg);
  position: fixed;
  inset: 0;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  overflow-y: auto;
  animation: fadeIn 0.25s ease-out;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== HOME ===== */
.title-wrap {
  text-align: center;
  margin-bottom: 40px;
}
.title-glow {
  font-size: 80px;
  filter: drop-shadow(0 0 30px var(--p1-glow)) drop-shadow(0 0 60px var(--p2-glow));
  animation: bob 3s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-10px) rotate(5deg); }
}
.title {
  font-size: 42px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-top: 10px;
  letter-spacing: -1px;
}
.subtitle {
  color: var(--dim);
  font-size: 15px;
  margin-top: 8px;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.btn {
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 16px 20px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  backdrop-filter: blur(10px);
}
.btn:active { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(135deg, var(--p1), var(--p2));
  border: none;
  box-shadow: 0 8px 30px rgba(168,85,247,0.4);
  font-size: 19px;
  padding: 18px 20px;
}
.btn.ghost {
  background: transparent;
  color: var(--dim);
  border: 1px dashed rgba(255,255,255,0.15);
}

.players-preview {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--dim);
  font-size: 14px;
}
.prev-p1 { color: var(--p1); }
.prev-p2 { color: var(--p2); }
.vs-mini {
  font-weight: 900;
  color: var(--dim);
  font-size: 12px;
}

/* ===== HOW TO / NAMES / CATEGORIES ===== */
.back-btn {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  right: 20px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  z-index: 10;
}

h2 {
  font-size: 28px;
  margin-bottom: 24px;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hint {
  color: var(--dim);
  font-size: 14px;
  margin-bottom: 20px;
  text-align: center;
  max-width: 320px;
}

.rules {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 340px;
  width: 100%;
  margin-bottom: 30px;
}
.rule {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--card);
  padding: 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.5;
}
.rule-num {
  background: linear-gradient(135deg, var(--p1), var(--p2));
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  flex-shrink: 0;
}

.name-input {
  width: 100%;
  max-width: 340px;
  margin-bottom: 16px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: 14px;
  border-left: 4px solid;
}
.name-input.purple { border-color: var(--p1); }
.name-input.orange { border-color: var(--p2); }
.name-input label {
  display: block;
  font-size: 13px;
  color: var(--dim);
  margin-bottom: 6px;
}
.name-input input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 18px;
  font-family: inherit;
  outline: none;
  text-align: right;
  font-weight: 600;
}

.cat-item {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  padding: 14px 16px;
  border-radius: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.cat-item.on { background: linear-gradient(90deg, rgba(168,85,247,0.2), rgba(249,115,22,0.2)); border: 1px solid rgba(255,255,255,0.15); }
.cat-emoji { font-size: 26px; }
.cat-name { flex: 1; font-weight: 600; font-size: 16px; }
.cat-check { font-size: 22px; opacity: 0.3; }
.cat-item.on .cat-check { opacity: 1; }

/* ===== COUNTDOWN ===== */
#countdown { background: radial-gradient(circle, rgba(168,85,247,0.3), var(--bg)); }
.cd-content { text-align: center; }
.cd-ready {
  font-size: 36px;
  font-weight: 900;
  color: var(--dim);
  margin-bottom: 20px;
}
.cd-num {
  font-size: 180px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--p1), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: pulse 1s ease-out;
  filter: drop-shadow(0 0 40px var(--p1-glow));
}
@keyframes pulse {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.cd-num.go {
  font-size: 100px;
  background: linear-gradient(135deg, var(--good), #10b981);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ===== BATTLE ===== */
.battle-screen {
  padding: 0 !important;
  overflow: hidden;
}

.side {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.side-top {
  top: 0;
  transform: rotate(180deg);
  background: linear-gradient(180deg, rgba(168,85,247,0.15), transparent 70%);
  border-bottom: 2px solid rgba(255,255,255,0.1);
}
.side-bottom {
  bottom: 0;
  background: linear-gradient(0deg, rgba(249,115,22,0.15), transparent 70%);
  border-top: 2px solid rgba(255,255,255,0.1);
}

.side-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.player-name {
  font-weight: 800;
  font-size: 14px;
  padding: 3px 10px;
  border-radius: 10px;
  flex-shrink: 0;
}
.side-top .player-name { background: var(--p1-dark); color: white; }
.side-bottom .player-name { background: var(--p2-dark); color: white; }

.hp-bar {
  flex: 1;
  height: 18px;
  background: rgba(0,0,0,0.4);
  border-radius: 9px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
}
.hp-fill {
  height: 100%;
  width: 100%;
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
  border-radius: 9px;
}
.side-top .hp-fill { background: linear-gradient(90deg, var(--p1), #c084fc); }
.side-bottom .hp-fill { background: linear-gradient(90deg, var(--p2), #fb923c); }
.hp-fill.low { background: linear-gradient(90deg, #ef4444, #f59e0b) !important; animation: dangerPulse 0.6s ease-in-out infinite; }
@keyframes dangerPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}
.hp-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.combo-badge {
  font-size: 12px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 8px;
  background: linear-gradient(90deg, #f59e0b, #ef4444);
  color: white;
  display: none;
  animation: comboBounce 0.4s ease-out;
}
.combo-badge.show { display: block; }
@keyframes comboBounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.riddle-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  min-height: 0;
}
.riddle-cat {
  font-size: 20px;
  text-align: center;
  opacity: 0.7;
}
.riddle-q {
  font-size: clamp(14px, 4vw, 20px);
  font-weight: 700;
  text-align: center;
  line-height: 1.35;
  padding: 0 6px;
  color: var(--text);
}
.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 4px;
}
.ans-btn {
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  color: var(--text);
  padding: 12px 8px;
  border-radius: 12px;
  font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  min-height: 48px;
  line-height: 1.2;
}
.ans-btn:active { transform: scale(0.95); }
.ans-btn.correct {
  background: var(--good);
  border-color: var(--good);
  color: white;
  animation: correctPop 0.4s ease-out;
}
.ans-btn.wrong {
  background: var(--bad);
  border-color: var(--bad);
  color: white;
  animation: shake 0.4s ease-out;
}
.ans-btn.disabled { opacity: 0.4; pointer-events: none; }

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 60px;
  font-weight: 900;
  pointer-events: none;
  opacity: 0;
  z-index: 5;
}
.feedback.hit {
  animation: hitShow 0.9s ease-out forwards;
  color: var(--bad);
  text-shadow: 0 0 40px rgba(239,68,68,0.9);
}
.feedback.win {
  animation: hitShow 0.9s ease-out forwards;
  color: var(--good);
  text-shadow: 0 0 40px rgba(34,197,94,0.9);
}
@keyframes hitShow {
  0% { opacity: 0; transform: scale(0.3); }
  30% { opacity: 1; transform: scale(1.3); }
  70% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.1); }
}

/* Center divider */
.divider {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  height: 44px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15) 30%, rgba(255,255,255,0.15) 70%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 3;
  pointer-events: none;
}
.vs-big {
  font-size: 20px;
  font-weight: 900;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 2px;
}
.timer-ring {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--p1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 900;
  transition: border-color 0.3s;
}
.timer-ring.hot { border-color: var(--bad); animation: dangerPulse 0.4s ease-in-out infinite; }

/* Hit flash */
.hit-flash {
  position: absolute;
  inset: 0;
  background: rgba(239,68,68,0.4);
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}
.hit-flash.top { animation: flashTop 0.4s ease-out; }
.hit-flash.bottom { animation: flashBottom 0.4s ease-out; }
@keyframes flashTop {
  0% { opacity: 0; clip-path: inset(0 0 50% 0); }
  50% { opacity: 1; clip-path: inset(0 0 50% 0); }
  100% { opacity: 0; clip-path: inset(0 0 50% 0); }
}
@keyframes flashBottom {
  0% { opacity: 0; clip-path: inset(50% 0 0 0); }
  50% { opacity: 1; clip-path: inset(50% 0 0 0); }
  100% { opacity: 0; clip-path: inset(50% 0 0 0); }
}

/* ===== WIN ===== */
#win { background: radial-gradient(circle, rgba(168,85,247,0.3), var(--bg)); }
.win-content {
  text-align: center;
  z-index: 2;
  position: relative;
}
.crown {
  font-size: 100px;
  animation: crownFloat 2s ease-in-out infinite;
  filter: drop-shadow(0 0 30px rgba(251,191,36,0.7));
}
@keyframes crownFloat {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-15px) rotate(8deg); }
}
.win-label {
  color: var(--dim);
  font-size: 16px;
  margin-top: 10px;
}
.win-name {
  font-size: 48px;
  font-weight: 900;
  margin: 8px 0 20px;
  background: linear-gradient(90deg, #fbbf24, #f97316, #a855f7);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: winShine 2s linear infinite;
  background-size: 200% 100%;
}
@keyframes winShine {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}
.win-stats {
  color: var(--dim);
  font-size: 14px;
  margin-bottom: 30px;
  line-height: 1.8;
}
.win-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 280px;
  margin: 0 auto;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(720deg); }
}
