* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  user-select: none;
}

#app {
  height: 100vh;
  width: 100vw;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: background 0.4s ease;
  background: radial-gradient(circle at top, #4b6cb7, #182848 100%);
  color: #fff;
}

.screen {
  display: none;
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  overflow-y: auto;
  text-align: center;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.screen.active { display: flex; }

.title { font-size: 3rem; margin: 0; text-shadow: 3px 3px 0 rgba(0,0,0,0.25); }
.subtitle { font-size: 1.2rem; opacity: 0.85; margin: 0 0 10px; }

.stack { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 380px; margin-top: 10px; }

.big-btn {
  padding: 20px 24px;
  font-size: 1.3rem;
  font-weight: bold;
  border: none;
  border-radius: 18px;
  background: #ffb347;
  color: #2b1300;
  cursor: pointer;
  border-bottom: 6px solid #c97f1f;
  transition: transform 0.05s ease;
}
.big-btn:active { transform: translateY(4px); border-bottom: 2px solid #c97f1f; }
.big-btn:disabled { opacity: 0.5; cursor: default; border-bottom: 6px solid rgba(0,0,0,0.2); }
.big-btn.secondary { background: #6fd0ff; border-bottom: 6px solid #2e9fd6; color: #04263a; }

.text-btn {
  background: none;
  border: none;
  color: #fff;
  opacity: 0.75;
  font-size: 1rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.field { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.field > span { font-weight: bold; font-size: 1rem; opacity: 0.9; }
.field input {
  padding: 16px;
  font-size: 1.2rem;
  border-radius: 12px;
  border: none;
  outline: none;
}

.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 12px 16px;
  border-radius: 30px;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.95rem;
  font-weight: bold;
  cursor: pointer;
}
.chip.selected { background: #ffb347; color: #2b1300; border-color: #ffb347; }

.error-text { color: #ff8080; font-weight: bold; min-height: 20px; }

.room-code {
  font-size: 3.5rem;
  font-weight: bold;
  letter-spacing: 12px;
  background: rgba(0,0,0,0.25);
  padding: 10px 30px;
  border-radius: 16px;
}
.hint { opacity: 0.75; margin: 0; }

.settings-summary {
  background: rgba(255,255,255,0.1);
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: bold;
}

.opponent-status { font-weight: bold; opacity: 0.9; min-height: 24px; }

.theme-picker { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.theme-card {
  width: 140px;
  padding: 16px 10px;
  border-radius: 16px;
  border: 3px solid rgba(255,255,255,0.35);
  background: rgba(255,255,255,0.08);
  color: #fff;
  cursor: pointer;
}
.theme-card.selected { border-color: #ffb347; background: rgba(255,179,71,0.25); }
.theme-emoji { font-size: 2.2rem; }
.theme-name { font-weight: bold; margin-top: 6px; }

.countdown-number {
  font-size: 10rem;
  font-weight: bold;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.3);
}

.game-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 10px;
}
.hud-box {
  flex: 1;
  background: rgba(0,0,0,0.3);
  border-radius: 16px;
  padding: 10px;
}
.hud-label { font-size: 0.8rem; opacity: 0.8; font-weight: bold; text-transform: uppercase; }
.hud-score { font-size: 2rem; font-weight: bold; }
.timer-box { flex: 1.2; }
.hud-timer { font-size: 2.2rem; font-weight: bold; }

.problem-card {
  width: 100%;
  background: rgba(255,255,255,0.95);
  color: #222;
  border-radius: 24px;
  padding: 28px 20px;
  margin-top: 10px;
}
.instructions { font-weight: bold; opacity: 0.7; margin-bottom: 10px; font-size: 1rem; }
.problem { margin-bottom: 20px; display: flex; align-items: center; justify-content: center; }
.problem-stack {
  display: inline-flex;
  flex-direction: column;
  border-bottom: 5px solid #333;
  padding-bottom: 10px;
}
.problem-stack .stack-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 14px;
  font-size: 3rem;
  font-weight: bold;
  letter-spacing: 2px;
}
.problem-stack .op {
  width: 28px;
  text-align: left;
  opacity: 0.85;
}
.problem-stack .num {
  min-width: 110px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.answer-btn {
  padding: 26px 10px;
  font-size: 1.8rem;
  font-weight: bold;
  border: none;
  border-radius: 18px;
  background: #eef1f5;
  color: #222;
  cursor: pointer;
  border-bottom: 6px solid #c3c9d1;
}
.answer-btn:active { transform: translateY(4px); border-bottom: 2px solid #c3c9d1; }
.answer-btn:disabled { cursor: default; }
.answer-btn.correct { background: #4caf50; color: #fff; border-bottom: 6px solid #2e7d32; }
.answer-btn.wrong { background: #e53935; color: #fff; border-bottom: 6px solid #a52622; }

.feedback { min-height: 30px; font-size: 1.3rem; font-weight: bold; margin-top: 16px; }

.end-banner { font-size: 2.6rem; margin: 0; }
.end-scores { display: flex; align-items: center; gap: 20px; margin: 10px 0; }
.end-score-card {
  background: rgba(0,0,0,0.3);
  border-radius: 18px;
  padding: 20px 26px;
}
.end-name { font-weight: bold; opacity: 0.85; margin-bottom: 6px; }
.end-score { font-size: 3rem; font-weight: bold; }
.end-vs { font-size: 1.5rem; font-weight: bold; opacity: 0.6; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: bold;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- THEME: MINECRAFT ---------- */
#app.theme-minecraft {
  background: linear-gradient(180deg, #7ec0ee 0%, #7ec0ee 55%, #5b8a3a 56%, #3f6b28 100%);
  font-family: "Courier New", monospace;
}
.theme-minecraft .title, .theme-minecraft .end-banner { text-shadow: 3px 3px 0 #2b4d1c; color: #eaffc7; }
.theme-minecraft .big-btn { background: #7b5230; color: #fff; border-bottom: 6px solid #4a2f18; border-radius: 4px; }
.theme-minecraft .big-btn.secondary { background: #6b8e3a; border-bottom: 6px solid #3f5a22; }
.theme-minecraft .problem-card { background: #d7c9a3; border-radius: 4px; border: 4px solid #8a7248; }
.theme-minecraft .answer-btn { background: #a9a9a9; border-radius: 4px; border-bottom: 6px solid #6e6e6e; }
.theme-minecraft .answer-btn.correct { background: #5b8a3a; border-bottom: 6px solid #3f6b28; }
.theme-minecraft .answer-btn.wrong { background: #b23a2f; border-bottom: 6px solid #7a251d; }
.theme-minecraft .hud-box { background: #4a2f18; border-radius: 4px; }
.theme-minecraft .room-code { border-radius: 4px; }

/* ---------- THEME: FORTNITE ---------- */
#app.theme-fortnite {
  background: radial-gradient(circle at 50% 20%, #6a3fbf, #241a5e 60%, #100a33 100%);
  font-family: "Arial Black", Arial, sans-serif;
  font-style: italic;
}
.theme-fortnite .title, .theme-fortnite .end-banner {
  color: #fff;
  text-shadow: 0 0 12px #00e5ff, 0 0 24px #ff00c8;
}
.theme-fortnite .big-btn { background: linear-gradient(90deg, #00e5ff, #ff00c8); color: #10062b; border-radius: 10px; border-bottom: 6px solid #5a0e8f; }
.theme-fortnite .big-btn.secondary { background: linear-gradient(90deg, #ffdd00, #ff9100); color: #2b1a00; border-bottom: 6px solid #b35c00; }
.theme-fortnite .problem-card { background: rgba(20,10,50,0.9); color: #fff; border: 2px solid #00e5ff; }
.theme-fortnite .answer-btn { background: #2c1a6b; color: #fff; border: 2px solid #00e5ff; border-bottom: 6px solid #180d3d; }
.theme-fortnite .answer-btn.correct { background: #00c853; border-bottom: 6px solid #007a34; }
.theme-fortnite .answer-btn.wrong { background: #ff1744; border-bottom: 6px solid #a3001f; }
.theme-fortnite .hud-box { background: rgba(0,0,0,0.4); border: 1px solid #00e5ff; }

/* ---------- THEME: BRAINROT ---------- */
#app.theme-brainrot {
  background: linear-gradient(135deg, #ff00c8, #ffea00, #00ff9d, #00c8ff);
  background-size: 400% 400%;
  animation: brainrotShift 6s ease infinite;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
}
@keyframes brainrotShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
.theme-brainrot .title, .theme-brainrot .end-banner {
  color: #fff;
  text-shadow: 3px 3px 0 #ff00c8, -2px -2px 0 #00c8ff;
  animation: wiggle 0.4s ease-in-out infinite alternate;
}
@keyframes wiggle { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
.theme-brainrot .big-btn { background: #ff2fa0; color: #fff; border-bottom: 6px solid #a5006a; }
.theme-brainrot .big-btn.secondary { background: #2fe0ff; color: #002a33; border-bottom: 6px solid #0089a3; }
.theme-brainrot .problem-card { background: rgba(255,255,255,0.95); border: 4px dashed #ff2fa0; }
.theme-brainrot .answer-btn { background: #fff3b0; border-bottom: 6px solid #d4b400; }
.theme-brainrot .answer-btn.correct { background: #4dff88; border-bottom: 6px solid #17a34a; }
.theme-brainrot .answer-btn.wrong { background: #ff5c7a; border-bottom: 6px solid #b3002e; }
.theme-brainrot .hud-box { background: rgba(0,0,0,0.35); }

@media (max-width: 480px) {
  .title { font-size: 2.2rem; }
  .problem-stack .stack-row { font-size: 2.2rem; gap: 10px; }
  .problem-stack .num { min-width: 80px; }
  .answer-btn { font-size: 1.4rem; padding: 20px 8px; }
  .room-code { font-size: 2.6rem; letter-spacing: 8px; }
}
