:root {
  --bg-light: #F8F9FA;
  --bg-dark: #E9ECEF;
  --surface-white: #FFFFFF;
  --surface-dim: #F1F3F5;
  --text-main: #212529;
  --text-secondary: #6C757D;
  --accent-red: #DC3545;
  --accent-green: #198754;
  --accent-primary: #4F46E5;
  --font-main: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background: linear-gradient(135deg, #e0c3fc 0%, #c2e9fb 50%, #a1c4fd 100%) fixed;
}

/* Decorative shapes, gears, and grids removed for performance */

body.page-preload {
  opacity: 0;
}

body.page-leave {
  opacity: 0;
}

.app-container {
  width: 100%; 
  max-width: 600px; 
  padding: 1rem;
  margin: auto;
  position: relative;
  z-index: 1;
}

.card {
  background: var(--surface-white) !important;
  border: 1px solid rgba(0, 0, 0, 0.1) !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08) !important;
  border-radius: 24px !important;
  padding: 2.5rem; text-align: center;
  position: relative; max-height: 90vh; overflow-y: auto;
}

.card::-webkit-scrollbar { width: 6px; }
.card::-webkit-scrollbar-track { background: transparent; }
.card::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }

h1, h2, h3 {
  font-family: var(--font-main);
  font-weight: 700; margin-bottom: 1.5rem; color: var(--text-main);
}

h1.logo {
  font-size: clamp(1.8rem, 10vw, 3.5rem); 
  text-transform: uppercase; 
  letter-spacing: clamp(2px, 1vw, 5px); 
  margin-right: -4px; /* Offset to center text with letter-spacing */
  color: var(--text-main);
  line-height: 1;
  width: 100%;
}

input[type="text"], textarea {
  width: 100%; padding: 1rem; font-family: var(--font-main); font-size: 1.1rem;
  background: var(--surface-white); border: 2px solid rgba(0,0,0,0.2); border-radius: 12px;
  color: var(--text-main); margin-bottom: 2rem; outline: none; text-align: center;
  transition: all 0.2s ease;
}

input[type="text"]:focus, textarea:focus {
  border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  background: var(--surface-white);
}

input[type="text"]::placeholder, textarea::placeholder { color: var(--text-secondary); opacity: 0.6; }

/* The Family Standard: Main Action Button */
.classic-btn, .solo-btn-elegant {
  font-family: var(--font-main);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1.2rem 2.5rem;
  background: #1a237e; /* Default Deep Blue */
  color: #ffffff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 1rem;
  box-shadow: 0 8px 20px rgba(26, 35, 126, 0.2);
  text-transform: uppercase;
}

.classic-btn:hover:not(:disabled) {
  background: #283593;
  transform: translateY(-4px);
  box-shadow: 0 12px 25px rgba(26, 35, 126, 0.3);
}

.classic-btn:active:not(:disabled) {
  transform: translateY(-1px);
}

.classic-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #6C757D;
  box-shadow: none;
}

/* Premium Gold Variant (for high-impact moments) */
.classic-btn.primary, 
.continue-btn-gold,
.boss-btn {
  background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
  color: #000;
  box-shadow: 0 10px 25px rgba(255, 215, 0, 0.3);
}

.classic-btn.primary:hover:not(:disabled),
.continue-btn-gold:hover:not(:disabled),
.boss-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #FFE033 0%, #FFB833 100%);
  box-shadow: 0 15px 35px rgba(255, 215, 0, 0.4);
}

/* Premium Blue-Purple Gradient (The 'Saved' Style) */
.classic-btn.blue-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(118, 75, 162, 0.3);
}

.classic-btn.blue-gradient:hover:not(:disabled) {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  box-shadow: 0 15px 30px rgba(118, 75, 162, 0.4);
}

/* Premium Pink-Peach Gradient (The 'Guest' Style) */
.classic-btn.pink-gradient {
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  color: #1a237e;
  box-shadow: 0 10px 20px rgba(255, 154, 158, 0.3);
}

/* Premium Sky Gradient (The 'Switch' Style) */
.classic-btn.sky-gradient {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(79, 172, 254, 0.3);
}

/* Premium Danger Style (The 'Purge' Style) */
.classic-btn.danger {
  background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(255, 75, 43, 0.3);
}

.classic-btn.danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff4b2b 0%, #ff416c 100%);
  box-shadow: 0 15px 30px rgba(255, 75, 43, 0.4);
}

