/* --- Global Variables & Resets --- */
:root {
  --bg-color: #f5f5f5;
  --text-color: #222;
  --card-bg: white;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --primary-color: #007bff;
  --primary-text: white;
  --border-light: #ddd;
  --border-focus: #007acc;
  --border-focus-contrast: yellow;
  --button-disabled-bg: #ccc;
  --button-disabled-text: #888;
}

body {
  font-family: sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  padding: 2rem;
  text-align: center;
  margin: 0;
}

/* --- High Contrast Mode --- */
body.high-contrast {
  --bg-color: black;
  --text-color: white;
  --card-bg: #111;
  --shadow-color: rgba(255, 255, 255, 0.2);
  --primary-color: yellow;
  --primary-text: black;
  --border-light: #555;
  --border-focus: yellow;
  --button-disabled-bg: #555;
  --button-disabled-text: #aaa;
}

/* --- Reduced Motion Mode --- */
body.reduced-motion,
body.reduced-motion * {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* --- Larger Text Mode --- */
body.larger-text {
  font-size: 1.2rem;
}

body.larger-text h1 {
  font-size: 2.2rem;
}

body.larger-text h2 {
  font-size: 1.6rem;
}

body.larger-text button {
  font-size: 1.1rem;
  padding: 0.8rem 1.5rem;
}

body.larger-text .setting-group label {
  font-size: 1.2rem;
}

/* --- Base Layout & Screens --- */
main {
  max-width: 450px;
  margin: auto;
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 0 10px var(--shadow-color);
  position: relative; /* For back button positioning */
}

.screen {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

.hidden {
  display: none;
  opacity: 0;
}

/* Screen reader only utility class */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- Buttons & Inputs --- */
input[type="tel"],
input[type="range"],
button {
  font-size: 1.1rem;
  padding: 0.75rem;
  margin-top: 1rem;
  width: 100%;
  box-sizing: border-box; /* Makes width 100% behave */
  border-radius: 5px;
  border: 1px solid var(--border-light);
  transition: background-color 0.2s, transform 0.1s;
}

button {
  background: var(--primary-color);
  color: var(--primary-text);
  font-weight: bold;
  cursor: pointer;
}

button:disabled {
  background: var(--button-disabled-bg);
  color: var(--button-disabled-text);
  cursor: not-allowed;
}

button:not(:disabled):hover {
  filter: brightness(1.1);
}

button:not(:disabled):active {
  transform: scale(0.98);
}

/* Focus styles for accessibility */
button:focus,
input:focus {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

body.high-contrast button:focus,
body.high-contrast input:focus,
body.high-contrast input[type="range"]:focus {
  outline-color: var(--border-focus-contrast);
}

/* --- Game Screen --- */
#feedback {
  margin-top: 1rem;
  font-weight: bold;
  min-height: 1.5em;
}

#score,
#timer {
  margin-top: 1rem;
  font-size: 1.2rem;
}

.glow {
  animation: glow 0.5s ease-in-out;
}

@keyframes glow {
  0% {
    background-color: yellow;
    color: black;
  }
  100% {
    background-color: transparent;
    color: var(--text-color);
  }
}

/* --- Game Over Screen --- */
#score-breakdown {
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #f0f0f0;
  border-radius: 8px;
}

body.high-contrast #score-breakdown {
  background-color: #333;
}

#score-breakdown p {
  margin: 0.5rem 0;
}

/* --- NEW v0.5.0 STYLES --- */

/* Countdown Overlay */
#countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  color: white;
  font-size: 10rem;
  font-weight: bold;
}

/* Settings Dialog (Modal Styles) */
#settings-screen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  width: 90%;
  max-width: 500px;
  text-align: left;
}

/* MOTD Dialog (Modal Gate) */
#motd-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: 90%;
  max-width: 500px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

/* MOTD Backdrop with Blur */
#motd-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.motd-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: 90%;
  max-width: 500px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.motd-dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.motd-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem;
  gap: 1rem;
}

