:root {
  --bg: #FFF8EE;
  --bg-2: #F3EEFF;
  --ink: #2B2140;
  --ink-soft: #6B6383;
  --purple: #7A5AF8;
  --purple-dark: #5637D6;
  --purple-soft: #E9E2FF;
  --teal: #16BFAE;
  --teal-soft: #D7F7F2;
  --pink: #FF6F9C;
  --pink-soft: #FFE3EC;
  --sun: #FFC23D;
  --card: #FFFFFF;
  --line: #EDE6DA;
  --ok: #22B573;
  --ok-soft: #DDF7EA;
  --radius: 22px;
  --shadow: 0 8px 0 rgba(43, 33, 64, .08), 0 14px 30px rgba(43, 33, 64, .08);
  --font: "Nunito", "Baloo 2", "Quicksand", "Segoe UI Rounded", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, #FFE9C7 0, transparent 35%),
    radial-gradient(circle at 95% 10%, var(--bg-2) 0, transparent 40%),
    var(--bg);
  min-height: 100vh;
  line-height: 1.4;
}

button { font-family: inherit; cursor: pointer; }
button:disabled { cursor: default; }

[hidden] { display: none !important; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-left));
  max-width: 1200px;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.brand-owl { width: 44px; height: 52px; display: block; }
.brand-owl svg, [data-owl] svg { width: 100%; height: 100%; display: block; }

.brand-name { font-size: 26px; font-weight: 900; letter-spacing: -.5px; }
.brand-name span { color: var(--purple); }

.badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  background: var(--teal-soft);
  color: #0E7F74;
  border-radius: 999px;
  padding: 4px 10px;
}

.icon-btn {
  border: 0;
  width: 44px; height: 44px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 22px;
  font-weight: 900;
  color: var(--ink);
}

.screen {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px 32px;
}

/* ---------- home ---------- */

.hero {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--card);
  border-radius: 28px;
  padding: 20px 24px;
  box-shadow: var(--shadow);
  margin-top: 8px;
}

.hero-owl { width: 120px; height: 142px; flex: none; animation: bob 3s ease-in-out infinite; }
.hero h1 { margin: 0 0 6px; font-size: clamp(24px, 4vw, 34px); }
.hero p { margin: 0; font-size: 18px; color: var(--ink-soft); max-width: 640px; }

.section-title { font-size: 22px; margin: 28px 0 12px; }

.lang-row { display: flex; flex-wrap: wrap; gap: 10px; }

.lang-chip {
  display: flex; align-items: center; gap: 8px;
  border: 3px solid transparent;
  background: var(--card);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 18px; font-weight: 800;
  color: var(--ink);
  box-shadow: var(--shadow);
}
.flag { display: inline-block; width: 26px; height: 18px; border-radius: 4px; overflow: hidden; vertical-align: -3px; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.flag svg { width: 100%; height: 100%; display: block; }
.tag .flag { width: 18px; height: 12px; vertical-align: -1px; }
.lang-chip small { font-size: 12px; font-weight: 700; color: var(--ink-soft); }
.lang-chip.is-active { border-color: var(--purple); background: var(--purple-soft); }
.lang-chip:disabled { opacity: .55; }

.story-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.story-card {
  text-align: left;
  border: 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  color: var(--ink);
  transition: transform .15s ease;
}
.story-card:not(.is-placeholder):hover { transform: translateY(-4px) rotate(-.4deg); }
.story-card:not(.is-placeholder):active { transform: translateY(1px); }

.story-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--purple-soft); }
.story-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.story-play {
  position: absolute; inset: 0; margin: auto;
  width: 68px; height: 68px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .92);
  color: var(--purple);
  font-size: 28px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
}
.story-age {
  position: absolute; left: 10px; top: 10px;
  background: var(--teal); color: #fff;
  font-size: 15px; font-weight: 900;
  padding: 4px 10px; border-radius: 10px;
  box-shadow: 0 3px 0 #0E9C8E;
}
.story-age.is-older { background: var(--pink); box-shadow: 0 3px 0 #D2386B; }

.age-row { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 14px; }
.age-chip {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 15px; font-weight: 800;
}
.age-chip.is-active { border-color: var(--purple); background: var(--purple-soft); }

.story-duration {
  position: absolute; right: 10px; bottom: 10px;
  background: rgba(43, 33, 64, .8); color: #fff;
  font-size: 13px; font-weight: 800;
  padding: 3px 8px; border-radius: 8px;
}
.story-body { padding: 14px 16px 18px; }
.story-body h3 { margin: 0 0 10px; font-size: 20px; }
.story-body p { margin: 0; color: var(--ink-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { font-size: 13px; font-weight: 800; background: var(--bg); border-radius: 999px; padding: 4px 10px; }
.story-words { font-size: 22px; letter-spacing: 2px; }

.is-placeholder { opacity: .7; border: 3px dashed var(--line); box-shadow: none; background: transparent; }
.placeholder-thumb { display: grid; place-items: center; font-size: 48px; color: var(--ink-soft); background: transparent; }

/* ---------- player ---------- */

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.video-frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #1C1530;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 6px solid var(--card);
}
.video-frame iframe, #video-player { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pause-cover {
  display: none;
  position: absolute; inset: 0;
  border: 0; padding: 0;
  background: #1C1530;
  cursor: pointer;
}
.pause-cover img { width: 100%; height: 100%; object-fit: cover; filter: blur(6px) brightness(.55); transform: scale(1.06); }
.cover-card {
  position: absolute; inset: 0; margin: auto;
  width: max-content; max-width: 86%; height: max-content;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); color: var(--ink);
  border-radius: 20px; padding: 10px 18px 10px 10px;
  font-size: clamp(15px, 2.2vw, 20px); font-weight: 900; text-align: left;
  box-shadow: var(--shadow);
}
.cover-owl { width: 64px; height: 76px; flex: none; }
.video-frame.is-covered iframe { visibility: hidden; }
.video-frame.is-covered .pause-cover { display: block; }

