:root {
  --sky: #13b7de;
  --sky-light: #e8f9ff;
  --navy: #123d83;
  --ink: #073363;
  --orange: #f58a20;
  --yellow: #ffc83d;
  --mint: #3dbb82;
  --panel: #ffffff;
  --line: #cfeafa;
  --shadow: 0 18px 42px rgba(0, 58, 108, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #def7ff, #fbfeff);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, -apple-system, Segoe UI, sans-serif;
}

body {
  overflow-x: hidden;
}

button {
  font: inherit;
}

.screen {
  display: none;
  min-height: 100svh;
}

.screen.active {
  display: block;
}

.splash {
  position: relative;
  display: none;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.58), transparent 24%),
    radial-gradient(circle at 80% 18%, rgba(255, 255, 255, 0.52), transparent 24%),
    linear-gradient(180deg, #19c6ef, #08a9db);
}

.splash.active {
  display: grid;
}

.splash-panel {
  width: min(860px, 95vw);
  padding: clamp(24px, 5vw, 62px);
  text-align: center;
  background: rgba(255, 255, 255, 0.96);
  border: 6px solid rgba(255, 255, 255, 0.9);
  border-radius: 42px;
  box-shadow: 0 30px 84px rgba(0, 50, 100, 0.28);
}

.badge {
  display: inline-block;
  padding: 12px 20px;
  color: #0976ce;
  background: #e8f7ff;
  border-radius: 999px;
  font-size: clamp(0.95rem, 2vw, 1.12rem);
  font-weight: 1000;
}

h1 {
  margin: 18px 0 12px;
  color: var(--navy);
  font-size: clamp(3.4rem, 10vw, 8.2rem);
  letter-spacing: 0;
  line-height: 0.93;
  text-shadow: 0 5px 0 rgba(16, 184, 231, 0.14);
}

h1 span {
  color: var(--orange);
}

.subtitle {
  margin: 0 auto 12px;
  color: #0879da;
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 1000;
}

.demo-note {
  max-width: 42ch;
  margin: 0 auto 30px;
  color: #46749a;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  font-weight: 850;
}

.start {
  min-width: min(430px, 100%);
  padding: 22px 34px;
  color: #fff;
  background: linear-gradient(180deg, #ffd850, #ff9b0d);
  border: 0;
  border-radius: 999px;
  box-shadow: 0 16px 30px rgba(211, 130, 0, 0.34);
  cursor: pointer;
  font-size: clamp(1.75rem, 4vw, 2.55rem);
  font-weight: 1000;
}

.spark {
  position: absolute;
  color: #ffe44c;
  font-size: clamp(2.3rem, 6vw, 5rem);
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.08);
  animation: float 3.2s ease-in-out infinite;
}

.spark-a {
  left: 8%;
  top: 12%;
}

.spark-b {
  right: 9%;
  top: 18%;
  animation-delay: 0.8s;
}

.spark-c {
  left: 13%;
  bottom: 12%;
  animation-delay: 1.5s;
}

@keyframes float {
  50% {
    transform: translateY(-12px) rotate(7deg);
  }
}

.library,
.page-screen {
  padding: 16px clamp(14px, 3vw, 34px) 40px;
}

.header {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 16px 18px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 12px 28px rgba(0, 58, 108, 0.12);
}

.header.sticky {
  position: sticky;
  top: 10px;
  z-index: 20;
  backdrop-filter: blur(10px);
}

.header h2 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.6rem);
  line-height: 1.02;
}

.header p {
  margin: 5px 0 0;
  color: #4a759c;
  font-weight: 850;
}

.round,
.pill {
  color: #fff;
  background: linear-gradient(180deg, #2b9df4, #0879da);
  border: 0;
  box-shadow: 0 11px 20px rgba(8, 121, 218, 0.27);
  cursor: pointer;
  font-weight: 1000;
}

.round {
  flex: 0 0 auto;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 2rem;
}

.pill {
  padding: 14px 18px;
  border-radius: 999px;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 10px;
  padding: 2px 2px 16px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 12px 16px;
  color: #12518f;
  background: #fff;
  border: 2px solid #cce8fb;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 1000;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  background: #168ee6;
  border-color: #168ee6;
  box-shadow: 0 10px 18px rgba(22, 142, 230, 0.22);
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 46vw), 1fr));
  gap: 16px;
}

