﻿:root {
  /* Color Palette */
  --primary: #0071e3; /* Apple's signature blue */
  --primary-light: #47a9ff;
  --primary-dark: #0058b0;
  --secondary: #fa5252; /* Vibrant red for attention */
  --accent: #9866ff; /* Light purple for accent */
  --success: #30d158; /* Apple's green */
  --warning: #ff9f0a; /* Apple's orange */
  --error: #ff453a; /* Apple's red */
  /* Background and Surface */
  --background: #f5f5f7; /* Apple's light gray background */
  --surface: #ffffff; /* Clean white for surfaces */
  --surface-secondary: #f8f8fa; /* Subtle off-white for secondary surfaces */
  /* Text Colors */
  --text-primary: #1d1d1f; /* Almost black for primary text */
  --text-secondary: #6e6e73; /* Medium gray for secondary text */
  --text-tertiary: #86868b; /* Light gray for tertiary text */
  /* Feedback Colors */
  --feedback-correct-bg: #e6f4ea; /* Light green */
  --feedback-correct-text: #0a3d1d; /* Dark green */
  --feedback-incorrect-bg: #fce8e6; /* Light red */
  --feedback-incorrect-text: #5f1c15; /* Dark red */
  /* Borders and Shadows */
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 18px;
  --border-radius-xl: 22px;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  /* Transitions */
  --transition-fast: 200ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --transition-normal: 300ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
  /* Typography */
  --font-primary: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
  --spacing-xxl: 48px;
}
/* Base styles and resets - Apple style */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html {
    font-size: 16px;
    scroll-behavior: smooth;
}
body {
    font-family: var(--font-primary);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    width: 100%;
    padding: 0;
    margin: 0;
    overscroll-behavior: none;
    touch-action: manipulation;
    letter-spacing: -0.01em;
    /* --- MODIFIED FOR BACKGROUND IMAGES & CENTERING --- */
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    transition: background-image 0.8s ease-in-out, background-color 0.5s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}
.container {
    /* --- MODIFIED: This now acts as the main viewport for the centered app pane --- */
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    position: relative; /* For overlay effects */
}
/* NEW: Cracked screen effect for incorrect answers */
.container.cracked::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 50%, transparent, rgba(0,0,0,0.1) 70%),
                linear-gradient(105deg, transparent 49.5%, red 49.5%, red 50.5%, transparent 50.5%),
                linear-gradient(175deg, transparent 49.5%, red 49.5%, red 50.5%, transparent 50.5%);
    opacity: 0;
    animation: crackle 0.4s ease-out forwards;
    pointer-events: none;
    z-index: 10000;
}
@keyframes crackle {
    0% { opacity: 0; transform: scale(0.8); }
    50% { opacity: 0.3; }
    100% { opacity: 0; transform: scale(1.2); }
}
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}
h1 {
    font-size: 2.8rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    line-height: 1.1;
}
h2 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: var(--spacing-xxl);
}
h3 {
    font-size: 1.5rem;
}
p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 1.0625rem;
    line-height: 1.47059;
}
strong {
    font-weight: 600;
    color: var(--text-primary);
}
a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}
.btn {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 17px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    text-decoration: none;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
    width: 100%;
    margin: var(--spacing-sm) 0;
}
.btn:hover {
    background-color: var(--primary-light);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn:active {
    transform: scale(0.98) translateY(0);
    box-shadow: 0 0 0 3px rgba(0, 125, 250, 0.15);
}
.btn-secondary {
    background-color: var(--surface);
    color: var(--primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
}
.btn-secondary:hover {
    background-color: var(--surface-secondary);
}
.btn-icon {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-sm);
  border-radius: 50%;
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--transition-fast);
}
.btn-icon:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* --- Dark Mode Base Styles --- */
@media (prefers-color-scheme: dark) {
    :root {
        --primary: #0a84ff;
        --primary-light: #64aaff;
        --primary-dark: #0060cc;
        --secondary: #ff375f;
        --accent: #bf5af2;
        --success: #30d158;
        --warning: #ffd60a;
        --error: #ff453a;
        --background: #000000;
        --surface: #1c1c1e;
        --surface-secondary: #2c2c2e;
        --text-primary: #ffffff;
        --text-secondary: #ebebf5;
        --text-tertiary: #ebebf599;
        --shadow-sm: 0 2px 6px rgba(255, 255, 255, 0.05);
        --shadow-md: 0 4px 12px rgba(255, 255, 255, 0.08);
        --feedback-correct-bg: #1a3d23;
        --feedback-correct-text: #c2f0d1;
        --feedback-incorrect-bg: #4d1a16;
        --feedback-incorrect-text: #f8cfc9;
    }
    .btn-secondary {
        border-color: rgba(255,255,255,0.15);
        color: var(--primary-light);
    }
    .btn-secondary:hover {
        background-color: #2c2c2e;
    }
}

