/* ==========================================================================
   SCORCHFALL v3 — full-bleed stage, responsive HUD/dock, ad slots, ads UI.
   ========================================================================== */
:root {
  --ink: #170c05;
  --line: rgba(255, 190, 110, .22);
  --amber: #ffb43a;
  --gold: #ffe08a;
  --text: #ffe9c9;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex; flex-direction: column;
  background: #120a04;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}
button { font-family: inherit; border: 0; cursor: pointer; color: inherit; background: none; }

/* ------------------------------------------------------------ ad banners -- */
.ad-slot {
  position: relative;
  flex: 0 0 auto;
  min-height: 22px;
  max-height: 30px;
  height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 0;
  overflow: hidden;
  z-index: 20;
}
.ad-slot::after { content: none; }
.ad-slot[data-ad-status="off"]::before {
  content: "AD SLOT DISABLED";
  font-size: 10px; letter-spacing: .2em; color: rgba(255, 220, 160, .3);
}
.ad-slot.ad-loading::before { content: "LOADING AD…"; font-size: 10px; letter-spacing: .2em; color: rgba(255, 220, 160, .4); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }

/* ------------------------------------------------------- full-bleed stage -- */
#app { flex: 1 1 auto; min-height: 0; position: relative; }
#stage {
  position: absolute; inset: 0;
  overflow: hidden;
  touch-action: none;
  background: #6d4423;   /* dark: any sub-pixel seam reads as shadow, never a gap */
}
#world, #fx { position: absolute; inset: 0; width: 100%; height: 100%; }
#fx { pointer-events: none; z-index: 3; }
#storm-veil {
  /* v9.18: oversized + transform-animated = compositor-only (no fullscreen repaint).
     The old version animated background-position (repaint every frame) and a CSS
     filter sat on #world (re-filtered the whole canvas every frame) — that pair
     was the sandstorm lag. The desaturated look is baked into canvas draws now. */
  position: absolute; inset: -30px -110px; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 1.1s;
  background:
    repeating-linear-gradient(100deg, rgba(226,178,108,.16) 0 3px, transparent 3px 17px),
    linear-gradient(rgba(150,92,34,.34), rgba(120,70,24,.46));
  will-change: transform;
}
#stage.storming #storm-veil { opacity: 1; animation: veilMove .5s linear infinite; }
@keyframes veilMove { from { transform: translate3d(0,0,0); } to { transform: translate3d(-90px,14px,0); } }
#stage.blessed::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 4;
  box-shadow: inset 0 0 70px rgba(255, 210, 90, .35);
  animation: blessPulse 1.6s infinite;
}
@keyframes blessPulse { 50% { box-shadow: inset 0 0 110px rgba(255, 210, 90, .5); } }

