/* =========================================================================
   style.css - menu, HUD and leaderboard chrome
   ========================================================================= */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #f2fbff;
  font-family: Ubuntu, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
canvas { display: block; position: fixed; inset: 0; }
.hidden { display: none !important; }

/* ---------------- HUD ----------------
   Text runs the inverse of the board: dark on the light theme, light on the
   dark one. The leaderboard and warning banner carry their own backgrounds,
   so they stay light in both. */
#hud { position: fixed; inset: 0; pointer-events: none; color: #21262d; }
body.dark-theme #hud { color: #fff; }

#stats {
  position: absolute; left: 14px; bottom: 12px;
  text-shadow: 0 1px 3px rgba(255,255,255,.9), 0 0 10px rgba(255,255,255,.65);
}
body.dark-theme #stats { text-shadow: 0 2px 6px rgba(0,0,0,.85); }
#score { font-size: 28px; font-weight: 700; letter-spacing: .3px; }
#substats { font-size: 13px; opacity: .8; margin-top: 2px; }

#leaderboard {
  position: absolute; right: 14px; top: 58px; color: #fff;
  min-width: 190px; padding: 8px 12px 10px;
  background: rgba(0,0,0,.42); border-radius: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
#leaderboard h3 {
  margin: 0 0 6px; font-size: 16px; font-weight: 700;
  text-align: center; letter-spacing: .4px;
}
#lb { margin: 0; padding: 0; list-style: none; font-size: 13.5px; line-height: 1.55; }
#lb li {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 230px;
  display: flex; align-items: baseline; gap: 5px;
}
#lb li .n {
  flex: none; min-width: 17px; text-align: right; opacity: .6;
  font-variant-numeric: tabular-nums;
}
#lb li.me .n { opacity: .9; }
#lb li.out { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.22); }
#lb li.me { color: #ff6b81; font-weight: 700; }
#lb li .m { opacity: .55; font-size: 11.5px; margin-left: 5px; }

#warn {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); color: #fff;
  background: rgba(190,40,40,.88); padding: 6px 14px; border-radius: 4px;
  font-size: 13px; font-weight: 700; letter-spacing: .3px;
}
#hint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 12px; opacity: .6; text-shadow: 0 1px 3px rgba(255,255,255,.9);
}
body.dark-theme #hint { text-shadow: 0 1px 3px rgba(0,0,0,.9); }
#hint b { opacity: .95; }
#brhud {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; align-items: center;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(0,0,0,.45); color: #fff; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
#brhud #brPhase { color: #ff9a9a; }
#brhud #brTimer { opacity: .8; font-variant-numeric: tabular-nums; }
#brzone {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%);
  padding: 6px 16px; border-radius: 4px; background: rgba(214,58,58,.9);
  color: #fff; font-size: 13px; font-weight: 700;
  animation: zone-flash 1s ease-in-out infinite;
}
@keyframes zone-flash { 0%,100% { opacity: .75; } 50% { opacity: 1; } }
/* while the BR pill holds the top-centre slot, the banners stack below it */
body.br-mode #warn { top: 56px; }
body.br-mode #brzone { top: 96px; }
@media (prefers-reduced-motion: reduce) { #brzone { animation: none; } }
#spechint {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  font-size: 12.5px; opacity: .85; text-shadow: 0 1px 3px rgba(255,255,255,.9);
  white-space: nowrap;
}
body.dark-theme #spechint { text-shadow: 0 1px 3px rgba(0,0,0,.9); }
#spechint b { color: #4e8b36; }
body.dark-theme #spechint b { color: #8fd66a; }

