/* Components: buttons, panels, chips, sheet, modal, toasts, progress, ring, tiles, HUD, nav, onboarding.
   Arena design system — see tokens.css for the principles (ink outlines, bevels, one yellow CTA). */

/* =========================================================================
   ICONS (js/ui/icons.js) — 1em by default so they scale with their text
   ========================================================================= */
.ic { width: 1em; height: 1em; flex: none; display: inline-block; vertical-align: -0.15em; overflow: visible; }
.ic .o { stroke: var(--ink); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.ic .hl { fill: #fff; }
.ic--dim { filter: grayscale(1) brightness(0.85); opacity: 0.6; }

/* =========================================================================
   BUTTONS — beveled face, ink outline, inner lip that compresses on press
   variants: primary (blue) · gold (yellow: THE next action) · success (green) · danger (red) · ghost (slate)
   ========================================================================= */
.btn {
  --btn-hi: var(--blue-btn);
  --btn-lo: var(--blue-btn-lo);
  --btn-edge: var(--blue-btn-edge);
  --btn-fg: #fff;
  --btn-lip: 5px;
  --btn-h: var(--tap);

  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: var(--btn-h);
  min-width: var(--tap);
  margin-bottom: 4px;
  padding: 0 var(--s-5) var(--btn-lip);
  border: 2.5px solid var(--ink);
  border-radius: var(--r-md);
  background: linear-gradient(180deg, var(--btn-hi) 0%, var(--btn-hi) 45%, var(--btn-lo) 100%);
  color: var(--btn-fg);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.02em;
  text-shadow: var(--ts-outline-sm);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  box-shadow:
    inset 0 calc(var(--btn-lip) * -1) 0 var(--btn-edge),
    inset 0 2px 0 rgba(255, 255, 255, 0.45),
    0 4px 0 var(--ink-soft);
  transform: translate3d(0, 0, 0);
  transition: transform 60ms ease-out, box-shadow 60ms ease-out, padding 60ms ease-out, filter var(--t-fast);
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
/* gloss on the upper half */
.btn::before {
  content: '';
  position: absolute;
  left: 4px; right: 4px; top: 3px;
  height: 38%;
  border-radius: calc(var(--r-md) - 4px) calc(var(--r-md) - 4px) 40% 40% / calc(var(--r-md) - 4px) calc(var(--r-md) - 4px) 60% 60%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.08));
  pointer-events: none;
  z-index: -1;
}
.btn::after { content: none; }
.btn:active:not(:disabled),
.btn.is-down:not(:disabled) {
  transform: translate3d(0, 3px, 0);
  padding-bottom: 2px;
  box-shadow:
    inset 0 -2px 0 var(--btn-edge),
    inset 0 2px 0 rgba(255, 255, 255, 0.35),
    0 1px 0 var(--ink-soft);
  filter: brightness(1.06);
}
.btn.is-popping { animation: btn-pop 260ms var(--ease-pop); }
@keyframes btn-pop {
  0% { scale: 1; }
  40% { scale: 1.05 0.95; }
  70% { scale: 0.98 1.02; }
  100% { scale: 1; }
}
.btn:disabled, .btn[aria-disabled='true'] {
  --btn-hi: #9aa6bf; --btn-lo: #7d89a3; --btn-edge: #566079;
  color: #e9edf5;
  cursor: not-allowed;
}
.btn__icon { display: inline-flex; font-size: 1.35em; line-height: 1; text-shadow: none; }
.btn__icon .ic { vertical-align: 0; }
.btn__label { position: relative; }

.btn--primary { /* blue — defaults */ }
.btn--gold {
  --btn-hi: #ffd84a; --btn-lo: var(--yellow-lo); --btn-edge: var(--yellow-edge);
}
.btn--success { --btn-hi: var(--green); --btn-lo: var(--green-lo); --btn-edge: var(--green-edge); }
.btn--danger { --btn-hi: var(--red-btn); --btn-lo: var(--red-btn-lo); --btn-edge: var(--red-btn-edge); }
.btn--ghost { --btn-hi: var(--slate); --btn-lo: var(--slate-lo); --btn-edge: var(--slate-edge); }
.btn--sm { --btn-h: 42px; --btn-lip: 4px; padding-left: var(--s-4); padding-right: var(--s-4); font-size: 15px; border-radius: var(--r-sm); border-width: 2px; }
.btn--sm::before { border-radius: 5px 5px 40% 40% / 5px 5px 60% 60%; }
.btn--md { }
.btn--lg { --btn-h: 64px; --btn-lip: 6px; font-size: 22px; padding-left: var(--s-6); padding-right: var(--s-6); }
.btn--xl { --btn-h: 80px; --btn-lip: 7px; font-size: 28px; padding-left: var(--s-6); padding-right: var(--s-6); border-radius: var(--r-lg); width: 100%; border-width: 3px; }
.btn--xl::before { border-radius: 12px 12px 40% 40% / 12px 12px 60% 60%; }
.btn--block { display: flex; width: 100%; }
.btn--icon { padding-left: 0; padding-right: 0; width: var(--btn-h); }

/* =========================================================================
   PANELS / CHIPS / BADGES / TITLES
   ========================================================================= */
.card {
  position: relative;
  background: var(--grad-panel);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  box-shadow: var(--bevel), var(--shadow-card);
}
/* highlighted panel: white inner ring (selection / "this one") */
.card--glow { box-shadow: var(--bevel), inset 0 0 0 3px rgba(255, 255, 255, 0.75), var(--shadow-card); }
/* reward panel: gold inner ring */
.card--gold { box-shadow: var(--bevel), inset 0 0 0 3px var(--yellow), var(--shadow-card); }
.card--tap { cursor: pointer; transition: transform var(--t-fast) var(--ease-out); }
.card--tap:active { transform: translateY(2px) scale(0.985); }
/* recessed well inside a panel */
.well {
  background: var(--bg-2);
  border-radius: var(--r-md);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.25);
  border: 2px solid var(--ink);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 var(--s-3);
  border-radius: var(--r-pill);
  background: rgba(13, 24, 56, 0.55);
  border: 2px solid var(--ink);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  text-shadow: var(--ts-outline-sm);
}
.chip .ic { font-size: 18px; margin-left: -4px; }
.chip--gt { color: var(--gold); }
.chip--xp { color: #e2b6ff; }
.chip--accent { color: #fff; background: var(--blue-btn-lo); }
.chip--good { color: var(--good); }
.chip--bad { color: var(--bad); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--red-btn);
  border: 2px solid var(--ink);
  color: #fff;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: var(--ts-outline-sm);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.badge--gold { background: var(--yellow); }
.badge--lime { background: var(--green); }
.badge--common    { background: var(--r-common); }
.badge--rare      { background: var(--r-rare); }
.badge--epic      { background: var(--r-epic); }
.badge--legendary { background: var(--r-legendary); }

.section-title {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-2);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-shadow: var(--ts-outline);
}
.section-title .ic { font-size: 26px; }
.section-title > .grow + * { margin-left: auto; text-shadow: none; }

.display { font-family: var(--font-display); font-weight: 400; text-shadow: var(--ts-outline); }
.divider { height: 2px; background: var(--line); border: 0; margin: var(--s-2) 0; }

/* =========================================================================
   FORM CONTROLS
   ========================================================================= */
.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--s-4);
  border-radius: var(--r-md);
  border: 2.5px solid var(--ink);
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  box-shadow: inset 0 3px 0 rgba(13, 24, 56, 0.15);
  transition: box-shadow var(--t-fast);
}
.input::placeholder { color: #8b98b8; font-family: var(--font); font-weight: 700; }
.input:focus { outline: none; box-shadow: inset 0 3px 0 rgba(13, 24, 56, 0.15), 0 0 0 3px var(--yellow); }

.toggle {
  position: relative;
  flex: none;
  width: 60px;
  height: 34px;
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  transition: background var(--t-med);
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #dfe6f3);
  border: 2px solid var(--ink);
  box-sizing: border-box;
  transition: transform var(--t-med) var(--ease-pop);
}
.toggle[aria-checked='true'] { background: var(--green-lo); }
.toggle[aria-checked='true']::after { transform: translateX(26px); }

.choice {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  min-height: 64px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  border: 2px solid var(--ink);
  background: var(--grad-panel);
  box-shadow: var(--bevel), var(--shadow-card);
  text-align: left;
  font-family: var(--font-display);
  font-size: 18px;
  text-shadow: var(--ts-outline-sm);
  transition: transform var(--t-fast) var(--ease-pop), box-shadow var(--t-fast);
}
.choice .muted { font-family: var(--font); font-size: var(--fs-sm); text-shadow: none; }
.choice:active { transform: translateY(2px); }
.choice.is-selected { box-shadow: var(--bevel), inset 0 0 0 3px var(--yellow), var(--shadow-card); }
.choice__emoji { font-size: 36px; line-height: 1; display: inline-flex; }

/* =========================================================================
   BOTTOM SHEET + MODAL — panel with a title banner
   ========================================================================= */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  background: rgba(6, 12, 34, 0.62);
  opacity: 0;
  transition: opacity var(--t-med) ease-out;
}
.backdrop.is-open { opacity: 1; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-sheet);
  max-width: 640px;
  max-height: 88dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 2.5px solid var(--ink);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: inset 0 3px 0 var(--panel-hi), 0 -8px 30px rgba(0, 0, 0, 0.35);
  transform: translate3d(0, 105%, 0);
  transition: transform var(--t-slow) var(--ease-out);
  padding-bottom: var(--safe-bottom);
  will-change: transform;
}
.sheet.is-open { transform: translate3d(0, 0, 0); }
.sheet.is-dragging { transition: none; }
.sheet__grab {
  flex: none;
  padding: var(--s-2) var(--s-4) var(--s-3);
  touch-action: none;
  cursor: grab;
}
.sheet__handle {
  width: 48px; height: 6px;
  margin: 0 auto var(--s-3);
  border-radius: var(--r-pill);
  background: rgba(13, 24, 56, 0.55);
}
.sheet__title {
  font-family: var(--font-display);
  font-size: 24px;
  text-align: center;
  text-shadow: var(--ts-outline);
}
.sheet__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-2) var(--s-4) var(--s-5);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-sheet);
  display: grid;
  place-items: center;
  padding: var(--s-5);
  pointer-events: none;
}
.modal__card {
  pointer-events: auto;
  width: 100%;
  max-width: 380px;
  padding: 0 var(--s-5) var(--s-5);
  border-radius: 20px;
  background: var(--paper);
  color: var(--paper-ink);
  border: 3px solid var(--ink);
  box-shadow: inset 0 -4px 0 var(--paper-2), var(--shadow-pop);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  text-align: center;
  overflow: hidden;
  transform: scale(0.85);
  opacity: 0;
  transition: transform var(--t-med) var(--ease-pop), opacity var(--t-fast);
}
.modal.is-open .modal__card { transform: none; opacity: 1; }
.modal__title {
  margin: 0 calc(var(--s-5) * -1);
  padding: var(--s-4) var(--s-5);
  background: linear-gradient(180deg, var(--surface-3), var(--surface));
  border-bottom: 3px solid var(--ink);
  color: #fff;
  font-size: 24px;
}
.modal--danger .modal__title { background: linear-gradient(180deg, var(--red-btn), var(--red-btn-lo)); }
.modal__body { color: var(--paper-ink); font-weight: 700; }
.modal__actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.modal__actions .btn { padding-left: var(--s-3); padding-right: var(--s-3); }