/* --- Mobile Typography & Layout --- */
@media (max-width: 768px) {
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.75rem; }
    p { font-size: 1.1rem; }
}

/* --- Dynamic background for streaks --- */
body.streak-active {
  background: linear-gradient(135deg, var(--background), #eef5ff);
}
@media (prefers-color-scheme: dark) {
    body.streak-active {
        background: linear-gradient(135deg, var(--background), #0a1a33);
    }
}

/* --- REWRITTEN & ENHANCED: Glassmorphism Core --- */
#landing-screen, #game-screen, #paywall, #end-screen, #loading-screen {
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Allow scrolling on content-heavy screens */
  /* SIZING & SPACING: This makes it a centered pane instead of a full screen overlay */
  width: 100%;
  max-width: 480px; /* Optimal for mobile-first view */
  height: 95vh;
  max-height: 950px;
  padding: var(--spacing-lg);
  /* --- LIVELY GLASSMORPHISM EFFECT --- */
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
  backdrop-filter: blur(25px) saturate(180%);
  -webkit-backdrop-filter: blur(25px) saturate(180%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Hide screens based on JS inline style */
#game-screen, #paywall, #end-screen, #loading-screen {
    display: none;
}

/* --- Landing Screen --- */
#landing-screen {
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm); /* Reduced gap */
  padding: var(--spacing-xl);
}
#landing-screen h1 {
  font-size: 32px;
  margin-bottom: var(--spacing-md);
  text-align: center;
  color: var(--text-primary);
}

/* START: NEW CSS FOR SUBJECT SELECTION */
#subject-selection {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}
#subject-selection h3 {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}
.btn-subject-math {
    background: linear-gradient(135deg, #0071e3, #0058b0);
}
.btn-subject-english {
    background: linear-gradient(135deg, #9866ff, #6d3ccf);
}
/* END: NEW CSS FOR SUBJECT SELECTION */

/* START: NEW CSS FOR AUTH FORMS */
#auth-container {
    width: 100%;
}
#auth-container input[type="email"],
#auth-container input[type="password"] {
  width: 100%;
  padding: var(--spacing-md) var(--spacing-lg);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius-md);
  font-size: 17px;
  background-color: rgba(255, 255, 255, 0.5); /* Translucent input */
  margin-bottom: var(--spacing-md);
  transition: border var(--transition-fast);
  color: var(--text-primary);
}
#auth-container input::placeholder {
    color: var(--text-secondary);
}
#auth-container input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 125, 250, 0.15);
}
.form-switcher {
    font-size: 14px;
    text-align: center;
    margin-top: var(--spacing-md);
    color: var(--text-secondary);
}
.form-switcher a {
    font-weight: 500;
}
/* END: NEW CSS FOR AUTH FORMS */

#google-signin-btn,
#microsoft-signin-btn {
  background-color: white;
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}
#google-signin-btn:hover,
#microsoft-signin-btn:hover {
  background-color: var(--surface-secondary);
}
#google-signin-btn::before {
  content: "G";
  background: linear-gradient(45deg, #4285F4, #34A853, #FBBC05, #EA4335);
  color: white;
  border-radius: 50%;
  height: 24px;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
/* START: NEW ICON FOR MICROSOFT BUTTON */
#microsoft-signin-btn::before {
  content: "";
  background-image: url('data:image/svg+xml;charset=UTF-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 12"><path fill="%23f25022" d="M0 0h5.7v5.7H0z"/><path fill="%2300a4ef" d="M0 6.3h5.7V12H0z"/><path fill="%237fba00" d="M6.3 0H12v5.7H6.3z"/><path fill="%23ffb900" d="M6.3 6.3H12V12H6.3z"/></svg>');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 18px;
  height: 24px;
  width: 24px;
}
/* END: NEW ICON FOR MICROSOFT BUTTON */