.page-card {
  padding: 12px;
  text-align: left;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.page-card:hover,
.page-card:focus-visible,
.flash-card:hover,
.flash-card:focus-visible {
  outline: none;
  transform: translateY(-4px);
  box-shadow: 0 24px 44px rgba(0, 58, 108, 0.2);
}

.page-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #effaff;
  border-radius: 18px;
}

.page-card small {
  display: block;
  margin-top: 12px;
  color: #f58a20;
  font-size: 0.76rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-card strong {
  display: block;
  margin-top: 4px;
  color: #083d78;
  font-size: 1.2rem;
  font-weight: 1000;
  line-height: 1.14;
}

.page-card span {
  display: inline-block;
  margin-top: 8px;
  padding: 8px 11px;
  color: #0879da;
  background: #eaf7ff;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 1000;
}

.page-title-wrap {
  min-width: 0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 45vw), 1fr));
  gap: 16px;
  align-items: start;
}

.flash-card {
  display: grid;
  gap: 10px;
  padding: 8px 8px 14px;
  color: var(--ink);
  background: #fff;
  border: 0;
  border-radius: 24px;
  box-shadow: var(--shadow);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.flash-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: contain;
  background: #fff;
  border-radius: 18px;
}

.flash-card span {
  min-height: 2.6em;
  padding: 0 8px;
  color: #0c3d7b;
  font-size: 1.02rem;
  font-weight: 1000;
  line-height: 1.25;
  text-align: center;
}

.card-dialog {
  width: min(96vw, 980px);
  max-width: 980px;
  max-height: 94svh;
  padding: 0;
  background: transparent;
  border: 0;
}

.card-dialog::backdrop {
  background: rgba(0, 31, 62, 0.68);
  backdrop-filter: blur(6px);
}

.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 94svh;
  margin: 0;
  overflow: hidden;
  background: #fff;
  border: 5px solid rgba(255, 255, 255, 0.8);
  border-radius: 34px;
  box-shadow: 0 34px 92px rgba(0, 0, 0, 0.38);
  animation: cardPop 0.18s ease-out;
}

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 52px;
  height: 52px;
  color: #103d7d;
  background: rgba(255, 255, 255, 0.94);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  font-size: 2.3rem;
  font-weight: 700;
  line-height: 1;
}

.modal-card img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: calc(94svh - 190px);
  object-fit: contain;
  background: #fff;
}

.modal-copy {
  flex: 0 0 auto;
  padding: 16px 18px 22px;
  text-align: center;
  background: #fff;
}

.modal-copy p {
  margin: 0 0 14px;
  color: #0c3d7b;
  font-size: clamp(1.3rem, 3.5vw, 2rem);
  font-weight: 1000;
  line-height: 1.18;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.listen,
.next-card {
  padding: 15px 20px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 1000;
}

.listen {
  color: #fff;
  background: linear-gradient(180deg, #2d9ff4, #0879da);
  box-shadow: 0 11px 20px rgba(8, 121, 218, 0.27);
}

.next-card {
  color: #0879da;
  background: #eaf7ff;
}

#audioStatus {
  display: block;
  min-height: 1.3em;
  margin-top: 12px;
  color: #5d7e9f;
  font-weight: 850;
}

.load-error {
  padding: 24px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  font-weight: 900;
}

@keyframes cardPop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(14px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@media (max-width: 720px) {
  .header {
    align-items: flex-start;
  }

  .header.sticky {
    top: 8px;
  }

  .page-title-wrap h2 {
    font-size: 1.65rem;
  }

  .pill {
    padding: 13px 14px;
  }

  .card-dialog {
    width: min(97vw, 760px);
  }

  .modal-card img {
    max-height: calc(94svh - 220px);
  }
}