/* =========================================================================
   TOASTS — ink pill with a colored icon tab
   ========================================================================= */
.toast-stack {
  position: fixed;
  top: calc(var(--safe-top) + var(--hud-h) + var(--s-2));
  left: 0; right: 0;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  pointer-events: none;
}
.toast {
  --toast-c: var(--blue-btn);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: 100%;
  padding: var(--s-2) var(--s-4) var(--s-2) var(--s-2);
  border-radius: var(--r-pill);
  background: rgba(13, 24, 56, 0.94);
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--toast-c) 70%, transparent), var(--shadow-pop);
  font-family: var(--font-display);
  font-size: 16px;
  text-shadow: var(--ts-outline-sm);
  animation: toast-in var(--t-slow) var(--ease-pop) both;
}
.toast.is-leaving { animation: toast-out var(--t-med) ease-in both; }
.toast__icon {
  flex: none;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--toast-c) 35%, var(--bg-2));
  font-size: 24px; line-height: 1;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-24px) scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-16px) scale(0.95); } }

/* =========================================================================
   PROGRESS BAR — ink-outlined well, glossy fill
   ========================================================================= */
.progress { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.progress__label { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 800; color: var(--text-dim); }
.progress__right { font-family: var(--font-display); font-weight: 400; color: #fff; text-shadow: var(--ts-outline-sm); }
.progress__track {
  --bar-c: var(--blue-btn);
  position: relative;
  height: var(--bar-h, 14px);
  border-radius: var(--r-pill);
  background: var(--bg-2);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  overflow: hidden;
  box-sizing: content-box;
}
.progress__fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4) 0 35%, transparent 35% 70%, rgba(0, 0, 0, 0.15) 70%),
    var(--bar-c);
  transform-origin: 0 50%;
  transform: scaleX(var(--p, 0));
  transition: transform 700ms var(--ease-out);
}
.progress__track::after { content: none; }
.progress--gold .progress__track { --bar-c: var(--yellow); }
.progress--xp .progress__track { --bar-c: var(--violet); }
.progress.is-full .progress__track { --bar-c: var(--green); }

