/* Dino Dig Lab. System fonts only. No inline styles. */
[hidden]{display:none!important}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

body[data-game="dino-dig-lab"]{
  background:#e8c98a;
  color:#3a2614;
  display:flex;flex-direction:column;
  position:fixed;inset:0;width:100%;
  height:100%;height:100dvh;height:100svh;max-height:100svh;
  overflow:hidden;
  overscroll-behavior:none;touch-action:none;
  padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px);
  box-sizing:border-box;
}
html.ka-play-lock body[data-game="dino-dig-lab"]{
  height:100svh;max-height:100svh;
}
body[data-game="dino-dig-lab"] main{
  max-width:none;
  padding:0;
  display:flex;
  flex-direction:column;
  flex:1;
  min-height:0;
}
body[data-game="dino-dig-lab"] .site-header,
body[data-game="dino-dig-lab"] .site-footer{background:#fff8e8;border-color:#e0b56a;flex:0 0 auto}

.caption{
  font-size:1.1rem;font-weight:800;text-align:center;min-height:1.4em;
  margin:6px 12px 4px;color:#3a2614;
}

.screen{width:100%;display:flex;flex-direction:column;align-items:center;flex:1;min-height:0}
.row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin:8px 10px 12px}
.lead{font-size:1.15rem;font-weight:700;margin:.15em 0 .5em;text-align:center;line-height:1.35}
.lead.tight{margin:.1em 0 .6em;font-size:1.05rem}
.hint{
  font-weight:800;text-align:center;color:#3a2614;line-height:1.3;
  background:rgba(255,248,230,.96);
  border:3px solid #3a2614;border-radius:18px;
  padding:8px 16px;margin:8px auto;
  max-width:min(42rem, calc(100% - 24px));
  box-shadow:0 4px 0 #3a2614;
  min-height:0;
}
.quiz-card .hint, .ask .hint{margin:8px auto 0;box-shadow:0 3px 0 #3a2614}
.q{font-size:1.4rem;font-weight:900;text-align:center;margin:.2em 0 .5em}

/* chunky buttons */
.btn{
  min-height:56px;padding:10px 22px;border-radius:18px;
  border:4px solid #3a2614;background:#fff8e8;color:#3a2614;
  font:800 1.1rem system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  box-shadow:0 5px 0 #3a2614;cursor:pointer;touch-action:manipulation;
}
.btn:hover,.btn:focus-visible{background:#fff}
.btn:active{transform:translateY(3px);box-shadow:0 2px 0 #3a2614}
.btn.primary{background:linear-gradient(#f0c14b,#e0a01a);border-color:#3a2614;color:#3a2614}
.btn.primary:hover,.btn.primary:focus-visible{background:linear-gradient(#ffe08a,#f0c14b)}
.btn.soft{background:#efe0c4}
.btn:disabled{opacity:.45;cursor:default;box-shadow:none;transform:none}
button:focus-visible, .lev:focus-visible, .slot:focus-visible, .choices button:focus-visible{
  outline:4px solid #111;outline-offset:3px;box-shadow:0 0 0 7px #ffe66d;
}

/* ---------- title ---------- */
.title{
  position:relative;
  min-height:calc(100dvh - 8rem);
  justify-content:flex-end;
  background:#f3d7a4 url("assets/title.jpg") center 62% / cover no-repeat;
  padding:0;
}
.title-panel{
  width:min(520px, calc(100% - 20px));
  margin:0 auto 16px;
  background:rgba(255,248,230,.94);
  border:4px solid #3a2614;
  border-radius:26px;
  box-shadow:0 8px 0 #3a2614, 0 18px 28px rgba(58,38,20,.28);
  padding:16px 16px 18px;
  text-align:center;
}
.title h1{
  margin:.05em 0 .15em;
  font-size:clamp(1.8rem, 7vw, 2.7rem);
  font-weight:900;
  letter-spacing:-.02em;
  color:#3a2614;
  text-shadow:0 3px 0 #f0c14b;
}
.found-line{font-weight:800;margin:0 0 .6em;color:#6a4a22}
.levels{display:flex;flex-direction:column;gap:10px;width:100%}
.lev{
  display:flex;flex-direction:column;align-items:flex-start;gap:2px;
  text-align:left;padding:12px 16px;min-height:76px;width:100%;
  border-radius:18px;border:4px solid #3a2614;background:#fff;
  font:inherit;color:#3a2614;cursor:pointer;touch-action:manipulation;
  box-shadow:0 4px 0 #3a2614;
}
.lev:hover,.lev:focus-visible{background:#fff6d8}
.lev.primary{background:linear-gradient(#fff6d0,#f8e08a)}
.lev b{font-size:1.25rem;font-weight:900}
.lev small{color:#5a4630;font-weight:700;line-height:1.25}
.title-row{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-top:12px}

/* ---------- museum ---------- */
.museum{
  background:#e8d3a8 url("assets/museum.jpg") center / cover no-repeat;
  min-height:calc(100dvh - 4.4rem);
  justify-content:flex-start;padding:10px 0 20px;
}
.panel{
  width:min(860px, calc(100% - 20px));
  margin:8px auto;
  background:rgba(255,248,230,.93);
  border:4px solid #3a2614;border-radius:24px;
  box-shadow:0 7px 0 #3a2614;
  padding:14px 14px 16px;text-align:center;
}
.shelf{
  display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));
  gap:12px;margin:8px 0 12px;
}
.slot{
  appearance:none;border:4px solid #6a4a28;border-radius:18px;
  background:linear-gradient(#d8b57a,#c49a58);
  min-height:150px;padding:8px 6px 6px;cursor:pointer;
  display:flex;flex-direction:column;align-items:center;justify-content:flex-end;
  gap:4px;color:#3a2614;font:800 .9rem system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  box-shadow:inset 0 -10px 0 rgba(80,40,10,.18), 0 4px 0 #3a2614;
  touch-action:manipulation;
}
.slot img{width:100%;height:110px;object-fit:contain;pointer-events:none}
.slot.empty{cursor:default;opacity:.85}
.slot.empty .ghost{
  width:70px;height:70px;margin:auto 0 6px;
  background:rgba(58,38,20,.18);
  border-radius:50%;
  position:relative;
}
.slot.empty .ghost::before,
.slot.empty .ghost::after{
  content:"";position:absolute;background:rgba(58,38,20,.28);border-radius:8px;
}
.slot.empty .ghost::before{width:46px;height:16px;left:12px;top:27px}
.slot.empty .ghost::after{width:16px;height:46px;left:27px;top:12px}
.slot.found{background:linear-gradient(#fff8e8,#f3e0bc);border-color:#3a2614}
.slot .who{font-weight:900;font-size:.85rem;line-height:1.15}

/* ---------- shared hud / stage ---------- */
.hud{
  display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:8px 12px;
  width:min(960px, calc(100% - 16px));margin:6px auto 4px;
  position:sticky;top:0;z-index:12;
  background:rgba(246,226,184,.94);
  padding:6px 8px;border-radius:0 0 16px 16px;
}
.hud-title{margin:0;font-size:1.15rem;font-weight:900}
.pill{
  background:#fff8e8;border:3px solid #3a2614;border-radius:999px;
  padding:4px 14px;min-height:40px;display:inline-flex;align-items:center;
  font-weight:800;
}
.bar{
  flex:1 1 140px;height:18px;border:3px solid #3a2614;border-radius:999px;
  background:#c9a06a;overflow:hidden;min-width:120px;
}
.bar i{
  display:block;height:100%;width:100%;background:linear-gradient(#f0c14b,#d48a2a);
  transform-origin:left center;transform:scaleX(0);
  border-radius:999px;
}
.bar.p0 i{transform:scaleX(0)}
.bar.p1 i{transform:scaleX(.1)}
.bar.p2 i{transform:scaleX(.2)}
.bar.p3 i{transform:scaleX(.3)}
.bar.p4 i{transform:scaleX(.4)}
.bar.p5 i{transform:scaleX(.5)}
.bar.p6 i{transform:scaleX(.6)}
.bar.p7 i{transform:scaleX(.7)}
.bar.p8 i{transform:scaleX(.8)}
.bar.p9 i{transform:scaleX(.9)}
.bar.p10 i{transform:scaleX(1)}

.stage{
  position:relative;
  width:calc(100% - 16px);
  margin:0 auto;
  flex:1 1 auto;
  min-height:0;
  min-width:0;
  display:flex;align-items:center;justify-content:center;
  border:none;background:transparent;box-shadow:none;
  overflow:hidden;
  touch-action:none;
  container-type:size;
}
.stage canvas{
  display:block;
  flex:0 0 auto;
  border:4px solid #3a2614;border-radius:22px;
  box-shadow:0 8px 0 #3a2614, 0 16px 24px rgba(58,38,20,.22);
  background:#c9844a;
  touch-action:none;
  box-sizing:border-box;
}
#digC,#buildC{
  width:min(100cqw, calc(100cqh * 960 / 640));
  height:min(100cqh, calc(100cqw * 640 / 960));
}
#raceC{
  width:min(100cqw, calc(100cqh * 960 / 540));
  height:min(100cqh, calc(100cqw * 540 / 960));
}

.dig,.build,.race{
  min-height:calc(100dvh - 4.4rem);
  justify-content:flex-start;
  padding-bottom:18px;
}
.dig{background:#c9844a url("assets/sand.jpg") center / cover no-repeat;}
.build{background:#cbb48a url("assets/board.jpg") center bottom / cover no-repeat;padding-bottom:18px}
.fact,.quiz{background:#e8d3a8 url("assets/museum.jpg") center / cover no-repeat;}


/* ---------- come alive ---------- */
.alive{
  background:#f6d9a0 url("assets/meadow.jpg") center / cover no-repeat;
  min-height:calc(100dvh - 4.4rem);
  justify-content:flex-start;
  padding:8px 0 16px;
}
.alive-stage{
  position:relative;
  width:min(720px, calc(100% - 16px));
  aspect-ratio:16/11;
  margin:8px auto 0;
  display:flex;align-items:flex-end;justify-content:center;
}
#aliveDino{
  width:auto;height:88%;max-width:92%;object-fit:contain;
  filter:drop-shadow(0 18px 16px rgba(40,24,8,.28));
  transform-origin:50% 100%;
}
#aliveDino.wake{animation:wake 1s cubic-bezier(.2,1.5,.3,1) both}
#aliveDino.breathe{animation:wake 1s cubic-bezier(.2,1.5,.3,1) both, breathe 2.6s ease-in-out 1s infinite}
.fx{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.hello{
  font-size:clamp(1.3rem, 5vw, 2rem);font-weight:900;text-align:center;
  color:#3a2614;text-shadow:0 2px 0 #fff6d0, 0 0 16px #fff8e8;
  background:rgba(255,248,230,.88);border:4px solid #3a2614;border-radius:20px;
  padding:8px 18px;margin:10px 16px 0;box-shadow:0 5px 0 #3a2614;
}
@keyframes wake{
  0%{transform:scale(.25) translateY(50px);opacity:0;filter:brightness(1.8)}
  60%{transform:scale(1.08);opacity:1}
  100%{transform:scale(1)}
}
@keyframes breathe{
  0%,100%{transform:scale(1)}
  50%{transform:scale(1.035, .975)}
}

/* ---------- fact card ---------- */
.fact{padding:8px 0 16px;min-height:calc(100dvh - 4.4rem);justify-content:center}
.fact-card{
  width:min(640px, calc(100% - 20px));
  background:linear-gradient(#fffdf6,#f6e7c8);
  border:4px solid #3a2614;border-radius:26px;
  box-shadow:0 8px 0 #3a2614;
  padding:14px 14px 16px;text-align:center;
}
.dino-name{
  margin:.1em 0 0;font-size:clamp(1.5rem, 5vw, 2.2rem);font-weight:900;
  text-shadow:0 2px 0 #f0c14b;
}
.say-name{font-weight:800;color:#6a4a22;margin:.15em 0 .4em;font-size:1.1rem}
.fact-art{display:flex;justify-content:center}
#factDino{width:min(320px, 80%);height:auto;max-height:32vh;object-fit:contain;filter:drop-shadow(0 10px 10px rgba(40,24,8,.2))}
.fact-bits{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:8px}
.bit{
  background:#fff;border:3px solid #3a2614;border-radius:18px;padding:8px 8px 6px;
  display:flex;flex-direction:column;align-items:center;gap:4px;
}
.bit p{margin:0;font-weight:800;font-size:1.02rem;line-height:1.25}
.diet-art,.size-art{width:100%;min-height:78px;display:flex;align-items:center;justify-content:center;gap:6px}
.diet-art img{height:86px;width:auto;max-width:92%;object-fit:contain;filter:drop-shadow(0 5px 6px rgba(40,24,8,.18))}
.choices button img{height:70px;width:auto;max-width:120px;display:block;margin:0 auto 4px;object-fit:contain;filter:drop-shadow(0 3px 4px rgba(40,24,8,.16))}
.size-art img{height:78px;width:auto;max-width:48%;object-fit:contain;background:transparent}
.diet-art svg, .size-art svg{width:86px;height:72px;overflow:visible}

/* ---------- quiz / race ask ---------- */
.quiz{
  min-height:calc(100dvh - 4.4rem);
  justify-content:center;padding:12px 0;
}
.quiz-card, .ask{
  width:min(560px, calc(100% - 20px));
  background:linear-gradient(#fffdf6,#f6e7c8);
  border:4px solid #3a2614;border-radius:26px;
  box-shadow:0 8px 0 #3a2614;
  padding:16px 14px 18px;text-align:center;
}
.quiz-art{min-height:90px;display:flex;align-items:center;justify-content:center;gap:16px;flex-wrap:wrap;margin:4px 0 10px}
.quiz-art img{height:120px;width:auto;max-width:42%;object-fit:contain;filter:drop-shadow(0 6px 6px rgba(40,24,8,.2))}
.choices{display:flex;flex-wrap:wrap;gap:10px;justify-content:center}
.choices button{
  min-width:110px;min-height:72px;padding:8px 16px;border-radius:18px;
  border:4px solid #3a2614;background:#fff;font:900 1.2rem system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
  color:#3a2614;cursor:pointer;touch-action:manipulation;box-shadow:0 4px 0 #3a2614;
}
.choices button:hover,.choices button:focus-visible{background:#fff6d8}
.choices button.right{background:#c8f5e1;border-color:#1f5b34}
.choices button.wrong{background:#ffe1e1;animation:wob .4s}
.choices button .who{display:block;font-size:.95rem}
.ask-back{
  position:fixed;inset:0;background:rgba(40,24,8,.45);
  display:flex;align-items:center;justify-content:center;z-index:40;padding:16px;
}
.ask-back[hidden]{display:none!important}

/* ---------- race ---------- */
.race{background:#c9b07a;padding-bottom:8px}
.race .stage{background:#8aa85a}

/* motion */
@media (prefers-reduced-motion:reduce){
  #aliveDino.wake,#aliveDino.breathe,.choices button.wrong{animation:none}
  .btn:active,.lev{transition:none}
}

/* phone */
@media (max-width:799px){
  .dig .hint,.build .hint,.race .hint{margin:8px 12px 6px}
  .dig .row,.build .row,.race .row{margin:6px 10px 14px}
  .title{min-height:calc(100dvh - 4.6rem);justify-content:flex-end;background-position:center 40%}
  .title-panel{margin-bottom:8px;padding:10px 10px 12px;border-radius:22px}
  .title h1{font-size:1.7rem}
  .lead{font-size:.98rem;margin:.1em 0 .35em}
  .lev{min-height:60px;padding:8px 12px}
  .lev b{font-size:1.15rem}
  .lev small{font-size:.85rem}
  .title-row .btn{min-height:48px;padding:8px 14px}
  .fact-bits{grid-template-columns:1fr 1fr; }
  #factDino{max-height:22vh}
  .dino-name{font-size:1.45rem}
  .shelf{grid-template-columns:repeat(2,1fr)}
  .alive-stage{aspect-ratio:4/3}
  .stage canvas{border-radius:16px}
  .caption{font-size:.95rem;margin:4px 10px;max-height:2.5em;overflow:hidden}
  .fact{padding:4px 0 8px}
  .fact-card{padding:10px 10px 12px}
  .hello{font-size:1.15rem;margin:8px 12px 0;padding:6px 12px}
}

@media (min-width:800px){
  .title{justify-content:center;align-items:flex-end;min-height:calc(100dvh - 5.5rem);background-position:center 68%}
  .title-panel{margin:0 28px 32px auto}
  .fact-art #factDino{max-height:38vh}
}

@keyframes wob{0%,100%{transform:translateX(0)}25%{transform:translateX(-7px)}75%{transform:translateX(7px)}}
@keyframes popin{from{transform:scale(.7);opacity:.3}to{transform:scale(1);opacity:1}}

body.g-title .caption{display:none}
body.g-dig .caption, body.g-build .caption, body.g-alive .caption,
body.g-quiz .caption, body.g-race .caption, body.g-fact .caption,
body.g-museum .caption{display:none}
body.g-title .site-footer{display:none}
body.g-dig .site-footer, body.g-build .site-footer, body.g-alive .site-footer, body.g-quiz .site-footer, body.g-race .site-footer, body.g-fact .site-footer, body.g-museum .site-footer{display:none}


/* ---------- viewport fit: never taller than the visible screen ---------- */
.title,.museum,.dig,.build,.race,.alive,.fact,.quiz{
  min-height:0 !important;
  max-height:100%;
  overflow:hidden;
}
.play{
  flex:1 1 0;
  min-height:0;
  width:100%;
  display:flex;
  flex-direction:column;
  align-items:stretch;
}
.play .stage{
  flex:1 1 0;
  width:auto;
  min-width:0;
  min-height:0;
  margin:4px 10px;
}
.dock{
  flex:0 0 auto;
  display:flex;
  flex-direction:column;
  align-items:center;
  width:100%;
}
.dock .hint{margin:4px 12px}
.dock .row{margin:4px 10px 8px}
.callout{
  position:absolute;left:50%;bottom:12%;
  transform:translateX(-50%);
  z-index:3;margin:0;pointer-events:none;
  background:rgba(255,248,230,.96);
  border:3px solid #3a2614;border-radius:18px;
  padding:8px 16px;font-weight:900;font-size:1.05rem;
  box-shadow:0 4px 0 #3a2614;
  max-width:calc(100% - 24px);
  text-align:center;
}
.callout.pop{animation:popin .45s ease}
.museum .panel{
  flex:1 1 auto;min-height:0;max-height:100%;
  display:flex;flex-direction:column;
  overflow:hidden;
}
.museum .shelf{flex:1 1 auto;min-height:0;overflow:auto;overscroll-behavior:contain}
.alive{display:flex;flex-direction:column}
.alive-stage{flex:1 1 0;min-height:0;max-height:100%}
.fact,.quiz{overflow:hidden}

/* Landscape or short tablet: instruction pill and buttons sit beside the stage */
@media (orientation:landscape) and (max-height:820px){
  .play{
    flex-direction:row;
    align-items:stretch;
    padding:0 8px 6px;
    gap:8px;
  }
  .play .stage{
    flex:1 1 0;
    margin:0;
    max-height:100%;
  }
  .dock{
    flex:0 0 auto;
    width:min(280px, 34%);
    max-width:320px;
    justify-content:center;
    gap:8px;
    padding:0 4px 0 0;
  }
  .dock .hint{
    margin:0;
    max-width:100%;
    font-size:.95rem;
    padding:8px 10px;
  }
  .dock .row{
    margin:0;
    flex-direction:column;
    width:100%;
  }
  .dock .row .btn{width:100%}
  .dig .hud,.build .hud,.race .hud{margin:2px 8px 4px;padding:4px 8px}
  .hud-title{font-size:1.02rem}
  .bar{min-width:80px;flex-basis:80px}
}

/* Short viewports (Safari toolbars, iPad landscape ~700px, 1024x650) */
@media (max-height:750px){
  body[data-game="dino-dig-lab"] .site-header{
    padding:4px 10px;min-height:0;
  }
  body[data-game="dino-dig-lab"] .site-header .brand{min-height:44px;font-size:1rem;gap:8px}
  body[data-game="dino-dig-lab"] .site-header .brand img{width:32px;height:32px}
  body[data-game="dino-dig-lab"] .site-header .btn.icon{width:44px;min-width:44px;min-height:44px}
  .btn{min-height:48px;padding:8px 16px}
  .title-panel{padding:10px 12px 12px;margin:0 auto 8px}
  .title h1{font-size:clamp(1.4rem, 4.5vh, 2rem)}
  .lev{min-height:52px;padding:6px 12px}
  .lev b{font-size:1.1rem}
  .lev small{font-size:.8rem}
  .lead{font-size:1rem;margin:.08em 0 .3em}
  .title-row{margin-top:8px}
  .hello{margin:6px 12px 0;padding:6px 12px;font-size:clamp(1.1rem, 3.5vh, 1.6rem)}
  .fact-card,.quiz-card{padding:8px 10px 10px}
  #factDino{max-height:22vh}
  .quiz-art img{height:80px}
  .diet-art,.size-art{min-height:54px}
  .diet-art img{height:56px}
  .size-art img{height:52px}
  .slot{min-height:110px}
  .slot img{height:72px}
  .museum{padding:4px 0 8px}
  .panel{padding:8px 10px 10px;margin:4px auto}
}

@media (max-height:660px){
  .hud{margin:2px auto;padding:3px 6px;gap:4px 8px}
  .hud-title{font-size:.95rem}
  .pill{min-height:32px;padding:2px 10px;font-size:.9rem}
  .bar{height:12px;min-width:60px}
  .dock .hint{font-size:.88rem;padding:6px 8px}
  .btn{min-height:44px;padding:6px 14px;font-size:1rem}
  .title-panel{padding:8px 10px}
  .lev{min-height:44px;padding:4px 10px}
  .fact-bits{gap:6px}
  #factDino{max-height:18vh}
  .alive-stage{margin-top:2px}
}

@media (orientation:landscape) and (max-height:500px){
  .fact{flex-direction:row;align-items:stretch;justify-content:center;padding:4px 8px 6px;gap:8px}
  .fact-card{
    flex:1 1 0;min-width:0;min-height:0;max-height:100%;
    width:auto;margin:0;padding:6px 8px;
    display:flex;flex-direction:column;overflow:hidden;
  }
  .fact-art{flex:1 1 0;min-height:0}
  #factDino{max-height:100%;height:100%;width:auto}
  .dino-name{font-size:1.15rem;margin:0}
  .say-name{font-size:.9rem;margin:0 0 4px}
  .fact-bits{margin-top:4px;gap:6px}
  .bit{padding:4px}
  .bit p{font-size:.9rem}
  .diet-art,.size-art{min-height:28px}
  .diet-art img,.size-art img{height:32px}
  .fact .row{flex-direction:column;justify-content:center;margin:0;gap:6px}
  .quiz-card{padding:6px 8px;max-height:100%;overflow:hidden}
  .quiz-art img{height:56px}
  .q{font-size:1.1rem;margin:.1em 0 .3em}
  .hello{margin:4px 8px 0;padding:4px 10px}
}
