:root{
  --ink:#0d1b1a;
  --paper:#f4f7ec;
  --gold:#ffd45e;
  --gold-deep:#f0a92b;
  --leaf:#3f7d4e;
  --leaf-dark:#28543a;
  --danger:#ff6b6b;
  --sky-top:#8ed6ff;
  --sky-mid:#bdeaff;
  --sky-low:#e9f7d6;
}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{
  font-family:"Trebuchet MS","Segoe UI",system-ui,sans-serif;
  background:#0d1b1a;
  color:var(--paper);
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
}
#app{position:relative;width:100%;height:100%;overflow:hidden}
#sky{position:absolute;inset:0;width:100%;height:100%;display:block}

/* ---- HUD lives along the bottom of the screen ---- */
#hud{
  position:absolute;left:0;right:0;bottom:0;
  display:flex;gap:8px;align-items:stretch;justify-content:center;
  padding:12px 12px calc(12px + env(safe-area-inset-bottom));
  flex-wrap:wrap;
  pointer-events:none;z-index:5;
}
.hud-box{
  background:rgba(13,27,26,.62);
  border:1px solid rgba(255,255,255,.16);
  border-radius:12px;
  padding:6px 14px;
  min-width:74px;
  text-align:center;
  backdrop-filter:blur(6px);
  box-shadow:0 6px 18px rgba(0,0,0,.25);
}
.hud-box .label{
  display:block;font-size:10px;letter-spacing:.18em;text-transform:uppercase;
  color:#bfe3d2;opacity:.85
}
.hud-box .value{display:block;font-size:20px;font-weight:700;color:var(--gold);line-height:1.15}
.hud-box.danger .value{color:var(--danger)}
.hud-box.miss .value{color:#ff9f68}
.hud-box.hawkbox .value{color:#c9b6ff}
.hud-box.pop{animation:pop .28s ease}
@keyframes pop{0%{transform:scale(1)}40%{transform:scale(1.18)}100%{transform:scale(1)}}

#wordPanel{
  position:absolute;top:76px;left:50%;transform:translateX(-50%);
  z-index:6;text-align:center;pointer-events:none;
  background:rgba(13,27,26,.55);
  border:1px solid rgba(255,212,94,.35);
  border-radius:16px;padding:10px 22px 12px;
  backdrop-filter:blur(6px);
  transition:opacity .25s;
  max-width:92vw;
}
#wordPanel.hidden{opacity:0;visibility:hidden}
.word-title{font-size:10px;letter-spacing:.32em;color:var(--gold);opacity:.9;margin-bottom:6px}
.boss-word{
  font-size:clamp(20px,4.6vw,38px);font-weight:800;letter-spacing:.12em;
  color:#fff;text-shadow:0 3px 0 rgba(0,0,0,.35);
  font-family:Georgia,"Times New Roman",serif;
  word-break:break-word;
}
.boss-word .ch{display:inline-block;transition:color .12s,transform .12s}
.boss-word .ch.done{color:var(--leaf)}
.boss-word .ch.cur{color:var(--gold);transform:translateY(-3px) scale(1.1)}
.boss-word .ch.bad{color:var(--danger)}
.boss-tries{margin-top:6px;font-size:12px;letter-spacing:.14em;color:#ffd9d9}
.boss-hint{margin-top:4px;font-size:12px;color:#d8ece0;opacity:.9}

/* ---- Hawk warning panel ---- */
#hawkPanel{
  position:absolute;top:76px;left:50%;transform:translateX(-50%);
  z-index:7;text-align:center;pointer-events:none;
  background:rgba(30,18,44,.68);
  border:1px solid rgba(201,182,255,.55);
  border-radius:16px;padding:8px 20px 10px;
  backdrop-filter:blur(6px);
  transition:opacity .25s;
  max-width:92vw;
  box-shadow:0 10px 34px rgba(0,0,0,.45);
}
#hawkPanel.hidden{opacity:0;visibility:hidden}
.hawk-kicker{font-size:10px;letter-spacing:.32em;color:#c9b6ff;opacity:.95;margin-bottom:4px}
.hawk-letter{
  font-family:Georgia,"Times New Roman",serif;
  font-size:clamp(24px,5vw,40px);font-weight:800;letter-spacing:.1em;
  color:#fff;text-shadow:0 3px 0 rgba(0,0,0,.4);
}
.hawk-warn{margin-top:2px;font-size:11px;letter-spacing:.06em;color:#ffd0d0}
#hawkPanel.alarm{animation:hawkAlarm .7s ease-in-out infinite}
@keyframes hawkAlarm{
  0%,100%{box-shadow:0 10px 34px rgba(0,0,0,.45)}
  50%{box-shadow:0 10px 40px rgba(201,182,255,.75)}
}

/* ---- Level sign (LEVEL CLEARED / BOSS LEVEL) ---- */
#sign{
  position:absolute;inset:0;z-index:14;
  display:flex;align-items:center;justify-content:center;
  pointer-events:none;
  opacity:1;transition:opacity .28s;
}
#sign.hidden{opacity:0;visibility:hidden}
#sign::before{
  content:"";position:absolute;inset:0;
  background:radial-gradient(circle at 50% 50%,rgba(10,28,26,.55),rgba(6,16,16,.78));
  opacity:0;transition:opacity .25s;
}
#sign.show::before{opacity:1}
.sign-inner{
  position:relative;text-align:center;
  padding:22px 34px;border-radius:22px;
  background:linear-gradient(180deg,rgba(23,50,44,.92),rgba(15,33,31,.92));
  border:2px solid rgba(255,212,94,.5);
  box-shadow:0 20px 60px rgba(0,0,0,.5), inset 0 0 40px rgba(255,212,94,.08);
  transform:scale(.7);opacity:0;
  transition:transform .35s cubic-bezier(.2,1.4,.4,1), opacity .25s;
}
#sign.show .sign-inner{transform:scale(1);opacity:1}
.sign-sub{
  font-size:12px;letter-spacing:.4em;color:#bfe3d2;margin-bottom:8px;
}
.sign-main{
  font-family:Georgia,"Times New Roman",serif;
  font-weight:800;letter-spacing:.06em;
  font-size:clamp(26px,7vw,58px);
  color:var(--gold);
  text-shadow:0 4px 0 rgba(0,0,0,.4), 0 0 24px rgba(255,212,94,.35);
}
#sign.boss .sign-inner{
  border-color:rgba(255,120,120,.55);
  box-shadow:0 20px 60px rgba(0,0,0,.5), inset 0 0 40px rgba(255,90,90,.1);
}
#sign.boss .sign-main{
  color:#ff8a8a;
  text-shadow:0 4px 0 rgba(0,0,0,.45), 0 0 26px rgba(255,90,90,.45);
}
#sign.flash .sign-inner{animation:signFlash .45s steps(1,end) infinite}
@keyframes signFlash{
  0%{filter:brightness(1)}
  50%{filter:brightness(2.1) saturate(1.4)}
  100%{filter:brightness(1)}
}