#support-email {
  margin-top: var(--spacing-lg);
  font-size: 14px;
  color: var(--text-secondary);
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
}
.footer-nav a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.footer-nav a:hover {
  color: var(--primary);
}

/* --- Loading Screen --- */
#loading-screen {
  justify-content: center;
  align-items: center;
}
#loading-tip {
  text-align: center;
  font-size: 17px;
  max-width: 85%;
  position: relative;
  padding-top: 100px;
  color: var(--text-secondary);
}
#loading-tip:before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.08);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: translateX(-50%) rotate(0deg); }
  100% { transform: translateX(-50%) rotate(360deg); }
}

/* --- Game Screen --- */
#game-screen {
  justify-content: space-between;
  gap: var(--spacing-md);
}
#header {
    width: 100%;
    flex-shrink: 0;
    /* REDUCED SPACING: Add a small gap for the elements below the header bar */
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.stats-bar {
    display: flex;
    justify-content: space-between; /* Pushes left, center, and right groups apart */
    align-items: center;
    width: 100%;
    gap: var(--spacing-sm);
    font-size: 15px; /* Slightly smaller font for compactness */
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0 var(--spacing-sm); /* Add a little horizontal padding */
}
/* Remove the old secondary bar styles */
.stats-bar-secondary {
    display: none;
}
/* NEW: Group for left-side stats */
.stat-group-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md); /* Space between individual stats */
}
/* NEW: Group for right-side actions */
.game-actions {
    display: flex;
    align-items: center;
    gap: 0; /* Let padding/margin on children handle spacing */
}
/* Adjust individual stat items to be compact */
#upgrade-link, #level-indicator, #score-indicator, #lives-indicator, #timer-indicator {
    background-color: transparent;
    padding: 0;
    box-shadow: none;
    font-size: inherit;
    color: inherit;
    display: flex;
    align-items: center;
    gap: 3px; /* Small gap between emoji and number */
}
/* NEW: Timer RAG coloring */
#timer-indicator.timer-ok { color: var(--success); }
#timer-indicator.timer-warn { color: var(--warning); }
#timer-indicator.timer-danger { color: var(--error); }
#timer-indicator #timer-count { transition: color var(--transition-fast); }


