/* ============================================================================
   den.css — the Dragon Den look, lifted from findlay-dragon-den.html.

   Values are unchanged. The only edits: `body` became `.den-bg` and `#app`
   became `.den-app`, so the same surface can be the whole /den page OR one
   screen inside the reader (the chapter-end Word Hunt). The book and the game
   share dragons, names and hex colours — never fork them.
   ========================================================================== */
:root{
  --sky:#2E2A5C; --sky-deep:#221E49;
  --parchment:#FFF6E3; --parchment-edge:#F0E2C4;
  --ink:#33255B; --ink-soft:#6A5C93;
  --flame:#FF9E3D; --good:#4ECBA0; --oops:#FF6B81;
  --cloud:#EDE9FF;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0;}

.den-bg{
  position:relative;
  min-height:100%;
  background:
    radial-gradient(1200px 600px at 50% -10%, #4A3F8C 0%, var(--sky) 45%, var(--sky-deep) 100%);
  font-family:'Nunito', ui-rounded, 'Comic Sans MS', sans-serif;
  color:var(--cloud);
  touch-action:manipulation;
  overflow-x:hidden;
}
body.den-page{min-height:100vh;}
body.den-page .den-bg{min-height:100vh;}

/* twinkling stars */
.star{position:absolute; width:4px; height:4px; border-radius:50%; background:#FFF3C9; opacity:.7; animation:twinkle 3s ease-in-out infinite; pointer-events:none; z-index:0;}
@keyframes twinkle{0%,100%{opacity:.25; transform:scale(.8);} 50%{opacity:.9; transform:scale(1.15);}}

.den-app{position:relative; z-index:1; max-width:460px; margin:0 auto; padding:18px 16px 40px;}

.title{
  font-family:'Baloo 2', ui-rounded, sans-serif;
  font-weight:800; font-size:30px; line-height:1.05; text-align:center;
  color:#FFE9B8; text-shadow:0 3px 0 rgba(0,0,0,.25); margin:6px 0 2px;
}
.subtitle{text-align:center; font-size:16px; font-weight:700; color:#BFB6EA; margin:0 0 14px;}
.den-count{
  display:flex; justify-content:center; align-items:center; gap:8px;
  font-family:'Baloo 2', sans-serif; font-weight:700; font-size:18px; color:#FFE9B8; margin-bottom:16px;
}
.den-count .pill{background:rgba(255,255,255,.12); border-radius:999px; padding:4px 14px;}

/* ---------- egg nest grid ---------- */
.nest-grid{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
.egg-card{
  border:none; cursor:pointer; border-radius:22px; padding:14px 10px 12px;
  background:rgba(255,255,255,.07);
  box-shadow:inset 0 0 0 2px rgba(255,255,255,.08);
  display:flex; flex-direction:column; align-items:center; gap:6px;
  color:var(--cloud); font-family:'Nunito', sans-serif;
  transition:transform .12s ease;
}
.egg-card:active{transform:scale(.96);}
.egg-card:focus-visible{outline:3px solid var(--flame); outline-offset:2px;}
.egg{
  width:78px; height:96px; position:relative;
  border-radius:50% 50% 50% 50% / 58% 58% 42% 42%;
  box-shadow:inset -10px -12px 0 rgba(0,0,0,.14), 0 0 22px var(--glow, rgba(255,255,255,.25));
  animation:eggIdle 4s ease-in-out infinite;
}
@keyframes eggIdle{0%,100%{transform:rotate(-1.5deg);} 50%{transform:rotate(1.5deg);}}
.egg .speck{position:absolute; border-radius:50%; background:rgba(255,255,255,.45);}
.egg .team-tag{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:24px; color:rgba(0,0,0,.55); letter-spacing:1px;
}
.dragon-face{font-size:56px; line-height:1; filter:drop-shadow(0 0 14px var(--glow, rgba(255,255,255,.4))); animation:eggIdle 4s ease-in-out infinite;}
.egg-name{font-weight:800; font-size:15px; color:#FFF;}
.egg-sub{font-size:13px; font-weight:700; color:#BFB6EA;}
.stars{font-size:13px; letter-spacing:1px; color:#FFD46A; min-height:16px;}

.grownups{display:block; margin:26px auto 0; background:none; border:none; color:#8F86C2; font-size:13px; font-weight:700; text-decoration:underline; cursor:pointer;}

/* ---------- session screen ---------- */
.top-bar{display:flex; align-items:center; gap:10px; margin-bottom:14px;}
.back-btn{
  border:none; background:rgba(255,255,255,.12); color:#FFF; font-size:22px; font-weight:800;
  width:44px; height:44px; border-radius:14px; cursor:pointer;
}
.progress{display:flex; gap:6px; flex:1; justify-content:center;}
.p-dot{width:18px; height:18px; border-radius:50%; background:rgba(255,255,255,.15);}
.p-dot.done{background:var(--flame); box-shadow:0 0 10px var(--flame);}
.p-dot.miss{background:rgba(255,255,255,.35);}

.word-card{
  background:linear-gradient(180deg, #FFFBF0, var(--parchment));
  border:3px solid var(--parchment-edge); border-radius:26px;
  padding:26px 14px; text-align:center; color:var(--ink);
  box-shadow:0 10px 0 rgba(0,0,0,.18);
  margin-bottom:18px; min-height:170px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px;
}
.prompt-label{font-size:15px; font-weight:800; color:var(--ink-soft); letter-spacing:.3px;}
.big-word{
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:56px; line-height:1; letter-spacing:2px;
  word-break:keep-all;
}
.big-word .team{color:var(--team, var(--flame));}
.big-emoji{font-size:76px; line-height:1;}
.big-sentence{
  font-family:'Baloo 2', sans-serif; font-weight:800; font-size:29px; line-height:1.4;
  letter-spacing:.5px; color:var(--ink); padding:0 4px;
}
.big-sentence .team{color:var(--team, var(--flame));}
.ans-btn.scene{font-size:38px; line-height:1.15; padding:16px 4px;}
.ans-btn.scene span{margin:0 3px;}
.slot{
  display:inline-flex; align-items:center; justify-content:center;
  min-width:74px; height:64px; border-radius:14px; margin:0 3px;
  border:3px dashed var(--team, var(--flame)); background:rgba(0,0,0,.04);
  vertical-align:middle; font-size:44px; color:var(--team, var(--flame));
  transform:translateY(-4px);
}
.hear-btn{
  border:none; cursor:pointer; border-radius:999px; padding:8px 18px;
  background:var(--cloud); color:var(--ink); font-family:'Nunito',sans-serif; font-weight:800; font-size:16px;
}
.hear-btn:active{transform:scale(.95);}

.answers{display:grid; gap:12px;}
.answers.emoji-row{grid-template-columns:1fr 1fr 1fr;}
.answers.team-row{grid-template-columns:1fr 1fr 1fr;}
.ans-btn{
  border:none; cursor:pointer; border-radius:20px; padding:14px 6px;
  background:#FFFFFF; color:var(--ink);
  box-shadow:0 6px 0 rgba(0,0,0,.22);
  font-family:'Baloo 2', sans-serif; font-weight:800;
  transition:transform .1s ease;
}
.ans-btn:active{transform:translateY(3px);}
.ans-btn:focus-visible{outline:3px solid var(--flame); outline-offset:2px;}
.ans-btn.emoji{font-size:52px; line-height:1.1; padding:18px 6px;}
.ans-btn.team-tile{font-size:34px; letter-spacing:2px; padding:18px 6px; color:var(--ink);}
.ans-btn.right{background:var(--good); color:#083D2C; box-shadow:0 6px 0 #2E8A6B;}
.ans-btn.wrong{background:var(--oops); color:#FFF; box-shadow:0 6px 0 #C24458; animation:shake .35s ease;}
.ans-btn.reveal{background:var(--good); color:#083D2C; box-shadow:0 6px 0 #2E8A6B; animation:pulse .5s ease 2;}
.ans-btn:disabled{cursor:default;}
@keyframes shake{0%,100%{transform:translateX(0);} 25%{transform:translateX(-7px);} 75%{transform:translateX(7px);}}
@keyframes pulse{0%,100%{transform:scale(1);} 50%{transform:scale(1.06);}}

.cheer{
  text-align:center; font-family:'Baloo 2',sans-serif; font-weight:800; font-size:22px;
  min-height:32px; margin-top:14px; color:#FFE9B8;
}

/* ---------- results / hatch ---------- */
.center-stage{display:flex; flex-direction:column; align-items:center; text-align:center; gap:12px; padding-top:24px;}
.hatch-egg{
  width:130px; height:160px; position:relative;
  border-radius:50% 50% 50% 50% / 58% 58% 42% 42%;
  box-shadow:inset -14px -16px 0 rgba(0,0,0,.14), 0 0 44px var(--glow, rgba(255,255,255,.4));
  animation:bigWobble .5s ease-in-out 3;
}
@keyframes bigWobble{0%,100%{transform:rotate(0);} 25%{transform:rotate(-7deg);} 75%{transform:rotate(7deg);}}
/* The Word Hunt prize clip. Sits where the emoji dragon does, so the win
   screen keeps its shape whether or not a chapter has one. Capped in height
   so a 3:2 clip never pushes the buttons off a phone screen. */
/* Sized from the VIEWPORT, not the parent: .center-stage computes to zero
   width here, so any percentage collapses the video to 0x0. The emoji never
   showed this because font-size sizes it intrinsically. */
.prize-slot{display:flex; justify-content:center;}
.hatch-video{
  width:min(92vw, 520px); max-height:46vh; height:auto; cursor:pointer;
  border-radius:16px; display:block; background:#0B0A1F;
  box-shadow:0 0 34px var(--glow,#FFF), 0 10px 24px rgba(0,0,0,.45);
  /* Fade, never scale. popIn starts at scale(.2), and CSS animations are
     PAUSED while a tab is hidden -- so a transform-based entrance can leave the
     clip frozen at a fifth of its size, with getBoundingClientRect happily
     reporting 104px for a 520px element. Opacity cannot corrupt layout. */
  animation:prizeFade .5s ease-out;
}
@keyframes prizeFade{from{opacity:0;} to{opacity:1;}}
.prize-fallback{display:contents;}

.hatch-dragon{font-size:120px; line-height:1; filter:drop-shadow(0 0 30px var(--glow,#FFF)); animation:popIn .6s cubic-bezier(.2,1.6,.4,1);}
@keyframes popIn{0%{transform:scale(.2); opacity:0;} 100%{transform:scale(1); opacity:1;}}
.hatch-title{font-family:'Baloo 2',sans-serif; font-weight:800; font-size:34px; color:#FFE9B8; text-shadow:0 3px 0 rgba(0,0,0,.25);}
.hatch-sub{font-size:18px; font-weight:700; color:#CFC8F2; max-width:300px;}
.big-btn{
  border:none; cursor:pointer; border-radius:22px; padding:16px 34px; margin-top:8px;
  font-family:'Baloo 2',sans-serif; font-weight:800; font-size:22px;
  background:var(--flame); color:#4A2404; box-shadow:0 7px 0 #C4701C;
}
.big-btn:active{transform:translateY(4px); box-shadow:0 3px 0 #C4701C;}
.big-btn.quiet{background:rgba(255,255,255,.14); color:#FFF; box-shadow:0 7px 0 rgba(0,0,0,.25);}

.confetti{position:fixed; top:-20px; width:12px; height:18px; border-radius:3px; z-index:50; pointer-events:none; animation:fall linear forwards;}
@keyframes fall{to{transform:translateY(110vh) rotate(720deg);}}

@media (prefers-reduced-motion: reduce){
  .egg, .dragon-face, .hatch-egg, .star{animation:none !important;}
  .confetti{display:none;}
}

@media (prefers-reduced-motion: reduce){
  .hatch-video{ animation:none; }
}

/* XP earned, on the Den's hatch and star screens. */
.hatch-xp{
  font-family:'Baloo 2', ui-rounded, sans-serif; font-weight:800;
  font-size:20px; color:#FFD98A; margin:6px 0 4px;
}
