/* ============================================================
   海拉鲁守望 · HYRULE WARDEN
   UI / HUD / overlays
   ============================================================ */
:root {
  --ink: #0b1512;
  --ink-2: #12231d;
  --panel: rgba(12, 26, 21, 0.84);
  --panel-2: rgba(20, 40, 32, 0.92);
  --gold: #e8c56a;
  --gold-hi: #fbe9ac;
  --gold-lo: #a87c28;
  --cream: #f4ecd8;
  --cream-dim: #d9cdb0;
  --muted: #a99e83;
  --green: #78d17a;
  --red: #e0523f;
  --blue: #72c8f0;
  --purple: #bb8cf0;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  --font-cn: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", Georgia, serif;
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #0a1310;
  color: var(--cream);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#app { position: fixed; inset: 0; overflow: hidden; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#stage canvas:active { cursor: grabbing; }
body.build-mode #stage canvas { cursor: crosshair; }
body.target-mode #stage canvas { cursor: crosshair; }
#sky-wash {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 72% 2%, rgba(255, 214, 140, 0.22), transparent 65%),
    radial-gradient(ellipse 80% 60% at 50% 110%, rgba(12, 30, 24, 0.5), transparent 70%);
  mix-blend-mode: soft-light;
}
#edge-vignette {
  position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 190px 40px rgba(4, 12, 9, 0.72), inset 0 0 60px rgba(4, 12, 9, 0.45);
  transition: box-shadow .18s ease;
}
body.hurt #edge-vignette {
  box-shadow: inset 0 0 230px 90px rgba(176, 24, 14, 0.85), inset 0 0 80px rgba(120, 10, 6, 0.6);
}

.hidden { display: none !important; }

/* ---------------------------------------------------------- HUD shell */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }
#hud button, #hud .rivet-panel, #build-cards, #pad-panel, #next-wave { pointer-events: auto; }

#hud-top {
  position: absolute; top: 16px; left: 20px; right: 20px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
#hud-left { display: flex; align-items: center; gap: 14px; }
#hud-right { display: flex; align-items: center; gap: 8px; }

.hearts { display: flex; gap: 1px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.55)); }
.heart { width: 26px; height: 24px; transition: transform .18s ease, opacity .25s ease; }
.heart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.heart .hp-fill { fill: #e3453d; stroke: #5e1414; stroke-width: 1.6; }
.heart .hp-shine { fill: #ff9a7d; opacity: .85; }
.heart.empty .hp-fill { fill: #2a3833; stroke: #455a50; }
.heart.empty .hp-shine { opacity: 0; }
.heart.hurt { animation: heartHurt .55s ease; }
.heart.beat { animation: heartBeat 1.4s ease-in-out infinite; }
@keyframes heartHurt {
  0% { transform: scale(1); }
  22% { transform: scale(1.45) rotate(-8deg); filter: brightness(2.4); }
  55% { transform: scale(.82) rotate(4deg); }
  100% { transform: scale(1); }
}
@keyframes heartBeat { 0%,100% { transform: scale(1); } 8% { transform: scale(1.08); } 16% { transform: scale(1); } }

.rivet-panel {
  position: relative;
  background: linear-gradient(155deg, rgba(24, 46, 37, .9), rgba(9, 20, 16, .88));
  border: 1px solid rgba(232, 197, 106, .34);
  border-radius: 10px;
  box-shadow: 0 8px 26px rgba(0,0,0,.4), inset 0 1px 0 rgba(255, 239, 190, .1);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
}
.rivet-panel::before, .rivet-panel::after {
  content: ""; position: absolute; width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f6dfa0, #8a6522);
  top: 7px; box-shadow: 0 calc(100% + 46px) 0 #8a6522;
}
.rivet-panel::before { left: 8px; }
.rivet-panel::after { right: 8px; }

#wave-chip {
  display: flex; align-items: baseline; gap: 6px;
  padding: 9px 16px 8px 14px; letter-spacing: .06em;
}
.wave-label { font-size: 9px; letter-spacing: .3em; color: var(--gold); opacity: .85; font-weight: 600; }
#wave-num { font-family: var(--font-cn); font-size: 26px; color: var(--cream); line-height: 1; }
.wave-total { font-size: 12px; color: var(--muted); }

#hud-title {
  position: absolute; left: 50%; top: 4px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; opacity: .82;
}
.ht-name {
  font-family: var(--font-cn); font-size: 15px; letter-spacing: .34em; color: var(--gold-hi);
  text-shadow: 0 1px 12px rgba(0,0,0,.8);
}
.ht-rule { width: 46px; height: 1px; background: linear-gradient(90deg, transparent, rgba(232,197,106,.7)); }
.ht-rule:last-child { transform: scaleX(-1); }

#rupee-box { display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; }
.rupee-icon { width: 20px; height: 24px; filter: drop-shadow(0 0 6px rgba(80, 240, 130, .45)); }
#rupee-num {
  font-family: var(--font-cn); font-size: 21px; color: #c8f5c1; min-width: 34px; text-align: right;
  text-shadow: 0 0 12px rgba(80, 220, 120, .35);
}
#rupee-box.spend { animation: rupeeSpend .4s ease; }
@keyframes rupeeSpend { 0% { transform: scale(1); } 30% { transform: scale(.92); } 100% { transform: scale(1); } }