/* Specific styling for the upgrade link to make it compact */
#upgrade-link {
    font-weight: 600;
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-fast);
}
#upgrade-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    text-decoration: none;
}
#premium-indicator {
    line-height: 1;
    margin-left: 4px;
}
#lives-indicator {
    position: relative;
    overflow: hidden;
    transition: color 0.2s ease;
}
#streak-counter {
    font-size: 15px; /* Match the bar font size */
    font-weight: 700;
    color: var(--warning);
    background-color: transparent;
    padding: 0;
    box-shadow: none;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0; /* Prevent it from being squished */
}
#streak-counter.visible {
    opacity: 1;
    transform: scale(1);
    animation: glow 1.5s ease-in-out infinite alternate;
}
@keyframes glow {
  from { text-shadow: 0 0 4px rgba(255, 159, 10, 0.5); }
  to { text-shadow: 0 0 16px rgba(255, 159, 10, 0.9); }
}
#level-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    /* REDUCED SPACING: Removed top margin, reduced bottom margin */
    margin: 0 0 var(--spacing-sm) 0;
    animation: fadeIn 0.5s ease;
}
#character-question-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    margin: var(--spacing-md) 0;
}
#funny-character {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  justify-content: center;
  text-align: center;
}
.character-img {
  font-size: 30px;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease;
  flex-shrink: 0;
  position: relative; /* For aura positioning */
}
/* NEW: Character aura for streaks */
#character-aura {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.5s ease;
}
#character-aura.on-fire {
    opacity: 1;
    animation: fire-aura 2s ease-in-out infinite alternate;
}
@keyframes fire-aura {
    0% { box-shadow: 0 0 10px #ff9f0a, 0 0 20px #ff9f0a, 0 0 30px #ff453a, inset 0 0 5px #ff9f0a; transform: scale(1); }
    100% { box-shadow: 0 0 15px #ff9f0a, 0 0 25px #ff9f0a, 0 0 40px #ff453a, inset 0 0 8px #ff9f0a; transform: scale(1.05); }
}
.character-img.bounce-big {
    animation: bounce-big 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes bounce-big {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}
.character-img.shake {
    animation: shake 0.5s ease-in-out;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px) rotate(-5deg); }
    40% { transform: translateX(8px) rotate(5deg); }
    60% { transform: translateX(-8px) rotate(-5deg); }
    80% { transform: translateX(8px) rotate(5deg); }
}
/* NEW: Lightbulb moment animation */
.character-img.lightbulb::after {
    content: '💡';
    position: absolute;
    top: -20px;
    right: -10px;
    font-size: 24px;
    opacity: 0;
    animation: lightbulb-pop 1s ease-out forwards;
}
@keyframes lightbulb-pop {
    0% { transform: translateY(10px) scale(0.5); opacity: 0; }
    50% { transform: translateY(-5px) scale(1.2); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}
#character-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    /* NEW: Sunglasses effect */
    filter: none;
    transition: filter 0.5s ease;
}
#character-image.sunglasses {
    filter: drop-shadow(0px 5px 0px rgba(29, 29, 31, 1)); /* Simulates sunglasses */
}
.character-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.character-msg {
  background-color: var(--surface);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--border-radius-md);
  border-top-left-radius: 4px;
  max-width: 80%;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  line-height: 1.4;
  position: relative;
  transition: all 0.3s ease;
  margin: 0;
  border: 2px solid transparent;
}
/* NEW: Smart Tip Character Message Styles */
.character-msg.tip-weak {
  border-color: var(--warning);
  background-color: var(--feedback-incorrect-bg);
}
.character-msg.tip-hard {
  border-color: var(--error);
}
.character-msg.tip-strong {
  border-color: var(--success);
  background-color: var(--feedback-correct-bg);
}
.character-msg.correct {
    background-color: var(--feedback-correct-bg);
    color: var(--feedback-correct-text);
    transform: scale(1.02);
    border-color: transparent;
}
.character-msg.incorrect {
    background-color: var(--feedback-incorrect-bg);
    color: var(--feedback-incorrect-text);
    border-color: transparent;
}
.character-msg:before {
  content: "";
  position: absolute;
  left: -8px;
  top: 10px;
  width: 15px;
  height: 15px;
  background: var(--surface); /* Default background */
  transform: rotate(45deg);
  border-radius: 3px;
  transition: background-color 0.3s ease;
}
.character-msg.correct:before { background-color: var(--feedback-correct-bg); }
.character-msg.incorrect:before { background-color: var(--feedback-incorrect-bg); }
.character-msg.tip-weak:before { background-color: var(--feedback-incorrect-bg); }
.character-msg.tip-strong:before { background-color: var(--feedback-correct-bg); }

.progress-container {
  width: 100%;
}
#progress-bar {
  height: 8px;
  background-color: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