/* =========================================================================
   RING
   ========================================================================= */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); overflow: visible; }
.ring__track { fill: none; stroke: var(--bg-2); }
.ring__arc {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 400ms var(--ease-out), stroke var(--t-med);
}
.ring__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1;
}
.ring__text { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: var(--ring-fs, var(--fs-2xl)); text-shadow: var(--ts-outline); }
.ring__sub { margin-top: var(--s-1); font-size: var(--fs-sm); font-weight: 800; color: var(--text-dim); }

/* =========================================================================
   STAT TILE / EMPTY STATE
   ========================================================================= */
.stat-tile {
  --tile-c: #fff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: rgba(13, 24, 56, 0.35);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
  min-width: 0;
}
.stat-tile__value {
  font-family: var(--font-num);
  font-size: var(--fs-xl);
  font-variant-numeric: tabular-nums;
  color: var(--tile-c);
  text-shadow: var(--ts-outline-sm);
  line-height: 1.05;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-tile__label { display: flex; gap: 6px; align-items: center; font-size: var(--fs-sm); color: var(--text-dim); font-weight: 800; }
.stat-tile__label .ic { font-size: 18px; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-4);
  text-align: center;
  color: var(--text-dim);
  font-weight: 800;
  background: rgba(13, 24, 56, 0.3);
  border: 2px solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
}
.empty-state__emoji { font-size: 52px; line-height: 1; display: inline-flex; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }

/* =========================================================================
   HUD (top bar) — rank badge + resource pills with overlapping icons
   ========================================================================= */
.hud {
  --hide-y: -130%;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: var(--z-hud);
  height: calc(var(--safe-top) + var(--hud-h));
  padding: var(--safe-top) var(--s-3) 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 80%, #000) 0%, var(--bg) 100%);
  border-bottom: 3px solid var(--ink);
  box-shadow: inset 0 -3px 0 rgba(255, 255, 255, 0.08), 0 4px 0 var(--ink-soft);
  transition: transform var(--t-med) var(--ease-out), opacity var(--t-med);
}
.hud__rank {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
  flex: 1 1 auto;
  height: 48px;
  text-align: left;
}
.hud__emblem {
  --rank-c: var(--blue-btn);
  position: relative;
  flex: none;
  width: 42px; height: 46px;
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
}
/* shield-shaped badge: ink outline layer + colored face */
.hud__emblem::before, .hud__emblem::after {
  content: '';
  position: absolute;
  clip-path: polygon(50% 0, 100% 16%, 100% 62%, 50% 100%, 0 62%, 0 16%);
}
.hud__emblem::before { inset: 0; background: var(--ink); }
.hud__emblem::after {
  inset: 3px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rank-c) 70%, #fff) 0%, var(--rank-c) 45%, color-mix(in srgb, var(--rank-c) 70%, #000) 100%);
}
.hud__emblem > span { position: relative; z-index: 1; display: inline-flex; }
.hud__rank-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.1; gap: 1px; }
.hud__rank-name {
  font-family: var(--font-display);
  font-size: 16px;
  text-shadow: var(--ts-outline-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hud__rank-sub { font-size: 12px; font-weight: 800; color: var(--text-dim); }
.hud__rank-xp {
  margin-top: 2px; width: 76px; height: 6px;
  border-radius: 4px; background: var(--bg-2); border: 1.5px solid var(--ink); overflow: hidden; box-sizing: content-box;
}
.hud__rank-xp > i { display: block; height: 100%; background: var(--violet); transform-origin: 0 50%; transform: scaleX(var(--p, 0)); transition: transform var(--t-slow) var(--ease-out); }

/* resource pill: dark pill, icon overlapping its left edge */
.hud__pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  height: 32px;
  min-width: 62px;
  padding: 0 var(--s-3) 0 30px;
  margin-left: 12px;
  border-radius: var(--r-pill);
  background: rgba(13, 24, 56, 0.72);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.3);
  font-family: var(--font-num);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-shadow: var(--ts-outline-sm);
  line-height: 1;
  white-space: nowrap;
  flex: none;
}
.hud__pill > .hud__pill-ic {
  position: absolute;
  left: -14px; top: 50%;
  translate: 0 -50%;
  width: 40px; height: 40px;
  display: grid; place-items: center;
  font-size: 38px;
}
.hud__streak .flame { display: inline-flex; transform-origin: 50% 90%; }
.hud__streak.is-hot .flame { animation: flicker 0.9s ease-in-out infinite alternate; }
.hud__streak.is-cold { color: var(--text-dim); }
.hud__streak.is-cold .flame .ic { filter: grayscale(1) brightness(0.9); }
@keyframes flicker {
  0%   { transform: scale(1, 1) rotate(-3deg); }
  30%  { transform: scale(1.06, 0.95) rotate(2deg); }
  60%  { transform: scale(0.96, 1.06) rotate(-1deg); }
  100% { transform: scale(1.04, 1) rotate(3deg); }
}

