/* ============================================================
   Cosmic Guess — Game Styles
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #0f0f13;
  --bg-secondary:  #1a1a23;
  --bg-card:       #1e1e2a;
  --border:        #2d2d3d;
  --text:          #d0d0e0;
  --text-dim:      #6b6b8a;
  --text-bright:   #ffffff;
  --accent:        #f59e0b;
  --accent-glow:   rgba(245, 158, 11, 0.25);
  --correct:       #22c55e;
  --correct-bg:    rgba(34, 197, 94, 0.15);
  --wrong:         #ef4444;
  --wrong-bg:      rgba(239, 68, 68, 0.15);
  --versus:        #8b5cf6;
  --scale:         #3b82f6;
  --human:         #f97316;
  --absurd:        #ec4899;
  --estimate:      #06b6d4;
  --popCulture:    #a855f7;
  --font:          'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   LOADER
   ═══════════════════════════════════════════ */
.loader-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s;
}
.loader-overlay.fade-out { opacity: 0; pointer-events: none; }
.loader-content { text-align: center; }
.loader-icon { font-size: 4rem; margin-bottom: 16px; display: block; }
.loader-title {
  font-size: 1.8rem; font-weight: 900; letter-spacing: 0.15em;
  color: var(--accent); text-shadow: 0 0 30px var(--accent-glow);
  margin-bottom: 20px;
}
.loader-bar {
  width: 200px; height: 4px; border-radius: 2px;
  background: var(--border); margin: 0 auto; overflow: hidden;
}
.loader-fill {
  height: 100%; width: 0; background: var(--accent); border-radius: 2px;
  animation: loaderFill 0.8s ease-out forwards;
}
@keyframes loaderFill { to { width: 100%; } }

/* ═══════════════════════════════════════════
   TOOLBAR
   ═══════════════════════════════════════════ */
.toolbar {
  position: fixed; top: 8px; right: 8px;
  display: flex; gap: 6px; z-index: 100;
}
.tool-btn {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text-dim); font-size: 1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
}
.tool-btn:hover { border-color: var(--accent); background: var(--bg-card); }

/* ═══════════════════════════════════════════
   SETTINGS
   ═══════════════════════════════════════════ */
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  font-size: 0.95rem; color: var(--text);
}
.setting-row input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer;
}

#app {
  width: 100%;
  max-width: 580px;
  padding: 0 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Screens ── */
.screen { display: none; width: 100%; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ═══════════════════════════════════════════
   TITLE SCREEN
   ═══════════════════════════════════════════ */

.title-hero {
  text-align: center;
  padding: 40px 0 20px;
}

.title-icon {
  font-size: 4rem;
  display: block;
  margin-bottom: 12px;
}

.title-icon.pulse {
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.title-hero h1 {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
}

.tagline {
  margin-top: 12px;
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.6;
}

.tagline strong {
  color: var(--text);
}

/* Title stats */
.title-stats {
  display: flex;
  gap: 24px;
  margin: 24px 0;
  padding: 14px 24px;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.title-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.ts-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--accent);
}

.ts-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* Start button */
.start-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #d97706);
  color: #000;
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px var(--accent-glow);
  margin: 8px 0;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px var(--accent-glow);
}

.start-btn:active {
  transform: translateY(0);
}

.start-icon { font-size: 1.3rem; }

.how-btn {
  margin-top: 12px;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.how-btn:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

/* Difficulty slider */
.difficulty-row {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}

.difficulty-row label {
  font-size: 0.8rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.difficulty-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.diff-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  min-width: 32px;
  text-align: center;
}

#difficulty-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-secondary);
  outline: none;
}

#difficulty-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
}

#difficulty-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-card);
}

/* Category pills */
.title-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 28px;
  max-width: 400px;
}

.cat-pill {
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* ═══════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════ */

/* Progress */
.progress-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}

.progress-dots {
  display: flex;
  gap: 6px;
}

.p-dot {
  width: 24px;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}

.p-dot.current {
  background: var(--accent);
  transform: scaleY(1.3);
}

.p-dot.correct {
  background: var(--correct);
}

.p-dot.wrong {
  background: var(--wrong);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Game stats */
.game-stats {
  display: flex;
  width: 100%;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.g-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.g-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-bright);
}