#progress {
  height: 100%;
  background-color: var(--primary);
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  width: 0%;
}
#progress.progress-update {
    animation: progress-glow 1.5s ease-out;
}
@keyframes progress-glow {
  from {
    box-shadow: 0 0 4px var(--primary-light), 0 0 8px var(--primary-light);
  }
  to {
    box-shadow: 0 0 16px var(--primary-light), 0 0 24px var(--primary-light), 0 0 32px var(--primary);
  }
}
#badge-container {
  display: flex;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  overflow-x: auto;
  padding-bottom: var(--spacing-xs);
  scrollbar-width: none;
}
#badge-container::-webkit-scrollbar {
  display: none;
}
#question-container {
  background-color: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: var(--spacing-lg);
  border-radius: var(--border-radius-lg);
  box-shadow: none;
  position: relative;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.4s ease, opacity 0.4s ease;
}
#question-container.slide-out {
    opacity: 0;
    transform: translateX(-50px) scale(0.95);
}
#question-container.slide-in {
    opacity: 1;
    transform: translateX(0) scale(1);
}
#topic-display {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-align: center;
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#difficulty-display {
    text-align: center;
    font-size: 16px;
    color: var(--warning);
    margin-bottom: var(--spacing-md);
}
#question-text {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  margin-bottom: 0;
  letter-spacing: -0.02em;
}
#share-question {
  position: absolute;
  top: var(--spacing-md);
  right: var(--spacing-md);
  height: 40px;
  width: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  background-color: transparent;
  transition: background-color var(--transition-fast);
}
#share-question:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
#answer-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}
#yes-btn, #no-btn {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  border-radius: var(--border-radius-md);
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
  animation: button-breath 2s ease-in-out infinite;
}
#yes-btn.powered-up, #no-btn.powered-up {
    background-size: 200% 200%;
    animation: button-breath 2s ease-in-out infinite, shimmer 3s linear infinite;
}
@keyframes shimmer {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
#yes-btn.powered-up {
    background-image: linear-gradient(120deg, var(--success) 0%, #39e663 50%, var(--success) 100%);
}
#no-btn.powered-up {
    background-image: linear-gradient(120deg, var(--error) 0%, #ff5e54 50%, var(--error) 100%);
}
@keyframes button-breath {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}
#yes-btn:active, #no-btn:active {
  transform: scale(0.95);
  box-shadow: var(--shadow-sm);
}
#yes-btn {
  background-color: var(--success);
}
#yes-btn:hover {
  background-color: #26b84a;
}
#no-btn {
  background-color: var(--error);
}
#no-btn:hover {
  background-color: #e13c31;
}
.correct-answer-highlight {
    box-shadow: 0 0 0 4px var(--success), 0 0 20px var(--success);
    transform: scale(1.05);
}
#continue-btn {
    grid-column: 1 / -1; /* Make the button span both columns */
    background-color: var(--primary);
    animation: none; /* Disable breathing animation for this button */
}
/* NEW: Viral Share Buttons */
#viral-share-container {
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.btn-viral {
    background: linear-gradient(135deg, var(--accent), #7a42e6);
    font-weight: 600;
    animation: fadeIn 0.5s ease;
}
.btn-viral:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: var(--shadow-lg);
}
.btn-stumped {
    background: linear-gradient(135deg, var(--warning), #e68a00);
}

/* --- Paywall Screen --- */
#paywall {
  justify-content: center;
  align-items: center;
  padding: var(--spacing-xl);
  gap: var(--spacing-lg);
}
#paywall h2 {
  font-size: 28px;
  margin-bottom: var(--spacing-md);
  color: var(--text-primary);
  text-align: center;
  letter-spacing: -0.02em;
}
#paywall ul {
  list-style: none;
  margin-bottom: var(--spacing-lg);
  width: 100%;
}
#paywall li {
  padding: var(--spacing-md) 0;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
#paywall li:before {
  content: "✓";
  color: var(--success);
  font-weight: bold;
  font-size: 18px;
}

/* --- ================================== --- */
/* --- REWARD ROUND / END SCREEN STYLES --- */
/* --- ================================== --- */
#end-screen {
  padding: var(--spacing-xl);
  overflow-y: auto;
  text-align: center;
  position: relative; /* Needed for pep-talk overlay */
}
#end-screen-title {
    font-size: 2.5rem;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    letter-spacing: -0.02em;
    opacity: 0;
    transform: scale(1.5);
    transition: opacity 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#end-screen-title.visible {
    opacity: 1;
    transform: scale(1);
}
#end-screen-dynamic-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}

.end-screen-element {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, filter 0.4s ease;
}
#end-screen.pep-talk-active .end-screen-element {
    filter: blur(8px);
    opacity: 0.5;
}

#level-summary-container, #topic-performance-container, #achievements-container {
    background-color: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    margin-bottom: var(--spacing-lg);
    box-shadow: none;
    text-align: left;
}
#topic-performance-container h3, #achievements-container h3, #level-summary-container h3 {
    text-align: center;
    font-size: 1.1rem;
    margin-bottom: var(--spacing-lg);
}

/* Performance Summary Card Redesign */
#score-container {
    text-align: center;
    margin-bottom: var(--spacing-lg);
}
#final-score-value {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
    color: var(--primary);
    display: block;
}
#score-buildup-list {
    list-style: none;
    padding: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
}
#score-buildup-list li {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp 0.5s ease-out forwards;
}
#score-buildup-list li:nth-child(2) { animation-delay: 0.2s; }
#score-buildup-list li:nth-child(3) { animation-delay: 0.4s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#gauge-and-difficulty-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}
#accuracy-gauge-container, #difficulty-meter-container {
    text-align: center;
}
#accuracy-gauge-container p, #difficulty-meter-container p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: var(--spacing-sm) 0 0 0;
}
#accuracy-gauge {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: conic-gradient(var(--gauge-color, var(--success)) calc(var(--value, 0) * 1%), #e0e0e0 0);
    transition: --value 1.5s ease-in-out, background-color 1.5s ease;
}
#accuracy-gauge::before {
    content: "";
    position: absolute;
    width: 65px;
    height: 65px;
    background: var(--surface);
    border-radius: 50%;
}
#accuracy-gauge-value {
    position: relative;
    font-size: 1.2rem;
    font-weight: 600;
}
#difficulty-meter {
    font-size: 1.8rem;
    color: var(--warning);
}

