:root {
  --page-bg: #f2f4f8;   /* light-gray page background */
  --panel: #ffffff;     /* white panels */
  --blue: #3498db;      /* primary blue */
  --blue-dark: #217dbb; /* darker blue */
  --btn-blue: #1474e2;  /* button blue */
  --text: #0f1724;      /* dark text on panels */
  --muted: #6b7280;
  --radius: 10px;
  --max-w: 1100px;
  /* --- NEW BUTTON COLORS --- */
  --new-btn-hover: hsl(234, 100%, 50%);
  --new-btn-active: hsl(234, 100%, 30%);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--page-bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 28px 16px;
}

a {
  color: var(--blue);
  text-decoration: none;
  font-size: 16px;
}

a:hover {
  text-decoration: underline;
}

/* Unified Button Styles using new variables */
#fetchBtn, #clearBtn, #speakBtn, .print-btn {
  background-color: var(--btn-blue);
  color: white;
  transition: background-color 0.3s ease;
}

/* APPLY NEW HOVER COLOR */
#fetchBtn:hover, #clearBtn:hover, #speakBtn:hover, .print-btn:hover {
  background: var(--new-btn-hover);
  /* The original CSS used linear-gradient for the input-row buttons, 
     but the unified styles override them here */
}

/* APPLY NEW ACTIVE COLOR */
#fetchBtn:active, #clearBtn:active, #speakBtn:active, .print-btn:active {
  background: var(--new-btn-active);
  filter: none; /* Removed brightness filter since we use a darker color directly */
}

.contents:hover {
  background-color: var(--blue);
  color: white;
  opacity: 0.8;
}

.container {
  width: 100%;
  max-width: var(--max-w);
}

header {
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  color: white;
  padding: 18px;
  border-radius: var(--radius);
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 30px rgba(33, 125, 187, 0.12);
}

.logo {
  width: clamp(48px, 10vw, 78px);
  height: clamp(48px, 10vw, 78px);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: clamp(16px, 3vw, 22px);
  transition: all 0.3s ease;
}

header .title {
  display: flex;
  flex-direction: column;
}

header h1 {
  margin: 0;
  font-size: 18px;
}

header p.lead {
  margin: 2px 0 0;
  font-size: 13px;
  opacity: 0.95;
  color: rgba(255, 255, 255, 0.95);
}

.ebook {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: 0 8px 24px rgba(23, 31, 42, 0.04);
  overflow: hidden;
}

.columns {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  align-items: start;
}

nav {
  background: #fbfdff; /* Slight tint for sidebar */
  border-radius: var(--radius);
  padding: 12px;
  border: 1px solid rgba(16, 24, 40, 0.03);
}

nav h3 {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: var(--text);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

nav li {
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}

nav li.active {
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  color: white;
  font-weight: 600;
}

main.content {
  padding: 6px 0;
}

section.card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(16, 24, 40, 0.03);
}

section.card h2 {
  margin: 0 0 8px 0;
  color: var(--blue); /* Updated for better contrast */
  font-size: 18px;
}

.lesson-top {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.letter-box {
  width: 120px;
  height: 120px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--blue), var(--blue-dark));
  color: white;
  font-weight: 800;
  font-size: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(52, 152, 219, 0.14);
}

.lesson-info {
  flex: 1;
  min-width: 180px;
}

.input-row {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.input-row input[type=text] {
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(16, 24, 40, 0.1);
  font-size: 16px;
  width: 160px;
  background: #fff;
  color: var(--text);
}

/* Original gradient background kept for input-row button base state */
.input-row button {
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  color: white;
  border: 0;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(33, 125, 187, 0.12);
}

.input-row button[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.note {
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

.media-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.media {
  background: #fbfdff;
  padding: 10px;
  border-radius: var(--radius);
  min-height: 120px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid rgba(16, 24, 40, 0.1);
}

.media strong {
  display: block;
  color: var(--text);
}

.media .placeholder {
  font-size: 13px;
  color: var(--muted);
}

.demo-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-radius: 8px;
}

.media audio, .media video {
  width: 100%;
  border-radius: 8px;
}

pre#exampleMap {
  font-size: 16px;
  background: #f7fbff;
  padding: 10px;
  border-radius: var(--radius);
  overflow: auto;
  color: var(--text);
  font-weight: 700;
}

.ebook footer {
  margin-top: 8px;
  color: var(--muted);
  font-size: 16px;
}

.feedback {
  margin-top: 8px;
  font-size: 14px;
  color: rgb(0, 180, 0); /* Darkened slightly for readability */
}

.error {
  color: rgb(255, 0, 0);
  background: rgba(192, 57, 43, 0.06);
  padding: 8px;
  border-radius: 8px;
}

.success {
  color: rgb(0, 255, 0);
  background: rgba(22, 160, 133, 0.06);
  padding: 8px;
  border-radius: 8px;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
}

.controls label {
  font-size: 14px;
  color: var(--text);
  display: flex;
  gap: 8px;
  align-items: center;
}

.print-btn {
  background: linear-gradient(90deg, var(--blue), var(--blue-dark));
  color: white;
  border: none;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
}

/* Progress & stats */
.stats {
  display: flex;
  gap: 12px;
}

.stat-box {
  background: #fbfdff;
  padding: 10px;
  margin-top: 6px;
  border-radius: var(--radius);
  border: 1px solid rgba(16, 24, 40, 0.05);
  min-width: 140px;
  color: var(--text);
}

.small {
  font-size: 13px;
  color: var(--muted);
}

/* game */
#gameHeading {
  color: var(--blue);
}

.game-opts {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.game-opts button {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(16, 24, 40, 0.1);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  transition: all 0.2s ease;
}

.game-opts button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.game-opts button.correct {
  background: linear-gradient(90deg, rgb(0, 200, 0), #07b101);
  color: white;
  border: none;
}

.game-opts button.wrong {
  background: linear-gradient(90deg, rgb(220, 0, 0), #c50202);
  color: white;
  border: none;
}

#resetProgress, #resetGame {
  background: var(--btn-blue);
  border-radius: 4px;
  border: none;
  color: white;
  padding: 6px 12px;
  margin-top: 4px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

/* APPLY NEW HOVER/ACTIVE COLOR TO GAME RESET BUTTONS */
#resetProgress:hover, #resetGame:hover {
  background: var(--new-btn-hover);
}

#resetProgress:active, #resetGame:active {
  background: var(--new-btn-active);
}

/* === RESPONSIVENESS === */
@media(max-width: 980px) {
  .columns {
    grid-template-columns: 1fr;
  }
  .media-row {
    grid-template-columns: 1fr;
  }
  .letter-box {
    width: 100px;
    height: 100px;
    font-size: 44px;
  }
  nav {
    order: 0;
  }
  .logo {
    width: 100px;
  }
}

@media (max-width: 720px) {
  body {
    padding: 16px 8px;
  }
  header {
    flex-direction: column;
    text-align: center;
  }
  header h1 {
    font-size: 18px;
  }
  header p.lead {
    font-size: 13px;
  }
  .logo {
    width: 64px;
    height: 64px;
  }
  nav {
    padding: 10px;
  }
}

@media (max-width: 480px) {
  .columns {
    gap: 12px;
  }
  .ebook {
    padding: 12px;
  }
  nav li {
    font-size: 13px;
  }
  .choice {
    height: 50px;
    font-size: 14px;
  }
  input[type=text] {
    width: 100%;
  }
}