* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }

body {
  font-family: "Arial Rounded MT Bold", Arial, Helvetica, system-ui, sans-serif;
  background: #1f2937;
  color: #172033;
}

button, a { font: inherit; }

.stage {
  min-height: 100vh;
  padding: 22px;
}

.background {
  min-height: calc(100vh - 44px);
  background:
    url("site/letterbck.jpg") center / cover no-repeat,
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 36%),
    linear-gradient(135deg, #f0f7ff 0%, #f2edff 52%, #f9f0ff 100%);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 22px;
  box-shadow: inset 0 0 90px rgba(255, 255, 255, 0.28);
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

.back,
#activityBack {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  padding: 12px 22px;
  border-radius: 8px;
  text-decoration: none;
  color: #2f3a4c;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(93, 122, 150, 0.24);
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(39, 49, 66, 0.12);
}

.title {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(112, 104, 196, 0.52);
  border: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
  box-shadow: none;
}

.hint {
  color: #354156;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(93, 122, 150, 0.18);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 3px 12px rgba(39, 49, 66, 0.08);
}

.hint {
  display: none;
}

.lettersMenu {
  display: grid;
  gap: 18px;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(93, 122, 150, 0.2);
  box-shadow: 0 8px 24px rgba(39, 49, 66, 0.12);
}

body.learnMode .lettersMenu {
  display: none;
}

.lettersMenuHeader {
  display: block;
}