/* Topic Performance Chart */
#topic-performance-chart {
  height: 250px;
  width: 100%;
}
#performanceChart {
  width: 100% !important;
  height: 100% !important;
}

/* Achievements Card Redesign: "THE TROPHY WALL" */
#achievements-container {
    perspective: 1000px;
}
#newly-unlocked-achievement .achievement-medal {
    animation: fly-in-flip 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes fly-in-flip {
    0% { transform: translateY(50px) rotateX(-90deg) scale(0.8); opacity: 0; }
    100% { transform: translateY(0) rotateX(0deg) scale(1); opacity: 1; }
}

#trophy-wall {
    display: flex;
    justify-content: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}
.achievement-medal {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    text-align: center;
    position: relative;
}
.achievement-medal-icon {
    font-size: 4rem;
    line-height: 1;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
    position: relative;
    z-index: 1;
}
/* Medal Gradients for that metallic feel */
.medal-bronze { text-shadow: 0 2px 2px rgba(0,0,0,0.3); color: #CD7F32; }
.medal-silver { text-shadow: 0 2px 2px rgba(0,0,0,0.3); color: #C0C0C0; }
.medal-gold { text-shadow: 0 2px 2px rgba(0,0,0,0.3); color: #FFD700; }

.achievement-medal-text h4 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-primary);
}
.achievement-medal-text p {
    font-size: 0.8rem;
    margin: 0;
    color: var(--text-secondary);
}

/* States */
.achievement-medal.not-yet-unlocked .achievement-medal-icon {
    filter: grayscale(1) drop-shadow(0 2px 3px rgba(0,0,0,0.1));
    opacity: 0.5;
}
.achievement-medal.not-yet-unlocked .achievement-medal-text {
    opacity: 0.7;
}
.achievement-medal.newly-unlocked::after {
    content: 'NEW!';
    position: absolute;
    top: -5px;
    right: -10px;
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 10px;
    transform: rotate(15deg);
    animation: pop-in 0.5s 1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
}
@keyframes pop-in {
    0% { transform: scale(0.5) rotate(15deg); opacity: 0; }
    100% { transform: scale(1) rotate(15deg); opacity: 1; }
}

/* Button Hierarchy */
.btn-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
}
.btn.btn-primary-action {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    font-size: 1.1rem;
    padding: 18px var(--spacing-lg);
    animation: pulse 2s infinite;
}
.btn.btn-primary-action:hover {
    animation-play-state: paused;
    transform: translateY(-2px) scale(1.02);
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0, 113, 227, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 113, 227, 0); }
}
.btn.btn-secondary-action {
    background: var(--primary);
}
.btn.btn-social-action {
    background: #1DA1F2; /* Twitter Blue */
}
.btn.btn-utility-action {
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--text-tertiary);
}
.btn.btn-utility-action:hover {
    background: rgba(128, 128, 128, 0.1);
}

/* --- NEW: PEP TALK STYLES --- */
#pep-talk-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}
.pep-talk-content {
    background-color: var(--surface);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    transform: scale(0.8);
    opacity: 0;
    animation: zoomIn 0.5s 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes zoomIn {
    to { transform: scale(1); opacity: 1; }
}
#pep-talk-character-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin: -64px auto var(--spacing-md) auto;
    display: block;
    border: 4px solid var(--surface);
}
#pep-talk-opener {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}
#pep-talk-body {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-lg);
}
#pep-talk-body strong.strong-topic {
    color: var(--success);
}
#pep-talk-body strong.weak-topic {
    color: var(--warning);
}
#pep-talk-cta {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-tertiary);
    margin-bottom: var(--spacing-lg);
}
#pep-talk-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}
.btn-practice-drill {
    background: linear-gradient(135deg, var(--warning), #e68a00);
    animation: pulse 2s infinite;
}
/* --- END PEP TALK STYLES --- */

/* --- HISTORY SECTION / TUTOR PLAN --- */
#history-section {
    background-color: transparent;
    border: none;
    padding: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}