/* ------------------------------------------------------------------- HUD -- */
#hud { position: absolute; top: 0; left: 0; right: 0; z-index: 5; padding: 8px 10px 6px; pointer-events: none; background: linear-gradient(rgba(20,9,3,.55), transparent); }
#hud .hud-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.res { display: flex; align-items: center; gap: 5px; }
.res-plus {                       /* v9.22: watch-ad (+) on water / gold / food chips */
  flex: none; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%;
  background: linear-gradient(#ffd76e, #e0912f); color: #4a2c08;
  font: 900 16px/20px system-ui, sans-serif; text-align: center; cursor: pointer;
  pointer-events: auto;            /* #hud is pointer-events:none — without this the + is dead */
  box-shadow: 0 1px 3px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.5), 0 0 0 1px #7a4a12;
}
.res-plus:hover { filter: brightness(1.15); }
.res-plus.cooling { filter: grayscale(.8) brightness(.7); pointer-events: none; opacity: .55; }
.res-plus:active { transform: scale(.88); }
.res .ico {
  display: grid; place-items: center; width: 23px; height: 23px; flex: none;
  font-size: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #7d6142, #4a3419 60%, #2c1d0c);
  box-shadow: inset 0 1px 0 rgba(255,230,180,.35), inset 0 -2px 3px rgba(0,0,0,.6),
    0 2px 4px rgba(0,0,0,.6), 0 0 0 1px #1c1106;
  text-shadow: 0 1px 2px rgba(0,0,0,.7);
}
.res b {
  font-size: 13.5px; font-weight: 900; color: #ffeccb;
  text-shadow: 0 1px 0 rgba(0,0,0,.9), 0 0 8px rgba(255,190,90,.25);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.res-water { flex: 1 1 140px; min-width: 110px; max-width: 340px; }
.bar {
  position: relative; height: 16px; border-radius: 9px; overflow: hidden;
  background: linear-gradient(#050200, #170b03 70%, #241206);
  box-shadow: inset 0 2px 5px rgba(0,0,0,.85), inset 0 0 0 1px rgba(0,0,0,.9),
    0 1px 0 rgba(255,220,160,.14);
  flex: 1 1 auto; border: 1px solid #1c1106;
}
.bar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, transparent 32%, rgba(255,255,255,.16) 46%, rgba(255,255,255,.05) 52%, transparent 64%);
  background-size: 260% 100%;
  animation: sheen 3.4s linear infinite;
}
@keyframes sheen { from { background-position: 130% 0; } to { background-position: -130% 0; } }
.bar i { position: absolute; inset: 0; transform-origin: left center; background: linear-gradient(#8fd8ff,#2f9df0 60%,#1877c9); border-radius: 9px; }
.bar i::after { content: ""; position: absolute; inset: 0 0 55% 0; background: linear-gradient(rgba(255,255,255,.55), rgba(255,255,255,0)); border-radius: 9px; }
.bar.low i { background: linear-gradient(#ff9d8a,#e33d2c 60%,#a81f12); animation: lowPulse .7s infinite; }
@keyframes lowPulse { 50% { filter: brightness(1.5); } }
.bar.pulse { animation: barPulse .5s; }
@keyframes barPulse { 30% { transform: scale(1.06); box-shadow: 0 0 24px rgba(255,220,120,.8); } }
.bar.shield { height: 9px; max-width: 220px; flex: 0 1 220px; }
.bar.shield i { background: linear-gradient(#b8ffe9,#25c9a8 60%,#128f77); }
.hud-row2 { display: flex; align-items: center; gap: 8px; margin-top: 5px; }
.chip {
  position: relative;
  font-size: 11px; font-weight: 900; letter-spacing: .07em;
  color: #ffe9c0;
  background:
    radial-gradient(circle at 4px 50%, rgba(255,225,170,.5) 0 1.2px, rgba(0,0,0,.55) 1.6px, transparent 2.4px),
    radial-gradient(circle at calc(100% - 4px) 50%, rgba(255,225,170,.5) 0 1.2px, rgba(0,0,0,.55) 1.6px, transparent 2.4px),
    linear-gradient(#77593a, #4a3419 55%, #33220e);
  padding: 5px 13px; border-radius: 8px;
  border: 1px solid #1c1106;
  box-shadow: inset 0 1px 0 rgba(255,230,180,.35), inset 0 -2px 4px rgba(0,0,0,.55), 0 2px 5px rgba(0,0,0,.55);
  text-shadow: 0 1px 0 rgba(0,0,0,.85);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
#wall-chip.hurt { color: #ffb1a6; box-shadow: inset 0 0 0 1px rgba(255,110,90,.7); }
#wave-chip.warn { color: #ffd27a; box-shadow: inset 0 0 0 1px rgba(255,200,90,.6); }
#wave-chip.danger { color: #ffb1a6; background: rgba(90,15,8,.8); box-shadow: inset 0 0 0 1px rgba(255,110,90,.7); animation: blink .8s infinite; }
#wave-chip.raid { color: #ffd0c0; background: rgba(120,20,10,.85); box-shadow: inset 0 0 0 1px rgba(255,90,60,.8); animation: blink .6s infinite; }
.hud-btns { display: flex; gap: 6px; pointer-events: auto; margin-left: auto; }
.hud-btns button, #zoom-ctl button {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid #1c1106;
  background: linear-gradient(#8a6a44, #5d4426 48%, #3a2913);
  box-shadow: inset 0 1px 0 rgba(255,232,180,.45), inset 0 -3px 5px rgba(0,0,0,.55), 0 3px 7px rgba(0,0,0,.6);
  color: #ffe9c0; font-size: 15px; line-height: 1; cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,.85);
  transition: transform .07s ease, box-shadow .07s ease, filter .15s ease;
  pointer-events: auto;
}
.hud-btns button:hover, #zoom-ctl button:hover { filter: brightness(1.18); }
.hud-btns button:active, #zoom-ctl button:active {
  transform: translateY(1px) scale(.95);
  box-shadow: inset 0 2px 7px rgba(0,0,0,.7), 0 1px 2px rgba(0,0,0,.5);
}
#zoom-ctl {
  position: absolute; right: 10px; top: 78px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px; pointer-events: auto;
}
#zoom-ctl button { width: 36px; height: 32px; font-size: 16px; font-weight: 900; }
.hud-btns button { width: 28px; height: 28px; border-radius: 9px; font-size: 13px; background: rgba(10,5,2,.7); box-shadow: inset 0 0 0 1px var(--line); }
#btn-ads { width: auto; padding: 0 8px; font-size: 9px; font-weight: 900; letter-spacing: .12em; color: #ffd27a; }
#blessing-chip {
  position: absolute; top: 66px; left: 50%; transform: translate(-50%,-8px);
  background: linear-gradient(#ffdf8e,#ffab34); color: #4a2408;
  font-size: 11px; font-weight: 900; letter-spacing: .1em;
  padding: 4px 12px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(255,170,50,.5);
  opacity: 0; transition: .25s; pointer-events: none;
}
#blessing-chip.on { opacity: 1; transform: translate(-50%,0); }

/* banners: storm / raid / drought */
#storm-banner, #raid-banner {
  position: absolute; top: 96px; left: 50%; transform: translate(-50%,-16px);
  z-index: 6; pointer-events: none;
  font-weight: 900; font-size: 14px; letter-spacing: .1em;
  padding: 8px 18px; border-radius: 12px;
  opacity: 0; transition: .3s; white-space: nowrap;
}
#storm-banner { background: linear-gradient(#5c1c10,#3c0f08); color: #ffd9c9; box-shadow: 0 0 0 1px rgba(255,120,80,.5), 0 8px 24px rgba(0,0,0,.5); }
#raid-banner { top: 132px; background: linear-gradient(#7a1408,#4a0c04); color: #ffd0c0; box-shadow: 0 0 0 1px rgba(255,90,60,.6), 0 8px 24px rgba(0,0,0,.5); }
#storm-banner.on, #raid-banner.on { opacity: 1; transform: translate(-50%,0); }
#storm-banner.warn { animation: warnShake .5s infinite; }
@keyframes warnShake { 25% { transform: translate(-52%,0); } 75% { transform: translate(-48%,0); } }
#drought {
  position: absolute; inset: 0; z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(120,10,0,.45));
  opacity: 0; transition: .3s;
}
#drought.on { opacity: 1; }
#drought::before { content: "☠ DROUGHT"; font-size: 26px; font-weight: 900; letter-spacing: .18em; color: #ff8d7a; text-shadow: 0 3px 14px rgba(0,0,0,.8); }
#drought b { font-size: 40px; font-weight: 900; color: #fff; text-shadow: 0 0 24px rgba(255,60,30,.9); }
#drought::after { content: "PUMP WATER NOW"; font-size: 11px; letter-spacing: .2em; color: #ffc9b8; }
#drought.hunger { background: radial-gradient(ellipse at center, transparent 40%, rgba(90,40,0,.5)); }
#drought.hunger::before { content: "☠ STARVING"; color: #ffc07a; }
#drought.hunger::after { content: "FEED THE CAMP — UPGRADE THE FARM OR TAP +"; color: #ffe0b8; }
.res-food.low b { color: #ff9d8a; }

/* ------------------------------------------------------------------ dock -- */
#dock {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 8px 10px 8px;
  background: linear-gradient(transparent, rgba(16,8,3,.82) 34%);
}
#dock .dock-row { display: flex; gap: 8px; align-items: stretch; }
#dock .cards {
  display: flex; gap: 6px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; scroll-snap-type: x proximity;
  scrollbar-width: thin; scrollbar-color: rgba(255,190,110,.4) transparent;
  padding: 2px 2px 4px;
}
#dock .cards::-webkit-scrollbar { height: 4px; }
#dock .cards::-webkit-scrollbar-thumb { background: rgba(255,190,110,.35); border-radius: 4px; }
.card {
  position: relative; flex: 0 0 76px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 2px 5px;
  background: linear-gradient(#3a2410,#241408);
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--line), 0 3px 0 rgba(0,0,0,.45);
  transition: transform .12s;
}
.card:active { transform: scale(.94); }
.card .c-ico { font-size: 18px; line-height: 1.1; filter: drop-shadow(0 2px 3px rgba(0,0,0,.5)); }
.card .c-name { font-size: 7.5px; font-weight: 800; letter-spacing: .08em; color: rgba(255,230,190,.75); }
.card .c-lvl { font-size: 9px; font-weight: 900; color: #ffd27a; }
.card .c-cost { font-size: 9.5px; font-weight: 900; color: #c9a075; background: rgba(0,0,0,.35); padding: 2px 7px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.card.can { box-shadow: inset 0 0 0 1.5px rgba(255,210,100,.85), 0 3px 0 rgba(0,0,0,.45), 0 0 18px rgba(255,190,60,.35); }
.card.can .c-cost { color: #ffe9ad; background: rgba(120,70,10,.6); }
.card.can .c-ico { animation: bob 1s infinite; }
@keyframes bob { 50% { transform: translateY(-3px); } }
.card.max { opacity: .55; }
#btn-bless {
  position: relative; flex: 0 0 150px;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 14px;
  background: linear-gradient(#ffd76e,#ff9a2a 70%,#f07f16);
  color: #3d1d07; font-weight: 900; font-size: 12.5px; letter-spacing: .08em;
  box-shadow: 0 4px 0 #a3541a, 0 8px 26px rgba(255,150,40,.4);
  overflow: hidden;
}
#btn-bless small { font-size: 8.5px; font-weight: 800; letter-spacing: .12em; opacity: .75; background: rgba(255,255,255,.35); padding: 3px 7px; border-radius: 999px; }
#btn-bless::after { content: ""; position: absolute; top: 0; bottom: 0; width: 40%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent); animation: sheen 2.6s infinite; }
@keyframes sheen { 0% { left: -50%; } 60%, 100% { left: 120%; } }
#btn-bless:active { transform: translateY(2px); box-shadow: 0 2px 0 #a3541a; }
#btn-bless.active { filter: grayscale(.4) brightness(.9); }
/* v9.14: rewarded-ad cooldown — button visibly counts down (CrazyGames ad-limit friendly) */
#btn-bless.cooling { filter: grayscale(.8) brightness(.7); pointer-events: none; }
#btn-bless.cooling small { background: rgba(0,0,0,.55); color: #ffe9c0; }
/* v9.14: CONTINUE is a quiet secondary pill, never a giant primary CTA */
#btn-continue {
  width: auto; padding: 9px 18px; font-size: 11px; letter-spacing: .12em; border-radius: 999px;
  background: rgba(28,15,6,.78); color: #ffd9a0; border: 1px solid rgba(255,190,110,.5);
  box-shadow: 0 2px 0 rgba(0,0,0,.45);
}
#btn-continue:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,.45); }
#quest-chip {
  position: absolute; bottom: calc(100% - 8px); left: 12px;
  background: rgba(15,8,3,.8); color: #ffe6bd;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  padding: 5px 12px; border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(255,210,110,.4);
  opacity: 0; transition: .2s; pointer-events: none; white-space: nowrap;
  max-width: 46vw; overflow: hidden; text-overflow: ellipsis;
}
#quest-chip.on { opacity: 1; }
#boss-bar {
  position: absolute; top: 88px; left: 50%; transform: translate(-50%,-10px);
  z-index: 6; display: flex; align-items: center; gap: 8px;
  background: rgba(40,6,2,.85); padding: 6px 12px; border-radius: 12px;
  box-shadow: 0 0 0 1px rgba(255,90,60,.6), 0 8px 24px rgba(0,0,0,.5);
  opacity: 0; transition: .3s; pointer-events: none;
}
#boss-bar.on { opacity: 1; transform: translate(-50%,0); }
#boss-bar span { font-size: 11px; font-weight: 900; letter-spacing: .1em; color: #ffd0c0; white-space: nowrap; }
#boss-bar .bb { width: min(240px, 34vw); height: 10px; border-radius: 6px; background: rgba(0,0,0,.6); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.2); }
#boss-bar .bb i { display: block; height: 100%; transform-origin: left center; background: linear-gradient(#ff8d7a,#c22513); }
#hero-bar {
  position: absolute; right: 10px; bottom: 118px; z-index: 6;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-end;
}
.hbtn {
  position: relative; width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(#3a2410,#241408);
  box-shadow: inset 0 0 0 1px rgba(255,210,110,.5), 0 3px 0 rgba(0,0,0,.45);
  font-size: 20px; display: flex; align-items: center; justify-content: center;
}
.hbtn:disabled { opacity: .55; filter: grayscale(.5); }
.hbtn small { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 900; color: #fff; background: rgba(10,5,2,.55); border-radius: 12px; }
.hbtn small:empty { display: none; }
.hbtn.wide { width: auto; padding: 0 12px; gap: 7px; font-size: 16px; }
.hbtn.wide .hl { font-size: 9.5px; font-weight: 900; letter-spacing: .08em; color: #ffd88f; }
.hbtn.wide.can { box-shadow: inset 0 0 0 1.5px rgba(255,210,100,.9), 0 0 18px rgba(255,190,60,.4); animation: bob 1.2s infinite; }
#stage.warcry::after { box-shadow: inset 0 0 90px rgba(30,10,0,.45), inset 0 0 60px rgba(255,90,40,.35); }
#combo-chip {
  position: absolute; bottom: calc(100% - 8px); left: 50%; transform: translate(-50%,6px);
  background: linear-gradient(#ff8a3a,#e2571d);
  color: #fff; font-weight: 900; font-size: 13px; letter-spacing: .08em;
  padding: 5px 14px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(255,110,40,.55), inset 0 0 0 1px rgba(255,220,160,.5);
  opacity: 0; transition: .18s; pointer-events: none; white-space: nowrap;
}
#combo-chip.on { opacity: 1; transform: translate(-50%,0); }
#sun-num { display: inline-block; }
#sun-num.pop { animation: popNum .3s; }
@keyframes popNum { 30% { transform: scale(1.4); color: #fff; } }

/* -------------------------------------------------------------- overlays -- */
.ovl {
  position: absolute; inset: 0; z-index: 8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(12,6,2,.9);   /* no backdrop-filter: blurring a live canvas every frame = lag */
  padding: 24px; text-align: center;
}
.ovl.hidden { display: none; }
.ovl h1 {
  margin: 0; font-size: clamp(34px, 7vw, 58px); font-weight: 900; letter-spacing: .1em;
  color: #ffcf6e;
  text-shadow: 0 3px 0 #7a3c0c, 0 6px 0 #4a2408, 0 14px 34px rgba(0,0,0,.8);
}
.ovl h2 { margin: 0; font-size: 24px; font-weight: 900; letter-spacing: .12em; color: #ffd88f; text-shadow: 0 3px 12px rgba(0,0,0,.8); }
.ovl .sub { margin: -8px 0 0; font-size: 12px; letter-spacing: .3em; color: rgba(255,220,170,.8); }
.howto { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: rgba(255,236,205,.92); max-width: 560px; }
.howto span { background: rgba(0,0,0,.35); padding: 7px 12px; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); }
.big-btn {
  padding: 14px 40px; border-radius: 999px;
  background: linear-gradient(#ffd76e,#ff9a2a 70%,#f07f16);
  color: #3d1d07; font-size: 17px; font-weight: 900; letter-spacing: .12em;
  box-shadow: 0 5px 0 #a3541a, 0 12px 30px rgba(255,150,40,.45);
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #a3541a; }
.ghost-btn { padding: 11px 26px; border-radius: 999px; font-size: 13px; font-weight: 800; letter-spacing: .1em; background: rgba(255,255,255,.08); box-shadow: inset 0 0 0 1px rgba(255,220,160,.4); }
#menu-best, #over-best { font-size: 11px; letter-spacing: .2em; color: rgba(255,220,170,.7); }
#boon-cards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.boon-card {
  width: 128px; padding: 16px 10px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  background: linear-gradient(#41280f,#241408);
  box-shadow: inset 0 0 0 1px rgba(255,210,110,.4), 0 6px 0 rgba(0,0,0,.4);
  transition: transform .12s;
}
.boon-card:active { transform: scale(.94); }
.boon-card .b-ico { font-size: 30px; }
.boon-card b { font-size: 12px; font-weight: 900; color: #ffd88f; letter-spacing: .04em; }
.boon-card .b-desc { font-size: 10px; color: rgba(255,236,205,.8); }
#over-score { font-size: 52px; font-weight: 900; color: #fff; text-shadow: 0 0 30px rgba(255,180,60,.7); font-variant-numeric: tabular-nums; }
#over-stats { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: rgba(255,236,205,.9); }
#over-stats b { color: #ffd27a; }
#btn-revive { background: linear-gradient(#9df0dd,#25c9a8 70%,#12a184); box-shadow: 0 5px 0 #0a6b57, 0 12px 30px rgba(40,220,180,.4); color: #06382c; }

/* toasts + receipt */
#toasts { position: absolute; top: 120px; left: 0; right: 0; z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(15,8,3,.85); color: #ffe6bd; font-size: 11px; font-weight: 700; padding: 7px 14px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); opacity: 0; transform: translateY(-8px); transition: .25s; }
.toast.on { opacity: 1; transform: none; }
.toast.bad { color: #ffb4a8; box-shadow: inset 0 0 0 1px rgba(255,110,90,.5); }
#receipt {
  position: absolute; left: 50%; top: 38%; transform: translate(-50%,-50%);
  z-index: 9; display: flex; align-items: center; gap: 10px;
  background: linear-gradient(#fff3d2,#ffd98a);
  color: #4a2408; padding: 12px 18px; border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0,0,0,.6);
}
#receipt.hidden { display: none; }
#receipt .r-check { width: 30px; height: 30px; border-radius: 50%; background: #1fae8c; color: #fff; font-size: 16px; font-weight: 900; display: flex; align-items: center; justify-content: center; }
#receipt em { display: block; font-style: normal; font-size: 8px; letter-spacing: .22em; opacity: .7; }
#receipt b { font-size: 14px; font-weight: 900; letter-spacing: .06em; }
#receipt.stamp { animation: stampIn .45s cubic-bezier(.2,1.6,.4,1); }
@keyframes stampIn { 0% { transform: translate(-50%,-50%) scale(2.4) rotate(-10deg); opacity: 0; } 100% { transform: translate(-50%,-50%) scale(1) rotate(0); opacity: 1; } }


@media (max-width: 560px) {
  .ad-slot { height: 22px; min-height: 20px; }
  #btn-bless { flex: 0 0 96px; font-size: 10.5px; }
  .res b { font-size: 11.5px; }
}

/* ------------------------------------------------- kingdom dropdown panel -- */
html, body { overflow: hidden; overscroll-behavior: none; }
.dk {
  flex: 1 1 auto; pointer-events: auto; cursor: pointer;
  font: 800 12px/1 system-ui, sans-serif; letter-spacing: .06em; color: #ffe9c0;
  background: linear-gradient(#8a5a2e, #6d4423 55%, #5a3618);
  border: 1px solid #3a2410; border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255,230,170,.35), inset 0 -2px 0 rgba(0,0,0,.4), 0 3px 8px rgba(0,0,0,.5);
  padding: 10px 10px; text-shadow: 0 1px 2px rgba(0,0,0,.6);
}
.dk:active { transform: translateY(1px); }
.dk .dk-ar { float: right; opacity: .8; display: inline-block; transition: transform .18s; }
.dk.open .dk-ar { transform: rotate(180deg); }
.dk.open { background: linear-gradient(#a06a34, #7d4e26 55%, #6d4423); }
.kpanel {
  position: absolute; left: 6px; bottom: calc(100% + 4px);
  width: min(440px, 94vw); max-height: 46vh; overflow-y: auto;
  background: linear-gradient(rgba(38,22,10,.96), rgba(26,14,6,.97));
  border: 1px solid rgba(255,190,110,.35); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,230,170,.15);
  padding: 8px; pointer-events: auto;
}
.kpanel.hidden { display: none; }
.kpanel::-webkit-scrollbar { width: 6px; }
.kpanel::-webkit-scrollbar-thumb { background: rgba(255,190,110,.35); border-radius: 4px; }
.kp-head {
  font: 900 10px/1 system-ui, sans-serif; letter-spacing: .18em; color: rgba(255,220,160,.75);
  padding: 6px 4px 4px; border-bottom: 1px solid rgba(255,190,110,.2); margin-bottom: 4px;
}
.kp-row { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; }
.kp-row:hover { background: rgba(255,190,110,.08); }
.kp-ico { width: 20px; text-align: center; font-size: 14px; }
.kp-name { flex: 1 1 auto; font: 700 11px/1.2 system-ui, sans-serif; color: #ffe9c0; letter-spacing: .04em; }
.kp-lvl { font: 800 10px/1 system-ui, sans-serif; color: rgba(255,220,160,.8); min-width: 74px; text-align: right; }
.kp-up {
  cursor: pointer; min-width: 86px; font: 800 10px/1 system-ui, sans-serif; letter-spacing: .05em;
  color: #ffe9c0; background: linear-gradient(#7a4c22, #5a3618); border: 1px solid #3a2410; border-radius: 7px;
  padding: 6px 8px; box-shadow: inset 0 1px 0 rgba(255,230,170,.3), 0 2px 4px rgba(0,0,0,.4);
}
.kp-up.can { background: linear-gradient(#a4702e, #7a4c22); box-shadow: inset 0 1px 0 rgba(255,240,190,.5), 0 0 8px rgba(255,190,90,.35); }
.kp-up[disabled] { opacity: .42; cursor: default; }
.kp-actions { padding: 6px 4px 2px; }
.kp-actions button {
  width: 100%; cursor: pointer; font: 900 11px/1 system-ui, sans-serif; letter-spacing: .1em;
  color: #fff2d0; background: linear-gradient(#b0782e, #8a5a2e); border: 1px solid #3a2410; border-radius: 8px;
  padding: 8px; box-shadow: inset 0 1px 0 rgba(255,240,190,.45), 0 2px 6px rgba(0,0,0,.5);
}

/* v9.5: CSS vignette (was a per-frame fullscreen canvas blit) */
#stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 42%, rgba(44,18,0,.42) 96%);
}
#stage { touch-action: none; }
/* v9.11: dynamic viewport units (iOS Safari URL-bar) + boot-crash overlay */
html, body, #stage, #menu { height: 100%; }
@supports (height: 100dvh) { html, body, #stage, #menu { height: 100dvh; } }
#crash-ovl {
  position: fixed; inset: 0; z-index: 120; display: flex;
  align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 30%, #241209 0%, #120904 100%);
}
#crash-card { text-align: center; padding: 24px 30px; max-width: min(420px, 86vw); }
#crash-title { font-size: 20px; color: #ffcf5e; font-weight: 800; letter-spacing: .06em; margin-bottom: 8px; }
#crash-sub { font-size: 13px; color: #d8b487; margin-bottom: 18px; line-height: 1.5; }
#crash-reload { font-size: 15px; }
/* landscape-only play on phones / iOS */
#rotate-gate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate-gate {
    display: flex; align-items: center; justify-content: center;
    position: absolute; inset: 0; z-index: 60; background: #140a04;
  }
  .rg-box { font: 900 15px/1.5 system-ui, sans-serif; letter-spacing: .14em; color: #ffe9c0; text-align: center; padding: 20px; }
}
/* compact touch controls in landscape: never cover the battlefield */
@media (pointer: coarse) and (orientation: landscape) {
  #zoom-ctl { right: 4px; top: 44px; gap: 3px; }
  #zoom-ctl button { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
  .hud-btns button { width: 30px; height: 30px; font-size: 13px; }
  #dock { padding: 4px 6px; }
  #dock .dock-row { gap: 4px; }
  .dk { padding: 7px 8px; font-size: 11px; border-radius: 8px; }
  #btn-bless { padding: 6px 8px; }
  #speed-ctl { padding: 2px; border-radius: 8px; }
  .spd { padding: 6px 5px; font-size: 10px; }
  .kpanel { max-height: 40vh; width: min(360px, 62vw); }
  #hero-bar { bottom: 50px; left: 6px; gap: 4px; }
  .hbtn { width: 34px; height: 34px; font-size: 14px; }
  .chip { font-size: 10px; padding: 3px 6px; }
  .res b { font-size: 12px; }
  .hud-row2 { top: 40px; }
}

/* ------------------------------------------- v9.4: labels, menus, speed, i18n -- */
.res .rl {
  font: 800 8px/1 system-ui, sans-serif; letter-spacing: .12em; color: rgba(255,226,170,.62);
  margin-left: 5px; align-self: center; text-transform: uppercase;
}
@media (max-width: 700px) { .res .rl { font-size: 7px; letter-spacing: .03em; margin-left: 3px; } }   /* v9.13: resource labels ALWAYS visible */
#speed-ctl {
  display: flex; gap: 3px; align-items: center; pointer-events: auto;
  background: rgba(20,10,4,.72); border: 1px solid #3a2410; border-radius: 10px; padding: 3px;
}
.spd {
  cursor: pointer; font: 900 11px/1 system-ui, sans-serif; color: rgba(255,230,180,.75);
  background: transparent; border: 0; border-radius: 7px; padding: 8px 7px;
}
.spd.on { background: linear-gradient(#ffcf5e, #ff9a2a); color: #33180a; box-shadow: 0 2px 0 #a3541a; }
.spd.lock { opacity: .55; }
.spd.lock.unlocked { opacity: 1; }
#lang-wrap { margin: 10px auto 2px; width: min(560px, 92vw); }
.lang-title { font: 900 10px/1 system-ui, sans-serif; letter-spacing: .22em; color: rgba(255,220,160,.7); margin-bottom: 6px; text-align: center; }
#lang-grid, #lang-grid2 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
@media (max-width: 640px) { #lang-grid, #lang-grid2 { grid-template-columns: repeat(3, 1fr); } }
.lang-btn {
  cursor: pointer; font: 700 11px/1.1 system-ui, sans-serif; color: #ffe9c0;
  background: rgba(58,36,16,.85); border: 1px solid rgba(255,190,110,.3); border-radius: 8px;
  padding: 8px 4px; text-align: center;
}
.lang-btn.on { background: linear-gradient(#ffcf5e, #ff9a2a); color: #33180a; border-color: #a3541a; font-weight: 900; }

/* two-stage start: language-only screen, then the title screen */
#lang-screen, #menu-main { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; width: 100%; }
#lang-screen.hidden, #menu-main.hidden { display: none; }
.lang-hint { font: 700 10px/1 system-ui, sans-serif; letter-spacing: .18em; color: rgba(255,220,160,.55); margin-top: 8px; text-transform: uppercase; }
#menu.stage-lang { background: #140a04; }   /* nothing but the language grid */

/* v9.8: starter tutorial spotlight + card */
#tut-spot {
  position: fixed; z-index: 70; border-radius: 10px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.62); transition: all .25s ease;
}
#tut-card {
  position: fixed; z-index: 71; width: 300px; pointer-events: auto;
  background: linear-gradient(rgba(38,22,10,.98), rgba(26,14,6,.99));
  border: 1px solid rgba(255,190,110,.45); border-radius: 12px; padding: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
}
#tut-card p { font: 600 12px/1.5 system-ui, sans-serif; color: #ffe9c0; margin: 0 0 10px; }
.tut-btns { display: flex; justify-content: space-between; gap: 8px; }
.tut-btns button { cursor: pointer; font: 800 11px/1 system-ui, sans-serif; letter-spacing: .08em; border-radius: 8px; padding: 9px 12px; border: 0; }
#tut-skip { background: rgba(255,255,255,.12); color: rgba(255,230,190,.8); }
#tut-next { background: linear-gradient(#ffcf5e, #ff9a2a); color: #33180a; box-shadow: 0 2px 0 #a3541a; }
