:root {
  --bg: #070a0f;
  --bg2: #0f1623;
  --edge: rgba(210,245,255,0.9);
  --glass: rgba(160,220,255,0.12);
  --glow: 0 0 24px rgba(120,200,255,0.45), inset 0 0 20px rgba(120,200,255,0.18);
  --panel: rgba(255,255,255,0.06);
  --panel-border: rgba(255,255,255,0.15);
  --panel-hover: rgba(255,255,255,0.12);

  --accent: #8bd3ff;
  --accent-2: #60a5fa;
  --ok: #34d399;
  --warn: #f59e0b;
  --danger: #ef4444;
  --muted: #a6c3da;
  --shadow-1: 0 8px 30px rgba(0,0,0,.35);
  --shadow-2: 0 14px 50px rgba(0,0,0,.45);
  --ring: 0 0 0 1px rgba(255,255,255,0.14), 0 0 28px rgba(120,200,255,0.18);
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(1400px 900px at 20% 15%, #101a2b 0%, var(--bg) 40%),
    radial-gradient(1200px 700px at 80% 85%, #0b1220 0%, var(--bg2) 50%);
  color: #e8f6ff;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header polish */
header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(10px);
  background: linear-gradient(to bottom, rgba(10,14,22,0.7), rgba(10,14,22,0.35));
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}
h1 {
  font-size: 18px; letter-spacing: 0.6px; font-weight: 800;
  text-shadow: 0 2px 18px rgba(150,220,255,0.28);
  margin-right: 8px;
}

/* HUD chips */
#hud {
  margin-left: auto;
  font-weight: 800;
  display: inline-flex; align-items: center; gap: 14px;
  padding: 6px 12px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.06), 0 0 18px rgba(120,200,255,0.12);
}
#hud span { display:inline-block; min-width: 36px; text-align:right; }
.hud-pulse { animation: hudPulse .5s ease; }
@keyframes hudPulse {
  0% { transform: scale(1); text-shadow: 0 0 0 rgba(139,211,255,0); }
  50% { transform: scale(1.06); text-shadow: 0 0 14px rgba(139,211,255,.8); }
  100% { transform: scale(1); text-shadow: 0 0 0 rgba(139,211,255,0); }
}

/* Canvas wrap */
#canvas-wrap { position: relative; height: calc(100% - 64px); }
#c { width: 100%; height: 100%; display: block; }

/* Hint chip */
#hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 10px 14px; border-radius: 12px;
  background: rgba(10,14,22,0.55); border: 1px solid rgba(255,255,255,0.12);
  box-shadow: var(--glow);
  font-size: 14px; pointer-events: none;
}

/* Buttons */
button {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, var(--panel), rgba(255,255,255,0.04));
  color: inherit;
  padding: 8px 12px; border-radius: 12px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25), inset 0 0 12px rgba(255,255,255,0.06);
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease, filter .2s ease;
}
button:hover { background: var(--panel-hover); box-shadow: 0 8px 28px rgba(120,200,255,0.22), inset 0 0 12px rgba(255,255,255,0.08); }
button:active { transform: translateY(1px) scale(0.99); }
button:focus-visible { outline: none; box-shadow: var(--ring); }
button:disabled { opacity: 0.6; cursor: not-allowed; filter: grayscale(0.2); }
button.primary {
  border-color: rgba(120,200,255,0.6);
  background: linear-gradient(180deg, rgba(120,200,255,0.24), rgba(120,200,255,0.10));
  box-shadow: 0 10px 32px rgba(120,200,255,0.25), inset 0 0 14px rgba(255,255,255,0.08);
}