.overlay{
  position:absolute;inset:0;z-index:20;
  display:flex;align-items:center;justify-content:center;
  background:radial-gradient(circle at 50% 40%,rgba(20,60,70,.35),rgba(6,16,16,.82));
  backdrop-filter:blur(3px);
  transition:opacity .3s;
  overflow:auto;
  padding:16px 0;
}
.overlay.hidden{opacity:0;pointer-events:none;visibility:hidden}
.card{
  width:min(560px,94vw);
  max-height:96vh;
  overflow:auto;
  background:linear-gradient(180deg,#17322c,#0f211f);
  border:1px solid rgba(255,212,94,.28);
  border-radius:20px;
  padding:26px 28px 22px;
  text-align:center;
  box-shadow:0 24px 60px rgba(0,0,0,.55);
}
.brand{margin-bottom:10px}
.brand-kicker{
  display:inline-block;font-size:10px;letter-spacing:.42em;
  color:#bfe3d2;opacity:.8;margin-bottom:8px;
}
.card h1{
  font-family:Georgia,"Times New Roman",serif;
  font-size:clamp(26px,5.4vw,40px);color:var(--gold);
  letter-spacing:.02em;margin-bottom:10px;
}
.card p{font-size:15px;line-height:1.55;color:#dcefe2;margin-bottom:18px}
.card p b{color:#fff}
.card p code{
  background:rgba(255,255,255,.1);padding:1px 6px;border-radius:6px;
  font-family:ui-monospace,Menlo,Consolas,monospace;font-size:13px;color:#ffe9ad;
}

/* ---- Stage picker on the start screen ---- */
.stage-picker{
  border-top:1px solid rgba(255,255,255,.1);
  border-bottom:1px solid rgba(255,255,255,.1);
  padding:14px 0 16px;margin-bottom:16px;
}
.stage-picker-label{
  font-size:10px;letter-spacing:.3em;text-transform:uppercase;
  color:#bfe3d2;opacity:.8;margin-bottom:10px;
}
.stage-row{
  display:flex;gap:8px;justify-content:center;flex-wrap:wrap;
}
.stage{
  font:inherit;cursor:pointer;
  width:108px;
  background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.14);
  border-radius:14px;
  padding:10px 6px 9px;
  color:var(--paper);
  display:flex;flex-direction:column;align-items:center;gap:4px;
  transition:transform .14s, background .14s, border-color .14s, box-shadow .14s;
}
.stage:hover{transform:translateY(-3px);background:rgba(255,255,255,.1)}
.stage:focus-visible{outline:3px solid #fff8d8;outline-offset:2px}
.stage.selected{
  background:linear-gradient(180deg,rgba(255,212,94,.22),rgba(240,169,43,.1));
  border-color:var(--gold);
  box-shadow:0 0 0 1px rgba(255,212,94,.4), 0 10px 22px rgba(0,0,0,.35);
}
.stage-name{font-size:14px;font-weight:700;letter-spacing:.03em}
.stage-speed{font-size:10px;letter-spacing:.08em;color:#a9cfc0}
.stage.selected .stage-speed{color:#ffe9ad}
.stage-art{
  width:52px;height:40px;display:block;
  background-repeat:no-repeat;background-position:center;background-size:contain;
}
/* inline SVG art for each growth stage */
.stage-art[data-art="tadpole"]{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 48'><ellipse cx='30' cy='24' rx='15' ry='10' fill='%232b6b3c'/><circle cx='43' cy='24' r='9' fill='%233c8a49'/><circle cx='47' cy='21' r='2.6' fill='%23fff'/><circle cx='48' cy='21' r='1.4' fill='%23122219'/><path d='M15 24 q-9 -7 -12 -1 q3 6 12 1z' fill='%232b6b3c'/><circle cx='26' cy='21' r='1.8' fill='%23ffd45e'/></svg>");
}
.stage-art[data-art="polywog"]{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 48'><ellipse cx='30' cy='26' rx='17' ry='12' fill='%233c8a49'/><circle cx='47' cy='24' r='11' fill='%23499b52'/><circle cx='51' cy='21' r='2.8' fill='%23fff'/><circle cx='52' cy='21' r='1.5' fill='%23122219'/><path d='M13 26 q-11 -6 -14 0 q4 6 14 0z' fill='%233c8a49'/><circle cx='22' cy='22' r='2' fill='%236fd06a'/><circle cx='36' cy='24' r='2' fill='%236fd06a'/></svg>");
}
.stage-art[data-art="frog"]{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 48'><ellipse cx='32' cy='30' rx='20' ry='13' fill='%2359a24a'/><circle cx='18' cy='16' r='9' fill='%238fd36a'/><circle cx='46' cy='16' r='9' fill='%238fd36a'/><circle cx='18' cy='16' r='4' fill='%23fff'/><circle cx='46' cy='16' r='4' fill='%23fff'/><circle cx='19' cy='16' r='2.2' fill='%23122219'/><circle cx='47' cy='16' r='2.2' fill='%23122219'/><path d='M22 31 q10 7 20 0' stroke='%232b6b3c' stroke-width='2.4' fill='none' stroke-linecap='round'/></svg>");
}
.stage-art[data-art="bullfrog"]{
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 48'><ellipse cx='32' cy='30' rx='22' ry='15' fill='%236f9c3a'/><circle cx='16' cy='15' r='10' fill='%23a9cf52'/><circle cx='48' cy='15' r='10' fill='%23a9cf52'/><circle cx='16' cy='15' r='4.4' fill='%23fff'/><circle cx='48' cy='15' r='4.4' fill='%23fff'/><circle cx='17' cy='15' r='2.4' fill='%23122219'/><circle cx='49' cy='15' r='2.4' fill='%23122219'/><path d='M20 32 q12 9 24 0' stroke='%233f6b22' stroke-width='3' fill='none' stroke-linecap='round'/><path d='M10 26 q-6 4 -3 9' stroke='%235a8a30' stroke-width='2.4' fill='none' stroke-linecap='round'/></svg>");
}

/* ---- Share row on the start screen ---- */
.share-row{
  display:flex;align-items:center;justify-content:center;gap:10px;flex-wrap:wrap;
  margin-bottom:14px;
}
.btn-ghost{
  font-size:13px;padding:8px 16px;border-radius:999px;
  color:var(--gold);background:rgba(255,212,94,.12);
  border:1px solid rgba(255,212,94,.45);
  box-shadow:none;
}
.btn-ghost:hover{background:rgba(255,212,94,.22);box-shadow:none}
.btn-ghost.done{color:#0d1b1a;background:linear-gradient(180deg,#9fe08a,#5fbf52);border-color:#9fe08a}
.share-note{font-size:12px;color:#9fc4b4}

.ov-stats{
  display:flex;gap:10px;justify-content:center;flex-wrap:wrap;margin-bottom:16px;
  font-size:13px;color:#bfe3d2
}
.ov-stats span{background:rgba(255,255,255,.07);padding:5px 12px;border-radius:999px}
.ov-actions{
  display:flex;gap:10px;justify-content:center;align-items:center;flex-wrap:wrap;
}
.btn{
  font:inherit;font-weight:700;font-size:17px;letter-spacing:.04em;
  color:#20301c;background:linear-gradient(180deg,var(--gold),var(--gold-deep));
  border:none;border-radius:999px;padding:12px 30px;cursor:pointer;
  box-shadow:0 8px 20px rgba(240,169,43,.35);
  transition:transform .12s,box-shadow .12s;
  position:relative;z-index:1;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
.btn:hover{transform:translateY(-2px);box-shadow:0 12px 26px rgba(240,169,43,.45)}
.btn:active{transform:translateY(1px)}
.btn:focus-visible{outline:3px solid #fff8d8;outline-offset:3px}
.tip{margin-top:12px;font-size:12px;color:#9fc4b4}

@media (max-width:520px){
  .hud-box{min-width:60px;padding:5px 10px}
  .hud-box .value{font-size:17px}
  #wordPanel{top:18px;padding:8px 14px}
  #hawkPanel{top:18px;padding:6px 12px}
  .sign-inner{padding:16px 22px}
  .toast{bottom:26%}
  .card{padding:20px 18px 18px}
  .stage{width:calc(50% - 6px)}
  .ov-actions{gap:8px}
  .share-row{flex-direction:column;gap:6px}
}
@media (max-height:520px){
  #wordPanel{top:14px}
  #hawkPanel{top:14px}
  .stage-art{width:42px;height:32px}
}