* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #eef2f7;
  color: #0f172a;
}

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 24px;
}

.card {
  background: #ffffff;
  border-radius: 24px;
  padding: 28px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}

/* ================= HEADER ================= */

.header-row {
  display: block;
}

.stage-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.stage-tab {
  background: #e2e8f0;
  border: none;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.stage-tab.active {
  background: #2563eb;
  color: white;
}

h1 {
  margin: 0 0 20px;
  font-size: 48px;
}

/* ================= TEXT ================= */

p {
  margin: 0;
}

.muted {
  color: #475569;
}

/* ================= CONTROLS ================= */

.controls-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 20px 0;
  align-items: stretch;
}

.mode-row {
  display: contents;
}

/* ================= MODE BUTTONS ================= */

.mode-btn {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;

  background: #2563eb;
  border: 1px solid #2563eb;
  border-radius: 20px;
  padding: 16px 18px;

  min-height: 100px;
  cursor: pointer;
  transition: 0.2s;
  color: white;
}

.mode-btn:hover,
.guided-card:hover {
  background: #1d4ed8;
  border-color: #1d4ed8;
  transform: translateY(-1px);
}

.mode-title {
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.mode-sub {
  font-size: 14px;
  margin-top: 6px;
  color: rgba(255,255,255,0.85);
}

/* ================= GUIDED CARD ================= */

.guided-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;

  background: #2563eb;
  border: 1px solid #2563eb;
  border-radius: 20px;
  padding: 16px 18px;

  min-height: 100px;
  color: white;
}

.guided-card-text {
  display: flex;
  flex-direction: column;
}

.guided-title {
  font-weight: 700;
  font-size: 16px;
  color: white;
}

.guided-copy {
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  margin-top: 6px;
}

/* ================= TOGGLE ================= */

.switch {
  position: relative;
  width: 56px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.slider:before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 4px;
  top: 4px;
  border-radius: 50%;
  background: white;
  transition: 0.2s;
}

.switch input:checked + .slider {
  background: #22c55e; /* green so it stands out on blue */
}

.switch input:checked + .slider:before {
  transform: translateX(26px);
}

/* ================= LEVEL GRID ================= */

.level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 20px;

  opacity: 0;
  transform: translateY(-12px);
  pointer-events: none;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, max-height 0.25s ease;
}

.level-grid.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  max-height: 240px;
}
.level-btn {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 20px;
  text-align: left;
  cursor: pointer;
  min-height: 132px;
  transition: 0.2s;
  color: #0f172a;
}

.level-btn:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
}

.level-btn .level-title {
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  color: #0f172a;
}

.level-btn .level-copy {
  display: block;
  font-size: 15px;
  line-height: 1.3;
  color: #475569;
}

/* ================= BUTTONS ================= */

button {
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
  background: #2563eb;
  color: white;
}

button:hover {
  background: #1d4ed8;
}

button.secondary {
  background: #f1f5f9;
  color: #1e293b;
  border: 2px solid #cbd5e1;
  font-weight: 600;
}

button.secondary:hover {
  background: #e2e8f0;
}

.small-btn {
  padding: 10px 16px;
}

/* ================= PLAY TOP BAR ================= */

.play-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

/* Home button (keeps existing feel but refined) */
.small-btn {
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 600;
  background: #f8fafc;
  color: #0f172a;
  cursor: pointer;
  transition: 0.2s;
}

.small-btn:hover {
  background: #f1f5f9;
}

/* Streak badge styled to MATCH home button */
.score-badge {
  border: 2px solid #cbd5e1;
  border-radius: 14px;
  padding: 10px 16px;
  font-weight: 600;
  background: #f8fafc;
  color: #0f172a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 90px;
}


.score-badge.pop {
  transform: scale(1.1);
  transition: 0.2s;
}

/* Optional: slight emphasis when streak grows */
.score-badge.active {
  border-color: #2563eb;
  background: #eff6ff;
  color: #1e40af;
}

/* ================= LISTEN PANEL ================= */

.listen-panel {
  background: #e6ebf4;
  border-radius: 24px;
  padding: 20px;
  margin-bottom: 16px;
}

.listen-title {
  text-align: center;
  font-weight: 700;
  margin-bottom: 16px;
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.button-row.centered {
  justify-content: center;
}

.sentence-text {
  margin-top: 20px;
  padding: 20px 24px;
  background: #dcefe3;
  border: 2px solid #8ee0ab;
  border-radius: 24px;
  font-size: 24px;
}

/* ================= GUIDED INPUT ================= */

.guided-input-wrap {
  margin: 10px 0 14px;
}

.letter-boxes {
  display: flex;
  gap: 8px;
}

.letter-box {
  width: 46px;
  height: 54px;
  border: 2px solid #d1d9e5;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
}

/* ================= INPUT ================= */

#attemptInput {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 18px;
  padding: 18px;
  font-size: 20px;
  margin-top: 6px;
}

#attemptInput:focus {
  border-color: #8eb0ff;
  box-shadow: 0 0 0 4px rgba(142, 176, 255, 0.18);
}

/* ================= FEEDBACK ================= */

.hint-panel,
.feedback-panel {
  margin-top: 14px;
  padding: 16px 18px;
  border-radius: 18px;
}

.hint-panel {
  background: #fff7d6;
}

.feedback-panel {
  background: #e7f6ec;
}

.feedback-panel.error {
  background: #fdecec;
}

/* ================= SUMMARY ================= */

.summary-grid {
  display: grid;
  gap: 12px;
  margin: 20px 0;
}

.summary-item {
  background: #f8fafc;
  border: 1px solid #d6deea;
  border-radius: 18px;
  padding: 14px 16px;
}

.summary-item.passed {
  background: #dcfce7;
}

.summary-item.failed {
  background: #fee2e2;
}

/* ================= ATTENTION ANIMATION ================= */

.attention {
  animation: gentleWobble 1.2s ease-in-out infinite;
}

@keyframes gentleWobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg); }
  75% { transform: rotate(-1deg); }
}

/* ================= MOBILE ================= */

@media (max-width: 700px) {
  .container {
    padding: 18px 14px 120px;
  }

  .card {
    padding: 24px 18px;
    border-radius: 22px;
  }

  h1 {
    font-size: 42px;
    line-height: 1.05;
    margin-bottom: 24px;
  }

  .controls-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .mode-btn,
  .guided-card {
    min-height: 92px;
    padding: 18px;
  }

  .level-grid {
    grid-template-columns: 1fr;
    gap: 14px;
    overflow: hidden;
    max-height: 0;
  }

  .level-grid.show {
    max-height: 1200px;
    overflow: visible;
  }

  .level-btn {
    min-height: auto;
    padding: 22px;
  }

  .button-row {
    flex-direction: column;
  }

  .button-row button {
    width: 100%;
  }
}