.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; color: var(--cream-dim); cursor: pointer;
  background: linear-gradient(160deg, rgba(26,48,39,.92), rgba(8,18,14,.92));
  border: 1px solid rgba(232,197,106,.3);
  box-shadow: 0 4px 16px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,244,210,.08);
  transition: .16s ease;
  font-family: var(--font-cn); font-size: 14px;
}
.icon-btn:hover { color: var(--gold-hi); border-color: rgba(232,197,106,.72); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.45), 0 0 18px rgba(232,197,106,.14); }
.icon-btn:active { transform: scale(.94); }
.icon-btn .ico { width: 20px; height: 20px; }
.icon-btn.muted .sound-waves { opacity: .12; }
.icon-btn.muted::after {
  content: ""; position: absolute; width: 22px; height: 1.5px; background: var(--red);
  transform: rotate(-45deg);
}
.icon-btn { position: relative; }
.qmark { font-size: 18px; color: inherit; }

/* ---------------------------------------------------------- wave banner */
#wave-banner {
  position: absolute; left: 50%; top: 19%; transform: translateX(-50%);
  width: min(560px, 86vw); text-align: center; z-index: 12;
  animation: bannerIn 2.8s cubic-bezier(.2,.8,.2,1) forwards;
  text-shadow: 0 3px 18px rgba(0,0,0,.85);
}
@keyframes bannerIn {
  0% { opacity: 0; transform: translate(-50%, 14px) scale(.96); }
  10% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  78% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}
.wb-rule { height: 1px; background: linear-gradient(90deg, transparent, rgba(232,197,106,.8), transparent); }
.wb-kicker { margin: 9px 0 3px; font-size: 10px; letter-spacing: .38em; color: var(--gold); }
.wb-title { margin: 0; font-family: var(--font-cn); font-size: clamp(30px, 4.2vw, 44px); font-weight: 700; letter-spacing: .16em; color: var(--cream); }
.wb-sub { margin: 5px 0 9px; font-size: 12px; letter-spacing: .18em; color: var(--cream-dim); }

/* ---------------------------------------------------------- boss bar */
#boss-bar {
  position: absolute; left: 50%; top: 82px; transform: translateX(-50%);
  width: min(520px, 78vw); z-index: 11;
  animation: bossIn .7s ease;
}
@keyframes bossIn { from { opacity: 0; transform: translate(-50%, -14px); } }
.boss-head { display: flex; align-items: center; justify-content: center; gap: 9px; margin-bottom: 5px; text-shadow: 0 2px 8px #000; }
.boss-skull { color: #ff8a6a; font-size: 15px; }
#boss-name { font-family: var(--font-cn); letter-spacing: .22em; font-size: 16px; color: #ffd6bc; }
.boss-tag { font-size: 8px; letter-spacing: .28em; color: #ff8a6a; border: 1px solid rgba(255,120,90,.5); border-radius: 3px; padding: 1px 5px; }
.boss-track {
  height: 11px; border-radius: 6px; overflow: hidden;
  background: rgba(8, 12, 10, .86); border: 1px solid rgba(232,197,106,.35);
  box-shadow: 0 3px 16px rgba(0,0,0,.6), inset 0 1px 3px rgba(0,0,0,.8);
}
#boss-fill {
  display: block; height: 100%; width: 100%;
  background: linear-gradient(180deg, #ff8a5e, #c92f24 60%, #771712);
  box-shadow: 0 0 14px rgba(255, 80, 50, .6);
  transition: width .18s linear;
}

/* ---------------------------------------------------------- bottom left */
#bottom-left {
  position: absolute; left: 20px; bottom: calc(150px + var(--safe-b));
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
  max-width: min(380px, 34vw);
}
#next-wave { display: flex; align-items: center; gap: 14px; padding: 11px 14px 11px 16px; }
.nw-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nw-label { font-family: var(--font-cn); font-size: 15px; letter-spacing: .12em; color: var(--gold-hi); white-space: nowrap; }
.nw-comp { font-size: 10.5px; color: var(--muted); letter-spacing: .04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; }

.pad-panel { width: min(340px, 36vw); padding: 12px 14px 13px; animation: panelIn .22s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } }
.pp-head { display: flex; align-items: center; gap: 10px; }
.pp-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; background: rgba(232,197,106,.08); border: 1px solid rgba(232,197,106,.24); }
.pp-icon svg { width: 27px; height: 27px; }
.pp-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pp-title b { font-family: var(--font-cn); font-size: 16px; letter-spacing: .08em; color: var(--cream); }
.pp-title small { font-size: 10px; color: var(--muted); letter-spacing: .12em; }
.pp-close { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 2px; }
.pp-close:hover { color: var(--gold-hi); }
.pp-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 12px; margin: 9px 0 10px; font-size: 11px; color: var(--cream-dim); }
.pp-stats span { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed rgba(232,197,106,.14); padding-bottom: 2px; }
.pp-stats b { color: var(--gold-hi); font-weight: 600; }
.pp-actions { display: flex; gap: 8px; }
.pp-actions .gold-btn, .pp-actions .ghost-btn { flex: 1; padding: 7px 8px; font-size: 12px; }
.pp-actions .gold-btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.5); }