.hud__crate {
  position: relative;
  width: 42px; height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  font-size: 38px;
  animation: crate-bounce 1.6s var(--ease-pop) infinite;
}
.hud__crate .badge { position: absolute; top: -4px; right: -6px; }
@keyframes crate-bounce {
  0%, 60%, 100% { transform: translateY(0) rotate(0); }
  20% { transform: translateY(-6px) rotate(-6deg); }
  35% { transform: translateY(0) rotate(4deg) scale(1.05, 0.94); }
  48% { transform: translateY(-2px) rotate(-1deg); }
}

.hud__bank { color: #fff; }
.hud__coin { display: none; }
.hud__gt { min-width: 2.5ch; text-align: right; }
.hud__bank.is-bump { animation: hud-bump 420ms var(--ease-pop); }
.hud__bank.is-drop { animation: hud-drop 420ms ease-out; }
@keyframes hud-bump { 40% { transform: scale(1.15); } }
@keyframes hud-drop { 30% { transform: translateY(2px) scale(0.94); } }

/* =========================================================================
   BOTTOM NAV — uniform tabs; the active tab is a raised panel with its label
   ========================================================================= */
.nav {
  --hide-y: 130%;
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-nav);
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  transition: transform var(--t-med) var(--ease-out), opacity var(--t-med);
}
.nav__bar {
  position: absolute;
  inset: 8px 0 0 0;
  background: linear-gradient(180deg, var(--bg) 0%, color-mix(in srgb, var(--bg) 80%, #000) 100%);
  border-top: 3px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.12);
}
.nav__tabs {
  position: relative;
  height: var(--nav-h);
  display: flex;
  align-items: stretch;
  padding: 8px 6px 0;
  gap: 4px;
}
.nav__tab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 6px 0 8px;
  border-radius: var(--r-md);
  color: #fff;
  font-family: var(--font-display);
  font-size: 13px;
  text-shadow: var(--ts-outline-sm);
  transition: flex-grow var(--t-med) var(--ease-out), margin var(--t-med) var(--ease-out);
}
.nav__icon { display: inline-flex; font-size: 34px; line-height: 1; transition: transform var(--t-med) var(--ease-pop), filter var(--t-med); filter: saturate(0.75) brightness(0.9); }
.nav__label { display: none; white-space: nowrap; }
.nav__tab.is-active {
  flex-grow: 1.55;
  margin: -6px 0 6px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface-3) 70%, #fff) 0%, var(--surface-3) 55%, var(--surface) 100%);
  border: 2.5px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(0, 0, 0, 0.2), 0 4px 0 var(--ink-soft);
}
.nav__tab.is-active .nav__icon { transform: translateY(-2px) scale(1.12); filter: none; }
.nav__tab.is-active .nav__label { display: block; }
.nav__tab:active .nav__icon { transform: scale(0.88); }
.nav__tab.is-rest .nav__icon { filter: grayscale(0.9) brightness(0.85); }
.nav__tab .badge { position: absolute; top: 2px; right: calc(50% - 26px); z-index: 2; }
.nav__tab.is-active .badge { top: -6px; }
.nav__indicator { display: none; }