.motd-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.motd-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.motd-icon {
  font-size: 2rem;
  line-height: 1;
}

.motd-title {
  color: #4ecdc4;
  font-size: 1.5rem;
  margin: 0;
  font-weight: bold;
}

.motd-message {
  color: #e0e0e0;
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0.5rem 0;
  text-align: left;
}

.motd-message a {
  color: #4ecdc4;
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s ease;
}

.motd-message a:hover {
  color: #6decdc;
}

.motd-message strong {
  color: #4ecdc4;
  font-weight: bold;
}

.motd-dismiss-btn {
  background: linear-gradient(135deg, #4ecdc4 0%, #3db8af 100%);
  color: #000;
  font-weight: bold;
  padding: 0.75rem 2rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1rem;
}

.motd-dismiss-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(78, 205, 196, 0.3);
}

.motd-dismiss-btn:active {
  transform: translateY(0);
}

/* Overlay for modals */
body.modal-open::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
}

/* Play Now Button (Primary Action) */
.play-now-button {
  font-size: 1.3rem !important;
  padding: 1.2rem !important;
  background: linear-gradient(135deg, #4ecdc4 0%, #3db8af 100%) !important;
  color: #000 !important;
  font-weight: bold !important;
  margin-top: 2rem !important;
  margin-bottom: 2rem !important;
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3);
}

.play-now-button:not(:disabled):hover {
  filter: brightness(1.15);
  box-shadow: 0 12px 30px rgba(78, 205, 196, 0.5);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3);
  }
  50% {
    box-shadow: 0 12px 30px rgba(78, 205, 196, 0.5);
  }
}

/* Mode Selection Modal */
#mode-selection-screen {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: 90%;
  max-width: 500px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

#mode-selection-screen::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.mode-selection-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  width: 90%;
  max-width: 500px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.mode-selection-modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
}

.mode-selection-content {
  position: relative;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mode-selection-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  margin: 0;
  padding: 0;
}

.mode-selection-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

#mode-selection-heading {
  color: #4ecdc4;
  text-align: center;
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  margin-top: 0;
}

