/* ─────────────────────────────────────────────
   Quiz Dungeon — Complete Stylesheet
   Dark Fantasy / Dungeon Crawler aesthetic
   Slay the Spire / Darkest Dungeon vibes
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700;900&family=Crimson+Text:ital,wght@0,400;0,600;0,700;1,400;1,600&display=swap');

:root {
  --bg-primary: #0d0b08;
  --bg-secondary: #1a1510;
  --bg-tertiary: #231e17;
  --bg-card: #1e1912;
  --bg-hover: #2a2318;

  --accent: #d97706;
  --accent-dim: #92400e;
  --accent-glow: rgba(217, 119, 6, 0.3);
  --accent-red: #dc2626;
  --accent-gold: #ca8a04;
  --accent-green: #15803d;
  --accent-purple: #7c3aed;
  --accent-orange: #c2410c;

  --text-primary: #e8d5b0;
  --text-secondary: #a08060;
  --text-muted: #5c4a30;
  --text-success: #86efac;
  --text-error: #fca5a5;
  --text-warning: #fcd34d;

  --border-color: #3d3020;
  --border-accent: rgba(217, 119, 6, 0.4);

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255,220,130,0.04);
  --shadow-glow: 0 0 24px rgba(217, 119, 6, 0.25);
  --shadow-glow-lg: 0 0 48px rgba(217, 119, 6, 0.35);
  --shadow-red-glow: 0 0 24px rgba(220, 38, 38, 0.3);

  --transition-fast: 0.15s ease;
  --transition-med: 0.3s ease;
  --transition-slow: 0.5s ease;

  --font-heading: 'Cinzel', 'Palatino Linotype', 'Book Antiqua', serif;
  --font-main: 'Crimson Text', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'Cascadia Code', 'Fira Code', monospace;
}

/* ─── Reset & Base ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 17px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Stone texture background — layered radial gradients to simulate rough stone */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 30%, rgba(60, 40, 10, 0.18) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(40, 25, 8, 0.22) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(20, 15, 5, 0.35) 0%, transparent 80%),
    radial-gradient(circle at 10% 90%, rgba(80, 50, 10, 0.1) 0%, transparent 40%),
    radial-gradient(circle at 90% 10%, rgba(50, 30, 5, 0.12) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* Vignette edges */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.65) 100%);
  pointer-events: none;
  z-index: 0;
}

/* ─── Typography ─── */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1rem, 2vw, 1.3rem); }

p { line-height: 1.7; }

/* ─── Layout ─── */
#app {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.screen.active {
  display: flex;
  animation: chamberEnter 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes chamberEnter {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Keep fadeIn alias for toasts / results that still reference it */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ─── HUD ─── */
#hud {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 11, 8, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 7px 16px;
  width: 100%;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
}

#hud.visible {
  display: block;
}

.hud-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hud-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-main);
  background: var(--bg-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(255,200,100,0.04), 0 2px 6px rgba(0,0,0,0.4);
}

.hud-item .label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 400;
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#hud-lives { color: var(--accent-red); }
#hud-points { color: var(--accent-gold); }
#hud-level { color: var(--accent); }

.hud-progress {
  flex: 1;
  min-width: 140px;
}

.progress-bar-wrap {
  background: var(--bg-tertiary);
  border-radius: 2px;
  height: 6px;
  overflow: hidden;
  margin-top: 4px;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
}

/* Torchlight progress bar — amber to blood red like a burning fuse */
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #b45309 60%, var(--accent-red) 100%);
  border-radius: 2px;
  transition: width var(--transition-med);
  box-shadow: 0 0 6px rgba(217, 119, 6, 0.5);
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

