/* Thistledown Lane — shared look: warm felt, clay buttons, big tap targets. */
:root {
  --cream: #f6ead2;
  --cream-2: #efdcb8;
  --bark: #5a3a22;
  --bark-soft: #7a5536;
  --moss: #6f9a4a;
  --moss-dark: #4f7433;
  --berry: #a8323e;
  --pumpkin: #d9762b;
  --sky: #f3d9a6;
  --ink: #3b2716;
  --radius: 28px;
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--cream);
  /* felt texture: fine noise over warm cream */
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .45  0 0 0 0 .32  0 0 0 0 .18  0 0 0 .13 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse at 50% 0%, #fbf3e2 0%, var(--cream) 55%, var(--cream-2) 100%);
  background-attachment: fixed;
  font-size: 20px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* ---------- clay buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 64px; padding: .5em 1.2em;
  font-size: 1.25rem; font-weight: 800; letter-spacing: .01em;
  color: #fffaf0; text-decoration: none;
  background: linear-gradient(180deg, #86b25d 0%, var(--moss) 55%, var(--moss-dark) 100%);
  border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35), inset 0 -5px 0 rgba(0,0,0,.18), 0 6px 0 #3d5a27, 0 10px 18px rgba(60,40,20,.25);
  text-shadow: 0 2px 0 rgba(0,0,0,.18);
  transition: transform .08s ease, box-shadow .08s ease;
  user-select: none;
}
.btn:active { transform: translateY(5px); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), inset 0 -3px 0 rgba(0,0,0,.18), 0 1px 0 #3d5a27, 0 3px 8px rgba(60,40,20,.25); }
.btn:focus-visible { outline: 4px solid var(--pumpkin); outline-offset: 4px; }
.btn.berry { background: linear-gradient(180deg, #c64a55 0%, var(--berry) 60%, #86252f 100%); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), inset 0 -5px 0 rgba(0,0,0,.18), 0 6px 0 #6a1c25, 0 10px 18px rgba(60,40,20,.25); }
.btn.pumpkin { background: linear-gradient(180deg, #ec944a 0%, var(--pumpkin) 60%, #b65d1c 100%); box-shadow: inset 0 3px 0 rgba(255,255,255,.3), inset 0 -5px 0 rgba(0,0,0,.18), 0 6px 0 #8c4613, 0 10px 18px rgba(60,40,20,.25); }
.btn.bark { background: linear-gradient(180deg, #8a6240 0%, var(--bark-soft) 60%, var(--bark) 100%); box-shadow: inset 0 3px 0 rgba(255,255,255,.25), inset 0 -5px 0 rgba(0,0,0,.2), 0 6px 0 #3e2716, 0 10px 18px rgba(60,40,20,.25); }
.btn.round { width: 64px; padding: 0; font-size: 1.7rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: rgba(246,234,210,.86);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-bottom: 3px dashed rgba(122,85,54,.35);
}
.topbar .title { font-weight: 900; font-size: 1.35rem; color: var(--bark); text-align: center; flex: 1; min-width: 0; }
/* say-it-again sits beside the sound button, always in the same place */
.topbar .tbtns { display: flex; gap: 10px; flex: none; }
@media (max-width: 480px) { .topbar .title { font-size: 1.05rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } .topbar { gap: 8px; padding: 10px 12px; } .topbar .btn.round { width: 56px; min-height: 56px; font-size: 1.5rem; } }

/* ---------- sections ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 0 16px 48px; }
section { margin-top: 44px; }
h2 {
  font-size: clamp(1.7rem, 5vw, 2.4rem); margin: 0 0 18px; text-align: center;
  color: var(--bark);
  text-shadow: 0 2px 0 #fff6e4;
}
h2 .stitch {
  display: inline-block; padding: .15em .8em;
  background: #fffaf0; border-radius: 999px;
  border: 3px dashed #c8a271; box-shadow: 0 4px 0 #e2c89c;
}
.felt {
  background: #fffaf0;
  border-radius: var(--radius);
  box-shadow: 0 6px 0 #e2c89c, 0 14px 26px rgba(90,58,34,.16);
  outline: 3px dashed #e3cba2; outline-offset: -12px;
}

/* ---------- hero ---------- */
.hero { position: relative; text-align: center; padding-top: 18px; }
.hero .logo { width: min(640px, 92%); margin: 0 auto; filter: drop-shadow(0 8px 10px rgba(90,58,34,.25)); animation: bob 5s ease-in-out infinite; }
.hero .scene {
  position: relative; margin: 14px auto 0; border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 8px 0 #e2c89c, 0 18px 30px rgba(90,58,34,.22);
}
.hero .scene img { width: 100%; aspect-ratio: 16/9; object-fit: cover; }
.hero .hello { margin-top: 26px; display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; }
.hero p.lead { font-size: 1.3rem; font-weight: 700; color: var(--bark-soft); margin: 18px auto 0; max-width: 34em; }

@keyframes bob { 0%,100% { transform: translateY(0) rotate(-.6deg); } 50% { transform: translateY(-6px) rotate(.6deg); } }
@keyframes wiggle { 0%,100% { transform: rotate(0) } 20% { transform: rotate(-7deg) } 40% { transform: rotate(6deg) } 60% { transform: rotate(-4deg) } 80% { transform: rotate(3deg) } }
@keyframes hop { 0%,100% { transform: translateY(0) } 35% { transform: translateY(-22px) scale(1.03,.97) } 60% { transform: translateY(0) scale(1.04,.96) } }

/* ---------- games grid ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 22px; }
.game-tile {
  display: flex; flex-direction: column; text-decoration: none; color: inherit;
  overflow: hidden; transition: transform .12s ease;
}
.game-tile:active { transform: scale(.97); }
.game-tile:focus-visible { outline: 4px solid var(--pumpkin); outline-offset: 4px; }
.game-tile .pic { position: relative; aspect-ratio: 4/3; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; }
.game-tile .pic .bg { width: 100%; height: 100%; object-fit: cover; }
/* centred with margins, not a transform, so the hop animation can't knock them sideways */
.game-tile .pic .who { position: absolute; bottom: 4%; height: 74%; width: auto; left: 0; right: 0; margin: 0 auto; transform-origin: 50% 100%; filter: drop-shadow(0 6px 6px rgba(0,0,0,.3)); }
.game-tile:hover .who, .game-tile:focus-visible .who { animation: hop .7s ease; }
.game-tile .label { padding: 14px 18px 22px; text-align: center; }
.game-tile .label b { display: block; font-size: 1.45rem; color: var(--bark); }
.game-tile .label span { font-size: 1.05rem; color: var(--bark-soft); font-weight: 600; }

/* ---------- character cards ---------- */
.cast { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; }
.char {
  border: 0; padding: 14px 10px 18px; cursor: pointer; text-align: center; color: inherit;
  display: flex; flex-direction: column; align-items: center;
}
.char img { height: 190px; width: auto; filter: drop-shadow(0 6px 6px rgba(0,0,0,.25)); transform-origin: 50% 90%; }
.char:hover img { animation: hop .7s ease; }
.char.go img { animation: wiggle .7s ease; }
.char b { font-size: 1.45rem; margin-top: 8px; }
.char .about { font-size: 1rem; color: var(--bark-soft); font-weight: 600; margin-top: 4px; min-height: 2.7em; }
.char:focus-visible { outline: 4px solid var(--pumpkin); outline-offset: 2px; }
.char[data-who="bramble"] { background: #eef6e2; }
.char[data-who="moss"] { background: #eceae6; }
.char[data-who="lilly"] { background: #fbe6d5; }
.char[data-who="wren"] { background: #f3e7d6; }
.char[data-who="mam"] { background: #fbf2df; }

/* ---------- episodes ---------- */
.episode { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; padding: 18px; align-items: center; }
.episode video { width: 100%; border-radius: 20px; background: #000; aspect-ratio: 16/9; }
.episode h3 { margin: 0 0 6px; font-size: 1.5rem; color: var(--bark); }
.episode p { margin: 0; font-weight: 600; color: var(--bark-soft); }
@media (max-width: 720px) { .episode { grid-template-columns: 1fr; } }

/* ---------- footer / grown-ups ---------- */
footer { text-align: center; padding: 26px 16px 40px; color: var(--bark-soft); font-weight: 600; font-size: 1rem; }
.gate {
  position: fixed; inset: 0; z-index: 50; display: none; align-items: center; justify-content: center;
  background: rgba(59,39,22,.55); padding: 16px;
}
.gate.open { display: flex; }
.gate .box { max-width: 460px; width: 100%; padding: 26px 22px; text-align: center; }
.gate input {
  font: inherit; font-size: 1.6rem; width: 7em; text-align: center; padding: .3em; margin: 10px 0 16px;
  border-radius: 16px; border: 3px solid #c8a271; background: #fff;
}
.gate .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.gate .err { color: var(--berry); min-height: 1.3em; font-weight: 700; }
.grownups { text-align: left; font-size: 1.05rem; }
.grownups a { color: var(--moss-dark); font-weight: 800; }

/* ---------- game pages ---------- */
body.game { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; overflow-x: hidden; }
.stage-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 12px 20px; gap: 14px; }
.hud { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; font-weight: 800; font-size: 1.3rem; color: var(--bark); }
.prompt { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 800; color: var(--bark); text-align: center; margin: 0; }

/* win overlay */
.win {
  position: fixed; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center;
  background: rgba(59,39,22,.45); padding: 16px;
}
.win.open { display: flex; }
.win .box { padding: 24px 22px 28px; text-align: center; max-width: 440px; width: 100%; animation: pop .45s cubic-bezier(.2,1.6,.4,1); }
.win img { height: 200px; margin: 0 auto 6px; animation: hop 1s ease infinite; }
.win h3 { font-size: 2rem; margin: 4px 0 6px; color: var(--bark); }
.win p { margin: 0 0 18px; font-weight: 700; color: var(--bark-soft); }
.win .row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
@keyframes pop { from { transform: scale(.6); opacity: 0 } to { transform: scale(1); opacity: 1 } }

/* falling leaf confetti */
.leaf { position: fixed; top: -40px; z-index: 45; pointer-events: none; font-size: 32px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- learning games (shared) ---------- */
.rounds { display: flex; gap: 6px; justify-content: center; }
.rounds i { width: 22px; height: 22px; border-radius: 50%; background: #d8cfc0; box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); }
.rounds i.got { background: var(--moss); box-shadow: inset 0 -3px 0 var(--moss-dark); animation: pop .3s ease; }
.ask { display: flex; align-items: center; justify-content: center; gap: 12px; }
.panel { width: min(100%, 900px); padding: clamp(14px, 3vw, 26px); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.choices { display: flex; gap: clamp(10px, 3vw, 22px); justify-content: center; flex-wrap: wrap; }
.choice {
  border: 0; cursor: pointer; background: #fffaf0; border-radius: 24px; color: var(--bark);
  min-width: 96px; min-height: 96px; padding: 10px; font-weight: 900; font-size: 2.6rem;
  box-shadow: 0 6px 0 #d9bf93, 0 10px 16px rgba(90,58,34,.18); outline: 3px dashed #e3cba2; outline-offset: -9px;
  transition: transform .08s ease;
}
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 #d9bf93; }
.choice:focus-visible { outline: 4px solid var(--pumpkin); outline-offset: 3px; }
.choice.right { background: #e3f1d2; outline-color: var(--moss); animation: hop .5s ease; }
.choice.wrong { animation: shake .4s ease; opacity: .45; }
@keyframes shake { 0%,100% { transform: translateX(0) } 25% { transform: translateX(-8px) } 75% { transform: translateX(8px) } }
.sprite { width: 100%; height: 100%; }

/* ---------- talking host (episode replacement mouths on the full-body cut-out) ---------- */
.host {
  position: fixed; left: max(8px, 2vw); bottom: 0; z-index: 4; cursor: pointer; border: 0; padding: 0; background: none;
  height: min(68vh, 600px); aspect-ratio: 419 / 600;
}
.host img { position: absolute; left: 0; top: 0; width: 100%; height: auto; opacity: 0; filter: drop-shadow(0 8px 12px rgba(60,40,20,.3)); }
.host img.on { opacity: 1; }
.host.talking { animation: nod .5s ease-in-out infinite; transform-origin: 50% 100%; }
.host:focus-visible { outline: 4px solid var(--pumpkin); outline-offset: 4px; border-radius: 24px; }
@keyframes nod { 0%,100% { transform: rotate(0) translateY(0) } 50% { transform: rotate(-1.2deg) translateY(-3px) } }
body.has-host .stage-wrap { padding-left: calc(min(68vh, 600px) * 0.7 + 3vw); }
/* hosts who face left stand on the right, so they look at the game */
body.host-right .host { left: auto; right: max(8px, 2vw); }
body.has-host.host-right .stage-wrap { padding-left: 12px; padding-right: calc(min(68vh, 600px) * 0.7 + 3vw); }
@media (max-width: 900px), (max-height: 520px) {
  /* narrow screens: head and scarf peek over the top of the game panel */
  .host { position: relative; left: auto; right: auto; height: 150px; width: 190px; aspect-ratio: auto; overflow: hidden; margin: 0 auto -18px; z-index: 0; flex: none; }
  .host.talking { animation: none; }
  body.has-host .stage-wrap, body.has-host.host-right .stage-wrap { padding-left: 12px; padding-right: 12px; }
  body.has-host .panel { position: relative; z-index: 1; }
}
@media (min-width: 901px) and (min-height: 521px) {
  /* beside the host the panel is narrower: keep all three picture cards on one row */
  body.has-host .choice.pic { width: clamp(96px, 14vw, 190px); }
  body.has-host .letter { font-size: clamp(3.4rem, 9vh, 6rem); }
}

/* any element holding a talker's stacked mouth images */
.talker { position: relative; border: 0; padding: 0; background: none; }
.talker img { position: absolute; left: 0; top: 0; width: 100%; height: auto; opacity: 0; }
.talker img.on { opacity: 1; }

/* game boards keep one steady size from round to round, whatever is inside them */
body.game .panel { min-height: min(640px, calc(100dvh - 170px)); justify-content: space-evenly; }
@media (max-width: 900px), (max-height: 520px) { body.game.has-host .panel { min-height: calc(100dvh - 290px); } }

/* ---------- Thistledown lettering: puffy cream letters with a sage-green clay outline, like the title ---------- */
@font-face { font-family: "Fredoka"; src: url("../fonts/fredoka-latin.woff2") format("woff2"); font-weight: 300 700; font-display: swap; }
.clay {
  font-family: "Fredoka", var(--font); font-weight: 700; color: #fbf3df; letter-spacing: .01em;
  text-shadow:
    2px 0 0 #7f9a58, -2px 0 0 #7f9a58, 0 2px 0 #7f9a58, 0 -2px 0 #7f9a58,
    1.5px 1.5px 0 #7f9a58, -1.5px 1.5px 0 #7f9a58, 1.5px -1.5px 0 #7f9a58, -1.5px -1.5px 0 #7f9a58,
    0 4px 0 #5f7a3c, 0 6px 8px rgba(60,40,20,.35);
}
.clay.pumpkin { text-shadow:
    2px 0 0 #c9692a, -2px 0 0 #c9692a, 0 2px 0 #c9692a, 0 -2px 0 #c9692a,
    1.5px 1.5px 0 #c9692a, -1.5px 1.5px 0 #c9692a, 1.5px -1.5px 0 #c9692a, -1.5px -1.5px 0 #c9692a,
    0 4px 0 #8c4613, 0 6px 8px rgba(60,40,20,.35); }

/* ---------- breadcrumbs: Home › Games › Pairs, in clay letters with little leaves between ---------- */
.crumbs { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 6px; padding: 10px 14px 2px; font-size: clamp(1.05rem, 2.8vw, 1.35rem); line-height: 1.3; }
.crumbs a, .crumbs .here { text-decoration: none; padding: 2px 4px; border-radius: 12px; display: inline-block; transition: transform .15s; }
.crumbs a:hover { transform: translateY(-3px) rotate(-1.5deg); }
.crumbs a:focus-visible { outline: 3px solid var(--pumpkin); outline-offset: 2px; }
.crumbs .cleaf { width: 1.1em; height: 1.1em; flex: none; display: block; filter: drop-shadow(0 2px 1px rgba(60,40,20,.25)); }
.crumbs .cleaf:nth-of-type(3n+1) { color: #d9822b; transform: rotate(-20deg); }
.crumbs .cleaf:nth-of-type(3n+2) { color: #c64a55; transform: rotate(15deg); }
.crumbs .cleaf:nth-of-type(3n) { color: #e0a73a; transform: rotate(-5deg); }
@media (max-width: 480px) { .crumbs { padding-top: 6px; gap: 0 4px; } }
/* game screens lose a little height to the breadcrumbs */
body.game .panel { min-height: min(640px, calc(100dvh - 215px)); }
@media (max-width: 900px), (max-height: 520px) { body.game.has-host .panel { min-height: calc(100dvh - 336px); } }

/* ---------- home: big picture cards for each part of the site ---------- */
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: clamp(16px, 2.5vw, 28px); margin-top: 26px; }
.door { position: relative; display: block; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 10; text-decoration: none; box-shadow: 0 8px 0 #d9bf93, 0 14px 24px rgba(90,58,34,.25); transition: transform .15s; }
.door:hover { transform: translateY(-5px) rotate(-.4deg); }
.door:active { transform: scale(.98); }
.door:focus-visible { outline: 5px solid var(--pumpkin); outline-offset: 5px; }
.door > img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.door:hover > img { transform: scale(1.04); }
.door .who { position: absolute; right: 4%; bottom: 0; height: 78%; width: auto; filter: drop-shadow(0 8px 8px rgba(0,0,0,.35)); transform-origin: 50% 100%; }
.door:hover .who { animation: hop .7s ease; }
.door .say { position: absolute; left: 0; right: 0; bottom: 0; padding: 40px 22px 16px; background: linear-gradient(transparent, rgba(40,25,10,.62)); }
.door .say b { display: block; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.05; }
.door.wide { grid-column: 1 / -1; aspect-ratio: 32 / 9; }
.door.wide > img { object-position: 50% 45%; }
@media (max-width: 860px) { .door.wide { aspect-ratio: 16 / 10; } }
.door .say span { display: block; margin-top: 6px; color: #fff8ea; font-weight: 800; font-size: clamp(1rem, 2.2vw, 1.2rem); text-shadow: 0 2px 4px rgba(0,0,0,.6); max-width: 70%; }

/* home: a few words about the series, in the Thistledown lettering */
.hero .intro { font-family: "Fredoka", var(--font); font-weight: 600; font-size: clamp(1.15rem, 2.6vw, 1.5rem); line-height: 1.45; color: var(--bark); max-width: 34em; margin: 14px auto 0; text-wrap: balance; }

/* finished-game ticks and progress bars (games page) */
.progress { max-width: 560px; margin: 0 auto 18px; text-align: center; font-weight: 800; color: var(--bark); font-family: "Fredoka", var(--font); font-size: 1.15rem; }
.progress .bar { height: 18px; border-radius: 9px; background: #e6d6b8; overflow: hidden; box-shadow: inset 0 2px 3px rgba(0,0,0,.15); margin-top: 6px; }
.progress .bar i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, #8dbb5e, var(--moss)); }
.game-tile { position: relative; }
.game-tile .tick { position: absolute; right: 12px; top: 12px; z-index: 2; width: 46px; height: 46px; border-radius: 50%; background: var(--moss); color: #fff; display: grid; place-items: center; font-size: 1.5rem; font-weight: 900; box-shadow: 0 4px 0 var(--moss-dark); }