/* =========================================================================
   ONBOARDING
   ========================================================================= */
.onb {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.onb__top { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.onb__dots { display: flex; gap: 6px; }
.onb__dot { width: 12px; height: 12px; border-radius: var(--r-pill); background: var(--bg-2); border: 2px solid var(--ink); transition: width var(--t-med) var(--ease-pop), background var(--t-med); }
.onb__dot.is-on { width: 30px; background: var(--yellow); }
.onb__dot.is-done { background: var(--green); }
.onb__back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 var(--s-2); font-family: var(--font-display); font-size: 18px; text-shadow: var(--ts-outline-sm); }
.onb__back .ic { font-size: 20px; }
.onb__step {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--s-5);
  padding: var(--s-5) 0;
  animation: onb-in var(--t-slow) var(--ease-out) both;
}
.onb__step > * { animation: onb-rise 520ms var(--ease-out) both; }
.onb__step > *:nth-child(2) { animation-delay: 70ms; }
.onb__step > *:nth-child(3) { animation-delay: 140ms; }
.onb__step > *:nth-child(4) { animation-delay: 210ms; }
.onb__step > *:nth-child(5) { animation-delay: 280ms; }
@keyframes onb-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes onb-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.onb__foot { flex: none; display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-3); }
.onb__kicker { font-family: var(--font-display); font-size: 16px; letter-spacing: 0.04em; color: var(--yellow); text-shadow: var(--ts-outline-sm); }
.onb__headline { font-size: var(--fs-2xl); line-height: 1; }
.onb__lead { font-size: 17px; color: var(--text-dim); font-weight: 700; }