/* Torchlight amber — main action button */
.btn-primary {
  background: linear-gradient(180deg, #d97706 0%, #b45309 60%, #92400e 100%);
  color: #1a0e00;
  border-color: #92400e;
  border-top-color: #f59e0b;
  box-shadow: 0 3px 0 #78350f, 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,220,100,0.25);
  text-shadow: 0 1px 0 rgba(255,200,50,0.4);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 60%, #b45309 100%);
  box-shadow: 0 3px 0 #78350f, 0 6px 20px rgba(217,119,6,0.4), inset 0 1px 0 rgba(255,230,120,0.3);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #78350f, 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 3px rgba(0,0,0,0.3);
}

/* Dark stone secondary button */
.btn-secondary {
  background: linear-gradient(180deg, #2a2318 0%, #1e1912 100%);
  color: var(--text-primary);
  border-color: var(--border-color);
  border-top-color: #4a3a25;
  box-shadow: 0 2px 0 #0d0b08, 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,200,100,0.05);
}

.btn-secondary:hover {
  background: linear-gradient(180deg, #342b1e 0%, #2a2318 100%);
  border-color: var(--accent-dim);
  border-top-color: #5a4a30;
  color: var(--accent);
}

.btn-danger {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  border-color: #991b1b;
  border-top-color: #ef4444;
  box-shadow: 0 3px 0 #7f1d1d, 0 4px 12px rgba(0,0,0,0.5);
}

.btn-danger:hover {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 3px 0 #7f1d1d, var(--shadow-red-glow);
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent-dim);
}

.btn-outline:hover {
  background: rgba(217, 119, 6, 0.1);
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.btn-large {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  /* Carved stone inset feel */
  background-image:
    radial-gradient(ellipse at top left, rgba(255,200,100,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(0,0,0,0.3) 0%, transparent 60%);
}

.card-glow {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

/* ─── Main Menu Screen ─── */
#main-menu {
  justify-content: center;
  gap: 18px;
  /* Dungeon entrance glow from above — torchlight */
  background: radial-gradient(ellipse at center top, rgba(217, 119, 6, 0.07) 0%, transparent 55%);
}

.logo-section {
  text-align: center;
  padding: 24px 20px 10px;
}

.logo-title {
  /* Parchment gold gradient — aged torchlit metal */
  background: linear-gradient(180deg,
    #fde68a 0%,
    #d97706 30%,
    #ca8a04 60%,
    #92400e 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  margin-bottom: 10px;
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-family: var(--font-heading);
  font-weight: 900;
  letter-spacing: 0.06em;
  filter: drop-shadow(0 2px 12px rgba(217,119,6,0.25));
}

.logo-subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-family: var(--font-main);
  font-style: italic;
  letter-spacing: 0.02em;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  max-width: 300px;
}

.high-score-display {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: var(--font-main);
  padding: 10px 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.4);
}

.high-score-display span {
  color: var(--accent-gold);
  font-weight: 700;
}

.level-preview {
  width: 100%;
  max-width: 600px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.level-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  border-radius: var(--radius-md);
  padding: 14px 10px;
  text-align: center;
  box-shadow: inset 0 -2px 6px rgba(0,0,0,0.4);
}

.level-card .level-num {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.level-card .level-name {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Question Screen ─── */
#question-screen {
  gap: 0;
}

.question-screen-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.question-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 3px;
  font-family: var(--font-heading);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-category {
  background: rgba(124, 58, 237, 0.15);
  color: #a78bfa;
  border: 1px solid rgba(124, 58, 237, 0.3);
}

.badge-level {
  background: rgba(217, 119, 6, 0.1);
  color: var(--accent);
  border: 1px solid var(--border-accent);
}

.question-counter {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.question-card {
  padding: 14px;
}

.question-text {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-family: var(--font-main);
}

.options-grid {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-top: 18px;
}

/* Stone slab option buttons */
.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #231e17 0%, #1a1510 100%);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
  font-family: var(--font-main);
  font-size: 0.97rem;
  color: var(--text-primary);
  width: 100%;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4), inset 0 -1px 0 rgba(0,0,0,0.3);
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent-dim);
  border-top-color: var(--accent);
  background: linear-gradient(180deg, #2d2518 0%, #231e14 100%);
  box-shadow: 0 2px 12px rgba(217,119,6,0.15), inset 0 -1px 0 rgba(0,0,0,0.3);
  transform: translateX(3px);
}

.option-btn .option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
  transition: all var(--transition-fast);
}

.option-btn:hover:not(:disabled) .option-key {
  background: var(--accent-dim);
  color: #fff8e8;
  border-color: var(--accent);
}

/* Correct — deep dungeon green with rune glow */
.option-btn.correct {
  border-color: #166534;
  border-top-color: #16a34a;
  background: linear-gradient(180deg, #14301a 0%, #0f2011 100%);
  box-shadow: 0 0 14px rgba(21, 128, 61, 0.25), inset 0 1px 0 rgba(21,128,61,0.15);
  animation: pulseCorrect 0.4s ease;
}

.option-btn.correct .option-key {
  background: #15803d;
  color: #d1fae5;
  border-color: #16a34a;
}

/* Wrong — blood red cracked stone */
.option-btn.wrong {
  border-color: #991b1b;
  border-top-color: var(--accent-red);
  background: linear-gradient(180deg, #2d1010 0%, #1f0b0b 100%);
  box-shadow: 0 0 14px rgba(220, 38, 38, 0.2), inset 0 1px 0 rgba(220,38,38,0.1);
  animation: shakeWrong 0.5s ease;
}

.option-btn.wrong .option-key {
  background: var(--accent-red);
  color: #ffe4e4;
  border-color: #ef4444;
}

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

@keyframes pulseCorrect {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.012); }
  100% { transform: scale(1); }
}

@keyframes shakeWrong {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* Feedback banners */
.feedback-area {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  display: none;
  gap: 12px;
  align-items: flex-start;
  font-family: var(--font-main);
}

.feedback-area.show {
  display: flex;
  animation: fadeIn var(--transition-fast);
}

.feedback-area.correct.show {
  animation: goldGlow 0.6s ease forwards, pulseCorrect 0.4s ease;
}

.feedback-area.wrong.show {
  animation: bloodFlash 0.5s ease, shakeWrong 0.5s ease;
}

@keyframes goldGlow {
  0%   { box-shadow: 0 0 0 rgba(217,119,6,0); }
  50%  { box-shadow: 0 0 30px rgba(217,119,6,0.5); }
  100% { box-shadow: 0 0 10px rgba(217,119,6,0.2); }
}

@keyframes bloodFlash {
  0%, 100% { background: transparent; }
  25%       { background: rgba(220,38,38,0.15); }
}

/* Correct feedback — stone slab with rune/moss feel */
.feedback-area.correct {
  background: linear-gradient(135deg, #0f2014, #142a18);
  border: 1px solid #166534;
  border-top-color: #16a34a;
  color: #86efac;
  box-shadow: inset 0 1px 0 rgba(21,128,61,0.15), 0 0 12px rgba(21,128,61,0.15);
}

/* Wrong feedback — cracked blood-stone */
.feedback-area.wrong {
  background: linear-gradient(135deg, #1f0b0b, #2d1010);
  border: 1px solid #991b1b;
  border-top-color: var(--accent-red);
  color: #fca5a5;
  box-shadow: inset 0 1px 0 rgba(220,38,38,0.1), 0 0 12px rgba(220,38,38,0.12);
}

.feedback-icon { font-size: 1.3rem; flex-shrink: 0; }
.feedback-text { line-height: 1.7; font-size: 0.95rem; }
.feedback-points {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--accent-gold);
}

.next-btn-wrap {
  display: flex;
  justify-content: flex-end;
}

/* ─── Timer Bar — burning torch/fuse ─── */
#question-timer-wrap {
  margin: 6px 0 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#timer-seconds {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent);
  min-width: 32px;
}

#timer-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #b45309 50%, var(--accent-red) 100%);
  border-radius: 2px;
  transition: width 0.5s linear, background 0.5s;
  box-shadow: 0 0 6px rgba(217,119,6,0.4);
}

/* ─── Minigame Select Screen ─── */
#minigame-select {
  gap: 0;
}

.minigame-header {
  text-align: center;
  padding: 18px 20px 12px;
}

.minigame-header h2 {
  color: var(--accent);
  margin-bottom: 8px;
  text-shadow: 0 0 20px rgba(217,119,6,0.3);
}

.minigame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 20px;
  width: 100%;
  max-width: 720px;
}

