:root {
  --ink: #16243a;
  --muted: #5a687f;
  --bg: #f2f6fa;
  --surface: #ffffff;
  --line: #d8e1ec;
  --navy: #1f3a5f;
  --teal: #1f8a7e;
  --teal-light: #e6f6f4;
  --sun: #f4a261;
  --sun-light: #fef5ec;
  --coral: #d9603f;
  --coral-light: #fbeee9;
  --rail: #b8743c;
  --green: #2ecc71;
  --display: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  --body: "Lexend", system-ui, -apple-system, sans-serif;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 30px rgba(31, 58, 95, 0.08);
  --shadow-sm: 0 3px 10px rgba(31, 58, 95, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--body);
  background-color: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.8rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--teal), var(--navy));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.2rem;
  box-shadow: 0 3px 8px rgba(31, 138, 126, 0.3);
}

.brand-text h1 {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--navy);
}

.brand-text p {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Selectors in header */
.controls-bar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.select-wrap select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1.8rem 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%235a687f%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem top 50%;
  background-size: 0.65rem auto;
  transition: all 0.2s ease;
}

.select-wrap select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(31, 138, 126, 0.15);
}

.mode-pills {
  display: flex;
  background: var(--bg);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
}

.mode-btn {
  font-family: var(--body);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--surface);
  color: var(--navy);
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0,0,0,0.06);
}

/* Sound and mute button */
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: var(--bg);
  border-color: var(--teal);
}

/* Main Container */
main {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 880px) {
  main {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Left Pane: The Ladder */
.ladder-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.ladder-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.ladder-title {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.score-badge {
  background: var(--sun-light);
  color: #b35900;
  border: 1px solid rgba(244, 162, 97, 0.4);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* Visual Ladder Display */
.ladder-view {
  position: relative;
  height: 380px;
  background: linear-gradient(180deg, #d4f0ff 0%, #eef7fc 50%, #f4fbf5 100%);
  border-radius: var(--radius-md);
  border: 1px solid #c9e2f5;
  overflow: hidden;
  display: flex;
  justify-content: center;
  padding-bottom: 10px;
}

.ladder-svg {
  width: 100%;
  height: 100%;
}

.ladder-rails {
  stroke: var(--rail);
  stroke-width: 8;
  stroke-linecap: round;
}

.ladder-rung {
  stroke: var(--rail);
  stroke-width: 6;
  stroke-linecap: round;
  transition: all 0.3s ease;
}

.ladder-rung.reached {
  stroke: var(--teal);
  filter: drop-shadow(0 0 4px rgba(31, 138, 126, 0.5));
}

.cloud-top {
  position: absolute;
  top: 10px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  font-size: 0.8rem;
  font-weight: 700;
  color: #c97900;
  border: 1px solid #fae4a8;
}

/* Mascot Climber */
.mascot-avatar {
  position: absolute;
  width: 52px;
  height: 52px;
  transition: bottom 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
  z-index: 10;
  pointer-events: none;
}

.streak-card {
  margin-top: 1rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
}

.streak-flame {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
  color: var(--coral);
}

/* Right Pane: Game Stage */
.stage-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Pattern & Rule Banner */
.rule-banner {
  background: linear-gradient(135deg, var(--teal-light), #f0fbf9);
  border: 1px solid rgba(31, 138, 126, 0.2);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
}

.rule-icon {
  width: 36px;
  height: 36px;
  background: var(--teal);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.rule-content h3 {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.2rem;
}

.rule-content p {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.rule-badge {
  display: inline-block;
  background: var(--teal);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 0.4rem;
}

/* Dictation sentence box */
.dictation-box {
  background: var(--sun-light);
  border: 1px dashed rgba(244, 162, 97, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  color: #8c4e12;
}

.btn-speak-dictation {
  background: #fff;
  border: 1px solid rgba(244, 162, 97, 0.5);
  color: #8c4e12;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
  transition: all 0.2s;
}

.btn-speak-dictation:hover {
  background: var(--sun);
  color: #fff;
}

/* Audio Pronunciation Hero */
.pronounce-zone {
  text-align: center;
  padding: 0.8rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.big-speaker-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--coral), #f08a68);
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(217, 96, 63, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.big-speaker-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 24px rgba(217, 96, 63, 0.45);
}

.big-speaker-btn:active {
  transform: scale(0.95);
}

.speaker-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

/* Answer Slot Container */
.slots-container {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 64px;
  align-items: center;
  padding: 0.5rem;
}

.letter-slot {
  width: 52px;
  height: 60px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--navy);
  transition: all 0.2s ease;
  user-select: none;
}

.letter-slot.filled {
  background: #fff;
  border: 2px solid var(--teal);
  box-shadow: 0 4px 10px rgba(31, 138, 126, 0.15);
  cursor: pointer;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.letter-slot.current {
  border-color: var(--coral);
  background: var(--coral-light);
  transform: scale(1.05);
}

.letter-slot.correct-anim {
  background: #e8f8ed;
  border-color: var(--green);
  color: #1e824c;
}

.letter-slot.wrong-anim {
  background: #fde8e8;
  border-color: #e74c3c;
  animation: shake 0.4s ease;
}

/* Scrambled Letter Tiles */
.tiles-container {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem;
}

.letter-tile {
  width: 54px;
  height: 58px;
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--navy);
  box-shadow: 0 4px 12px rgba(31, 58, 95, 0.08);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.letter-tile:hover {
  transform: translateY(-3px);
  border-color: var(--teal);
  box-shadow: 0 8px 16px rgba(31, 138, 126, 0.2);
}

.letter-tile:active {
  transform: translateY(1px);
}

.letter-tile.used {
  opacity: 0.25;
  pointer-events: none;
  border-style: dashed;
  box-shadow: none;
}

/* Word Choice Mode Options */
.choices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  width: 100%;
}

.choice-btn {
  background: #ffffff;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.choice-btn:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  transform: translateY(-2px);
}

.choice-btn.correct {
  background: #e8f8ed;
  border-color: var(--green);
  color: #1e824c;
}

.choice-btn.wrong {
  background: #fde8e8;
  border-color: #e74c3c;
  color: #c0392b;
}

/* Action Bar below stage */
.action-bar {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
  border-top: 1px solid var(--line);
}

.btn-game {
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-game:hover {
  background: var(--bg);
  border-color: var(--teal);
}

.btn-game-primary {
  background: var(--coral);
  color: #fff;
  border-color: var(--coral);
  box-shadow: 0 4px 12px rgba(217, 96, 63, 0.3);
}

.btn-game-primary:hover {
  background: #c85333;
  color: #fff;
}

/* Overlay / Win Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 24, 38, 0.6);
  backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  padding: 2.2rem;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-trophy {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: float 2s infinite ease-in-out;
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 1.8rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}

.stars-rating {
  font-size: 1.8rem;
  color: #f1c40f;
  margin: 0.5rem 0 1rem;
}

.summary-stats {
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

.summary-stat-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
}

.summary-stat-val {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--navy);
}

/* Confetti Canvas */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

/* Animations */
@keyframes popIn {
  0% { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