/* NEW: Tab styling for history section */
.history-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}
.tab-btn {
    flex-grow: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.tab-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}
/* End of new tab styling */
.history-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--spacing-sm);
}
#tutor-priority-card {
    background-color: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-lg);
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: var(--shadow-md);
    text-align: center;
}
#tutor-priority-card h4 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
#tutor-priority-card .topic-name {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin: var(--spacing-xs) 0;
}
#tutor-priority-card .topic-accuracy {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--warning);
    margin-bottom: var(--spacing-md);
}
#tutor-priority-card .tutor-message {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
}
#skill-building-list .skill-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
#skill-building-list .skill-item:last-child {
    border-bottom: none;
}
#skill-building-list .skill-info {
    flex-grow: 1;
}
#skill-building-list .skill-info h5 {
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
}
.accuracy-bar-container {
    width: 100%;
    height: 6px;
    background-color: rgba(0,0,0,0.08);
    border-radius: 3px;
    overflow: hidden;
    margin-top: var(--spacing-xs);
}
.accuracy-bar {
    height: 100%;
    width: 0%; /* Set by JS */
    border-radius: 3px;
    transition: width 1s ease-out;
}
#journey-stats-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
    text-align: center;
}
.stat-block {
    background-color: var(--surface);
    padding: var(--spacing-md);
    border-radius: var(--border-radius-md);
}
.stat-block .stat-value {
    font-size: 1.8rem;
    font-weight: 600;
    display: block;
    line-height: 1.1;
}
.stat-block .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
#history-chart-container {
  max-width: 100%;
  margin: 0 auto;
  position: relative;
  height: 250px;
}

/* --- General Animations & Effects --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.fade-in {
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.slide-in {
  animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Responsive Adjustments for Game Screens --- */
@media (max-height: 667px) {
  #question-text { font-size: 20px; }
  .character-img { width: 42px; height: 42px; font-size: 24px; }
  #header { padding: var(--spacing-xs) 0; }
  #question-container { padding: var(--spacing-lg); }
}
@media (min-height: 800px) {
  #question-text { font-size: 24px; }
  .btn { padding: var(--spacing-md) var(--spacing-lg); font-size: 18px; }
  #question-container { padding: var(--spacing-xxl); }
  .character-img { width: 56px; height: 56px; font-size: 32px; }
}

/* --- Dark Mode Specific Game Styles --- */
@media (prefers-color-scheme: dark) {
  #auth-container input[type="email"],
  #auth-container input[type="password"] {
    background-color: rgba(28, 28, 30, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
  }
  #progress-bar {
    background-color: rgba(255, 255, 255, 0.1);
  }
  #paywall li {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
  #google-signin-btn, #microsoft-signin-btn {
    background-color: var(--surface);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
  }
  #loading-tip:before {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
  }
  #exit-btn {
    background-color: var(--surface);
    color: var(--primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
  #exit-btn:hover {
    background-color: var(--surface-secondary);
  }
  #share-question:hover {
    background-color: rgba(255, 255, 255, 0.05);
  }
  #landing-screen, #game-screen, #paywall, #end-screen, #loading-screen {
    background: linear-gradient(135deg, rgba(40, 40, 40, 0.25), rgba(40, 40, 40, 0.15));
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  }
  #question-container {
    background-color: rgba(44, 44, 46, 0.5);
    border-color: rgba(255, 255, 255, 0.1);
  }
  #level-summary-container, #topic-performance-container, #achievements-container, #review-section {
    background-color: rgba(44, 44, 46, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
  }
  .settings-item {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
  #close-settings {
    border-color: rgba(255, 255, 255, 0.1);
  }
  #accuracy-gauge {
    background: conic-gradient(var(--gauge-color, var(--success)) calc(var(--value, 0) * 1%), #2c2c2e 0);
  }
  .medal-bronze { color: #D29358; }
  .medal-silver { color: #D1D1D1; }
  .medal-gold { color: #F7E57A; }
  .pep-talk-content {
      background-color: var(--surface-secondary);
  }
  #pep-talk-character-img {
      border-color: var(--surface-secondary);
  }
  #tutor-priority-card, .stat-block {
      border-color: rgba(255,255,255,0.1);
  }
  #skill-building-list .skill-item {
      border-bottom-color: rgba(255,255,255,0.1);
  }
  /* NEW Dark mode character tips */
  .character-msg.tip-weak {
    background-color: #4d3d16;
  }
  .character-msg.tip-strong {
    background-color: #1a3d23;
  }
}