.minigame-card {
  background: linear-gradient(180deg, #231e17 0%, #1a1510 100%);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-card);
}

.minigame-card:hover {
  border-color: var(--accent-dim);
  border-top-color: var(--accent);
  background: linear-gradient(180deg, #2d2518 0%, #231e14 100%);
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0,0,0,0.6), 0 0 16px rgba(217,119,6,0.15);
}

.minigame-emoji {
  font-size: 2.8rem;
  line-height: 1;
}

.minigame-name {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.minigame-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  font-family: var(--font-main);
}

/* ─── Minigame Play Screen ─── */
#minigame-play {
  gap: 0;
}

.minigame-play-inner {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.game-area {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px;
}

.bet-control {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bet-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-heading);
  padding: 9px 14px;
  width: 100px;
  text-align: center;
  transition: border-color var(--transition-fast);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}

.bet-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4), 0 0 8px rgba(217,119,6,0.2);
}

/* Blackjack playing cards */
.cards-display {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 10px 0;
}

.playing-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 76px;
  background: #f5eed8;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 800;
  color: #2a1a08;
  border: 1px solid #d4c090;
  box-shadow: 0 3px 10px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
  position: relative;
}

.playing-card.hidden {
  background: linear-gradient(135deg, #3d1a00, #5c2800);
  color: transparent;
  border: 1px solid #7c3a00;
  background-image: repeating-linear-gradient(
    45deg,
    rgba(255,150,50,0.05) 0px,
    rgba(255,150,50,0.05) 2px,
    transparent 2px,
    transparent 8px
  );
}

.playing-card.hidden::after {
  content: '🂠';
  font-size: 2rem;
  position: absolute;
}

.playing-card.red-card { color: #991b1b; }

.hand-value {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.04em;
}

/* Roulette wheel — dark stone with torchlit segments */
.roulette-wheel {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 6px solid #3d2a10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  position: relative;
  box-shadow: 0 0 30px rgba(0,0,0,0.7), 0 0 16px rgba(217,119,6,0.15), inset 0 0 20px rgba(0,0,0,0.5);
  background: conic-gradient(
    #1a0f05 0deg, #7f1d1d 10deg,
    #7f1d1d 10deg, #1a0f05 20deg,
    #1a0f05 20deg, #7f1d1d 30deg,
    #7f1d1d 30deg, #1a0f05 40deg,
    #1a0f05 40deg, #7f1d1d 50deg,
    #7f1d1d 50deg, #1a0f05 60deg,
    #1a0f05 60deg, #7f1d1d 70deg,
    #7f1d1d 70deg, #1a0f05 80deg,
    #1a0f05 80deg, #7f1d1d 90deg,
    #7f1d1d 90deg, #1a0f05 100deg,
    #1a0f05 100deg, #7f1d1d 110deg,
    #7f1d1d 110deg, #1a0f05 120deg,
    #1a0f05 120deg, #7f1d1d 130deg,
    #7f1d1d 130deg, #1a0f05 140deg,
    #1a0f05 140deg, #7f1d1d 150deg,
    #7f1d1d 150deg, #1a0f05 160deg,
    #1a0f05 160deg, #7f1d1d 170deg,
    #7f1d1d 170deg, #1a0f05 180deg,
    #1a0f05 180deg, #7f1d1d 190deg,
    #7f1d1d 190deg, #1a0f05 200deg,
    #1a0f05 200deg, #7f1d1d 210deg,
    #7f1d1d 210deg, #1a0f05 220deg,
    #1a0f05 220deg, #7f1d1d 230deg,
    #7f1d1d 230deg, #1a0f05 240deg,
    #1a0f05 240deg, #7f1d1d 250deg,
    #7f1d1d 250deg, #1a0f05 260deg,
    #1a0f05 260deg, #7f1d1d 270deg,
    #7f1d1d 270deg, #1a0f05 280deg,
    #1a0f05 280deg, #7f1d1d 290deg,
    #7f1d1d 290deg, #1a0f05 300deg,
    #1a0f05 300deg, #7f1d1d 310deg,
    #7f1d1d 310deg, #1a0f05 320deg,
    #1a0f05 320deg, #7f1d1d 330deg,
    #7f1d1d 330deg, #1a0f05 340deg,
    #1a0f05 340deg, #7f1d1d 350deg,
    #7f1d1d 350deg, #14532d 360deg
  );
  transition: transform 1.5s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

.roulette-center {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 3px solid #3d2a10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  z-index: 2;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.6);
}

.roulette-bets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.roulette-bet-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}
.roulette-bet-label:hover {
  border-color: var(--accent-gold);
  background: rgba(212,175,55,0.08);
}
.roulette-bet-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-gold);
  cursor: pointer;
}
.roulette-bet-label input[type="checkbox"]:checked + * {
  color: var(--accent-yellow);
}
.roulette-bet-label:has(input:checked) {
  border-color: var(--accent-gold);
  background: rgba(212,175,55,0.12);
}
.bet-odds {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Dice — bone/ivory feel */
.dice-display {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
}

.dice-group {
  display: flex;
  gap: 8px;
}

.die {
  width: 52px;
  height: 52px;
  background: #f0e8d0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.5);
  border: 1px solid #c8b880;
  transition: transform 0.3s ease;
}

.die.rolling {
  animation: diceRoll 0.6s ease infinite;
}

@keyframes diceRoll {
  0%   { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(90deg) scale(1.1); }
  50%  { transform: rotate(180deg) scale(1); }
  75%  { transform: rotate(270deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1); }
}

.vs-text {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* High/Low — large parchment card */
.highlow-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.big-card {
  width: 90px;
  height: 130px;
  background: #f0e8d0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 900;
  color: #2a1a08;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.4);
  border: 2px solid #c8b880;
}

.streak-display {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  color: var(--accent-gold);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Result messages */
.result-message {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  text-align: center;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 1rem;
  display: none;
  animation: fadeIn var(--transition-fast);
}

.result-message.show { display: block; }

.result-message.win {
  background: linear-gradient(135deg, #0f2014, #142a18);
  color: #86efac;
  border: 1px solid #166534;
  border-top-color: #16a34a;
  box-shadow: 0 0 14px rgba(21,128,61,0.2);
}

.result-message.lose {
  background: linear-gradient(135deg, #1f0b0b, #2d1010);
  color: #fca5a5;
  border: 1px solid #991b1b;
  border-top-color: var(--accent-red);
  box-shadow: 0 0 14px rgba(220,38,38,0.15);
}

.result-message.push {
  background: linear-gradient(135deg, #1a1200, #251a00);
  color: var(--accent-gold);
  border: 1px solid var(--accent-dim);
  border-top-color: var(--accent);
}

/* ─── Boss Screen ─── */
#boss-screen {
  background: radial-gradient(ellipse at center top, rgba(220, 38, 38, 0.1) 0%, transparent 50%);
}

.boss-screen-inner {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.boss-header {
  text-align: center;
  padding: 14px;
}

.boss-title {
  font-family: var(--font-heading);
  color: var(--accent-red);
  font-size: 2rem;
  text-shadow: 0 0 20px rgba(220, 38, 38, 0.5);
  animation: bossGlow 2s ease-in-out infinite alternate;
  letter-spacing: 0.1em;
}

@keyframes bossGlow {
  from { text-shadow: 0 0 12px rgba(220, 38, 38, 0.3), 0 0 4px rgba(220,38,38,0.2); }
  to   { text-shadow: 0 0 32px rgba(220, 38, 38, 0.7), 0 0 60px rgba(220,38,38,0.25); }
}

.boss-timer-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.timer-bar-wrap {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.5);
}

/* Burning torch timer — amber to red as time runs low */
.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #b45309 40%, var(--accent-red) 100%);
  border-radius: 2px;
  transition: width 1s linear;
  box-shadow: 0 0 8px rgba(217,119,6,0.5);
}

.timer-display {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent-red);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
  letter-spacing: 0.05em;
}

.timer-display.urgent {
  animation: timerPulse 0.5s ease infinite;
  color: var(--accent-red);
  text-shadow: 0 0 10px rgba(220,38,38,0.6);
}

@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.1); }
}