.mode-button {
  background: linear-gradient(135deg, #2a2a4e 0%, #1e1e38 100%) !important;
  color: #4ecdc4 !important;
  border: 2px solid #4ecdc4 !important;
  padding: 1rem !important;
  font-size: 1.1rem !important;
  margin: 0.5rem 0 !important;
  border-radius: 8px !important;
  text-align: left !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.25rem;
}

.mode-button:not(:disabled):hover {
  background: linear-gradient(135deg, #3a3a5e 0%, #2e2e48 100%) !important;
  border-color: #6decdc !important;
  color: #6decdc !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3) !important;
}

.mode-button.danger {
  border-color: #d32f2f !important;
  color: #d32f2f !important;
}

.mode-button.danger:not(:disabled):hover {
  border-color: #ff5252 !important;
  color: #ff5252 !important;
  box-shadow: 0 8px 20px rgba(211, 47, 47, 0.3) !important;
}

.mode-subtitle {
  font-size: 0.85rem;
  opacity: 0.8;
  font-weight: normal;
}

/* Audio Error Banner (Main Menu) */
.audio-error-banner {
  background: linear-gradient(135deg, rgba(211, 47, 47, 0.1) 0%, rgba(229, 57, 53, 0.05) 100%);
  border: 2px solid #d32f2f;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  position: relative;
  display: none;
}

.audio-error-banner.visible {
  display: block;
}

.audio-error-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.audio-error-banner h3 {
  color: #ff5252;
  margin: 0;
  font-size: 1rem;
}

.audio-error-banner p {
  color: #e0e0e0;
  margin: 0.25rem 0 0 0;
  font-size: 0.9rem;
}

.audio-error-close {
  background: rgba(211, 47, 47, 0.2);
  border: 1px solid #d32f2f;
  color: #ff5252;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: bold;
  transition: all 0.2s ease;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
}

.audio-error-close:hover {
  background: rgba(211, 47, 47, 0.3);
  border-color: #ff5252;
}

/* Responsive: Stack error banner content on mobile */
@media (max-width: 480px) {
  .audio-error-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .audio-error-close {
    align-self: flex-end;
    margin-top: -0.5rem;
  }
}

/* Back Button (Top Left) */
.back-button {
  position: absolute;
  top: 1rem;
  left: 1rem;
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 1rem;
  margin: 0;
}

/* Tabbed Interface */
.tab-list {
  display: flex;
  border-bottom: 2px solid var(--border-light);
  margin-bottom: 1.5rem;
}

.tab-list button {
  background: none;
  color: var(--text-color);
  border: none;
  border-bottom: 3px solid transparent;
  padding: 0.75rem 1rem;
  margin: 0 0.5rem 0 0;
  font-size: 1rem;
  font-weight: normal;
  width: auto;
  border-radius: 5px 5px 0 0;
}

.tab-list button[aria-selected="true"] {
  font-weight: bold;
  border-bottom-color: var(--primary-color);
}

.tab-list button:focus {
  outline-offset: -2px;
}

body.high-contrast .tab-list button[aria-selected="true"] {
  border-bottom-color: var(--border-focus-contrast);
}

/* Setting Groups */
.setting-group,
fieldset.setting-group {
  margin-bottom: 1.5rem;
  border: none;
  padding: 0;
}

.setting-group label,
fieldset.setting-group legend {
  font-weight: bold;
  font-size: 1.1rem;
  display: block;
  margin-bottom: 0.5rem;
}

.setting-description {
  font-size: 0.85rem;
  color: #888;
  margin: 0.25rem 0 0 1.75rem;
  font-weight: normal;
}

/* Small Button */
.small-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.9rem;
  background: var(--primary-color);
  color: var(--primary-text);
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.small-btn:hover {
  opacity: 0.9;
}

/* Danger Button */
.danger-btn {
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.danger-btn:hover {
  background: #c82333;
}

/* Checkbox/Toggle Styles */
input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  transform: scale(1.5);
}

input[type="checkbox"] + label {
  font-weight: normal;
  display: inline;
  font-size: 1rem;
}

/* Range Slider Styles */
input[type="range"] {
  padding: 0;
  margin-top: 0.5rem;
}

/* --- Footer --- */
footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.9rem;
  color: #777;
}

footer a {
  color: var(--primary-color);
}
/* --- New Stats Layout --- */
.stats-row {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
  font-size: 1.2rem;
  font-weight: bold;
}

/* Hide lives by default (toggle visible in JS for Endless Mode) */
#lives.hidden {
  display: none;
}

/* Subtitle for buttons (e.g. "60 Seconds") */
.btn-subtitle {
  display: block;
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.9;
}

/* --- Gabriel The Cat (Mascot) --- */
#gabriel-container {
  height: 120px; /* Adjust based on how big you want him */
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 1rem;
  overflow: hidden;
}

#gabriel-sprite {
  width: 100px;  /* Estimated width of one frame */
  height: 100px; /* Estimated height of one frame */
  background-image: url('./img/gabriel.png'); 
  background-size: 200% 200%; /* Since it is a 2x2 grid */
  background-position: 0 0;
  border-radius: 50%; /* Optional: Makes the square JPG look like a token/circle */
}

/* The Running Animation */
/* This moves the background image to show the 4 different frames */
@keyframes gabrielRun {
  0% { background-position: 0 0; }       /* Top Left */
  25% { background-position: 100% 0; }   /* Top Right */
  50% { background-position: 0 100%; }   /* Bottom Left */
  75% { background-position: 100% 100%; }/* Bottom Right */
  100% { background-position: 0 0; }
}

/* Class to trigger running */
.running {
  animation: gabrielRun 0.6s steps(1) infinite;
}