/* ---------------------------------------------------------- buttons */
.gold-btn {
  position: relative;
  border: 1px solid #f3dc9b;
  border-radius: 6px;
  padding: 9px 18px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600; letter-spacing: .1em;
  color: #241c08; cursor: pointer;
  background: linear-gradient(180deg, #f6e3a4 0%, #e8c56a 42%, #c79a3f 100%);
  box-shadow: 0 3px 0 #6e4f14, 0 7px 20px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.55);
  transition: transform .12s ease, filter .16s ease, box-shadow .16s ease;
  white-space: nowrap;
}
.gold-btn:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 0 #6e4f14, 0 10px 26px rgba(0,0,0,.5), 0 0 24px rgba(232,197,106,.22), inset 0 1px 0 rgba(255,255,255,.6); }
.gold-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #6e4f14, 0 3px 10px rgba(0,0,0,.4); }
.gold-btn:disabled { filter: grayscale(.55) brightness(.8); cursor: wait; transform: none; }
.gold-btn.small { padding: 7px 12px; font-size: 12px; letter-spacing: .06em; }
.gold-btn.large { padding: 14px 52px; font-size: 16px; letter-spacing: .32em; border-radius: 8px; }
.gold-btn kbd {
  font-family: var(--font-ui); font-size: 9px; font-weight: 600; padding: 1px 4px; border-radius: 3px;
  background: rgba(30, 22, 6, .24); border: 0; color: #3b2a06; margin-left: 3px; vertical-align: 1px;
}
.ghost-btn {
  border: 1px solid rgba(232,197,106,.36); border-radius: 6px;
  background: rgba(10, 22, 18, .6); color: var(--cream-dim);
  font-family: var(--font-ui); font-size: 12px; letter-spacing: .08em;
  padding: 8px 15px; cursor: pointer; transition: .16s ease;
}
.ghost-btn:hover { color: var(--gold-hi); border-color: rgba(232,197,106,.75); background: rgba(232,197,106,.08); }
.ghost-btn:disabled { opacity: .35; cursor: not-allowed; }
.ghost-btn.small { padding: 7px 10px; font-size: 12px; }

/* ---------------------------------------------------------- build bar */
#bottom-bar {
  position: absolute; left: 50%; bottom: calc(14px + var(--safe-b)); transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(760px, calc(100vw - 40px));
}
#build-cards { display: flex; gap: 10px; justify-content: center; }
.tower-card {
  position: relative; width: 106px; height: 116px; padding: 8px 6px 7px;
  border: 1px solid rgba(232,197,106,.25); border-radius: 9px;
  background: linear-gradient(170deg, rgba(28, 50, 40, .92), rgba(8, 18, 14, .96));
  color: var(--cream); cursor: pointer; overflow: hidden;
  box-shadow: 0 8px 26px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,244,210,.08);
  transition: .16s ease; font-family: var(--font-ui);
}
.tower-card::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent); opacity: .35;
}
.tower-card:hover { transform: translateY(-3px); border-color: rgba(232,197,106,.7); box-shadow: 0 12px 30px rgba(0,0,0,.55), 0 0 24px rgba(232,197,106,.14); }
.tower-card.selected { border-color: var(--gold-hi); box-shadow: 0 0 0 1px rgba(251,233,172,.4), 0 12px 32px rgba(0,0,0,.55), 0 0 34px rgba(232,197,106,.28); transform: translateY(-3px); }
.tower-card.cant { filter: saturate(.5); opacity: .68; }
.tower-card.cant:hover { transform: none; }
.card-key {
  position: absolute; top: 5px; left: 7px; font-size: 9px; color: var(--gold);
  border: 1px solid rgba(232,197,106,.3); border-radius: 3px; padding: 0 3px; opacity: .8;
}
.card-icon { display: block; width: 42px; height: 42px; margin: 5px auto 2px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.5)); }
.card-icon svg { width: 100%; height: 100%; }
.card-name { display: block; font-family: var(--font-cn); font-size: 13.5px; letter-spacing: .08em; text-align: center; color: var(--cream); }
.card-cost { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: #a8ecab; margin-top: 2px; }
.card-cost i {
  width: 8px; height: 11px; display: block; background: linear-gradient(160deg, #8bf5a3, #2a9a48);
  clip-path: polygon(50% 0, 100% 26%, 100% 74%, 50% 100%, 0 74%, 0 26%);
  box-shadow: 0 0 6px rgba(80,240,130,.5);
}
.tower-card.cant .card-cost { color: #e08b7e; }
.card-lock {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(5, 12, 9, .72); color: var(--cream-dim); font-size: 10px; letter-spacing: .1em;
  padding: 0 10px; text-align: center;
}
#build-hint { margin: 0; font-size: 10px; letter-spacing: .08em; color: rgba(244,236,216,.55); text-shadow: 0 1px 4px #000; }

/* ---------------------------------------------------------- ability */
#bottom-right {
  position: absolute; right: 26px; bottom: calc(24px + var(--safe-b));
  display: flex; flex-direction: column; align-items: center; gap: 7px;
}
.ability {
  position: relative; width: 78px; height: 78px; border-radius: 50%;
  border: 1px solid rgba(232,197,106,.55); cursor: pointer;
  background: radial-gradient(circle at 38% 28%, #2b4d3d, #0a1712 72%);
  color: var(--gold-hi);
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.55), inset 0 0 20px rgba(232,197,106,.1), 0 0 0 5px rgba(6,16,12,.55);
  transition: .18s ease;
}
.ability:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(0,0,0,.6), 0 0 30px rgba(232,197,106,.3), inset 0 0 24px rgba(232,197,106,.18); }
.ability.ready { animation: abilityPulse 2.6s ease-in-out infinite; }
@keyframes abilityPulse {
  0%,100% { box-shadow: 0 10px 30px rgba(0,0,0,.55), 0 0 0 5px rgba(6,16,12,.55), 0 0 0 rgba(255,236,170,0); }
  50% { box-shadow: 0 10px 30px rgba(0,0,0,.55), 0 0 0 5px rgba(6,16,12,.55), 0 0 34px rgba(255,236,170,.42); }
}
.ability-ring {
  position: absolute; inset: 5px; border-radius: 50%;
  border: 1px solid rgba(232,197,106,.35);
  border-top-color: rgba(255,245,200,.85);
  animation: ringSpin 10s linear infinite;
}
@keyframes ringSpin { to { transform: rotate(360deg); } }
.ability-icon { width: 40px; height: 40px; margin-top: -3px; filter: drop-shadow(0 0 8px rgba(255,235,170,.45)); }
.ability-icon svg { width: 100%; height: 100%; }
.ability-key {
  position: absolute; bottom: 1px; right: 5px; font-size: 9px; letter-spacing: .04em;
  background: rgba(8,16,12,.85); border: 1px solid rgba(232,197,106,.3); border-radius: 3px; padding: 0 3px; color: var(--gold);
}
.ability-cd {
  position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(4, 10, 8, .82) calc(var(--p, 0) * 1%), transparent 0);
  display: none;
}
.ability.cooling .ability-cd { display: block; }
.ability.cooling .ability-icon { opacity: .45; }
.ability.cooling::after {
  content: attr(data-cd); position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--font-cn); font-size: 22px; color: var(--cream); text-shadow: 0 2px 6px #000;
  pointer-events: none;
}
#ability-label { font-family: var(--font-cn); font-size: 11px; letter-spacing: .2em; color: var(--gold); text-shadow: 0 1px 5px #000; }
#ability-hint {
  position: absolute; right: 0; bottom: 96px; white-space: nowrap;
  padding: 6px 12px; border-radius: 5px; font-size: 11px; letter-spacing: .1em;
  background: rgba(8, 18, 14, .88); border: 1px solid rgba(232,197,106,.4); color: var(--gold-hi);
  animation: hintFloat 1.6s ease-in-out infinite;
}
@keyframes hintFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ---------------------------------------------------------- toast & floaters */
#toast {
  position: absolute; left: 50%; bottom: 160px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: 30;
}
.toast-item {
  padding: 7px 18px; border-radius: 5px; font-size: 12px; letter-spacing: .08em;
  color: var(--cream); background: rgba(8, 18, 14, .9); border: 1px solid rgba(232,197,106,.35);
  box-shadow: 0 6px 22px rgba(0,0,0,.5); animation: toastIn 2.4s ease forwards;
}
.toast-item.gold { color: var(--gold-hi); border-color: rgba(232,197,106,.65); }
.toast-item.bad { color: #ffb3a4; border-color: rgba(224,82,63,.55); }
@keyframes toastIn {
  0% { opacity: 0; transform: translateY(10px) scale(.96); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-8px); }
}
#floaters { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 9; }
.floater {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--font-cn); font-size: 15px; font-weight: 700; letter-spacing: .02em;
  color: #fff6d8; text-shadow: 0 2px 5px #000, 0 0 10px rgba(0,0,0,.8);
  animation: floatUp .95s cubic-bezier(.15,.7,.3,1) forwards; will-change: transform, opacity;
}
.floater.gold { color: #ffe08a; }
.floater.green { color: #9ef0a1; }
.floater.red { color: #ff8d7d; }
.floater.frost { color: #a8e9ff; }
.floater.rupee { color: #8dfaa2; font-size: 13px; }
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.7); }
  16% { opacity: 1; transform: translate(-50%, -60%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(.94); }
}

/* ---------------------------------------------------------- tooltip */
#tooltip {
  position: absolute; z-index: 40; pointer-events: none; max-width: 250px;
  padding: 10px 12px; border-radius: 7px;
  background: rgba(8, 18, 14, .95); border: 1px solid rgba(232,197,106,.4);
  box-shadow: 0 10px 30px rgba(0,0,0,.6); font-size: 11px; color: var(--cream-dim);
  transform: translate(-50%, -100%);
}
#tooltip b { color: var(--gold-hi); font-family: var(--font-cn); font-size: 13px; letter-spacing: .06em; }
#tooltip .tt-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; margin-top: 6px; color: var(--muted); }
#tooltip .tt-stats span b { color: var(--cream); font-family: var(--font-ui); font-size: 11px; }
#tooltip .tt-desc { margin-top: 6px; line-height: 1.5; color: var(--muted); }

/* ---------------------------------------------------------- overlays */
.overlay {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 42%, rgba(6, 16, 12, .46), rgba(3, 9, 7, .82) 78%),
    linear-gradient(180deg, rgba(4, 10, 8, .3), rgba(4, 10, 8, .7));
  backdrop-filter: blur(6px) saturate(1.05); -webkit-backdrop-filter: blur(6px) saturate(1.05);
  animation: overlayIn .35s ease;
}
.overlay.hidden { display: none !important; }
.overlay.show { display: flex; }
@keyframes overlayIn { from { opacity: 0; } }
.modal {
  position: relative; width: min(520px, 94vw); padding: 34px 40px 30px;
  text-align: center;
  background:
    linear-gradient(160deg, rgba(23, 44, 35, .97), rgba(7, 17, 13, .98)),
    radial-gradient(circle at 50% 0%, rgba(232,197,106,.14), transparent 60%);
  border: 1px solid rgba(232,197,106,.42); border-radius: 12px;
  box-shadow: 0 30px 90px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,244,210,.14), inset 0 0 80px rgba(232,197,106,.04);
  animation: modalIn .4s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.modal::before, .modal::after {
  content: "◆"; position: absolute; top: 12px; font-size: 9px; color: rgba(232,197,106,.55);
}
.modal::before { left: 15px; }
.modal::after { right: 15px; }
.modal.wide { width: min(880px, 94vw); }
.modal-kicker { margin: 0 0 5px; font-size: 9px; letter-spacing: .34em; color: var(--gold); opacity: .9; }
.modal h2 { margin: 2px 0 0; font-family: var(--font-cn); font-size: clamp(28px, 3.4vw, 38px); font-weight: 700; letter-spacing: .18em; color: var(--cream); text-shadow: 0 2px 18px rgba(0,0,0,.6); }
.modal-rule { height: 1px; margin: 16px auto 20px; width: min(280px, 70%); background: linear-gradient(90deg, transparent, rgba(232,197,106,.65), transparent); }
.modal-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.modal-foot { margin: 16px 0 0; font-size: 10px; letter-spacing: .06em; color: var(--muted); }
kbd {
  font-family: var(--font-ui); font-size: 9.5px; font-weight: 600; padding: 1.5px 5px; border-radius: 3px;
  background: rgba(244,236,216,.09); border: 1px solid rgba(232,197,106,.28); color: var(--cream-dim);
  box-shadow: 0 1px 0 rgba(0,0,0,.4); margin: 0 1px;
}

/* start screen */
#start-screen {
  z-index: 60;
  background:
    radial-gradient(ellipse 60% 54% at 50% 40%, rgba(20, 44, 32, .26), rgba(3, 9, 7, .7) 76%),
    linear-gradient(180deg, rgba(4, 12, 9, .3), rgba(3, 8, 6, .72));
  backdrop-filter: blur(3px) saturate(1.05); -webkit-backdrop-filter: blur(3px) saturate(1.05);
}
.start-inner { text-align: center; max-width: 660px; animation: startIn 1.1s cubic-bezier(.2,.8,.2,1); }
@keyframes startIn { from { opacity: 0; transform: translateY(18px); } }
.triforce { width: 88px; margin: 0 auto 14px; filter: drop-shadow(0 10px 28px rgba(232,197,106,.35)); animation: triforceFloat 5s ease-in-out infinite; }
.triforce svg { width: 100%; height: auto; }
@keyframes triforceFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.kicker { margin: 0; font-size: 9px; letter-spacing: .42em; color: var(--gold); opacity: .85; }
#start-screen h1 {
  margin: 12px 0 2px;
  font-family: var(--font-cn); font-weight: 700;
  font-size: clamp(58px, 9vw, 92px); letter-spacing: .12em; line-height: 1.04;
  background: linear-gradient(180deg, #fff9e2 8%, #f5e2a4 38%, #d8ad52 68%, #a97c2c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 2px rgba(30, 20, 4, .55)) drop-shadow(0 0 32px rgba(232, 197, 106, .22));
}
.subtitle { margin: 0; font-size: 10px; letter-spacing: .58em; color: var(--cream-dim); opacity: .8; }
.title-rule { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 20px 0 18px; color: rgba(232,197,106,.7); }
.title-rule i { width: 92px; height: 1px; background: linear-gradient(90deg, transparent, rgba(232,197,106,.8)); }
.title-rule i:last-child { transform: scaleX(-1); }
.title-rule span { font-size: 8px; }
#start-screen .lead {
  margin: 0 auto 26px; font-family: var(--font-cn); font-size: 14px; line-height: 2.05;
  letter-spacing: .14em; color: var(--cream-dim); text-shadow: 0 2px 10px rgba(0,0,0,.8);
}
.start-hints { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; margin-top: 24px; font-size: 10px; letter-spacing: .06em; color: rgba(244,236,216,.6); }
.start-hints i { color: var(--gold); font-style: normal; margin-right: 4px; }
.best { margin: 18px 0 0; font-size: 10px; letter-spacing: .14em; color: var(--muted); }
.best b { color: var(--gold-hi); font-family: var(--font-cn); font-size: 13px; letter-spacing: .08em; }
.credit { margin: 20px 0 0; font-size: 8px; letter-spacing: .3em; color: rgba(244,236,216,.28); }