/* Meter polish */
#meter {
  position: relative;
  height: 18px;
  margin: 8px 16px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(18px 60% at calc(var(--cursor-x, 0%)) 50%, rgba(255,255,255,0.20), transparent 60%),
    linear-gradient(to right, #ff5a5a 0%, #ffd44a 30%, #3cff7a 50%, #ffd44a 70%, #ff5a5a 100%);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: inset 0 0 18px rgba(0,0,0,0.35), 0 0 28px rgba(120,200,255,0.2);
}
#crystalZone {
  position: absolute; top: 0; left: 48%;
  width: 4%; height: 100%;
  background: linear-gradient(180deg, rgba(140,220,255,0.75), rgba(140,220,255,0.18));
  box-shadow: 0 0 16px rgba(120,200,255,0.65), inset 0 0 12px rgba(255,255,255,0.25);
  border-left: 1px dashed rgba(255,255,255,0.45);
  border-right: 1px dashed rgba(255,255,255,0.45);
  display: flex; align-items: flex-start; justify-content: center;
}
#crystalZone span {
  position: absolute; top: -22px; white-space: nowrap; font-size: 12px; font-weight: 800;
  text-shadow: 0 0 10px rgba(120,200,255,0.9);
}
#meterFill {
  position: absolute; top: 0; left: 0; bottom: 0; width: 0%;
  mix-blend-mode: screen;
  background: linear-gradient(to right, rgba(255,255,255,0.0), rgba(255,255,255,0.7));
  filter: drop-shadow(0 0 8px rgba(120,200,255,0.6));
}
#meterCursor {
  position: absolute; top: -6px;
  width: 0; height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 14px solid rgba(255,255,255,0.95);
  filter: drop-shadow(0 0 8px rgba(120,200,255,0.9));
  cursor: grab; z-index: 1;
}

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: radial-gradient(900px 600px at 50% 40%, rgba(10,14,22,0.92), rgba(7,10,15,0.98));
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.modal.hidden { display: none; }
.modal-card {
  width: min(560px, 92vw);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 18px; padding: 18px 18px 16px;
  box-shadow: var(--shadow-2), inset 0 0 16px rgba(255,255,255,0.06);
  animation: cardIn .4s ease;
}
@keyframes cardIn { from{ transform: translateY(8px); opacity: 0 } to{ transform:none; opacity:1 } }
.modal-card h2 { margin: 0 0 8px; font-size: 20px; letter-spacing: .2px; }
.modal-card ul { margin: 8px 0 12px 18px; padding: 0; line-height: 1.45; }
.legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip {
  padding: 4px 8px; border-radius: 999px; font-size: 12px; font-weight: 800; border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
}
.chip.red { background: rgba(255,80,80,0.18); }
.chip.yellow { background: rgba(255,212,74,0.18); }
.chip.green { background: rgba(60,255,122,0.18); }
.chip.crystal { background: rgba(140,220,255,0.25); box-shadow: 0 0 12px rgba(120,200,255,0.5) inset; }
.dontshow { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; opacity: 0.95; }