/* Secondary/Subtle Variant (for Skip/Back) */
.classic-btn.secondary,
.classic-btn.outline {
  background: rgba(255, 255, 255, 0.5);
  color: #1a237e;
  border: 2px solid rgba(26, 35, 126, 0.1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.classic-btn.secondary:hover:not(:disabled),
.classic-btn.outline:hover:not(:disabled) {
  background: #ffffff;
  border-color: #1a237e;
  color: #1a237e;
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* Legacy Support / Specific Overrides */
.solo-btn-elegant {
  /* This now inherits from .classic-btn via the shared selector above */
}

.spinner {
  display: inline-block; width: 40px; height: 40px;
  border: 3px solid rgba(79, 70, 229, 0.2); border-radius: 50%;
  border-top-color: var(--accent-primary);
  animation: spin 1s linear infinite;
}

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

#modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 100;
  display: flex; justify-content: center; align-items: center;
  backdrop-filter: blur(4px);
}
#modal-overlay.hidden { display: none; }

/* Global Floating Timer */
#global-game-timer {
  position: fixed;
  top: 1.5rem;
  right: 2rem;
  background: rgba(26, 35, 126, 0.85); /* Deep Blue */
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  font-weight: 800;
  z-index: 10000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transition: all 0.3s ease;
}

#global-game-timer::before {
  content: "Time Spent: ";
  font-size: 1rem;
}

@media (max-width: 768px) {
  #global-game-timer {
    top: 1rem;
    right: 1rem;
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
  }
  .scoreboard {
    top: 1rem;
    right: auto;
    left: 1rem;
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
  }
  #global-game-timer::before {
    content: "TIME: ";
  }
}

@media (max-width: 480px) {
  .app-container { padding: 0.5rem; }
  .card { 
    padding: 2rem 1.2rem !important; 
    border-radius: 16px !important; 
    margin-top: 1rem; 
  }
  h2 { font-size: 1.1rem !important; margin-bottom: 0.8rem !important; }
  h3 { font-size: 1rem !important; margin-bottom: 0.6rem !important; }
  p { font-size: 0.9rem !important; }
  .classic-btn { padding: 0.7rem 1rem !important; font-size: 0.95rem !important; margin-bottom: 0.6rem !important; }
  input[type="text"], textarea { font-size: 0.95rem !important; padding: 0.7rem !important; margin-bottom: 1rem !important; }
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: var(--surface-white);
  color: var(--text-main);
  border-left: 5px solid var(--accent-green);
  padding: 1rem 1.5rem;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 1.1rem;
  opacity: 0;
  transform: translateX(100%);
  animation: slideIn 0.3s ease forwards;
}

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

.toast.fade-out {
  animation: fadeOut 0.5s ease forwards;
}

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

@keyframes scorePop {
  0% { transform: scale(1); color: #ffeb3b; }
  50% { transform: scale(1.3); color: #fff; }
  100% { transform: scale(1); color: #fff; }
}

/* Scoreboard & Floating Text */
.scoreboard {
  position: fixed;
  top: 1.5rem;
  left: 2rem;
  background: rgba(26, 35, 126, 0.85); /* Deep Blue */
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 0.5rem 1.2rem;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,0.2);
  font-family: 'Courier New', Courier, monospace;
  font-size: 1rem;
  font-weight: 800;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  border: 2px solid rgba(255,255,255,0.4);
}

.floating-point {
  position: fixed;
  color: #ffeb3b;
  font-size: 3rem;
  font-weight: 900;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px #000, 2px 2px 0 #000;
  pointer-events: none;
  z-index: 10000;
  animation: floatUpPoint 1s ease-out forwards;
}

@keyframes floatUpPoint {
  0% { opacity: 1; transform: translateY(0) scale(1.5); }
  100% { opacity: 0; transform: translateY(-80px) scale(1); }
}

/* ===== Long Word / Definition Overflow Protection ===== */

/* Prevent any word from overflowing its container */
.masked-word,
.highlight-word,
.flash-word,
.revision-item strong,
.revision-item p,
.nd-word,
.nd-meaning,
.meaning-fill-area,
.word-tile,
h1, h2, h3 {
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
}

/* Scale down large word displays so long words fit */
.masked-word {
  font-size: clamp(1.4rem, 5vw, 3rem);
  letter-spacing: clamp(0.15rem, 1vw, 0.5rem);
}

.highlight-word {
  font-size: clamp(1.6rem, 5vw, 3rem);
  letter-spacing: clamp(1px, 0.5vw, 3px);
}

.flash-word {
  font-size: clamp(1.4rem, 6vw, 3rem);
  letter-spacing: clamp(1px, 0.8vw, 4px);
  display: inline-block;
  max-width: 100%;
}

/* Revision item words — keep readable but bounded */
.revision-item strong {
  font-size: clamp(1rem, 3vw, 1.8rem);
}

.revision-item p {
  font-size: clamp(0.9rem, 2.5vw, 1.2rem);
}

/* Definition selection option text */
.nd-meaning,
.meaning-fill-area {
  font-size: clamp(1rem, 2.5vw, 1.5rem);
}

/* Stage headings — allow wrapping on long titles */
.s4f-header h2,
.s6-header h2,
.s3-header h2,
.header h2 {
  font-size: clamp(1rem, 3.5vw, 1.6rem);
  line-height: 1.3;
  white-space: normal;
}