/* help */
.help-grid { display: grid; grid-template-columns: 1fr 1.15fr 1.15fr; gap: 26px; text-align: left; }
.help-col h3 {
  margin: 0 0 10px; font-family: var(--font-cn); font-size: 14px; font-weight: 700; letter-spacing: .2em; color: var(--gold-hi);
  padding-bottom: 6px; border-bottom: 1px solid rgba(232,197,106,.2);
}
.keys, .bestiary, .tips { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.keys li { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.keys li kbd { min-width: 40px; text-align: center; }
.keys li span { margin-left: auto; color: var(--cream-dim); text-align: right; }
.bestiary li { display: grid; grid-template-columns: 12px 64px 1fr; align-items: baseline; gap: 7px; font-size: 10.5px; color: var(--muted); }
.bestiary li b { font-family: var(--font-cn); font-size: 12px; color: var(--cream-dim); letter-spacing: .06em; }
.bestiary li span { line-height: 1.45; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; transform: translateY(-1px); box-shadow: 0 0 7px currentColor; }
.dot.bok { background: #d06a44; color: #d06a44; }
.dot.keese { background: #a678d8; color: #a678d8; }
.dot.moblin { background: #b59b63; color: #b59b63; }
.dot.wizz { background: #6f9ff0; color: #6f9ff0; }
.dot.stalfos { background: #dfe6d8; color: #dfe6d8; }
.dot.boss { background: #e84a3c; color: #e84a3c; }
.tips li { font-size: 10.5px; line-height: 1.55; color: var(--muted); padding-left: 14px; position: relative; }
.tips li::before { content: "◈"; position: absolute; left: 0; top: 0; color: rgba(232,197,106,.6); font-size: 8px; }
.tips li::before { line-height: 1.9; }

/* blessing */
.blessing-modal { padding-bottom: 36px; }
.bless-sub { margin: 6px 0 0; font-size: 11px; letter-spacing: .12em; color: var(--muted); }
.blessing-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }
.bless-card {
  position: relative; padding: 20px 14px 16px; text-align: center; cursor: pointer;
  border: 1px solid rgba(232,197,106,.28); border-radius: 10px;
  background: linear-gradient(170deg, rgba(32, 56, 44, .8), rgba(8, 18, 14, .92));
  transition: .18s ease; color: var(--cream);
  overflow: hidden;
}
.bless-card::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(232,197,106,.16), transparent 62%);
  opacity: 0; transition: .2s;
}
.bless-card:hover { transform: translateY(-4px); border-color: rgba(251,233,172,.8); box-shadow: 0 16px 40px rgba(0,0,0,.55), 0 0 30px rgba(232,197,106,.18); }
.bless-card:hover::before { opacity: 1; }
.bless-icon { width: 52px; height: 52px; margin: 0 auto 10px; display: grid; place-items: center; color: var(--gold-hi); }
.bless-icon svg { width: 100%; height: 100%; filter: drop-shadow(0 0 12px rgba(232,197,106,.4)); }
.bless-name { font-family: var(--font-cn); font-size: 15px; letter-spacing: .1em; color: var(--gold-hi); margin-bottom: 5px; }
.bless-desc { font-size: 10.5px; line-height: 1.6; color: var(--muted); min-height: 34px; }
.bless-goddess { margin-top: 9px; font-size: 8px; letter-spacing: .26em; color: rgba(232,197,106,.55); }

/* end */
.end-modal { width: min(560px, 94vw); }
#end-screen { background: radial-gradient(ellipse 60% 55% at 50% 44%, rgba(18, 36, 26, .5), rgba(3, 8, 6, .9) 76%); }
.end-glow {
  position: absolute; width: 74vw; height: 74vw; max-width: 900px; max-height: 900px;
  border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(232,197,106,.16), transparent 62%);
  animation: endGlow 6s ease-in-out infinite;
}
@keyframes endGlow { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: 1; transform: scale(1.06); } }
#end-screen.defeat { background: radial-gradient(ellipse 60% 55% at 50% 44%, rgba(50, 16, 13, .55), rgba(4, 8, 6, .94) 76%); }
#end-screen.defeat .end-glow { background: radial-gradient(circle, rgba(220, 70, 50, .15), transparent 62%); }
#end-screen.defeat h2 { color: #ffc3b4; }
.end-copy { margin: 0 auto; max-width: 420px; font-family: var(--font-cn); font-size: 13px; line-height: 1.95; letter-spacing: .1em; color: var(--cream-dim); }
.end-stats { display: flex; justify-content: center; gap: 34px; margin-top: 22px; }
.end-stats div { display: flex; flex-direction: column; gap: 5px; }
.end-stats span { font-size: 9px; letter-spacing: .18em; color: var(--muted); }
.end-stats b { font-family: var(--font-cn); font-size: 24px; color: var(--gold-hi); }
#end-screen.defeat .end-stats b { color: #ffb3a4; }

/* loading */
#loading { position: fixed; inset: 0; z-index: 100; background: #08100c; display: grid; place-items: center; }
#loading.hidden { display: none; }

/* ---------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  #hud-title { display: none; }
  .tower-card { width: 96px; height: 110px; }
  #bottom-bar { width: min(680px, calc(100vw - 32px)); }
  #bottom-left { max-width: 300px; }
  .nw-comp { max-width: 150px; }
}
@media (max-width: 860px) {
  #hud-top { left: 12px; right: 12px; top: 10px; gap: 8px; }
  #hud-left { gap: 8px; }
  .heart { width: 21px; height: 20px; }
  .wave-label { display: none; }
  #wave-chip { padding: 7px 12px; }
  #wave-num { font-size: 21px; }
  .icon-btn { width: 35px; height: 35px; }
  #rupee-box { padding: 5px 10px 5px 8px; }
  #rupee-num { font-size: 18px; min-width: 26px; }
  .rupee-icon { width: 17px; height: 20px; }
  #hud-right { gap: 5px; }
  #bottom-left { bottom: calc(132px + var(--safe-b)); left: 12px; }
  #next-wave { padding: 8px 10px; gap: 8px; }
  .nw-label { font-size: 13px; }
  .nw-comp { display: none; }
  #btn-next { padding: 6px 9px; font-size: 11px; }
  .tower-card { width: 82px; height: 100px; padding: 6px 4px; }
  .card-icon { width: 32px; height: 32px; margin: 5px auto 1px; }
  .card-name { font-size: 12px; }
  .card-cost { font-size: 10px; }
  #bottom-bar { width: calc(100vw - 20px); }
  #build-cards { gap: 6px; }
  #build-hint { display: none; }
  #bottom-right { right: 12px; bottom: calc(128px + var(--safe-b)); }
  .ability { width: 62px; height: 62px; }
  .ability-icon { width: 30px; height: 30px; }
  #ability-label { display: none; }
  #ability-hint { display: none !important; }
  #toast { bottom: 140px; }
  .help-grid { grid-template-columns: 1fr; gap: 16px; max-height: 62vh; overflow-y: auto; padding-right: 6px; }
  .blessing-cards { grid-template-columns: 1fr; }
  .bless-card { display: grid; grid-template-columns: 46px 1fr; text-align: left; align-items: center; padding: 12px 14px; }
  .bless-icon { width: 38px; height: 38px; margin: 0; }
  .bless-desc { min-height: 0; }
  .bless-goddess { display: none; }
  .bless-name { margin-bottom: 2px; }
  .modal { padding: 24px 20px; }
  #start-screen h1 { font-size: clamp(48px, 13vw, 68px); }
  .start-hints { gap: 10px; font-size: 9px; }
  .lead { font-size: 12px !important; }
  .end-stats { gap: 22px; }
}
@media (max-width: 560px) {
  .hearts { gap: 0; }
  .heart { width: 17px; height: 16px; }
  #bottom-left { left: 8px; bottom: calc(122px + var(--safe-b)); }
  #next-wave { gap: 6px; }
  #btn-next { font-size: 10px; padding: 5px 7px; }
  .nw-label { font-size: 11px; }
  #pad-panel { width: min(280px, calc(100vw - 20px)); }
  .tower-card { width: 70px; height: 92px; }
  .card-icon { width: 26px; height: 26px; }
  .card-name { font-size: 10.5px; }
  .card-key { display: none; }
  .ability { width: 54px; height: 54px; }
  .ability-label { display: none; }
  .pp-stats { font-size: 10px; }
  .start-hints { display: none; }
  .triforce { width: 64px; }
}
@media (max-width: 430px) {
  #hud-top { left: 8px; right: 8px; top: 8px; gap: 6px; }
  #hud-left { gap: 6px; }
  .hearts { gap: 0; }
  .heart { width: 13px; height: 12px; }
  #wave-chip { padding: 4px 7px 3px 6px; gap: 3px; }
  #wave-num { font-size: 16px; }
  .wave-total { font-size: 9px; }
  #hud-right { gap: 3px; }
  #rupee-box { padding: 4px 7px 4px 5px; gap: 4px; }
  .rupee-icon { width: 13px; height: 16px; }
  #rupee-num { font-size: 15px; min-width: 21px; }
  .icon-btn { width: 28px; height: 28px; }
  .icon-btn .ico { width: 16px; height: 16px; }
  .qmark { font-size: 15px; }
  #build-cards { gap: 5px; }
  .tower-card { width: 68px; height: 90px; padding: 5px 3px; }
  .card-icon { width: 25px; height: 25px; }
  .card-name { font-size: 10px; }
  #bottom-left { bottom: calc(118px + var(--safe-b)); }
  #bottom-right { bottom: calc(118px + var(--safe-b)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
