/* Bean — desktop web. Near-black room, red felt, one loud purple, champagne-gold trim. */

:root {
  --accent: #8F33FF;
  --accent-light: #BC85FF;
  --accent-deep: #4D149E;
  --gold: #D6B066;
  --gold-light: #F7E3AD;
  --gold-dark: #80612B;
  --card: 11, 8, 18;
  --serif: ui-serif, "New York", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --gold-gradient: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dark));
  --coin: none;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: #fff;
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }

[hidden] { display: none !important; }
.defs { position: absolute; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }

#arena {
  position: fixed;
  left: 0;
  top: 0;
  display: block;
  touch-action: none;
  cursor: default;
}
body.playing #arena { cursor: crosshair; }

.layer {
  position: fixed;
  inset: 0;
  padding: max(10px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
           max(10px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}

/* ---------- Shared pieces ---------- */

.caps {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.32em;
  margin-right: -0.32em;
  text-transform: uppercase;
  color: var(--gold);
}
.caps.dim { color: rgba(255, 255, 255, 0.5); }

.gold-text {
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}

.plaque {
  background: rgba(var(--card), 0.88);
  border: 0.75px solid rgba(214, 176, 102, 0.45);
  border-radius: 12px;
}

.ornament { display: flex; align-items: center; gap: 10px; max-width: 100%; }
.ornament i { flex: 1; height: 1px; background: rgba(214, 176, 102, 0.6); }
.ornament b { width: 6px; height: 6px; background: var(--gold); transform: rotate(45deg); }

.cash { --cash: 17px; display: inline-flex; align-items: center; gap: calc(var(--cash) * 0.35); }
.cash b {
  font-family: var(--serif);
  font-weight: 700;
  font-size: var(--cash);
  color: var(--gold-light);
  font-variant-numeric: tabular-nums;
}
.coin {
  display: inline-block;
  width: calc(var(--cash) * 1.25);
  height: calc(var(--cash) * 1.25);
  background: var(--coin) center / contain no-repeat;
  flex: none;
}

.round {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: rgba(var(--card), 0.88);
  border: 0.75px solid rgba(214, 176, 102, 0.55);
  color: #fff;
  position: relative;
  transition: transform 0.1s ease-out, border-color 0.2s;
}
.round svg { width: 17px; height: 17px; fill: currentColor; }
.round:hover { border-color: rgba(247, 227, 173, 0.9); }
.round:active { transform: scale(0.92); }

.primary {
  width: 100%;
  height: 56px;
  border-radius: 28px;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 4px;
  text-indent: 4px;
  text-transform: uppercase;
  color: #fff;
  background:
    linear-gradient(180deg, var(--accent), var(--accent-deep)) padding-box,
    var(--gold-gradient) border-box;
  border: 1.25px solid transparent;
  box-shadow: 0 6px 22px rgba(143, 51, 255, 0.5);
  position: relative;
  transition: transform 0.1s ease-out, filter 0.2s, box-shadow 0.2s;
}
.primary::after, .action::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: inherit;
  border: 0.75px solid rgba(214, 176, 102, 0.3);
  pointer-events: none;
}
.primary:hover { filter: brightness(1.12); box-shadow: 0 6px 28px rgba(143, 51, 255, 0.7); }
.primary:active { transform: scale(0.98); }

.secondary {
  width: 100%;
  height: 48px;
  border-radius: 24px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 3.5px;
  text-indent: 3.5px;
  text-transform: uppercase;
  color: rgba(247, 227, 173, 0.9);
  border: 0.75px solid rgba(214, 176, 102, 0.45);
  transition: transform 0.1s ease-out, border-color 0.2s, background 0.2s;
}
.secondary:hover { border-color: rgba(247, 227, 173, 0.85); background: rgba(214, 176, 102, 0.07); }
.secondary:active { transform: scale(0.98); }

.tagline {
  margin: 14px 0 0;
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.7);
}

.heading {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 10px;
  padding-left: 10px;
  line-height: 1.2;
}

.stack { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 320px; margin: 0; }
.grow { flex: 1 1 0; min-height: 10px; }

/* ---------- Overlays ---------- */

.overlay {
  display: flex;
  justify-content: center;
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
  z-index: 20;
}
.overlay.show { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 0.3s ease-in-out; }

.scrim { background: linear-gradient(180deg, rgba(0, 0, 0, 0.92), rgba(0, 0, 0, 0.62) 50%, rgba(0, 0, 0, 0.92)); }

.column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: 100%;
  padding: 0 10px;
  text-align: center;
}

/* ---------- Menu ---------- */

.toggles { position: absolute; top: max(14px, env(safe-area-inset-top)); right: max(20px, env(safe-area-inset-right)); display: flex; gap: 10px; z-index: 2; }
.toggle { color: var(--gold-light); }
.toggle[aria-pressed="false"] { color: rgba(255, 255, 255, 0.3); border-color: rgba(214, 176, 102, 0.2); }
.toggle[aria-pressed="false"]::after {
  content: "";
  position: absolute;
  width: 24px;
  height: 1.25px;
  background: rgba(255, 255, 255, 0.45);
  transform: rotate(-45deg);
}