/* splash logo: big bolt on a sunburst badge */
.logo {
  position: relative;
  display: grid;
  place-items: center;
  align-self: center;
  width: 200px;
  height: 200px;
}
.logo__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.16) 0 10deg, transparent 10deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 40%, transparent 70%);
  mask: radial-gradient(circle, #000 40%, transparent 70%);
  animation: spin 24s linear infinite;
}
.logo__ring--2 {
  inset: 34px;
  animation: none;
  background: linear-gradient(180deg, var(--surface-3), var(--surface-2));
  border: 3px solid var(--ink);
  box-shadow: inset 0 4px 0 var(--panel-hi), inset 0 -6px 0 var(--panel-lo), 0 6px 0 var(--ink-soft);
  -webkit-mask: none;
  mask: none;
}
.logo__bolt {
  position: relative;
  width: 96px;
  height: 96px;
  font-size: 96px;
  display: grid;
  place-items: center;
  animation: bolt-slam 700ms var(--ease-pop) both;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bolt-slam { from { transform: scale(2.4) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }
.title-slam {
  font-family: var(--font-display);
  text-align: center;
  font-size: 48px;
  line-height: 0.98;
}
.title-slam > span { display: block; animation: slam-in 600ms var(--ease-pop) both; text-shadow: var(--ts-outline), 0 6px 0 var(--ink-soft); }
.title-slam > span:nth-child(2) { animation-delay: 180ms; }
.title-slam .t-fat { color: #fff; }
.title-slam .t-fun { color: var(--yellow); }
@keyframes slam-in { from { transform: scale(2.2); opacity: 0; } 60% { opacity: 1; } to { transform: none; opacity: 1; } }

.loop { display: flex; flex-direction: column; gap: var(--s-3); }
.loop__item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-lg);
  background: var(--grad-panel);
  border: 2px solid var(--ink);
  box-shadow: var(--bevel), var(--shadow-card);
  animation: onb-rise 520ms var(--ease-out) both;
}
.loop__item:nth-child(2) { animation-delay: 120ms; }
.loop__item:nth-child(3) { animation-delay: 240ms; }
.loop__emoji {
  flex: none;
  width: 60px; height: 60px;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  font-size: 42px;
  background: rgba(13, 24, 56, 0.4);
  border: 2px solid var(--ink);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.2);
}
.loop__title { font-family: var(--font-display); font-size: 20px; color: var(--loop-c, #fff); text-shadow: var(--ts-outline-sm); }
.loop__text { font-size: var(--fs-sm); color: var(--text-dim); }

.safety-list { display: flex; flex-direction: column; gap: var(--s-3); }
.safety-item { display: flex; gap: var(--s-3); align-items: flex-start; font-size: 15px; }
.safety-item__icon { flex: none; font-size: 26px; line-height: 1; display: inline-flex; }
.ack {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-4);
  min-height: var(--tap);
  border-radius: var(--r-md);
  border: 2px solid var(--ink);
  background: rgba(13, 24, 56, 0.35);
  text-align: left;
  font-weight: 800;
  font-size: 15px;
  transition: box-shadow var(--t-fast);
}
.ack__box {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 2.5px solid var(--ink);
  background: var(--paper);
  display: grid; place-items: center;
  font-size: 24px;
  color: transparent;
  transition: background var(--t-fast), transform var(--t-med) var(--ease-pop);
}
.ack__box .ic { visibility: hidden; }
.ack.is-checked { box-shadow: inset 0 0 0 3px var(--green); }
.ack.is-checked .ack__box { transform: scale(1.08); }
.ack.is-checked .ack__box .ic { visibility: visible; }
.round-cap { display: flex; gap: var(--s-2); }
.round-cap__pip {
  flex: 1;
  padding: var(--s-3) 0;
  border-radius: var(--r-md);
  text-align: center;
  font-family: var(--font-display);
  font-size: 16px;
  text-shadow: var(--ts-outline-sm);
  background: var(--grad-accent);
  border: 2px solid var(--ink);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.round-cap__pip.is-locked { background: rgba(13, 24, 56, 0.4); color: var(--text-mute); }

/* Reduced motion: kill decorative loops */
@media (prefers-reduced-motion: reduce) {
  .hud__crate, .hud__streak .flame, .logo__ring, .logo__bolt, .empty-state__emoji { animation: none !important; }
}
html.reduce-motion .hud__crate, html.reduce-motion .hud__streak .flame, html.reduce-motion .logo__ring,
html.reduce-motion .logo__bolt, html.reduce-motion .empty-state__emoji { animation: none !important; }