/* Make him run faster as you streak! */
.running.fast {
  animation-duration: 0.3s;
}
/* --- Winter Holiday Theme (v0.6.0, scoped) --- */
body.theme-winter {
  --bg-color: #e3f2fd; /* Ice Blue */
  --primary-color: #d32f2f; /* Santa Red */
  --border-focus: #0288d1; /* Deep Ice Blue */
}

body.theme-winter #ready-screen::before {
  content: "❄️"; 
  display: block;
  font-size: 3rem;
  margin-bottom: 1rem;
}

body.theme-winter #gabriel-sprite {
  border: 4px solid white;
  box-shadow: 0 0 10px rgba(0, 150, 255, 0.3);
}

body.high-contrast {
  --bg-color: black;
  --primary-color: yellow;
}

/* Santa hat marker */
.santa-hat {
  position: relative;
}

.santa-hat::after {
  content: "🎅";
  position: absolute;
  top: -18px;
  right: -12px;
  font-size: 1.6rem;
}

/* Overdrive visual pulse */
body.overdrive-active {
  box-shadow: inset 0 0 0 9999px rgba(255, 0, 0, 0.08);
}

.overdrive-text {
  color: #d32f2f;
  text-shadow: 0 0 8px rgba(211, 47, 47, 0.6);
}

