/* The Letter Key - Main Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
}

/* Header & Nav */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  min-height: 60px;
}

h1, h2, h3 {
  line-height: 1.3;
  margin-bottom: 12px;
}

/* Navigation Menu */
nav.main-menu {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 40px;
}

/* Basic Layouts */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  animation: fadeIn 0.4s ease-in-out;
}
.screen.active {
  display: flex;
}

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

/* Glassmorphic Globals & Reusables */
.neu-btn {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: bold;
  border-radius: 16px;
  padding: 20px; /* massive tap targets */
  min-height: 64px;
  min-width: 64px;
  cursor: pointer;
  box-shadow: var(--glass-shadow);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.neu-btn:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px 0 rgba(0, 0, 0, 0.3);
  filter: brightness(1.1);
}

.neu-btn:active {
  transform: translateY(2px) scale(0.98);
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
}

.neu-btn.icon-only {
  font-size: 1.5rem;
  border-radius: 50%;
  padding: 16px;
}

.neu-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--glass-shadow);
  margin-bottom: 24px;
}

/* Large Text Display */
.word-display {
  font-size: 4rem;
  font-weight: 800;
  text-align: center;
  margin: 40px 0;
  word-break: break-word;
}
.syllable-divider {
  color: var(--primary-color);
  opacity: 0.6;
}

/* Reading Ruler Overlay */
#reading-ruler {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none; /* Let clicks pass through */
  z-index: 9999;
  display: none;
  /* Top dark, middle clear, bottom dark */
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.5) 0%,
    rgba(0,0,0,0.5) calc(50% - 40px),
    transparent calc(50% - 40px),
    transparent calc(50% + 40px),
    rgba(0,0,0,0.5) calc(50% + 40px),
    rgba(0,0,0,0.5) 100%
  );
}
#reading-ruler.active {
  display: block;
}

/* Minigame 2: Listen & Spell */
.elkonin-boxes {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}
.elkonin-box {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  border: 2px dashed var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
}
.phoneme-pool {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.phoneme-tile {
  width: 70px;
  height: 70px;
  font-size: 1.8rem;
  border-radius: 12px;
  /* Drag support */
  touch-action: none;
}
.phoneme-tile.dragging {
  opacity: 0.7;
  transform: scale(1.05);
}

/* Minigame 3: Subtitle Sprinter */
.sprinter-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}
.sprinter-sentence {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 40px;
  min-height: 120px;
}
.progress-bar-container {
  width: 100%;
  height: 24px;
  border-radius: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--glass-border);
  box-shadow: inset 2px 2px 6px rgba(0,0,0,0.5);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 100%;
  background-color: var(--primary-color);
  border-radius: 12px;
  transform-origin: left;
}
.progress-bar.running {
  transition: transform linear;
}

/* Settings Controls */
.setting-group {
  margin-bottom: 24px;
}
.setting-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 1.2rem;
}
.setting-group select, .setting-group input[type="range"] {
  width: 100%;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0,0,0,0.1);
  color: var(--text-color);
  border: 1px solid var(--glass-border);
  font-family: inherit;
  font-size: 1.1rem;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
  outline: none;
}
.setting-group select option {
  background: #333; /* Dark background for dropdown options so text is legible */
  color: #fff;
}

/* Range Slider Styling */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  height: 16px;
  padding: 0;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 2px 2px 5px var(--shadow-dark);
}

/* Utility / Feedback */
.feedback-msg {
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  min-height: 2.5rem;
  margin: 16px 0;
}
.feedback-success { color: var(--success-color); }
.feedback-warning { color: var(--warning-color); }
.feedback-error { color: var(--danger-color); }

/* Input for Wishlist */
.wishlist-input-container {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}
.wishlist-input-container input {
  flex: 1;
  padding: 16px;
  border-radius: 16px;
  background: rgba(0,0,0,0.1);
  border: 1px solid var(--glass-border);
  color: var(--text-color);
  font-size: 1.2rem;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
  font-family: inherit;
  outline: none;
}
.wishlist-list {
  list-style: none;
}
.wishlist-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  font-size: 1.3rem;
  font-weight: bold;
}

/* Pulse Animation for Play Button */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(255, 152, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 152, 0, 0); }
}

#g2-play-audio {
  animation: pulse 2s infinite;
  border: 2px solid var(--primary-color);
}

/* --- Space Particles System --- */
#particles-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.space-particle {
  position: absolute;
  top: -100px;
  user-select: none;
  animation: fallAndRotate linear infinite;
  text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

@keyframes fallAndRotate {
  0% { transform: translateY(-100px) rotate(0deg); }
  100% { transform: translateY(110vh) rotate(360deg); }
}

/* --- Word Chopper Styles --- */
.chopper-display {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  font-size: 3.5rem;
  font-weight: bold;
  user-select: none;
  flex-wrap: wrap;
}

.chopper-letter {
  padding: 0 5px;
}

.chopper-gap {
  width: 20px;
  height: 60px;
  background: rgba(0,0,0,0.05);
  margin: 0 5px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background 0.2s;
}

.chopper-gap:hover {
  background: rgba(0,0,0,0.1);
}

.chopper-gap.chopped::after {
  content: "✂️";
  font-size: 1.5rem;
  position: absolute;
  transform: translateY(-5px);
}

.chopper-gap.chopped-line {
  background: var(--primary-color);
  width: 4px;
}

/* --- Heart Word Styles --- */
.heart-word-display {
  font-size: 4rem;
  font-weight: bold;
  display: flex;
  justify-content: center;
  gap: 2px;
}

.heart-char {
  color: #2e7d32; /* Phonetic Green */
}

.heart-part {
  color: #c62828; /* Tricky Red */
  position: relative;
  cursor: pointer;
}

.heart-part::before {
  content: "❤️";
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  animation: heartPulse 1.5s infinite;
}

@keyframes heartPulse {
  0% { transform: translateX(-50%) scale(1); opacity: 0.8; }
  50% { transform: translateX(-50%) scale(1.3); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); opacity: 0.8; }
}

.heart-dot {
  font-size: 1.5rem;
  opacity: 0.2;
  transition: opacity 0.3s;
}

.heart-dot.active {
  opacity: 1;
}