.menu-column { height: 100%; min-height: 600px; }
.menu-bean { width: 104px; height: 104px; flex: none; }
.title {
  margin: -6px 0 0;
  font-weight: 700;
  font-size: 62px;
  line-height: 1.15;
  letter-spacing: 18px;
  padding-left: 18px;
  filter: drop-shadow(0 0 22px rgba(143, 51, 255, 0.7));
}
.menu-column .ornament { margin-top: 6px; }

.name-field {
  width: 100%;
  height: 52px;
  border-radius: 26px;
  border: 0.75px solid rgba(214, 176, 102, 0.4);
  background: rgba(var(--card), 0.9);
  color: #fff;
  font-family: var(--serif);
  font-size: 18px;
  text-align: center;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
  transition: border-color 0.2s;
}
.name-field::placeholder { color: rgba(255, 255, 255, 0.35); }
.name-field:focus, .name-field:focus-visible { border-color: rgba(214, 176, 102, 0.95); outline: none; }

.bank { display: flex; justify-content: center; align-items: center; gap: 22px; padding-top: 8px; min-height: 30px; }
.bank-item { display: inline-flex; align-items: center; gap: 8px; }
.bank-best { font-size: 15px; font-weight: 700; color: var(--gold-light); }

.hints { display: flex; justify-content: center; align-items: flex-start; gap: 22px; padding-bottom: 6px; flex-wrap: wrap; }
.hint { display: flex; flex-direction: column; align-items: center; gap: 8px; font-style: italic; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.keys { display: inline-flex; gap: 5px; }
kbd {
  display: inline-block;
  min-width: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 0.75px solid rgba(214, 176, 102, 0.55);
  background: rgba(var(--card), 0.88);
  font-family: var(--sans);
  font-style: normal;
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}
.hints-touch { display: none; }
@media (hover: none) and (pointer: coarse) {
  .hints-keys { display: none; }
  .hints-touch { display: flex; }
}

.menu-footer { padding: 8px 0 4px; }
.menu-footer a {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-decoration: none;
  color: rgba(214, 176, 102, 0.7);
  transition: color 0.2s;
}
.menu-footer a:hover { color: var(--gold-light); }

/* ---------- Shop ---------- */

.shop { background: rgba(0, 0, 0, 0.95); z-index: 30; transition-duration: 0.25s; }
.shop-column { max-width: 640px; padding: 0; }
.shop-bar { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 4px 2px 0; }
.shop-bar .round { color: var(--gold-light); }
.shop-wallet {
  height: 40px;
  padding: 0 14px;
  border-radius: 20px;
  background: rgb(var(--card));
  border: 0.75px solid rgba(214, 176, 102, 0.55);
}
.shop .heading { margin-top: 10px; }
.shop-tagline { font-size: 15px; color: rgba(255, 255, 255, 0.65); margin: 10px 0 14px; }

.skins { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 2px 24px; }
@media (max-width: 560px) { .skins { grid-template-columns: repeat(2, 1fr); } }

.skin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 12px;
  border-radius: 14px;
  background: rgba(var(--card), 0.9);
  border: 0.75px solid rgba(214, 176, 102, 0.35);
  transition: border-color 0.2s, transform 0.1s ease-out, background 0.2s;
}
.skin canvas { width: 92px; height: 92px; }
.skin-name { font-weight: 600; font-size: 16px; color: #fff; }
.skin-foot { height: 34px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.skin[data-status="wearing"] { cursor: default; border: 1.5px solid transparent; background: linear-gradient(rgb(var(--card)), rgb(var(--card))) padding-box, var(--gold-gradient) border-box; }
.skin[data-status="tooDear"] { cursor: default; }
.skin[data-status="tooDear"] canvas { opacity: 0.55; }
.skin[data-status="owned"]:hover, .skin[data-status="affordable"]:hover { border-color: rgba(247, 227, 173, 0.8); }
.skin[data-status="owned"]:active, .skin[data-status="affordable"]:active { transform: scale(0.98); }

.skin-wearing { display: inline-flex; align-items: center; gap: 6px; color: var(--gold); }
.skin-wearing svg { width: 11px; height: 11px; }
.skin-wearing .caps { letter-spacing: 3px; margin-right: -3px; }
.skin-wear {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 22px;
  border-radius: 15px;
  border: 0.75px solid rgba(214, 176, 102, 0.6);
}
.skin-wear .caps { color: var(--gold-light); letter-spacing: 3px; margin-right: -3px; }
.skin-buy {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 16px;
  border-radius: 15px;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep)) padding-box, var(--gold-gradient) border-box;
  border: 1px solid transparent;
}
.skin-short { font-style: italic; font-size: 11px; color: rgba(255, 255, 255, 0.45); margin-top: 2px; }
.skin-dear .cash { opacity: 0.55; }

/* ---------- Pause ---------- */

.pause { background: rgba(0, 0, 0, 0.8); }
.pause-column { max-width: 300px; justify-content: center; gap: 14px; padding: 28px 0; }
.pause-column .heading { margin: 0; }

/* ---------- Game over ---------- */