/* ---------------- menu ---------------- */
#menu {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(20,26,34,.72), rgba(8,10,14,.92));
  backdrop-filter: blur(2px);
  /* Above the arena chrome. The ML Lab panels live at 16 and are fixed to the
     left edge - at 10 they could sit ON TOP of this menu and swallow clicks
     meant for Play. The shop, settings and popups are all higher still. */
  z-index: 18;
}
.panel {
  width: 560px; max-width: calc(100vw - 28px); max-height: calc(100vh - 28px);
  overflow-y: auto;
  padding: 26px 28px 22px; border-radius: 12px;
  background: #fff; box-shadow: 0 24px 60px rgba(0,0,0,.45);
  text-align: center;
}
.panel h1 { margin: 0 0 10px; font-size: 40px; font-weight: 300; color: #2b2f36; letter-spacing: -1px; }
.panel h1 span { color: #6ab04c; font-weight: 700; }
.tag { margin: 2px 0 18px; font-size: 12.5px; color: #8b929c; }

/* front page: wallet, level and the potions you have brewing */
#frontbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 11px;
  padding: 7px 9px; background: #f7f9fa; border: 1px solid #eaeef1; border-radius: 10px;
}
/* level badge, like the star on the game's profile card */
.fb-badge {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  background: #f5b301; box-shadow: inset 0 -2px 0 rgba(0,0,0,.14);
}
.fb-mid { flex: 1; min-width: 0; text-align: left; }
/* XP bar with the counts sitting inside it */
.fb-mid .xpbar {
  position: relative; height: 17px; border-radius: 9px; background: #e6eaed;
  margin: 0; overflow: hidden;
}
.fb-mid .xpbar i {
  display: block; height: 100%; border-radius: 9px;
  background: linear-gradient(180deg, #7ed03a, #63b026);
  transition: width .5s ease;
}
.fb-mid .xpbar b {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.fb-sub { margin-top: 3px; font-size: 10.5px; color: #8b939c; }
.fb-sub b { color: #2b2f36; }
.fb-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.fb-wallet { display: flex; gap: 8px; }
.fb-wallet span {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border: 1.5px solid #8dd04a; border-radius: 999px; background: #fff;
  font-size: 12px; font-weight: 700; color: #56606b;
}
.fb-wallet svg { width: 17px; height: 17px; }
.fb-boosts { display: flex; gap: 4px; }
.fb-boosts span {
  padding: 1px 6px; border-radius: 999px; font-size: 9.5px; font-weight: 700;
  background: #eaf6e0; color: #4e8b36; border: 1px solid #cfe6c2;
}

#frontslots { display: flex; gap: 8px; margin-top: 8px; }
.fs {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
  padding: 7px 4px; border-radius: 8px; background: #f6f8f9; border: 1px solid #eceff2;
  font-size: 10.5px; font-weight: 700; color: #8b939c; cursor: pointer;
  transition: background .15s;
}
.fs:hover { background: #eef2f4; }
.fs svg { width: 20px; height: 28px; }
.fs.ready { background: #f2faec; border-color: #cfe6c2; color: #4e8b36; }
.fs.none { color: #c2c8ce; cursor: default; }
.fs.none:hover { background: #f6f8f9; }

#nick {
  width: 100%; padding: 12px 14px; font-size: 16px;
  border: 1px solid #d6dae0; border-radius: 6px; outline: none;
  font-family: inherit;
}
#nick:focus { border-color: #6ab04c; }
#play {
  width: 100%; margin-top: 10px; padding: 13px;
  font-size: 17px; font-weight: 700; color: #fff; font-family: inherit;
  background: #6ab04c; border: 0; border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
#play:hover { background: #5a9c40; }
#playBr {
  width: 100%; margin-top: 8px; padding: 12px;
  font-size: 15px; font-weight: 700; color: #fff; font-family: inherit;
  background: #e2564a; border: 0; border-bottom: 3px solid #b93d33;
  border-radius: 6px; cursor: pointer; transition: background .15s;
}
#playBr:hover { background: #cf4a3f; }
.btnrow { display: flex; gap: 8px; }
.btnrow button { flex: 1; }
#spectate {
  width: 100%; margin-top: 8px; padding: 10px;
  font-size: 14px; font-weight: 700; color: #6b7280; font-family: inherit;
  background: #fff; border: 1px solid #d6dae0; border-radius: 6px; cursor: pointer;
  transition: background .15s, color .15s;
}
#spectate:hover { background: #f2f4f6; color: #2b2f36; }
#shop {
  width: 100%; margin-top: 8px; padding: 10px;
  font-size: 14px; font-weight: 700; color: #8a6d1f; font-family: inherit;
  background: #fdf6e3; border: 1px solid #f0dfae; border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
#shop:hover { background: #faeecd; }

#deathbox {
  margin-top: 16px; padding: 12px; border-radius: 8px;
  background: #fdf1f1; border: 1px solid #f3d4d4;
}
#deathbox.win { background: #fdf8e7; border-color: #f0dfae; }
#deathbox.win .dead-title { color: #c9920c; }
.dead-title { font-size: 18px; font-weight: 700; color: #c0392b; }
.dead-score { margin-top: 3px; font-size: 14px; color: #6b7280; }
.dead-sub { margin-top: 3px; font-size: 12px; color: #9aa1ab; }

.keysline {
  margin: 14px 0 0; font-size: 12.5px; color: #7b828b; line-height: 1.5;
}
.keysline b { color: #2b2f36; }
.keysline .dim { color: #a6adb6; }

.cols { display: flex; gap: 22px; margin-top: 16px; text-align: left; }
.col { flex: 1; }
.col h4 {
  margin: 0 0 7px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .9px; color: #9aa1ab;
}
.keys { margin: 0; padding: 0; list-style: none; font-size: 12.5px; color: #555b63; line-height: 1.75; }
.keys b { color: #2b2f36; }
.col label {
  display: block; font-size: 12.5px; color: #555b63; line-height: 1.9; cursor: pointer;
  user-select: none;
}
.col input[type=checkbox] { vertical-align: -1px; margin-right: 6px; accent-color: #6ab04c; }
.col label.sub { padding-left: 21px; font-size: 12px; color: #7b828b; }
.col label.sub:has(input:disabled) { opacity: .45; cursor: default; }
.col label.num { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.col label.num input {
  width: 86px; padding: 4px 6px; font: inherit; font-size: 12.5px;
  border: 1px solid #d6dae0; border-radius: 4px; outline: none; text-align: right;
}
.col label.num input:focus { border-color: #6ab04c; }
.col label.num select {
  width: 86px; padding: 4px 4px; font: inherit; font-size: 12.5px;
  border: 1px solid #d6dae0; border-radius: 4px; outline: none; background: #fff;
  color: #555b63;
}
.col label.num select:focus { border-color: #6ab04c; }
.col .note { font-size: 10.5px; color: #a6adb6; line-height: 1.5; margin-top: 1px; }
#privworld, #reset {
  display: block; width: 100%; margin-top: 8px; padding: 8px; font: inherit;
  font-size: 12px; font-weight: 700; color: #7b828b; background: #f2f4f6;
  border: 1px solid #e0e4e8; border-radius: 5px; cursor: pointer;
  text-align: center;
}
#privworld:hover, #reset:hover { background: #e8ebef; color: #555b63; }
#privworld { margin-top: 14px; }
#privworld.on {
  background: #eef7e9; border-color: #cfe6c2; color: #4e8b36;
}
#privworld.on:hover { background: #e4f1dc; }

/* ---------------- settings dialog ---------------- */
#settingsBtn {
  position: fixed; top: 14px; right: 14px; z-index: 15;
  width: 34px; height: 34px; border-radius: 50%;
  font: inherit; font-size: 18px; line-height: 1; color: #fff;
  background: rgba(90,101,112,.9); border: 0; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#settingsBtn:hover { background: #5a6570; }
#settingsOverlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(20,26,34,.74), rgba(8,10,14,.93));
  z-index: 26;
}
.settings-panel { width: 560px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.settings-body { padding: 16px 22px 20px; max-height: calc(100vh - 150px); overflow-y: auto; }
.settings-body .cols { margin-top: 0; }
#settingsClose {
  width: 34px; height: 34px; flex: none; font: inherit; font-size: 15px; line-height: 1;
  font-weight: 700; color: #fff; background: #e2564a; border: 0; border-radius: 50%;
  cursor: pointer;
}
#settingsClose:hover { background: #cf4a3f; }

/* ---------------- mechanics info ---------------- */
#infoBtn {
  position: fixed; top: 14px; left: 14px; z-index: 15;
  width: 34px; height: 34px; border-radius: 50%;
  font: inherit; font-size: 18px; font-weight: 700; font-style: italic;
  color: #fff; background: rgba(53,182,232,.92); border: 0; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
#infoBtn:hover { background: #35b6e8; }
#infoOverlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(20,26,34,.74), rgba(8,10,14,.93));
  z-index: 25;
}
.info-panel { width: 680px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.headspacer { width: 38px; flex: none; }
#infoClose {
  width: 38px; height: 38px; flex: none; font: inherit; font-size: 26px; line-height: 1;
  font-weight: 700; color: #fff; background: #35b6e8; border: 0; border-radius: 50%;
  cursor: pointer; padding: 0 0 3px;
}
#infoClose:hover { background: #279fd0; }
.info-body { padding: 14px 22px 20px; max-height: calc(100vh - 150px); overflow-y: auto; }
.info-body ul { margin: 0; padding-left: 20px; font-size: 12.5px; color: #616870; line-height: 1.7; }
.info-body li { margin-bottom: 6px; }
.info-body b { color: #2b2f36; }

/* ---------------- potion reward popup ---------------- */
#rewardOverlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.66); z-index: 40;
}
.reward-box {
  position: relative; width: 320px; max-width: calc(100vw - 32px);
  padding: 22px 22px 20px; text-align: center;
  background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.45);
  animation: reward-in .34s cubic-bezier(.2,1.3,.5,1);
}
@keyframes reward-in {
  from { transform: scale(.72); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes glow-pulse {
  0%, 100% { transform: scale(.92); opacity: .55; }
  50%      { transform: scale(1.06); opacity: .85; }
}
@keyframes reward-drop {
  0%   { transform: translateY(-18px) scale(.7); opacity: 0; }
  60%  { transform: translateY(4px) scale(1.06); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
@keyframes row-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
/* A soft radial glow rather than spinning rays: a rotating conic gradient with
   hard stops shimmers badly at these sizes. */
.reward-burst {
  position: absolute; top: 22px; left: 50%; width: 210px; height: 210px;
  margin-left: -105px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle,
    rgba(255,221,80,.55) 0%, rgba(255,221,80,.28) 38%, rgba(255,221,80,0) 68%);
  animation: glow-pulse 2.6s ease-in-out infinite;
}
.reward-art { position: relative; }
.reward-art svg {
  width: 104px; height: 138px;
  animation: reward-drop .45s ease-out, potion-bob 3.4s ease-in-out .45s infinite;
  transform-origin: 50% 80%;
}
.reward-art .bub { animation: bub-rise 2.4s ease-in-out infinite; }
.reward-title { margin-top: 6px; font-size: 19px; font-weight: 700; color: #2b2f36; }
.reward-rows { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.reward-rows .rrow {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: #56606b;
  animation: row-in .3s ease-out backwards;
}
.reward-rows .rrow:nth-child(2) { animation-delay: .07s; }
.reward-rows .rrow:nth-child(3) { animation-delay: .14s; }
.reward-rows .rrow:nth-child(4) { animation-delay: .21s; }
.reward-rows .rrow svg { width: 24px; height: 24px; }
.reward-rows .rrow.boost { color: #4e8b36; }
.brend-sub { margin-top: 4px; font-size: 12.5px; color: #8b939c; }
/* The Battle Royale result. It had no rule of its own, so it laid out as a
   plain block in the flow instead of a dialog - centred like every other
   popup now, and above the HUD. */
#brEndOverlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.66); z-index: 41;
}
#rewardOk, #brEndOk {
  width: 100%; margin-top: 16px; padding: 11px; font: inherit; font-size: 15px;
  font-weight: 700; color: #fff; background: #6fc02c; border: 0;
  border-bottom: 3px solid #559a1f; border-radius: 9px; cursor: pointer;
}
#rewardOk:hover, #brEndOk:hover { background: #63ad27; }

@media (prefers-reduced-motion: reduce) {
  .reward-box, .reward-art svg, .reward-rows .rrow, .reward-burst { animation: none !important; }
}

/* ---------------- shop ---------------- */
#shopOverlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(20,26,34,.74), rgba(8,10,14,.93));
  z-index: 20;
}
.shop-panel {
  width: 880px; max-width: calc(100vw - 24px); text-align: left;
  padding: 0; overflow: hidden;
}
.shop-head {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-bottom: 2px solid #eceff2;
}
.shop-head h2 {
  margin: 0; flex: 1; font-size: 26px; font-weight: 700; color: #56606b;
  text-align: center; letter-spacing: -.3px;
}
#shopClose {
  width: 38px; height: 38px; flex: none; font: inherit; font-size: 26px; line-height: 1;
  font-weight: 700; color: #fff; background: #35b6e8; border: 0; border-radius: 50%;
  cursor: pointer; padding: 0 0 3px;
}
#shopClose:hover { background: #279fd0; }

.wallet { display: flex; gap: 8px; flex: none; }
.wallet .pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border: 2px solid #8dd04a; border-radius: 999px;
  background: #fff; font-size: 14px; font-weight: 700; color: #56606b;
}
.wallet .pill svg { width: 22px; height: 22px; }

.shop-tabs { display: flex; gap: 8px; padding: 12px 18px 0; }
.tab {
  flex: 1; padding: 9px 8px; font: inherit; font-size: 13px; font-weight: 700;
  color: #56606b; background: #fff; border: 2px solid #d7dde3; border-radius: 8px;
  cursor: pointer;
}
.tab:hover { background: #f4f7f9; }
.tab.on { border-color: #35b6e8; color: #1d94c4; background: #eef9fe; }

#metaBody {
  padding: 12px 18px 18px; font-size: 12px; color: #555b63;
  max-height: calc(100vh - 210px); overflow-y: auto;
}
.lvlbar { margin-bottom: 10px; }
.lvl { font-size: 12px; color: #7b828b; }
.lvl b { color: #2b2f36; }
.xpbar { height: 5px; border-radius: 3px; background: #eceff2; margin-top: 5px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: #8dd04a; }
.blurb {
  margin: 0 0 12px; text-align: center; font-size: 13px; color: #6b7280;
}
.blurb b { color: #2b2f36; }

/* the browsing grid: one big card per item */
.cards { display: flex; gap: 12px; align-items: stretch; }
.card {
  flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center;
  padding: 14px 10px 12px; background: #f6f8f9; border-radius: 12px;
}
.card.empty { background: #fbfcfc; border: 2px dashed #e2e7ea; justify-content: center; }
.card-title {
  font-size: 16px; font-weight: 700; color: #6b7580; text-align: center;
  line-height: 1.25; min-height: 40px;
}
.card-art { margin: 10px 0 6px; }

/* --- potion animation: a slow float, rising bubbles, and a pulse once ready --- */
@keyframes potion-bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50%      { transform: translateY(-6px) rotate(1deg); }
}
@keyframes bub-rise {
  0%   { transform: translateY(2px); opacity: .15; }
  35%  { opacity: .95; }
  100% { transform: translateY(-6px); opacity: 0; }
}
@keyframes potion-ready {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(111,192,44,0)); }
  50%      { transform: scale(1.07); filter: drop-shadow(0 0 9px rgba(111,192,44,.8)); }
}
@keyframes bar-shine {
  0%   { background-position: -120px 0; }
  100% { background-position: 120px 0; }
}
@keyframes liq-slosh {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(3.2px); }
}
.ico .liq { animation: liq-slosh 2.7s ease-in-out infinite; }

@keyframes pop-in {
  from { transform: scale(.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.card-art svg { animation: potion-bob 3.4s ease-in-out infinite; transform-origin: 50% 80%; }
.cards .card:nth-child(2) .card-art svg { animation-delay: -1.1s; }
.cards .card:nth-child(3) .card-art svg { animation-delay: -2.2s; }
.cards .card:nth-child(4) .card-art svg { animation-delay: -.6s; }
.card-art .bub { animation: bub-rise 2.4s ease-in-out infinite; }
.card-art .bub:nth-of-type(2) { animation-delay: -.8s; }
.card-art .bub:nth-of-type(3) { animation-delay: -1.6s; }
.slot-card.ready .card-art svg { animation: potion-ready 1.2s ease-in-out infinite; }

.brewbar {
  width: 100%; height: 5px; border-radius: 3px; background: #e6eaed;
  overflow: hidden; margin: 2px 0 6px;
}
.brewbar i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, #6fc02c, #9bdb5c, #6fc02c);
  background-size: 120px 100%;
  animation: bar-shine 1.4s linear infinite;
  transition: width .9s linear;
}
.slot-card.ready .brewbar i { background: #6fc02c; animation: none; }

@media (prefers-reduced-motion: reduce) {
  .card-art svg, .card-art .bub, .brewbar i,
  .ico .liq { animation: none !important; }
}
.card-art svg { width: 92px; height: 122px; display: block; }
.card-sub {
  font-size: 11.5px; color: #98a1ab; text-align: center; min-height: 30px;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px;
}
.card-sub svg { width: 15px; height: 15px; vertical-align: -3px; }
.card-sub .on { color: #4e8b36; font-weight: 700; }
.slot-empty { text-align: center; color: #b9bfc6; font-size: 13px; font-weight: 700; }
.slot-empty span { font-size: 11px; font-weight: 400; }

.buy {
  width: 100%; margin-top: auto; padding: 10px 6px; font: inherit; font-size: 15px;
  font-weight: 700; color: #fff; background: #6fc02c; border: 0; border-bottom: 3px solid #559a1f;
  border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
}
.buy:hover:not(.off) { background: #63ad27; }
.buy svg { width: 20px; height: 20px; }
.buy.off { background: #c8cfd4; border-bottom-color: #adb5bb; cursor: default; }
.buy.wide { max-width: 320px; margin: 0 auto; }
.freerow { display: flex; justify-content: center; margin-top: 14px; }

/* the reward reference under the mystery slots: a scrollable gallery */
.gallery {
  display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px;
  scroll-snap-type: x proximity; border-top: 2px solid #eceff2; padding-top: 12px;
  cursor: grab; user-select: none; overscroll-behavior-x: contain;
}
.gallery.dragging { cursor: grabbing; scroll-snap-type: none; }
.gallery.dragging * { pointer-events: none; }
.gallery::-webkit-scrollbar { height: 8px; }
.gallery::-webkit-scrollbar-track { background: #f1f4f6; border-radius: 4px; }
.gallery::-webkit-scrollbar-thumb { background: #cbd4da; border-radius: 4px; }
.gallery::-webkit-scrollbar-thumb:hover { background: #b3bfc7; }
.gcard {
  flex: 0 0 176px; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 8px; background: #f6f8f9; border-radius: 10px;
}
.gart svg { width: 68px; height: 90px; display: block;
  animation: potion-bob 3.4s ease-in-out infinite; transform-origin: 50% 80%; }
.gallery .gcard:nth-child(2) .gart svg { animation-delay: -.7s; }
.gallery .gcard:nth-child(3) .gart svg { animation-delay: -1.4s; }
.gallery .gcard:nth-child(4) .gart svg { animation-delay: -2.1s; }
.gallery .gcard:nth-child(5) .gart svg { animation-delay: -2.8s; }
.gart .bub { animation: bub-rise 2.4s ease-in-out infinite; }
.gname { margin-top: 7px; font-size: 14px; font-weight: 700; color: #56606b; }
.grows { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 7px; margin-top: 5px; }
.grows span { display: inline-flex; align-items: center; gap: 2px; font-size: 10.5px; color: #7b828b; }
.grows svg { width: 13px; height: 13px; }
.gbrew { margin-top: 5px; font-size: 9.5px; color: #a6adb6; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .gart svg, .gart .bub { animation: none !important; }
}


.dead-reward { margin-top: 7px; font-size: 12px; color: #4e8b36; font-weight: 700; line-height: 1.5; }

.meta { margin-top: 16px; text-align: left; }
.meta summary {
  cursor: pointer; font-size: 12px; color: #6ab04c; font-weight: 700;
  letter-spacing: .2px; outline: none;
}
/* The shop list scrolls inside the panel rather than growing it, so the panel
   itself always fits the viewport however many rows the store gains. */
#metaBody {
  margin-top: 10px; font-size: 12px; color: #555b63;
  max-height: calc(100vh - 148px); overflow-y: auto; padding-right: 4px;
}
.wallet {
  display: flex; gap: 18px; font-weight: 700; color: #2b2f36; font-size: 13.5px;
  align-items: center; padding: 7px 11px; background: #f7f9fa;
  border: 1px solid #eaeef1; border-radius: 7px;
}
.wallet span { display: inline-flex; align-items: center; gap: 5px; }
.lvl { margin-top: 5px; color: #7b828b; font-size: 11.5px; }
.xpbar { height: 4px; border-radius: 2px; background: #eceff2; margin-top: 4px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: #6ab04c; }
.meta h5 {
  margin: 9px 0 4px; font-size: 10px; text-transform: uppercase;
  letter-spacing: .8px; color: #a6adb6; font-weight: 700;
}
.slots { display: flex; gap: 8px; }
.slot {
  flex: 1; padding: 7px 6px; border: 1px solid #e4e8ec; border-radius: 6px;
  text-align: center; background: #fafbfc;
}
.slot .t { font-weight: 700; color: #2b2f36; font-size: 11.5px; }
.slot .c { color: #9aa1ab; font-size: 10.5px; margin: 2px 0 4px; }
.slot.empty {
  color: #b9bfc6; font-size: 11px; display: flex; align-items: center;
  justify-content: center; min-height: 98px; border-style: dashed;
}
.meta button {
  font: inherit; font-size: 11px; font-weight: 700; padding: 4px 7px;
  border: 1px solid #d9dee3; border-radius: 4px; background: #fff;
  color: #555b63; cursor: pointer;
}
.meta button:hover:not(:disabled) { background: #f2f4f6; color: #2b2f36; }
.meta button:disabled { opacity: .4; cursor: default; }
.meta button.go { border-color: #bcdcaa; color: #4e8b36; background: #f4faf0; }
.shelf { display: flex; flex-wrap: wrap; gap: 5px; }
.shelf button { flex: 1 1 auto; }
.boost-on { color: #4e8b36; font-weight: 700; }
.rules summary {
  cursor: pointer; font-size: 12px; color: #6ab04c; font-weight: 700;
  letter-spacing: .2px; outline: none;
}
.rules ul { margin: 9px 0 0; padding-left: 18px; font-size: 12px; color: #616870; line-height: 1.65; }
.rules b { color: #2b2f36; }


/* ---------------- dark theme for the dialogs ----------------
   The board already flips; these carry the menu, shop, settings, info and
   the popups along with it. */
body.dark-theme .panel,
body.dark-theme .reward-box {
  background: #1b2027; box-shadow: 0 24px 60px rgba(0,0,0,.7);
}
body.dark-theme .panel h1 { color: #e6edf3; }
body.dark-theme .panel h1 span { color: #7bc95c; }
body.dark-theme .shop-head { border-bottom-color: #2d353f; }
body.dark-theme .shop-head h2,
body.dark-theme .reward-title,
body.dark-theme .card-title,
body.dark-theme .gname { color: #d7dee6; }
body.dark-theme .keysline, body.dark-theme .blurb,
body.dark-theme .lvl, body.dark-theme .fb-sub,
body.dark-theme .card-sub, body.dark-theme .brend-sub,
body.dark-theme .gbrew, body.dark-theme .grows span,
body.dark-theme .dead-score, body.dark-theme .dead-sub { color: #8b949e; }
body.dark-theme .keysline b, body.dark-theme .blurb b,
body.dark-theme .lvl b, body.dark-theme .fb-sub b,
body.dark-theme .fb-lvltext b { color: #d7dee6; }
body.dark-theme .col h4 { color: #7d8790; }
body.dark-theme .col label, body.dark-theme .col label.sub { color: #aab4bf; }
body.dark-theme #nick,
body.dark-theme .col label.num input,
body.dark-theme .col label.num select {
  background: #12161b; border-color: #39424c; color: #dbe3ea;
}
body.dark-theme .card, body.dark-theme .gcard,
body.dark-theme #frontbar, body.dark-theme .wallet .pill,
body.dark-theme .fb-wallet span { background: #232a33; }
body.dark-theme #frontbar { border-color: #2d353f; }
body.dark-theme .wallet .pill, body.dark-theme .fb-wallet span {
  border-color: #3f6d2e; color: #d7dee6;
}
body.dark-theme .card.empty { background: #1e242c; border-color: #39424c; }
body.dark-theme .fs { background: #232a33; border-color: #2d353f; color: #8b949e; }
body.dark-theme .fs.ready { background: #1e2a1c; border-color: #2e4a2b; color: #8fd66a; }
body.dark-theme .tab { background: #232a33; border-color: #39424c; color: #aab4bf; }
body.dark-theme .tab:hover { background: #2b333d; }
body.dark-theme .tab.on { background: #14303c; border-color: #35b6e8; color: #6cc6ec; }
body.dark-theme .xpbar { background: #2d353f; }
body.dark-theme .gallery { border-top-color: #2d353f; }
body.dark-theme .gallery::-webkit-scrollbar-track { background: #232a33; }
body.dark-theme .gallery::-webkit-scrollbar-thumb { background: #39424c; }
body.dark-theme #spectate, body.dark-theme #privworld, body.dark-theme #reset {
  background: #232a33; border-color: #39424c; color: #aab4bf;
}
body.dark-theme #spectate:hover, body.dark-theme #privworld:hover,
body.dark-theme #reset:hover { background: #2b333d; color: #d7dee6; }
body.dark-theme #shop { background: #2c2716; border-color: #4a3f1e; color: #d9b64a; }
body.dark-theme #shop:hover { background: #35301c; }
body.dark-theme #deathbox { background: #2a1c1e; border-color: #4a2b2e; }
body.dark-theme #deathbox.win { background: #2a2415; border-color: #4a3f1e; }
body.dark-theme .buy.off { background: #39424c; border-bottom-color: #2d353f; }
body.dark-theme .info-body ul { color: #aab4bf; }
body.dark-theme .info-body b { color: #e6edf3; }
body.dark-theme .reward-rows .rrow { color: #aab4bf; }
body.dark-theme .fb-boosts span { background: #1e2a1c; border-color: #2e4a2b; color: #8fd66a; }
body.dark-theme .brewbar { background: #2d353f; }
body.dark-theme .slot-empty { color: #5a636d; }


/* ---------------- ML lab ---------------- */
#mlhud {
  position: fixed; top: 14px; left: 14px; z-index: 16; pointer-events: auto;
  width: 320px; padding: 10px 12px; border-radius: 10px;
  background: rgba(15,18,24,.88); color: #cfd7df; font-size: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
}
#mlhud .ml-row { margin-top: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#mlhud .ml-head { margin-top: 0; font-size: 13px; }
#mlhud .ml-head b { color: #6cc6ec; margin-right: 4px; }
#mlhud #mlHist { font-family: Consolas, monospace; font-size: 10.5px; color: #8fa0af; display: block; white-space: pre; }
.mlbtn {
  font: inherit; font-size: 11px; font-weight: 700; padding: 3px 9px;
  border: 1px solid #39424c; border-radius: 4px; background: #232a33; color: #aab4bf;
  cursor: pointer;
}
.mlbtn:hover { background: #2b333d; color: #dbe3ea; }
.mlbtn.on { border-color: #35b6e8; color: #6cc6ec; }
#mlhud .ml-w input {
  width: 44px; font: inherit; font-size: 11px; padding: 2px 4px;
  background: #12161b; border: 1px solid #39424c; border-radius: 3px; color: #dbe3ea;
}
.ml-dep { cursor: pointer; }
.ml-esc { margin-left: auto; color: #5a636d; font-size: 10.5px; }
#mlLab {
  width: 100%; margin-top: 8px; padding: 10px;
  font-size: 13px; font-weight: 700; color: #6cc6ec; font-family: inherit;
  background: #14303c; border: 1px solid #1d4a5c; border-radius: 6px; cursor: pointer;
}
#mlLab:hover { background: #183a49; }


/* ML lab: wipe confirmation */
#mlConfirm {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,14,.66); z-index: 45;
  /* it lives inside #hud, whose pointer-events:none would otherwise let every
     real click fall straight through the dialog */
  pointer-events: auto;
}
.mlc-box { position: relative; }
.mlc-x {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px;
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1;
  color: #fff; background: #e2564a; border: 0; border-radius: 50%; cursor: pointer;
}
.mlc-x:hover { background: #cf4a3f; }
.mlc-box { width: 340px; }
.mlc-btns { display: flex; gap: 8px; margin-top: 16px; }
.mlc-btns button {
  flex: 1; padding: 10px 6px; font: inherit; font-size: 13px; font-weight: 700;
  border: 0; border-radius: 8px; cursor: pointer;
}
#mlWipeYes { color: #fff; background: #e2564a; border-bottom: 3px solid #b93d33; }
#mlWipeYes:hover { background: #cf4a3f; }
#mlWipeNo { color: #56606b; background: #eceff2; border-bottom: 3px solid #d3d9de; }
#mlWipeNo:hover { background: #e2e6ea; }
body.dark-theme #mlWipeNo { background: #232a33; color: #aab4bf; border-bottom-color: #171c22; }
#mlhud { width: 348px; }
/* the training graph: its own panel, same width, sitting right under the hud */
#mlgraphbox {
  position: fixed; left: 14px; z-index: 16; pointer-events: auto;
  width: 348px; padding: 8px 12px 10px; border-radius: 10px;
  background: rgba(15,18,24,.88); color: #cfd7df; font-size: 12px;
  box-shadow: 0 4px 18px rgba(0,0,0,.4);
}
#mlgraphbox .ml-legend {
  display: flex; gap: 12px; font-size: 11px; font-weight: 700; margin-bottom: 6px;
}
.lg-best { color: #7bd66a; }
.lg-avg { color: #6cc6ec; }
.lg-mass { color: #f0a24b; }
.lg-vs { color: #c792ea; cursor: help; }
#mlGraph {
  /* the global canvas rule pins canvases fullscreen for the board - undo it */
  position: static; inset: auto;
  display: block; width: 100%; height: 86px;
  border-radius: 6px; background: #10141a; border: 1px solid #2a323c;
}

/* a finished potion is claimable straight from the menu */
.fs.ready { animation: fs-pulse 2.2s ease-in-out infinite; }
.fs.ready:hover { background: #e7f6dc; border-color: #b6d9a2; }
@keyframes fs-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(110,180,70,0); }
  50%      { box-shadow: 0 0 0 3px rgba(110,180,70,.22); }
}
body.dark-theme .fs.ready:hover { background: #24361f; }