/* Powerups HUD polish */
.powerups-panel{
  position: fixed; left: 20px; top: 110px; z-index: 1200;
  display: flex; flex-direction: column; gap: 16px;
}
.pu-tile{
  position: relative;
  width: 150px; height: 160px; padding: 12px 12px 16px 12px;
  border-radius: 20px;
  background:
    radial-gradient(180px 120px at 20% -20%, rgba(120,200,255,.14), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 14px 42px rgba(0,0,0,.45), inset 0 0 18px rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
  display: grid; grid-template-rows: 84px 1fr; gap: 10px; overflow: hidden;
  transition: transform .16s ease, box-shadow .2s ease, border-color .2s ease;
}
.pu-tile:hover{
  transform: translateY(-2px);
  border-color: rgba(160,220,255,.28);
  box-shadow: 0 22px 54px rgba(0,0,0,.55), inset 0 0 18px rgba(255,255,255,.08);
}
.pu-ico{ display:grid; place-items:center; font-size: 56px; text-shadow: 0 2px 14px rgba(120,200,255,.5); }
.pu-meta{ display:flex; flex-direction:column; line-height:1.15; }
.pu-name{ font: 900 16px/1.1 ui-sans-serif,system-ui; color:#ecf7ff; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pu-sub{  font: 800 13px/1 ui-sans-serif,system-ui; color:#c9e1ff; opacity:.95; }
.pu-uses{
  position:absolute; top:10px; right:10px; padding:6px 10px; border-radius:999px;
  font:900 13px/1 ui-sans-serif; color:#052716; background:#81f5bf; border:1px solid rgba(0,0,0,.2);
  box-shadow: 0 8px 22px rgba(0,0,0,.25);
}
.pu-bottom{ position:absolute; left:12px; right:12px; bottom:10px; display:flex; align-items:center; gap:10px; }
.pu-hbar{
  position: relative; flex: 1 1 auto; height: 8px; border-radius: 999px;
  background: linear-gradient(180deg, rgba(255,255,255,.15), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.18); overflow: hidden; box-shadow: inset 0 0 8px rgba(255,255,255,.08);
}
.pu-hfill{ height:100%; width:0%; background: linear-gradient(90deg, #81f5bf, #6be7ff); box-shadow: 0 0 10px rgba(129,245,191,.6); }
.pu-htime{ flex: 0 0 auto; min-width: 52px; text-align: right; font: 900 13px/1 ui-sans-serif; color:#eafff4; text-shadow: 0 1px 2px rgba(0,0,0,.5); }

/* Toasts */
#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 12px; padding: 10px 12px; min-width: 220px;
  box-shadow: var(--shadow-1);
  font-weight: 700; color: #e8f6ff;
  animation: toastIn .35s ease;
}
@keyframes toastIn { from{ transform: translateY(10px); opacity: 0 } to{ transform:none; opacity:1 } }

.neon { text-shadow: 0 0 14px rgba(120,200,255,0.5), 0 0 36px rgba(120,200,255,0.25); }


/* Widen the store sheet/dialog */
.store, .store-root, .store-sheet, .store-modal, .store-container {
  max-width: 1400px !important;
  width: min(96vw, 1400px) !important;
}

/* Main two-pane layout: keep the left nav narrow, give content the rest */
.store-layout, .store-body, .store-content-wrap {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px 28px;
}
@media (max-width: 960px) {
  .store-layout, .store-body, .store-content-wrap {
    grid-template-columns: 1fr;
  }
}

.exchange-wide {
  width: 100%;
  padding: 16px 8px 28px;
}

/* Headline & helper text spacing inside Exchange */
.exchange-wide h2, .exchange-wide h3, .exchange-wide p {
  max-width: none;
}

/* Two big cards (“You pay” / “You receive”) side by side with space */
.exchange-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  gap: 24px 40px;
  align-items: start;
}
@media (max-width: 900px) {
  .exchange-grid {
    grid-template-columns: 1fr;
  }
}

/* Amount buttons (+1, +5, …) as a tidy grid */
.exchange-amounts {
  display: grid;
  grid-template-columns: repeat(4, minmax(90px, 1fr));
  gap: 12px;
  max-width: 620px;
}
@media (max-width: 600px) {
  .exchange-amounts {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Make the numeric cards bigger and clearer */
.exchange-card {
  background: var(--panel, rgba(255,255,255,0.03));
  border: 1px solid var(--panel-border, rgba(255,255,255,0.08));
  border-radius: 16px;
  padding: 16px 18px;
  min-height: 120px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18) inset;
}
.exchange-card .value {
  font-size: clamp(28px, 4.2vw, 40px);
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Place the confirm button where the eye expects it */
.exchange-actions-row {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 12px;
}
.exchange-actions-row .spacer {
  flex: 1;
}

/* Small print (rate, balance) widened and aligned */
.exchange-meta {
  margin-top: 10px;
  font-size: 14px;
  opacity: 0.9;
}

/* Ensure the entire right pane isn’t constrained by old max-widths */
.store-content, .store-right, .store-main {
  max-width: none !important;
  width: 100% !important;
}

/* ===== Header action buttons (Reset / Buy Pane) ===== */
#resetBtn,
#buyPaneBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;                 /* future-proof if you add icons/spans later */
  padding: 8px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.18);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  box-shadow: 0 6px 22px rgba(0,0,0,0.35), inset 0 0 14px rgba(255,255,255,0.05);
  font-weight: 800;
  letter-spacing: .2px;
  font-variant-numeric: tabular-nums; /* keeps big prices from jittering */
  transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
}

/* Differentiation: primary vs. tertiary */
#buyPaneBtn {
  border-color: rgba(120,200,255,0.45);
  background:
    radial-gradient(140% 120% at 20% -30%, rgba(120,200,255,0.18), transparent 60%),
    linear-gradient(180deg, rgba(120,200,255,0.22), rgba(120,200,255,0.10));
  box-shadow:
    0 12px 34px rgba(120,200,255,0.22),
    inset 0 0 16px rgba(255,255,255,0.07);
}

/* “Reset” stays subtle, with a cooler tone */
#resetBtn {
  border-color: rgba(255,255,255,0.14);
  background:
    radial-gradient(140% 120% at 20% -30%, rgba(120,200,255,0.10), transparent 60%),
    linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  color: #d6e9ff;
}

/* Shared interactions */
#resetBtn:hover,
#buyPaneBtn:hover {
  transform: translateY(-1px);
  border-color: rgba(160,220,255,0.55);
  box-shadow: 0 18px 46px rgba(120,200,255,0.28), inset 0 0 18px rgba(255,255,255,0.09);
}
#resetBtn:active,
#buyPaneBtn:active {
  transform: translateY(0);
  box-shadow: 0 6px 22px rgba(120,200,255,0.18), inset 0 0 12px rgba(255,255,255,0.08);
}

