:root {
  /* Cuboid Pump — pump.fun green/white */
  --green:   #54c17b;
  --green-d: #16382b;   /* dark green: text, outlines */
  --green-l: #86d9a0;
  --white:   #ffffff;
  --mint:    #eaf6ef;
  --coin:    #f5b100;
  --accent:  #2fa866;
  --danger:  #ef4d5e;
  --text:    #16382b;
  --muted:   #6d8a7b;
  --card:    #ffffff;
  --line:    rgba(22,56,43,.14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --z-hud: 30; --z-inventory: 40; --z-modal: 50; --z-toast: 60;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--mint); color: var(--text); font-family: var(--font);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; touch-action: none;
}
#game { display: block; width: 100vw; height: 100vh; }

/* subtle vignette (light) */
body::after {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(130% 110% at 50% 40%, transparent 72%, rgba(22,56,43,.1) 100%);
}

/* --- Overlays (loading) --- */
.overlay {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  background: radial-gradient(120% 90% at 50% 20%, #eafaf0 0%, var(--mint) 55%, #dff2e8 100%);
  z-index: var(--z-modal); transition: opacity .5s ease;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.logo { font-weight: 900; font-size: clamp(34px, 8vw, 74px); letter-spacing: 1px; color: var(--green); text-shadow: 0 3px 0 var(--green-d); }
.logo span { color: var(--green-d); text-shadow: none; }
.bar { width: min(320px, 70vw); height: 10px; border-radius: 99px; background: rgba(22,56,43,.1); overflow: hidden; border: 2px solid var(--green-d); }
.bar i { display: block; height: 100%; width: 0%; background: var(--green); transition: width .25s ease; }
.hint { color: var(--muted); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }

/* --- Debug --- */
.debug { position: fixed; bottom: 10px; left: 12px; z-index: var(--z-hud); font-size: 11px; line-height: 1.5; color: rgba(22,56,43,.5); font-variant-numeric: tabular-nums; pointer-events: none; white-space: pre; }

/* --- In-game HUD --- */
.hud { position: fixed; inset: 0; z-index: var(--z-hud); pointer-events: none;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.hud-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hud-left { min-width: 90px; }
.hud-center { text-align: center; flex: 1; }
.hud-right { min-width: 90px; text-align: right; }
.hud-level { font-weight: 900; font-size: clamp(13px, 2.4vw, 18px); letter-spacing: 2px; color: var(--green-d); text-shadow: 0 1px 0 rgba(255,255,255,.7); }
.hud-objective { margin-top: 4px; display: inline-block; font-size: 12px; font-weight: 800; letter-spacing: 1px; color: var(--green-d);
  background: rgba(255,255,255,.75); border: 1.5px solid var(--green); padding: 3px 12px; border-radius: 99px; }
.hud-boss { display: none; margin-top: 6px; }
.hud-boss b { color: var(--danger); font-size: 11px; letter-spacing: 2px; margin-right: 6px; }
.hud-boss .bh { display: inline-block; width: 15px; height: 15px; margin: 0 1.5px; border-radius: 4px; background: rgba(22,56,43,.15); vertical-align: middle; border: 1px solid rgba(22,56,43,.2); }
.hud-boss .bh.on { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 8px rgba(239,77,94,.5); }
.hud-volt { font-size: clamp(16px, 3vw, 22px); font-weight: 900; color: var(--green-d); display: flex; align-items: center; gap: 6px; justify-content: flex-end; text-shadow: 0 1px 0 rgba(255,255,255,.7); }
.hud-volt b { font-size: 11px; color: var(--muted); }
.hud-volt .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--coin); box-shadow: 0 0 8px rgba(245,177,0,.6); }
.hud-timer { margin-top: 3px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* hearts */
#hud-hearts { display: flex; gap: 4px; }
.heart { font-size: 20px; line-height: 1; transition: transform .15s, opacity .2s; }
.heart.on { color: var(--danger); filter: drop-shadow(0 1px 2px rgba(0,0,0,.15)); }
.heart.off { color: rgba(22,56,43,.2); }

/* nametag */
.nametag { position: fixed; top: 0; left: 0; z-index: 25; pointer-events: none;
  font-size: 10px; font-weight: 800; letter-spacing: .3px; color: var(--green-d);
  background: rgba(255,255,255,.85); border: 1.5px solid var(--green); padding: 1px 8px; border-radius: 99px;
  white-space: nowrap; display: none; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }

/* settings toggles */
.settings-row { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 16px; }
.toggle { display: flex; align-items: center; justify-content: space-between; background: var(--mint); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.toggle span { font-size: 13px; color: var(--text); }
.toggle .sw { width: 42px; height: 24px; border-radius: 99px; background: rgba(22,56,43,.18); position: relative; transition: background .2s; }
.toggle .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle.on .sw { background: var(--green); }
.toggle.on .sw::after { transform: translateX(18px); }

/* ability bar */
.ability-bar { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 12px; z-index: var(--z-hud); }
.ability { position: relative; width: 58px; height: 58px; border-radius: 14px; background: rgba(255,255,255,.9); border: 2px solid var(--green-d); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--green-d); box-shadow: 0 4px 0 rgba(22,56,43,.15); }
.ability i { font-size: 24px; font-style: normal; z-index: 2; }
.ability b { position: absolute; bottom: 3px; right: 4px; font-size: 8px; color: var(--muted); z-index: 2; letter-spacing: .5px; }
.ability .cd { position: absolute; left: 0; bottom: 0; width: 100%; height: 0%; background: rgba(22,56,43,.55); z-index: 1; transition: height .08s linear; }
.ability.ready { border-color: var(--green); box-shadow: 0 0 12px rgba(84,193,123,.5), 0 4px 0 rgba(22,56,43,.15); }
#ab-over.ready { border-color: var(--coin); box-shadow: 0 0 14px rgba(245,177,0,.5), 0 4px 0 rgba(22,56,43,.15); animation: ab-pulse 1s infinite; }
#ab-over.active { border-color: var(--coin); background: rgba(245,177,0,.2); }
@keyframes ab-pulse { 0%,100% { box-shadow: 0 0 10px rgba(245,177,0,.4), 0 4px 0 rgba(22,56,43,.15); } 50% { box-shadow: 0 0 20px rgba(245,177,0,.75), 0 4px 0 rgba(22,56,43,.15); } }

/* touch */
.touch { position: fixed; inset: 0; z-index: var(--z-hud); pointer-events: none; }
body:not(.touch) .touch { display: none !important; }
body.touch .ability-bar { display: none; }
.joy-base { position: absolute; left: max(20px, env(safe-area-inset-left)); bottom: max(26px, env(safe-area-inset-bottom)); width: 118px; height: 118px; border-radius: 50%; background: rgba(84,193,123,.14); border: 2px solid var(--green); pointer-events: auto; touch-action: none; }
.joy-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: var(--green); border: 2px solid var(--green-d); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.touch-btns { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(2, 60px); gap: 12px; pointer-events: auto; }
.tbtn { width: 60px; height: 60px; border-radius: 50%; font-size: 24px; color: var(--green-d); background: rgba(255,255,255,.92); border: 2px solid var(--green-d); touch-action: none; display: flex; align-items: center; justify-content: center; transition: transform .06s, background .1s; }
.tbtn.hit { transform: scale(.9); background: var(--green-l); }
.tbtn-jump { border-color: var(--green); }
.tbtn-pulse { border-color: var(--accent); }
.tbtn-overload { border-color: var(--coin); }

/* toasts */
.toast-wrap { position: fixed; top: 78px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; z-index: var(--z-toast); }
.toast { background: #fff; border: 2px solid var(--green); color: var(--green-d); font-size: 13px; font-weight: 800; letter-spacing: .5px; padding: 8px 16px; border-radius: 99px; opacity: 0; transform: translateY(-8px); transition: opacity .25s, transform .25s; box-shadow: 0 6px 16px rgba(22,56,43,.15); }
.toast.in { opacity: 1; transform: translateY(0); }

/* countdown */
.countdown { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; font-weight: 900; font-size: clamp(90px, 22vw, 200px); color: var(--green); text-shadow: 0 4px 0 var(--green-d); pointer-events: none; }
.countdown.show { display: flex; }
.countdown.pop { animation: cd-pop .5s ease; }
@keyframes cd-pop { 0% { transform: scale(.4); opacity: 0; } 40% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: .9; } }

/* --- Overlay screens (menu/onboard/complete/victory) --- */
.screens { position: fixed; inset: 0; z-index: var(--z-modal); display: none; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(120% 90% at 50% 25%, rgba(84,193,123,.25) 0%, rgba(234,246,239,.72) 50%, rgba(223,242,232,.85) 100%); backdrop-filter: blur(3px); }
.card { background: var(--card); border: 2px solid var(--green-d); border-radius: 22px; padding: 30px 28px; text-align: center; width: min(440px, 92vw); box-shadow: 0 14px 0 rgba(22,56,43,.12), 0 24px 50px rgba(22,56,43,.18); }
.title { font-weight: 900; font-size: clamp(38px, 9vw, 66px); letter-spacing: 1px; color: var(--green); line-height: 1; text-shadow: 0 4px 0 var(--green-d); }
.title span { color: var(--green-d); text-shadow: none; }
.subtitle { margin: 12px 0 22px; color: var(--muted); font-size: 14px; }
.subtitle b { color: var(--accent); }
.hintline { margin-top: 16px; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.card-kicker { color: var(--accent); font-weight: 800; letter-spacing: 3px; font-size: 12px; }
.card-kicker.gameover { color: var(--danger); }
.card-title { font-weight: 900; font-size: clamp(24px, 6vw, 38px); letter-spacing: 1px; margin: 6px 0 16px; color: var(--green-d); }
.tips { list-style: none; text-align: left; margin: 0 0 22px; display: flex; flex-direction: column; gap: 9px; }
.tips li { color: var(--text); font-size: 14px; padding-left: 24px; position: relative; }
.tips li::before { content: '▪'; position: absolute; left: 4px; color: var(--green); font-size: 16px; }
.stars { font-size: 34px; color: var(--coin); letter-spacing: 4px; margin-bottom: 14px; }
.best-badge { color: var(--accent); font-weight: 800; letter-spacing: 2px; font-size: 13px; margin-bottom: 8px; animation: cd-pop .5s ease; }
.stat-row { display: flex; justify-content: center; gap: 30px; margin-bottom: 24px; }
.stat span { display: block; font-size: 28px; font-weight: 900; color: var(--green); }
.stat small { color: var(--muted); font-size: 11px; letter-spacing: 2px; }

/* buttons */
.btn { pointer-events: auto; cursor: pointer; border: 2px solid var(--green-d); border-radius: 14px; font-family: inherit; font-weight: 800; letter-spacing: 1px; font-size: 15px; padding: 12px 22px; min-height: 46px; min-width: 88px; transition: transform .1s, box-shadow .2s, background .2s; }
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 4px 0 var(--green-d); }
.btn-primary:hover { background: #4bb371; }
.btn-ghost { background: #fff; color: var(--green-d); box-shadow: 0 4px 0 rgba(22,56,43,.15); }
.btn-ghost:hover { background: var(--mint); }
.btn-buy { background: var(--coin); color: var(--green-d); box-shadow: 0 4px 0 #b98700; }
.btn-buy:hover { background: #ffc21f; }
.btn-lg { font-size: 18px; padding: 15px 28px; width: 100%; margin-top: 8px; }
.btn.is-disabled { opacity: .45; cursor: not-allowed; filter: grayscale(.5); box-shadow: none; }
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.btn-row .btn { flex: 1; min-width: 92px; }
.btn-sm { padding: 5px 12px; min-height: 30px; min-width: 50px; font-size: 11px; border-width: 1.5px; }

/* claim + gate + menu foot */
.claim-amount { font-size: 40px; font-weight: 900; color: var(--coin); margin: 8px 0 18px; text-shadow: 0 2px 0 var(--green-d); }
.claim-amount b { font-size: 16px; color: var(--muted); text-shadow: none; }
.claim-req { text-align: left; background: var(--mint); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 18px; }
.req-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; letter-spacing: .5px; }
.req { font-size: 13px; color: var(--text); margin: 5px 0; }
.req .x { color: var(--accent); margin-right: 6px; }
.req-why { font-size: 11px; color: var(--muted); margin-top: 10px; font-style: italic; }
.gate-err { color: var(--danger); font-size: 12px; margin-bottom: 12px; }
.menu-foot { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.menu-foot .who { font-size: 12px; color: var(--muted); }

/* inventory */
.inventory { position: fixed; inset: 0; z-index: var(--z-inventory); display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(234,246,239,.8); backdrop-filter: blur(3px); }
.inv-panel { background: #fff; border: 2px solid var(--green-d); border-radius: 22px; padding: 24px; width: min(520px, 94vw); box-shadow: 0 14px 0 rgba(22,56,43,.12), 0 24px 50px rgba(22,56,43,.18); }
.inv-title { font-weight: 900; letter-spacing: 2px; text-align: center; margin-bottom: 18px; color: var(--green-d); }
.inv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.inv-cell { background: var(--mint); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.inv-cell.empty { opacity: .45; }
.inv-icon { font-size: 30px; line-height: 1; }
.inv-name { font-size: 13px; font-weight: 800; color: var(--green-d); }
.inv-desc { font-size: 10px; color: var(--muted); }
.inv-count { font-size: 12px; font-weight: 800; color: var(--accent); margin-top: 2px; }
.inv-use { margin-top: 8px; padding: 7px 14px; min-height: 36px; font-size: 12px; }
.inv-hint { text-align: center; color: var(--muted); font-size: 13px; margin-top: 16px; }
.inv-close { display: block; margin: 18px auto 0; }

/* level select (kept, unused) */
.card-select { width: min(620px, 95vw); }
.lvl-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 18px 0; }
.lvl-cell { cursor: pointer; background: var(--mint); border: 1.5px solid var(--green); border-radius: 14px; padding: 12px 8px; text-align: center; font-family: inherit; color: var(--green-d); display: flex; flex-direction: column; gap: 3px; align-items: center; }
.lvl-cell.locked { opacity: .45; cursor: not-allowed; }
.lvl-num { font-size: 22px; font-weight: 900; color: var(--green); }
.lvl-name { font-size: 10px; color: var(--muted); min-height: 24px; display: flex; align-items: center; }
.lvl-stars { color: var(--coin); font-size: 13px; }
.lvl-best { font-size: 10px; color: var(--muted); }

/* error toast */
.errbox { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: var(--z-toast); background: #fff; border: 2px solid var(--danger); color: #a11; padding: 10px 14px; border-radius: 10px; font-size: 12px; font-family: ui-monospace, monospace; max-height: 40vh; overflow: auto; white-space: pre-wrap; }