/* Shop grid + items */
.currency-display {
  margin: 1rem 0;
  font-size: 1.2rem;
  font-weight: bold;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.shop-item {
  background: var(--card-bg);
  border: 2px solid var(--border-light);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 6px var(--shadow-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.shop-item .item-icon,
.item-badge,
.achievement-icon {
  width: 56px;
  height: 56px;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: radial-gradient(circle at 30% 30%, rgba(78, 205, 196, 0.12), rgba(0, 0, 0, 0.2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
  margin-bottom: 0.35rem;
}

.shop-item .item-icon svg,
.item-badge svg,
.achievement-icon svg {
  width: 26px;
  height: 26px;
  color: var(--primary-color);
  stroke-width: 2;
}

.item-button {
  gap: 0.45rem;
  align-items: center;
}

.shop-item .item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.shop-item .item-cost {
  font-weight: bold;
}

.shop-item .buy-btn {
  width: auto;
  min-width: 80px;
  padding: 0.5rem 0.75rem;
}

.shop-item .item-owned {
  font-size: 0.9rem;
  color: #555;
}

.shop-item .item-description {
  font-size: 0.95rem;
  color: #444;
}

/* Quick use bar */
.quick-use-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.item-button {
  width: auto;
  padding: 0.5rem 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.item-button .count {
  font-weight: bold;
}

.item-button.item-active {
  box-shadow: 0 0 10px rgba(0, 150, 255, 0.6);
}

/* Toast-style feedback */
.item-feedback-toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  z-index: 2000;
  animation: slideIn 0.25s ease-out;
}

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

/* --- Audio Loading Spinner --- */
.audio-loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.audio-loading-spinner.hidden {
  display: none;
}

.audio-loading-spinner .spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.audio-loading-spinner p {
  margin: 0;
  font-size: 0.9rem;
  color: #666;
}

body.high-contrast .audio-loading-spinner p {
  color: #ccc;
}

/* --- Audio Loading Banner --- */
.audio-loading-banner {
  margin-top: 1rem;
  padding: 1rem;
  background: #e3f2fd;
  border-left: 4px solid #007bff;
  border-radius: 4px;
  text-align: left;
}

.audio-loading-banner.hidden {
  display: none;
}

.audio-loading-banner p {
  margin: 0;
  font-size: 0.95rem;
  color: #01579b;
}

body.high-contrast .audio-loading-banner {
  background: #333;
  border-left-color: yellow;
}

body.high-contrast .audio-loading-banner p {
  color: #ffff00;
}

/* --- Red Flash Animation for Consecutive Mistakes Warning --- */
@keyframes redFlash {
  0% {
    background-color: rgba(255, 0, 0, 0);
  }
  50% {
    background-color: rgba(255, 0, 0, 0.3);
  }
  100% {
    background-color: rgba(255, 0, 0, 0);
  }
}

.red-flash {
  animation: redFlash 0.6s ease-out;
  pointer-events: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
}

/* --- Shop Tabs --- */
.shop-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.shop-tab-btn {
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  background: var(--shadow-color);
  color: var(--text-color);
  border: 2px solid transparent;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.shop-tab-btn[aria-selected="true"] {
  background: var(--primary-color);
  color: var(--primary-text);
  border-color: var(--primary-color);
  font-weight: bold;
}

.shop-tab-btn:focus {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

body.high-contrast .shop-tab-btn {
  border: 2px solid var(--border-light);
}

body.high-contrast .shop-tab-btn[aria-selected="true"] {
  background: yellow;
  color: black;
  border-color: yellow;
}

/* --- Achievements --- */
.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.achievement-card {
  background: var(--shadow-color);
  padding: 1rem;
  border-radius: 8px;
  border: 2px solid var(--border-light);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.achievement-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color);
}

.achievement-icon {
  margin-bottom: 0.5rem;
}

.achievement-card h3 {
  margin: 0.5rem 0;
  font-size: 1rem;
  color: var(--primary-color);
}

body.high-contrast .achievement-card h3 {
  color: yellow;
}

.achievement-description {
  font-size: 0.85rem;
  color: #666;
  margin: 0.5rem 0;
}

body.high-contrast .achievement-description {
  color: #ccc;
}

.achievement-reward {
  font-size: 0.9rem;
  font-weight: bold;
  color: #ffab00;
  margin-top: 0.5rem;
}

body.high-contrast .achievement-reward {
  color: #ffeb3b;
}

.achievements-secret-btn {
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  margin-top: 1rem;
  background: rgba(0, 123, 255, 0.1);
  color: var(--primary-color);
  border: 1px dashed var(--primary-color);
}

body.high-contrast .achievements-secret-btn {
  background: rgba(255, 255, 0, 0.1);
  color: yellow;
  border-color: yellow;
}

/* --- Achievement Popup --- */
.achievement-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.achievement-popup-content {
  background: var(--card-bg);
  padding: 2rem;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
  animation: slideUp 0.4s ease-out;
}

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

.achievement-popup-header {
  margin-bottom: 1rem;
}

.achievement-popup-header h2 {
  margin: 0;
  color: var(--primary-color);
  font-size: 1.5rem;
}

body.high-contrast .achievement-popup-header h2 {
  color: yellow;
}

.gabriel-celebration {
  font-size: 3rem;
  margin: 1rem 0;
  animation: pulse 0.6s ease-in-out;
}

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

.achievement-popup-body h3 {
  margin: 0.5rem 0;
  color: var(--text-color);
  font-size: 1.3rem;
}

.achievement-popup-body p {
  margin: 0.5rem 0;
  color: #666;
  font-size: 0.95rem;
}

body.high-contrast .achievement-popup-body p {
  color: #ccc;
}

.achievement-popup-footer {
  margin-top: 1.5rem;
}

.achievement-close-btn {
  padding: 0.8rem 2rem;
  font-size: 1rem;
  background: var(--primary-color);
  color: var(--primary-text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: transform 0.2s, box-shadow 0.2s;
  width: auto;
  display: inline-block;
}

.achievement-close-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

body.high-contrast .achievement-close-btn {
  background: yellow;
  color: black;
}

/* --- Onboarding Screens --- */
#onboarding-step1,
#onboarding-step2,
#onboarding-step3 {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  width: 90%;
  max-width: 500px;
  text-align: left;
}

.onboarding-content {
  text-align: left;
}

.onboarding-content h2 {
  text-align: center;
  margin-bottom: 1rem;
  font-size: 1.8rem;
}

.onboarding-content p {
  text-align: center;
  color: #aaa;
  line-height: 1.6;
}

.onboarding-content form {
  margin: 1.5rem 0;
}

.onboarding-content label {
  display: block;
  margin: 0.75rem 0 0.5rem 0;
  font-weight: 600;
  color: #fff;
}

.onboarding-content input[type="text"] {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #4ecdc4;
  border-radius: 8px;
  font-size: 1rem;
  background: #222;
  color: #fff;
  transition: border-color 0.2s;
}

.onboarding-content input:focus {
  outline: none;
  border-color: #00d4ff;
  box-shadow: 0 0 8px rgba(78, 205, 196, 0.3);
}

body.high-contrast .onboarding-content input[type="text"] {
  border-color: yellow;
  background: #000;
}

.onboarding-content small {
  display: block;
  margin-top: 0.5rem;
  color: #999;
  font-size: 0.9rem;
}

.popup-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.popup-button {
  flex: 1;
  min-width: 150px;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  border: 2px solid #4ecdc4;
  background: transparent;
  color: #4ecdc4;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

.popup-button:hover {
  background: rgba(78, 205, 196, 0.1);
  transform: translateY(-2px);
}

.popup-button.primary {
  background: linear-gradient(135deg, #4ecdc4, #00d4ff);
  color: #000;
  border-color: transparent;
}

.popup-button.primary:hover {
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.4);
}

body.high-contrast .popup-button {
  border-color: yellow;
  color: yellow;
}

body.high-contrast .popup-button:hover {
  background: rgba(255, 255, 0, 0.2);
}

body.high-contrast .popup-button.primary {
  background: yellow;
  color: black;
}
/* --- MOTD Dialog Styles --- */
.motd-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 500px;
  width: 90%;
  background: transparent;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: motdFadeIn 0.3s ease-out;
}

.motd-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  animation: backdropFadeIn 0.3s ease-out;
}

@keyframes motdFadeIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.motd-content {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  padding: 2rem;
  border-radius: 12px;
  position: relative;
  color: #fff;
}

.motd-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  color: #999;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.motd-close:hover,
.motd-close:focus {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  outline: 2px solid #4ecdc4;
  outline-offset: 2px;
}

.motd-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 1rem;
  animation: iconBounce 0.6s ease-out;
}

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

.motd-title {
  color: #4ecdc4;
  margin: 0 0 1rem 0;
  font-size: 1.5rem;
  text-align: center;
}

.motd-message {
  color: #e0e0e0;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  text-align: left;
  font-size: 1rem;
}

.motd-note {
  background: rgba(78,205,196,0.06);
  border-left: 3px solid #4ecdc4;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
  color: #cfeeea;
  border-radius: 4px;
}

.motd-message strong {
  color: #4ecdc4;
  font-weight: 600;
}

.motd-message a {
  color: #4ecdc4;
  text-decoration: underline;
  font-weight: 600;
  transition: color 0.2s;
}

.motd-message a:hover,
.motd-message a:focus {
  color: #00d4ff;
  outline: 2px solid #4ecdc4;
  outline-offset: 2px;
  border-radius: 2px;
}

.motd-dismiss-btn {
  width: 100%;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, #4ecdc4, #00d4ff);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.3);
}

.motd-dismiss-btn:hover,
.motd-dismiss-btn:focus {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(78, 205, 196, 0.5);
  outline: 2px solid #4ecdc4;
  outline-offset: 2px;
}

.motd-dismiss-btn:active {
  transform: translateY(0);
}

/* High Contrast MOTD Styles */
body.high-contrast .motd-content {
  background: #000;
  border: 3px solid yellow;
}

body.high-contrast .motd-title {
  color: yellow;
}

body.high-contrast .motd-message {
  color: #fff;
}

body.high-contrast .motd-message strong {
}

.motd-changelog-toggle {
  display: inline-block;
  margin-top: 0.5rem;
  background: transparent;
  border: none;
  color: #00d4ff;
  cursor: pointer;
  font-weight: 600;
}

.motd-changelog-toggle:focus,
.motd-changelog-toggle:hover {
  text-decoration: underline;
  outline: none;
}

.motd-changelog {
  margin-top: 1rem;
  padding-left: 1.2rem;
  color: #ddd;
  max-height: 220px;
  overflow: auto;
}

#motd-badge {
  margin-left: 0.35rem;
}
  color: yellow;
}

body.high-contrast .motd-message a {
  color: yellow;
  text-decoration: underline;
}

body.high-contrast .motd-message a:hover,
body.high-contrast .motd-message a:focus {
  background: yellow;
  color: #000;
  outline: 2px solid yellow;
}

body.high-contrast .motd-dismiss-btn {
  background: yellow;
  color: #000;
  border: 2px solid yellow;
}

body.high-contrast .motd-close {
  color: yellow;
  border: 2px solid yellow;
}

body.high-contrast .motd-close:hover,
body.high-contrast .motd-close:focus {
  background: yellow;
  color: #000;
}

/* Screen reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* --- Algebra Tutorial Styles --- */
#algebra-tutorial-screen {
  background: linear-gradient(135deg, #0f0f1e 0%, #1a1a2e 100%);
}

.algebra-lesson-container,
.algebra-practice-container,
.algebra-completion-container {
  background: #1a1a1a;
  border: 1px solid rgba(78, 205, 196, 0.3);
  border-radius: 8px;
  padding: 2rem;
  color: #ddd;
}

.lesson-header,
.practice-header,
.completion-header {
  margin-bottom: 2rem;
  border-bottom: 2px solid rgba(78, 205, 196, 0.3);
  padding-bottom: 1rem;
}

.lesson-header h3,
.practice-header h3,
.completion-header h3 {
  color: #4ecdc4;
  font-size: 1.5rem;
  margin: 0 0 0.5rem 0;
}

.lesson-progress,
.practice-progress {
  color: #999;
  font-size: 0.9rem;
  margin: 0;
}

.lesson-content {
  text-align: left;
}

.lesson-description {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
  color: #ddd;
}

.lesson-example {
  background: rgba(78, 205, 196, 0.1);
  border-left: 4px solid #4ecdc4;
  padding: 1rem;
  margin: 1.5rem 0;
  border-radius: 4px;
  color: #fff;
  font-family: 'Monaco', 'Courier New', monospace;
}

.lesson-steps {
  background: rgba(100, 100, 100, 0.1);
  padding: 1.5rem;
  border-radius: 6px;
  margin: 1.5rem 0;
}

.lesson-steps ol {
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.lesson-steps li {
  margin-bottom: 0.8rem;
  line-height: 1.6;
  color: #ddd;
}

.lesson-steps li:last-child {
  margin-bottom: 0;
}

.lesson-controls,
.practice-buttons,
.completion-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn-lesson,
.btn-practice {
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #4ecdc4, #00d4ff);
  border: none;
  border-radius: 6px;
  color: #000;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-lesson:hover,
.btn-practice:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

.btn-lesson:active,
.btn-practice:active {
  transform: scale(0.98);
}

.btn-lesson:disabled,
.btn-practice:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: scale(1);
}

.btn-lesson.secondary,
.btn-practice.secondary {
  background: rgba(78, 205, 196, 0.2);
  color: #4ecdc4;
  border: 1px solid #4ecdc4;
}

.btn-lesson.secondary:hover,
.btn-practice.secondary:hover {
  background: rgba(78, 205, 196, 0.3);
}

.practice-problem {
  background: rgba(0, 0, 0, 0.3);
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid rgba(78, 205, 196, 0.2);
}

.problem-equation {
  font-size: 1.8rem;
  color: #4ecdc4;
  margin-bottom: 2rem;
  font-family: 'Monaco', 'Courier New', monospace;
  background: rgba(78, 205, 196, 0.1);
  padding: 1.5rem;
  border-radius: 6px;
  border-left: 4px solid #4ecdc4;
}

.practice-input-group {
  margin: 1.5rem 0;
  text-align: left;
}

.practice-input-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #4ecdc4;
  font-weight: bold;
}

.practice-input-group input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid rgba(78, 205, 196, 0.3);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1.1rem;
  box-sizing: border-box;
  transition: border-color 0.3s;
}

.practice-input-group input:focus {
  outline: none;
  border-color: #4ecdc4;
  box-shadow: 0 0 10px rgba(78, 205, 196, 0.2);
}

.hint-display,
.solution-display {
  background: rgba(78, 205, 196, 0.1);
  border: 1px solid rgba(78, 205, 196, 0.3);
  padding: 1.5rem;
  border-radius: 6px;
  margin: 1.5rem 0;
  text-align: left;
}

.hint-display.hidden,
.solution-display.hidden {
  display: none;
}

.hint-display strong,
.solution-display strong {
  color: #4ecdc4;
  display: block;
  margin-bottom: 0.75rem;
}

.solution-display ol {
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.solution-display li {
  margin-bottom: 0.6rem;
  color: #ddd;
}

.practice-feedback {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 6px;
  text-align: center;
  font-weight: bold;
  min-height: 1.5em;
}

.practice-feedback.success {
  background: rgba(76, 175, 80, 0.2);
  border: 1px solid rgba(76, 175, 80, 0.5);
  color: #76ff77;
}

.practice-feedback.error {
  background: rgba(244, 67, 54, 0.2);
  border: 1px solid rgba(244, 67, 54, 0.5);
  color: #ff6b6b;
}

.feedback-success {
  color: #76ff77;
}

.feedback-error {
  color: #ff6b6b;
}

.practice-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* Icon inline styling */
.icon-inline {
  width: 1.2em;
  height: 1.2em;
  display: inline-block;
  vertical-align: middle;
}

/* Completion screen styles */
.completion-content {
  text-align: left;
  margin: 2rem 0;
}

.lessons-summary h4,
.completion-stats {
  color: #4ecdc4;
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.lessons-summary ul {
  list-style: none;
  padding: 0;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.lessons-summary li {
  padding: 0.5rem 0;
  color: #ddd;
  border-bottom: 1px solid rgba(78, 205, 196, 0.2);
}

.lessons-summary li:last-child {
  border-bottom: none;
}

.lessons-summary li.completed {
  color: #76ff77;
}

.lessons-summary li.not-completed {
  color: #999;
}

.completion-stats {
  background: rgba(78, 205, 196, 0.1);
  padding: 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
}

.completion-stats p {
  margin: 0.5rem 0;
  color: #ddd;
}

.completion-reward {
  background: rgba(255, 171, 0, 0.15);
  border: 2px solid rgba(255, 171, 0, 0.5);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  margin: 1.5rem 0;
  color: #ffab00;
}

#algebra-tutorial-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(78, 205, 196, 0.2);
  border: 1px solid #4ecdc4;
  color: #4ecdc4;
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
}

#algebra-tutorial-close:hover {
  background: #4ecdc4;
  color: #000;
}

/* High contrast mode for algebra tutorial */
body.high-contrast .algebra-lesson-container,
body.high-contrast .algebra-practice-container,
body.high-contrast .algebra-completion-container {
  background: #111;
  border: 2px solid yellow;
}

body.high-contrast .lesson-header,
body.high-contrast .practice-header,
body.high-contrast .completion-header {
  border-color: yellow;
}

body.high-contrast .lesson-header h3,
body.high-contrast .practice-header h3,
body.high-contrast .completion-header h3,
body.high-contrast .problem-equation {
  color: yellow;
}

body.high-contrast .btn-lesson,
body.high-contrast .btn-practice {
  background: yellow;
  color: #000;
}

body.high-contrast .practice-input-group input {
  background: #1a1a1a;
  border-color: yellow;
  color: #fff;
}

body.high-contrast .practice-input-group input:focus {
  border-color: white;
}