.controls {
  display: flex; align-items: center; gap: 14px;
  margin-top: 14px;
  background: var(--card);
  border-radius: 999px;
  padding: 8px 18px 8px 8px;
  box-shadow: var(--shadow);
}

.play-btn {
  width: 60px; height: 60px; flex: none;
  border: 0; border-radius: 50%;
  background: var(--purple); color: #fff;
  font-size: 24px; font-weight: 900;
  box-shadow: 0 5px 0 var(--purple-dark);
}
.play-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--purple-dark); }

.track {
  position: relative; flex: 1;
  height: 14px; border-radius: 999px;
  background: var(--purple-soft);
}
.track-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--teal), var(--purple)); }
.track-mark {
  position: absolute; top: 50%;
  width: 16px; height: 16px; margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--purple);
}
.track-mark.is-done { background: var(--teal); border-color: var(--teal); }
.track-mark.is-star { background: var(--sun); border-color: #E7A400; transform: scale(1.25); }

.word-counter { font-weight: 900; font-size: 18px; white-space: nowrap; }

.hint { color: var(--ink-soft); font-size: 14px; margin: 10px 8px 0; }

.side-panel {
  position: relative;
  background: var(--card);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 20px;
  min-height: 340px;
  overflow: hidden;
}

.side-panel.is-idle { display: flex; flex-direction: column; align-items: center; text-align: center; }
.panel-owl { width: 130px; height: 154px; animation: bob 3s ease-in-out infinite; }
.panel-owl.small { width: 72px; height: 86px; flex: none; animation: none; }

.bubble {
  position: relative;
  background: var(--purple-soft);
  border-radius: 18px;
  padding: 12px 16px;
  font-size: 18px; font-weight: 800;
  margin: 14px 0;
}
.bubble::before {
  content: ""; position: absolute; top: -10px; left: 50%; margin-left: -10px;
  border: 10px solid transparent; border-top: 0; border-bottom-color: var(--purple-soft);
}

.collected { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.collected-chip { font-size: 26px; background: var(--bg); border-radius: 12px; padding: 4px 6px; }

/* quiz */

.side-panel.is-quiz { border: 4px solid var(--sun); animation: pop .35s ease; }
.quiz-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.quiz-title { font-size: 22px; font-weight: 900; margin: 0; line-height: 1.15; }
.quiz-sub { margin: 4px 0 0; color: var(--ink-soft); font-weight: 700; }
.quiz-sub.is-oops { color: #D2386B; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 118px;
  border: 0; border-radius: 20px;
  background: var(--bg);
  box-shadow: 0 6px 0 var(--line);
  color: var(--ink);
  transition: transform .1s ease, opacity .2s ease;
}
.tile:hover:not(:disabled) { transform: translateY(-2px); background: #FFF1D6; }
.tile:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--line); }
.tile-emoji { font-size: 46px; line-height: 1; }
.tile-word { font-size: 22px; font-weight: 900; }
.tile.is-wrong { background: var(--pink-soft); box-shadow: 0 6px 0 #F7C3D3; opacity: .45; }

.replay-btn { width: 100%; margin-top: 14px; }

/* correct */

.side-panel.is-correct { display: flex; flex-direction: column; align-items: center; text-align: center; border: 4px solid var(--ok); background: linear-gradient(180deg, var(--ok-soft), #fff 55%); }
.side-panel.is-correct .panel-owl { width: 110px; height: 130px; animation: hop .6s ease 2; }
.correct-title { font-size: 28px; font-weight: 900; margin: 6px 0 10px; color: #138A55; }

.word-card {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border-radius: 20px;
  padding: 12px 18px;
  box-shadow: var(--shadow);
}
.word-emoji { font-size: 54px; }
.word-en { font-size: 30px; font-weight: 900; text-align: left; white-space: nowrap; }
.word-pl { font-size: 18px; font-weight: 800; color: var(--ink-soft); text-align: left; }
.say-btn { border: 0; background: var(--purple-soft); border-radius: 10px; font-size: 18px; padding: 2px 8px; vertical-align: middle; }

.sentence { font-size: 17px; font-style: italic; color: var(--ink-soft); margin: 14px 0; }
.sentence mark { background: var(--sun); color: var(--ink); font-style: normal; font-weight: 900; border-radius: 6px; padding: 0 4px; }

.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i {
  position: absolute; top: 30%; left: 50%;
  width: 10px; height: 10px; border-radius: 3px;
  animation: burst 1.1s ease-out forwards;
}
.burst i:nth-child(3n) { background: var(--sun); }
.burst i:nth-child(3n+1) { background: var(--pink); }
.burst i:nth-child(3n+2) { background: var(--teal); }
.burst i:nth-child(1) { --dx: -140px; --dy: -60px; }
.burst i:nth-child(2) { --dx: 140px; --dy: -70px; }
.burst i:nth-child(3) { --dx: -110px; --dy: 90px; }
.burst i:nth-child(4) { --dx: 120px; --dy: 100px; }
.burst i:nth-child(5) { --dx: -60px; --dy: -120px; }
.burst i:nth-child(6) { --dx: 70px; --dy: -130px; }
.burst i:nth-child(7) { --dx: -160px; --dy: 20px; }
.burst i:nth-child(8) { --dx: 165px; --dy: 10px; }
.burst i:nth-child(9) { --dx: -30px; --dy: 140px; }
.burst i:nth-child(10) { --dx: 40px; --dy: 150px; }
.burst i:nth-child(11) { --dx: -150px; --dy: -110px; }
.burst i:nth-child(12) { --dx: 150px; --dy: -120px; }

/* buttons */

.big-btn {
  border: 0;
  background: var(--purple); color: #fff;
  font-size: 20px; font-weight: 900;
  padding: 14px 26px;
  border-radius: 18px;
  box-shadow: 0 6px 0 var(--purple-dark);
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--purple-dark); }
.continue-btn { position: relative; overflow: hidden; }
.continue-btn .countdown { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: rgba(255,255,255,.55); transform-origin: left; animation: countdown var(--auto, 8s) linear forwards; }
.big-btn.secondary { background: var(--card); color: var(--ink); box-shadow: 0 6px 0 var(--line); }

.ghost-btn {
  border: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 16px; font-weight: 800;
  padding: 10px 16px;
  border-radius: 14px;
}
.ghost-btn:hover { background: var(--bg); }

.parent-tools {
  margin-top: 22px;
  color: var(--ink-soft);
  font-size: 14px;
}
.parent-tools summary { cursor: pointer; font-weight: 800; }
.parent-tools .ghost-btn { font-size: 14px; margin: 4px 6px 4px 0; }

/* ---------- summary ---------- */

.summary-head {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: 28px; padding: 20px 24px; box-shadow: var(--shadow);
}
.summary-owl { width: 120px; height: 142px; flex: none; animation: hop .6s ease 3; }
.summary-head h1 { margin: 0 0 6px; }
.summary-head p { margin: 0; font-size: 18px; color: var(--ink-soft); font-weight: 700; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.summary-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 16px 10px 14px;
  color: var(--ink);
}
.summary-card:hover { transform: translateY(-2px); }
.summary-emoji { font-size: 46px; }
.summary-card.is-locked { background: transparent; border: 3px dashed var(--line); box-shadow: none; opacity: .7; }
.summary-card.is-locked:hover { transform: none; }
.summary-en { font-size: 22px; font-weight: 900; }
.summary-pl { font-size: 16px; font-weight: 700; color: var(--ink-soft); }
.summary-star { position: absolute; top: 8px; right: 10px; font-size: 18px; }
.summary-say { position: absolute; top: 8px; left: 10px; font-size: 16px; opacity: .6; }

.summary-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* ---------- misc ---------- */

.footer {
  max-width: 1200px; margin: 0 auto;
  padding: 18px 16px 30px;
  font-size: 13px; color: var(--ink-soft);
}

.file-warning {
  background: var(--pink-soft); color: #9C1F4A;
  padding: 12px 16px; font-weight: 800; text-align: center;
}

.wiggle { animation: wiggle .4s ease; }

@keyframes countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-14px) rotate(-4deg); } }
@keyframes pop { 0% { transform: scale(.94); } 60% { transform: scale(1.02); } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
@keyframes burst {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(260deg); opacity: 0; }
}

@media (max-width: 1000px) {
  .player-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .tile { min-height: 100px; }
  .tile-emoji { font-size: 38px; }
}

@media (max-width: 720px) {
  .player-layout { grid-template-columns: 1fr; }
  .side-panel { min-height: 0; }
  .panel-owl { width: 96px; height: 114px; }
}

@media (max-width: 560px) {
  .hero, .summary-head { flex-direction: column; text-align: center; }
  .brand-name { font-size: 22px; }
  .tile { min-height: 100px; }
  .tile-emoji { font-size: 38px; }
  .tile-word { font-size: 19px; }
  .controls { padding-right: 12px; }
  .word-counter { font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