.boss-penalty-note {
  text-align: center;
  color: var(--accent-red);
  font-family: var(--font-main);
  font-size: 0.88rem;
  padding: 8px 14px;
  background: rgba(220, 38, 38, 0.07);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.boss-goal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  font-size: 0.9rem;
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.4);
}

.goal-progress {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--accent-gold);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

/* ─── Game Over Screen ─── */
#gameover-screen {
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(220, 38, 38, 0.08) 0%, transparent 55%);
}

.gameover-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  max-width: 500px;
}

.gameover-emoji {
  font-size: 5rem;
  animation: bounceIn 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
  filter: drop-shadow(0 0 20px rgba(220,38,38,0.3));
}

.gameover-title {
  font-family: var(--font-heading);
  color: var(--accent-red);
  font-size: 2.5rem;
  text-shadow: 0 0 24px rgba(220,38,38,0.4);
  letter-spacing: 0.08em;
}

.score-display {
  padding: 22px 28px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  border-top-color: #4a3a25;
  width: 100%;
  box-shadow: var(--shadow-card);
}

.score-display .final-score {
  font-family: var(--font-heading);
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.04em;
  text-shadow: 0 0 20px rgba(202,138,4,0.3);
}

.score-display .score-label {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.score-display .high-score-label {
  margin-top: 10px;
  font-size: 0.9rem;
  color: var(--accent);
  font-family: var(--font-main);
}

@keyframes bounceIn {
  0%   { transform: scale(0.3); opacity: 0; }
  50%  { transform: scale(1.15); opacity: 1; }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

/* ─── Victory Screen ─── */
#victory-screen {
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(202, 138, 4, 0.1) 0%, transparent 55%);
}