/* Tighten emoji alignment in the buy button line without HTML changes */
#buyPaneBtn { text-shadow: 0 1px 0 rgba(0,0,0,0.25); word-spacing: 2px; }

/* ===== Store FAB polish (bottom-right) ===== */
.bbx-fab {
  border-radius: 16px !important;
  padding: 12px 16px !important;
  gap: 10px !important;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(120,200,255,0.22), transparent 60%),
    linear-gradient(180deg, rgba(59,130,246,0.28), rgba(37,99,235,0.24)) !important;
  border: 1px solid rgba(160,220,255,0.35) !important;
  backdrop-filter: blur(8px) !important;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5), inset 0 0 14px rgba(255,255,255,0.06) !important;
  font-weight: 800 !important;
  letter-spacing: .2px !important;
}
.bbx-fab:hover {
  transform: translateY(-2px) !important;
  border-color: rgba(180,240,255,0.65) !important;
  box-shadow: 0 22px 60px rgba(0,0,0,0.55), 0 0 24px rgba(120,200,255,0.35) !important;
}
.bbx-fab:active { transform: translateY(0) scale(0.99) !important; }

#bbx-close {
  border-radius: 12px !important;
  border: 1px solid rgba(255,255,255,0.16) !important;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03)) !important;
  font-weight: 700 !important;
}
#bbx-close:hover { border-color: rgba(160,220,255,0.45) !important; }

/* ===== Responsive tweaks ===== */
@media (max-width: 720px) {
  #resetBtn, #buyPaneBtn { padding: 8px 12px; border-radius: 12px; }
  .bbx-fab { right: 12px !important; bottom: 12px !important; padding: 10px 12px !important; }
}

/* Store FAB with stacked emoji */
#bbx-store-fab {
  flex-direction: column;       /* stack vertically */
  align-items: center;
  justify-content: center;
  width: 90px; height: 90px;    /* bigger touch target */
  border-radius: 20px;
  font-weight: 800;
  gap: 4px;
}

#bbx-store-fab .fab-emoji {
  font-size: 34px;              /* bigger emoji */
  line-height: 1;
}

#bbx-store-fab .fab-label {
  font-size: 15px;
  letter-spacing: .3px;
}