.g-stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.streak-stat .g-stat-val {
  color: var(--accent);
}

/* Question card */
.question-card {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.q-category {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.q-category[data-cat="scale"]      { background: rgba(59,130,246,0.2); color: #60a5fa; }
.q-category[data-cat="versus"]     { background: rgba(139,92,246,0.2); color: #a78bfa; }
.q-category[data-cat="humanPower"] { background: rgba(249,115,22,0.2); color: #fb923c; }
.q-category[data-cat="estimate"]   { background: rgba(6,182,212,0.2); color: #22d3ee; }
.q-category[data-cat="absurd"]     { background: rgba(236,72,153,0.2); color: #f472b6; }
.q-category[data-cat="popCulture"] { background: rgba(168,85,247,0.2); color: #c084fc; }
.q-category[data-cat="flags"]      { background: rgba(34,197,94,0.2); color: #4ade80; }
.q-category[data-cat="languages"]  { background: rgba(251,191,36,0.2); color: #fbbf24; }
.q-category[data-cat="history"]    { background: rgba(180,83,9,0.2); color: #d97706; }
.q-category[data-cat="astronomy"]  { background: rgba(99,102,241,0.2); color: #818cf8; }
.q-category[data-cat="biology"]    { background: rgba(16,185,129,0.2); color: #34d399; }
.q-category[data-cat="technology"] { background: rgba(14,165,233,0.2); color: #38bdf8; }
.q-category[data-cat="sports"]     { background: rgba(239,68,68,0.2); color: #f87171; }
.q-category[data-cat="earthScience"] { background: rgba(20,184,166,0.2); color: #2dd4bf; }
.q-category[data-cat="economics"]  { background: rgba(234,179,8,0.2); color: #facc15; }

.q-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.q-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-bright);
  line-height: 1.5;
}

.flag-img {
  width: 200px;
  max-width: 60%;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  margin-bottom: 10px;
}

/* Choices */
.choices {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.choice-btn {
  width: 100%;
  padding: 16px 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.choice-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background: rgba(245, 158, 11, 0.08);
  transform: translateY(-1px);
}

.choice-btn:active:not(.disabled) {
  transform: translateY(0);
}

.choice-btn.disabled {
  cursor: default;
  opacity: 0.7;
}

.choice-btn.selected-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  opacity: 1 !important;
}

.choice-btn.selected-wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
  opacity: 1 !important;
}

.choice-btn.reveal-correct {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  opacity: 1 !important;
}

/* Two-choice layout removed — all questions now use 4 choices */

/* Time bonus indicator */
.time-bonus-indicator {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fbbf24;
  padding: 6px;
  animation: scoreFly 2s ease-out forwards;
}

/* Fun fact */
.fun-fact {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  text-align: center;
  animation: fadeUp 0.3s ease-out;
}

.fun-fact.hidden { display: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fact-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-bottom: 8px;
}

.fact-text {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 16px;
}

.next-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #000;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.next-btn:hover {
  transform: translateY(-1px);
  opacity: 0.9;
}

/* ═══════════════════════════════════════════
   RESULT SCREEN
   ═══════════════════════════════════════════ */

.result-hero {
  text-align: center;
  padding: 32px 0 16px;
}

.result-icon {
  font-size: 3.5rem;
  margin-bottom: 8px;
}

.result-hero h2 {
  font-size: 1.8rem;
  font-weight: 900;
  color: var(--text-bright);
}

.result-subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.result-score-card {
  text-align: center;
  padding: 20px 40px;
  background: linear-gradient(135deg, var(--accent-glow), transparent);
  border: 2px solid var(--accent);
  border-radius: 16px;
  margin: 16px 0;
}

.result-big-score {
  font-size: 3rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
}

.result-score-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-top: 4px;
}

.result-stats {
  display: flex;
  gap: 24px;
  margin: 16px 0;
  padding: 14px 24px;
  background: var(--bg-secondary);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.r-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.r-stat-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-bright);
}

.r-stat-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

/* Answer review */
.result-review {
  width: 100%;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.4;
}

.review-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.review-text {
  flex: 1;
  color: var(--text);
}

.review-text .review-q {
  font-weight: 600;
  color: var(--text-bright);
  display: block;
  margin-bottom: 2px;
}

.review-result {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.review-result .you-answered {
  color: var(--wrong);
}

.review-result .correct-answer {
  color: var(--correct);
}

.review-item.was-correct {
  border-left: 3px solid var(--correct);
}

.review-item.was-wrong {
  border-left: 3px solid var(--wrong);
}

/* Result actions */
.result-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.share-btn {
  padding: 12px 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.share-btn:hover {
  border-color: var(--text-dim);
  background: var(--bg-card);
}

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 480px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal h2 {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-bright);
  margin-bottom: 16px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text); }

.how-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}

.how-step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.how-step strong {
  color: var(--text-bright);
  font-size: 0.9rem;
}

.how-step p {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.4;
  margin-top: 2px;
}

.how-categories h3 {
  font-size: 0.9rem;
  color: var(--text-bright);
  margin-bottom: 10px;
}

.how-cats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text);
}

.how-cats strong { color: var(--text-bright); }

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.shake {
  animation: shakeWrong 0.3s ease-in-out;
}

@keyframes popCorrect {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.pop {
  animation: popCorrect 0.3s ease-in-out;
}

@keyframes confettiBurst {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) scale(0.5); }
}

/* Score fly-up animation */
.score-fly {
  position: absolute;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--correct);
  animation: flyUp 0.8s ease-out forwards;
  pointer-events: none;
  z-index: 100;
}

@keyframes flyUp {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-50px); }
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 400px) {
  .title-hero h1 { font-size: 1.7rem; }
  .q-text { font-size: 1rem; }
  .title-stats { gap: 16px; padding: 12px 16px; }
  .result-stats { gap: 16px; }
}

/* ═══════════════════════════════════════════
   ITCH.IO / IFRAME MOBILE — Compact Layout
   ═══════════════════════════════════════════ */

/* Short viewport (landscape mobile or small itch.io frame) */
@media (max-height: 600px) {
  .title-hero { padding: 12px 0 8px; }
  .title-icon { font-size: 2.5rem; margin-bottom: 6px; }
  .title-hero h1 { font-size: 1.5rem; }
  .tagline { font-size: 0.8rem; margin-top: 6px; line-height: 1.3; }
  .title-stats { margin: 12px 0; padding: 10px 16px; gap: 16px; }
  .ts-val { font-size: 1.1rem; }
  .start-btn { padding: 10px 24px; font-size: 0.95rem; }
  .how-btn { margin-top: 6px; padding: 6px 14px; font-size: 0.78rem; }
  .title-categories { margin-top: 12px; gap: 4px; }
  .cat-pill { padding: 3px 8px; font-size: 0.65rem; }
  .question-card { padding: 14px 14px; margin-bottom: 12px; }
  .q-icon { font-size: 1.6rem; margin-bottom: 6px; }
  .q-text { font-size: 0.95rem; }
  .progress-bar { padding: 8px 0 4px; }
  .game-stats { padding: 8px 12px; margin-bottom: 10px; }
  .g-stat-val { font-size: 1rem; }
  .choice-btn { padding: 10px 14px; font-size: 0.9rem; }
  .choices { gap: 6px; margin-bottom: 10px; }
  .fun-fact { padding: 10px 14px; }
  .result-hero { padding: 16px 0 8px; }
  .result-icon { font-size: 2.5rem; }
  .result-hero h2 { font-size: 1.4rem; }
  #app { padding: 0 12px 16px; }
}

@media (max-height: 450px) {
  .title-hero { padding: 4px 0; }
  .title-icon { font-size: 1.8rem; margin-bottom: 2px; }
  .title-hero h1 { font-size: 1.2rem; }
  .tagline { display: none; }
  .title-stats { margin: 8px 0; padding: 6px 10px; }
  .title-categories { display: none; }
  .question-card { padding: 10px; margin-bottom: 8px; border-radius: 10px; }
  .q-icon { font-size: 1.3rem; margin-bottom: 4px; }
  .q-text { font-size: 0.85rem; line-height: 1.3; }
  .choice-btn { padding: 8px 10px; font-size: 0.82rem; border-radius: 8px; }
  .toolbar { top: 4px; right: 4px; }
  .tool-btn { width: 28px; height: 28px; font-size: 0.8rem; }
}