.victory-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  max-width: 500px;
}

.victory-emoji {
  font-size: 5rem;
  animation: victoryBounce 1s ease infinite alternate;
  filter: drop-shadow(0 0 20px rgba(202,138,4,0.4));
}

@keyframes victoryBounce {
  from { transform: translateY(0) rotate(-5deg); }
  to   { transform: translateY(-12px) rotate(5deg); }
}

.victory-title {
  font-family: var(--font-heading);
  color: var(--accent-gold);
  font-size: 2.5rem;
  text-shadow: 0 0 30px rgba(202,138,4,0.5), var(--shadow-glow-lg);
  letter-spacing: 0.08em;
}

.confetti-wrap {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* ─── Notifications / Toast ─── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  padding: 11px 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.95rem;
  animation: toastSlide 0.3s ease forwards;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
  pointer-events: auto;
  max-width: 300px;
  border: 1px solid transparent;
}

.toast-success {
  background: linear-gradient(135deg, #0f2014, #1a3520);
  color: #86efac;
  border-color: #166534;
}

.toast-error {
  background: linear-gradient(135deg, #1f0b0b, #2d1010);
  color: #fca5a5;
  border-color: #991b1b;
}

.toast-info {
  background: linear-gradient(135deg, #1a1200, #251a00);
  color: var(--accent);
  border-color: var(--accent-dim);
}

@keyframes toastSlide {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.toast.hiding {
  animation: toastSlide 0.3s ease reverse forwards;
}

/* ─── Leaderboard — carved stone tablet ─── */
#leaderboard-screen h2 {
  color: var(--accent-gold);
  text-shadow: 0 0 20px rgba(202,138,4,0.25);
}

/* ─── Spin Wheel ─── */
#spin-wheel { display: block; }
#wheel-result { min-height: 80px; }

/* Wheel pointer — torchlight amber instead of green */
#wheel-pointer {
  border-top-color: var(--accent) !important;
  filter: drop-shadow(0 0 6px rgba(217,119,6,0.7)) !important;
}

/* Wheel canvas glow */
#spin-wheel {
  box-shadow: 0 0 40px rgba(217,119,6,0.15), 0 0 80px rgba(0,0,0,0.5) !important;
}

/* ─── Utilities ─── */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex  { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

.separator {
  width: 100%;
  height: 1px;
  background: var(--border-color);
  margin: 8px 0;
  box-shadow: 0 1px 0 rgba(255,200,100,0.03);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; border: 1px solid var(--border-color); }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ─── Selection ─── */
::selection { background: rgba(217, 119, 6, 0.25); color: var(--text-primary); }

/* ─── Torch Flicker — subtle amber oscillation on key accent elements ─── */
@keyframes torchFlicker {
  0%   { filter: brightness(0.85); }
  20%  { filter: brightness(1.0); }
  40%  { filter: brightness(0.92); }
  60%  { filter: brightness(1.0); }
  80%  { filter: brightness(0.88); }
  100% { filter: brightness(1.0); }
}

.logo-title,
.boss-title,
#hud-lives,
#hud-points,
#hud-level,
#timer-seconds {
  animation: torchFlicker 3.5s ease-in-out infinite;
}

/* Stagger flicker so elements don't all pulse together */
.boss-title         { animation-delay: 0.3s; }
#hud-points         { animation-delay: 0.7s; }
#hud-level          { animation-delay: 1.1s; }
#timer-seconds      { animation-delay: 0.5s; }

/* ─── HUD Lives — critical pulse when <= 2 ─── */
.lives-critical {
  animation: criticalPulse 1s ease infinite !important;
}

@keyframes criticalPulse {
  0%, 100% { color: #dc2626; }
  50%       { color: #fca5a5; text-shadow: 0 0 10px rgba(220,38,38,0.8); }
}

/* ─── Timer Bar — torch burn shimmer ─── */
#timer-bar {
  position: relative;
  overflow: hidden;
}

#timer-bar::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 100%;
  background: rgba(255,255,255,0.4);
  filter: blur(4px);
  animation: burnGlow 0.8s ease-in-out infinite alternate;
}

@keyframes burnGlow {
  from { opacity: 0.3; }
  to   { opacity: 0.9; }
}

/* ─── Dungeon Particles — floating ember sparks ─── */
#dungeon-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

#dungeon-particles span {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #d97706;
  opacity: 0;
  animation: floatEmber 8s ease-in infinite;
}