.over-column { max-width: 420px; justify-content: center; padding: 20px 10px; }
.over-killer { margin: 0; font-size: 17px; }
.over-score {
  font-weight: 700;
  font-size: 92px;
  line-height: 1.12;
  font-variant-numeric: tabular-nums;
  filter: drop-shadow(0 0 24px rgba(143, 51, 255, 0.7));
}
.over-label { font-size: 11px; }
.stats { display: flex; gap: 10px; width: 100%; margin-top: 24px; }
.stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 14px 4px; }
.stat b { font-size: 22px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.stat .caps { font-size: 8.5px; }
.purse { display: flex; align-items: center; width: 100%; padding: 14px 0; margin: 10px 0 26px; }
.purse-half { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.purse-half .caps { font-size: 9px; }
.purse-rule { width: 0.75px; min-width: 1px; height: 38px; background: rgba(214, 176, 102, 0.35); }
.over-column .stack { gap: 12px; }

/* ---------- HUD ---------- */

#hud {
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-in-out, visibility 0s linear 0.3s;
  z-index: 10;
}
#hud.show { opacity: 1; visibility: visible; transition: opacity 0.3s ease-in-out; }

.hud-left { position: absolute; top: max(10px, env(safe-area-inset-top)); left: max(18px, env(safe-area-inset-left)); display: flex; flex-direction: column; align-items: flex-start; }
.hud-label { letter-spacing: 3.5px; }
.hud-score { font-weight: 700; font-size: 42px; line-height: 1.1; color: #fff; font-variant-numeric: tabular-nums; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.5); }
.hud-rank { font-style: italic; font-size: 13px; color: rgba(255, 255, 255, 0.6); }
.hud-cash { margin-top: 8px; }
.minimap { width: 70px; height: 70px; margin-top: 10px; }
.hud-powers { display: flex; gap: 8px; margin-top: 10px; min-height: 40px; }
.hud-powers canvas { width: 40px; height: 40px; }

.hud-right { position: absolute; top: max(10px, env(safe-area-inset-top)); right: max(18px, env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#hud.show #btn-pause, #hud.show .action { pointer-events: auto; }
#btn-pause svg { width: 16px; height: 16px; }

.leaderboard { width: 156px; padding: 10px 12px; border-radius: 10px; }
.leaders-title { font-size: 9px; letter-spacing: 3px; margin-right: -3px; text-align: center; }
.leaders-rule { height: 0.75px; min-height: 1px; background: rgba(214, 176, 102, 0.35); margin: 5px 0 7px; }
#leaders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
#leaders li { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: rgba(255, 255, 255, 0.85); }
#leaders .lead-rank { width: 12px; text-align: left; color: rgba(255, 255, 255, 0.4); flex: none; }
#leaders .lead-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
#leaders .lead-mass { font-variant-numeric: tabular-nums; color: rgba(255, 255, 255, 0.55); }
#leaders li.me { font-weight: 700; color: var(--gold-light); }
#leaders li.me .lead-mass { color: #fff; }

.hud-actions { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 16px; }
.action {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--gold-light);
  background: linear-gradient(180deg, var(--accent), var(--accent-deep)) padding-box, var(--gold-gradient) border-box;
  border: 1.5px solid transparent;
  opacity: 0.3;
  transition: opacity 0.15s ease-out, box-shadow 0.15s ease-out, transform 0.1s ease-out;
  touch-action: none;
}
.action::after { inset: 5px; border-color: rgba(214, 176, 102, 0.35); }
.action-big { width: 78px; height: 78px; }
.action svg { width: 36%; height: 36%; fill: currentColor; margin-top: -6px; }
.action.ready { opacity: 1; box-shadow: 0 0 22px rgba(143, 51, 255, 0.55); }
.action:active, .action.pressed { transform: scale(0.9); }
.action-key {
  position: absolute;
  bottom: 9px;
  left: 0;
  right: 0;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 7.5px;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  text-transform: uppercase;
  color: rgba(247, 227, 173, 0.75);
}
.action-big .action-key { bottom: 13px; font-size: 8.5px; }
@media (hover: none) and (pointer: coarse) {
  .action-key { display: none; }
  .action svg { margin-top: 0; }
}

/* ---------- Touch joystick ---------- */

#joystick { position: fixed; inset: 0; pointer-events: none; display: none; z-index: 5; }
#joystick.on { display: block; }
.joy-ring {
  position: absolute;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  border: 2px solid rgba(143, 51, 255, 0.55);
  background: rgba(143, 51, 255, 0.08);
}
.joy-knob {
  position: absolute;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: rgba(188, 133, 255, 0.85);
}

.noscript { position: fixed; inset: auto 0 20px; text-align: center; font-style: italic; color: var(--gold-light); z-index: 99; }

@media (max-height: 640px) {
  .title { font-size: 48px; }
  .menu-bean { width: 80px; height: 80px; }
  .over-score { font-size: 68px; }
  .stats { margin-top: 14px; }
  .purse { margin-bottom: 16px; }
}
@media (max-width: 520px) {
  .leaderboard { width: 136px; }
  .hints { gap: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .overlay, #hud, .primary, .secondary, .round, .action, .skin { transition: none; }
}