.learnAlphabetButton {
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 154px;
  padding: 18px 28px 20px;
  border-radius: 8px;
  color: #223044;
  background: #b9dfe6;
  border: 2px solid rgba(48, 62, 84, 0.42);
  box-shadow: 5px 5px 0 rgba(32, 48, 71, 0.18);
  font-size: clamp(1.6rem, 2.8vw, 2.6rem);
  font-weight: 800;
  line-height: 1.05;
  text-align: center;
  text-decoration: none;
  text-shadow: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.learnAlphabetPicture {
  display: grid;
  place-items: center;
  width: min(540px, 100%);
  height: 150px;
  overflow: hidden;
  padding: 4px;
  border: 2px solid rgba(38, 55, 79, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.learnAlphabetPicture img {
  display: block;
  width: calc(100% - 8px);
  height: 134px;
  max-width: none;
  max-height: none;
  object-fit: contain;
  transition: transform 0.18s ease;
}

.learnAlphabetButton:hover .learnAlphabetPicture img {
  transform: scale(1.025);
}

.learnAlphabetButton:hover {
  filter: brightness(1.04);
  transform: translate(1px, 1px);
  box-shadow: 4px 4px 0 rgba(32, 48, 71, 0.24);
}

.activityGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.activityLink {
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  gap: 10px;
  min-height: 160px;
  padding: 16px;
  border: 2px solid rgba(48, 62, 84, 0.42);
  border-radius: 8px;
  color: #223044;
  box-shadow: 4px 4px 0 rgba(32, 48, 71, 0.18);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.activityLink:nth-child(4n + 1) {
  background: #b9dfe6;
}

.activityLink:nth-child(4n + 2) {
  background: #f3d77b;
}

.activityLink:nth-child(4n + 3) {
  background: #eeb0a6;
}

.activityLink:nth-child(4n) {
  background: #c8dda6;
}

.activityLink:hover {
  transform: translate(1px, 1px);
  box-shadow: 3px 3px 0 rgba(32, 48, 71, 0.24);
}

.activityPicture {
  display: grid;
  place-items: center;
  height: 132px;
  overflow: hidden;
  padding: 4px;
  border: 2px solid rgba(38, 55, 79, 0.7);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.activityPicture img {
  display: block;
  width: calc(100% - 8px);
  height: 116px;
  max-width: none;
  max-height: none;
  object-fit: contain;
  transition: transform 0.18s ease;
}

.activityLink:hover .activityPicture img {
  transform: scale(1.04);
}

.matchPicture {
  font-size: clamp(2.2rem, 3.2vw, 3.1rem);
}

.listenPicture {
  grid-template-columns: auto auto;
  gap: 8px;
  font-size: clamp(2rem, 3vw, 2.85rem);
}

.activityDetail {
  display: block;
  min-width: 0;
  color: rgba(34, 48, 68, 0.7);
  font-size: clamp(0.98rem, 1.2vw, 1.12rem);
  font-weight: 800;
  line-height: 1.18;
  overflow-wrap: normal;
  text-align: center;
  word-break: keep-all;
}

.chooser {
  display: none;
  min-height: 0;
  overflow: auto;
  max-width: 1520px;
  width: 100%;
  margin: 0 auto;
}

body.learnMode .chooser {
  display: block;
}

.levelsList {
  display: grid;
  gap: 20px;
  padding-right: 4px;
}

.levelRow {
  display: grid;
  grid-template-columns: 94px 1fr;
  gap: 22px;
  align-items: stretch;
  position: relative;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.52);
  background: rgba(150, 138, 210, 0.72);
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: 0 7px 22px rgba(51, 45, 103, 0.2);
  cursor: pointer;
  text-align: left;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.levelRow.completed {
  background: rgba(185, 239, 154, 0.9);
  border-color: rgba(71, 142, 72, 0.68);
}

.levelHeading {
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(180deg, #8a7ac8, #6f60b6);
  border-radius: 8px;
  padding: 14px;
  font-size: 42px;
  line-height: 1.05;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 4px 12px rgba(71, 57, 134, 0.2);
}

.unitButton {
  min-height: 106px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(128, 112, 196, 0.22);
  border-radius: 8px;
  background: rgba(246, 240, 255, 0.72);
  color: #4f3d7a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.64);
  font-size: 50px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  text-shadow: none;
  cursor: pointer;
  word-spacing: 0.24em;
  white-space: normal;
}

.unitButton.longLabel {
  font-size: 38px;
  line-height: 1.15;
}

.unitButton.denseLabel {
  font-size: 28px;
  line-height: 1.25;
}

.levelRow:hover {
  background: rgba(160, 148, 220, 0.82);
  box-shadow: 0 10px 28px rgba(51, 45, 103, 0.22);
}

.levelRow.completed:hover {
  background: rgba(199, 246, 170, 0.96);
}

.levelRow:hover .unitButton {
  border-color: rgba(128, 112, 196, 0.34);
  background: rgba(249, 245, 255, 0.86);
}

.levelRow:active {
  transform: translateY(2px);
  box-shadow: 0 5px 16px rgba(51, 45, 103, 0.12);
}

.doneBadge {
  position: absolute;
  right: 18px;
  top: 18px;
  width: 34px;
  height: 34px;
  display: none;
  place-items: center;
  border-radius: 999px;
  color: #ffffff;
  background: #3f8f4c;
  font-size: 24px;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(43, 106, 53, 0.28);
}

.levelRow.completed .doneBadge {
  display: grid;
}

.levelRow:focus-visible,
.back:focus-visible,
#activityBack:focus-visible,
.learnAlphabetButton:focus-visible,
.activityLink:focus-visible {
  outline: 4px solid #f97316;
  outline-offset: 3px;
}

#activityOverlay {
  position: fixed;
  inset: 0;
  background: #f6fbff;
  z-index: 9999;
  display: none;
}

#activityOverlay.active {
  display: grid;
  grid-template-rows: auto 1fr;
}

#activityHud {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: #ffffff;
  border-bottom: 2px solid rgba(93, 122, 150, 0.18);
}

.hudSpacer {
  width: 88px;
}

#progressContainer {
  flex: 1;
  max-width: 760px;
  margin: 0 auto;
}

.progress-track {
  width: 100%;
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: #36a2a0;
  border-radius: 999px;
  transition: width 0.25s ease-out;
}

#activityFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f6fbff;
}

@media (max-width: 780px) {
  .stage {
    padding: 10px;
  }

  .background {
    min-height: calc(100vh - 20px);
    padding: 14px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .lettersMenu {
    padding: 14px;
  }

  .learnAlphabetButton {
    min-height: 132px;
    padding: 14px;
    font-size: clamp(1.2rem, 6vw, 1.8rem);
  }

  .learnAlphabetPicture {
    height: 124px;
  }

  .learnAlphabetPicture img {
    height: 108px;
  }

  .activityGrid {
    grid-template-columns: 1fr;
  }

  .activityLink {
    min-height: 136px;
    padding: 14px;
  }

  .activityPicture {
    height: 116px;
  }

  .activityPicture img {
    height: 100px;
  }

  .activityDetail {
    font-size: 0.96rem;
  }

  .title {
    font-size: 30px;
    min-height: 62px;
  }

  .levelRow {
    grid-template-columns: 1fr;
  }

  .unitButton {
    min-height: 82px;
    font-size: 34px;
  }

  #activityHud {
    padding: 10px;
  }
}

/* The three entry points share equal emphasis. */
.mainLettersGrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.mainLettersGrid .activityLink { padding: 22px; min-height: 280px; gap: 20px; }
.mainLettersGrid .activityPicture { height: 190px; }
.mainLettersGrid .activityPicture img { height: 160px; }
.mainLettersGrid .activityDetail { font-size: clamp(1.8rem, 3vw, 2.6rem); color: #223044; }
body.watchMode .lettersMenu { display: none; }
#watchPanel { width: 100%; max-width: 1200px; margin: 0 auto; }
#watchFrame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 8px; background: #000; }
.watchNext {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(100%, 440px);
  min-height: 78px;
  margin: 24px auto 8px;
  padding: 16px 28px;
  border: 2px solid #743342;
  border-radius: 8px;
  background: #8f3d4c;
  color: #fff;
  box-shadow: 4px 4px 0 rgba(91, 36, 48, 0.25);
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 800;
  text-decoration: none;
}
.watchNext:hover { background: #743342; }
.watchNext:focus-visible { outline: 4px solid #c9aa44; outline-offset: 4px; }
@media (max-width: 780px) {
  .mainLettersGrid { grid-template-columns: 1fr; }
  .mainLettersGrid .activityLink { min-height: 170px; padding: 14px; gap: 12px; }
  .mainLettersGrid .activityPicture { height: 116px; }
  .mainLettersGrid .activityPicture img { height: 100px; }
}