#dungeon-particles span:nth-child(1) { left: 10%; animation-delay: 0s;   animation-duration: 7s; }
#dungeon-particles span:nth-child(2) { left: 25%; animation-delay: 1.5s; animation-duration: 9s; }
#dungeon-particles span:nth-child(3) { left: 40%; animation-delay: 3s;   animation-duration: 6s; }
#dungeon-particles span:nth-child(4) { left: 55%; animation-delay: 0.5s; animation-duration: 11s; }
#dungeon-particles span:nth-child(5) { left: 70%; animation-delay: 2s;   animation-duration: 8s; }
#dungeon-particles span:nth-child(6) { left: 82%; animation-delay: 4s;   animation-duration: 7s; }
#dungeon-particles span:nth-child(7) { left: 18%; animation-delay: 5s;   animation-duration: 10s; }
#dungeon-particles span:nth-child(8) { left: 62%; animation-delay: 1s;   animation-duration: 9s; }

@keyframes floatEmber {
  0%   { bottom: -10px; opacity: 0; transform: translateX(0) scale(1); }
  10%  { opacity: 0.6; }
  50%  { transform: translateX(20px) scale(0.8); opacity: 0.4; }
  90%  { opacity: 0.2; }
  100% { bottom: 100vh; opacity: 0; transform: translateX(-10px) scale(0.4); }
}

/* ─── Stone wall background (reinforced) ─── */
body {
  background-color: #0d0b08;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(80,40,10,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(60,30,5,0.06) 0%, transparent 40%),
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.03) 2px, rgba(0,0,0,0.03) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0,0,0,0.02) 3px, rgba(0,0,0,0.02) 5px);
}

/* Vignette (tightened) */
body::after {
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,0,0,0.6) 100%);
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .screen { padding: 14px; }
  .card { padding: 16px; }
  .hud-inner { gap: 7px; }
  .hud-item { padding: 4px 7px; font-size: 0.78rem; }
  .minigame-grid { grid-template-columns: repeat(2, 1fr); }
  .question-text { font-size: 1rem; }
  .option-btn { padding: 11px 12px; font-size: 0.9rem; }
  .roulette-bets { grid-template-columns: repeat(2, 1fr); }
  .logo-title { font-size: clamp(2rem, 10vw, 3rem); }
}

@media (max-width: 400px) {
  .minigame-grid { grid-template-columns: 1fr; }
  .roulette-bets { grid-template-columns: 1fr; }
}