/* --- Settings Panel --- */
#settings-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}
.settings-content {
  background-color: var(--surface);
  padding: var(--spacing-lg);
  border-radius: var(--border-radius-lg);
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.settings-content h3 {
  margin-bottom: var(--spacing-lg);
  text-align: center;
  color: var(--text-primary);
}
.settings-item {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-md) 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}
#manage-subscription {
  margin-top: var(--spacing-lg);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}
#close-settings {
  margin-top: var(--spacing-sm);
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* --- Miscellaneous UI Elements --- */
.screenshot-feedback {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  animation: fadeInOut 3s ease-in-out;
  z-index: 1000;
}
@keyframes fadeInOut {
  0% { opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { opacity: 0; }
}
.feedback-image {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  margin-left: 5px;
}
.feedback-image, #funny-character img {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

/* --- Fullscreen on small devices --- */
@media (max-width: 600px) {
    .container {
        padding: 0; /* No padding on container for small screens */
    }
    #landing-screen, #game-screen, #paywall, #end-screen, #loading-screen {
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
    }
}

/* --- Juicy Impactful Animations --- */
.screen-flash-correct {
  animation: flash-correct 0.5s ease-out;
}
.screen-flash-incorrect {
  animation: flash-incorrect 0.5s ease-out;
}
@keyframes flash-correct {
  0% { box-shadow: inset 0 0 0 0px rgba(48, 209, 88, 0); }
  50% { box-shadow: inset 0 0 0 10px rgba(48, 209, 88, 0.4); }
  100% { box-shadow: inset 0 0 0 0px rgba(48, 209, 88, 0); }
}
@keyframes flash-incorrect {
  0% { box-shadow: inset 0 0 0 0px rgba(255, 69, 58, 0); }
  50% { box-shadow: inset 0 0 0 10px rgba(255, 69, 58, 0.4); }
  100% { box-shadow: inset 0 0 0 0px rgba(255, 69, 58, 0); }
}
.score-jump {
  animation: jump-and-sparkle 0.6s ease-out;
  display: inline-block;
}
@keyframes jump-and-sparkle {
  0% { transform: scale(1); }
  25% { transform: scale(1.6) rotate(-10deg); color: var(--success); }
  50% { transform: scale(1.6) rotate(10deg); }
  100% { transform: scale(1); }
}
.button-pop {
  animation: pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes pop {
  0% { transform: scale(1); } 50% { transform: scale(1.1); } 100% { transform: scale(1); }
}
.gain-life {
    animation: gain-life-anim 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes gain-life-anim {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); text-shadow: 0 0 15px var(--success); }
    100% { transform: scale(1); }
}
.lose-life {
    animation: lose-life-anim 0.6s ease-in-out;
}
@keyframes lose-life-anim {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}
#lives-indicator.flash-red {
    color: var(--error);
}
.plus-one-life {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: bold;
    color: var(--success);
    opacity: 1;
    animation: float-up-fade-out 1.5s ease-out forwards;
    pointer-events: none;
}
@keyframes float-up-fade-out {
    0% { transform: translate(-50%, 0); opacity: 1; }
    100% { transform: translate(-50%, -50px); opacity: 0; }
}

/* --- Confetti --- */
#confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}
.confetti-piece {
    position: absolute;
    width: 8px;
    height: 16px;
    background: #f00;
    top: 0;
    opacity: 0;
}
@keyframes fall {
    to {
        transform: translateY(100vh) rotate(360deg);
        opacity: 1;
    }
}
/* NEW: Level Transition Overlay */
#level-transition-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#level-transition-overlay.visible {
    opacity: 1;
    pointer-events: all;
}
#level-transition-text {
    font-size: 4rem;
    font-weight: bold;
    color: white;
    text-shadow: 0 0 20px var(--primary);
    transform: scale(0.5);
    opacity: 0;
}
#level-transition-overlay.visible #level-transition-text {
    animation: zoom-in-out 1.5s ease-in-out forwards;
}
@keyframes zoom-in-out {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}