/* Shape system: interactive controls are full pills (999px), panels and cards 20px, keycaps 7px.
   Theme: the game is dark by design (one theme for the whole page). The accent follows the active world. */
:root {
  --ink: #0b0a10;
  --ink-2: #15121b;
  --paper: #f3efe7;
  --muted: #b8b0c2;
  --glut: #ff8a4c;
  --frost: #5ee0ff;
  --accent: var(--glut);
  /* item tiers (game convention: silver, blue, violet, gold); all >= 7:1 on the card colour */
  --t-common: #c9c1d4;
  --t-rare: #72b4ff;
  --t-epic: #c493ff;
  --t-legendary: #ffcc4d;
  --card: #17141e;
  --r-pill: 999px;
  --r-panel: 20px;
  --r-key: 7px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --z-grain: 1;
  --z-hud: 10;
  --z-touch: 15;
  --z-screen: 20;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: 'Outfit', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body {
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 26px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(243 239 231 / 0.22);
  background: rgb(21 18 27 / 0.55);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: var(--paper);
  font: 600 16px/1 'Outfit', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.08);
  transition: transform 0.25s var(--ease), border-color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--paper);
  color: var(--ink);
  border-color: transparent;
  box-shadow: 0 10px 40px -12px var(--accent);
}
.btn-primary:hover { background: #fffaf2; border-color: transparent; transform: translateY(-1px); }
.btn i { font-size: 18px; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(243 239 231 / 0.18);
  background: rgb(21 18 27 / 0.5);
  color: var(--paper);
  font-size: 16px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn-lg { width: 48px; height: 48px; font-size: 19px; }

:is(.btn, .icon-btn, .level-card, .t-btn):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: var(--z-screen);
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.screen-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding-bottom: clamp(32px, 9vh, 96px);
  padding-left: clamp(24px, 7vw, 112px);
  padding-right: clamp(24px, 5vw, 80px);
  background: linear-gradient(90deg, rgb(11 10 16 / 0.82) 0%, rgb(11 10 16 / 0.35) 45%, transparent 75%);
}
.title-block { max-width: 680px; }
.logo {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: clamp(48px, 9.5vw, 132px);
  letter-spacing: -0.045em;
  line-height: 0.95;
  padding-bottom: 0.08em;
  position: relative;
  animation: rise 1s var(--ease) both;
}
.logo::after {
  content: "";
  display: block;
  width: 1.6em;
  height: 6px;
  margin-top: 0.3em;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--glut) 0 50%, var(--frost) 50% 100%);
}
.lead {
  margin-top: 20px;
  max-width: 44ch;
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
  animation: rise 1s 0.1s var(--ease) both;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  animation: rise 1s 0.2s var(--ease) both;
}
.actions-col { flex-direction: column; align-items: stretch; }
.actions-col .btn { justify-content: center; }

.controls {
  justify-self: end;
  padding: 20px 22px;
  border-radius: var(--r-panel);
  background: rgb(15 13 20 / 0.55);
  border: 1px solid rgb(243 239 231 / 0.1);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: rise 1s 0.3s var(--ease) both;
}
.controls dl { display: grid; gap: 10px; }
.controls dl > div { display: grid; grid-template-columns: 112px auto; align-items: center; gap: 12px; }
.controls dt { font-size: 14px; color: var(--muted); }
.controls .hl dt { color: var(--paper); font-weight: 600; }
.controls dd { display: flex; gap: 6px; align-items: center; }
.controls .or { font-size: 12px; color: var(--muted); }
.controls-note { margin-top: 14px; font-size: 13px; color: var(--muted); }
kbd {
  display: inline-block;
  min-width: 28px;
  padding: 5px 8px;
  border-radius: var(--r-key);
  border: 1px solid rgb(243 239 231 / 0.18);
  border-bottom-width: 2px;
  background: rgb(255 255 255 / 0.05);
  font: 700 12px/1 'JetBrains Mono', monospace;
  text-align: center;
  color: var(--paper);
}
.controls .hl kbd { border-color: var(--accent); }

/* ---------- level select ---------- */
.screen-select {
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgb(11 10 16 / 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.select-wrap { width: min(1080px, 100%); }
.select-head { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.select-head h2, .panel h2 {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.03em;
  line-height: 1.05;
  text-wrap: balance;
}
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.level-card {
  display: grid;
  gap: 14px;
  padding: 14px 14px 18px;
  text-align: left;
  border-radius: var(--r-panel);
  border: 1px solid rgb(243 239 231 / 0.12);
  background: rgb(21 18 27 / 0.7);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.35s var(--ease), border-color 0.25s var(--ease);
  animation: rise 0.7s var(--ease) both;
  animation-delay: calc(var(--i) * 70ms);
}
.level-card:hover:not(:disabled) { transform: translateY(-4px); border-color: var(--accent); }
.level-card:disabled { cursor: not-allowed; opacity: 0.45; }
.minimap {
  width: 100%;
  aspect-ratio: 5 / 1;
  object-fit: contain;
  padding: 10px;
  border-radius: 12px;
  background: linear-gradient(180deg, #160f1c, #0d1424);
  image-rendering: pixelated;
}
.lc-num { font: 500 13px 'JetBrains Mono', monospace; color: var(--muted); }
.lc-name { display: block; font: 600 22px/1.15 'Unbounded', sans-serif; letter-spacing: -0.02em; margin-top: 4px; }
.lc-best { display: flex; align-items: center; gap: 6px; margin-top: 8px; font: 500 13px 'JetBrains Mono', monospace; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- settings ---------- */
.screen-settings .select-wrap { width: min(1120px, 100%); padding-block: 8px; }
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}
.settings-col { display: grid; gap: 16px; }
.set-group {
  padding: 22px 24px;
  border-radius: var(--r-panel);
  background: rgb(21 18 27 / 0.78);
  border: 1px solid rgb(243 239 231 / 0.12);
  animation: rise 0.6s var(--ease) both;
}
.set-group h3 {
  margin-bottom: 14px;
  font: 600 17px/1.2 'Unbounded', sans-serif;
  letter-spacing: -0.01em;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
}
.set-row + .set-row { border-top: 1px solid rgb(243 239 231 / 0.07); }
.set-row label { display: grid; gap: 2px; font-size: 15px; cursor: pointer; }
.set-hint { font-size: 13px; color: var(--muted); }
.set-range { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; padding-block: 10px; }
.set-range input { grid-column: 1 / -1; }
.set-range output { font: 700 13px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; color: var(--muted); }
.set-note { font-size: 14px; line-height: 1.5; color: var(--muted); margin-bottom: 14px; }
.set-done { margin: 12px 0 0; color: var(--paper); }
.confirm { margin-top: 4px; }
.confirm p { font-size: 15px; line-height: 1.5; }
.confirm .actions { margin-top: 14px; animation: none; }

/* range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
}
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: var(--r-pill); background: rgb(243 239 231 / 0.14); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: var(--r-pill); background: rgb(243 239 231 / 0.14); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: var(--r-pill); background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  margin-top: -7px;
  border-radius: var(--r-pill);
  background: var(--paper);
  border: 3px solid var(--accent);
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: var(--r-pill); background: var(--paper); border: 3px solid var(--accent); }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 6px; }

/* switch */
.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  border-radius: var(--r-pill);
  background: rgb(243 239 231 / 0.16);
  cursor: pointer;
  transition: background-color 0.25s var(--ease);
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: var(--r-pill);
  background: var(--paper);
  transition: transform 0.25s var(--ease);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); background: var(--ink); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* controls table */
.keys { width: 100%; border-collapse: collapse; font-size: 14px; }
.keys th, .keys td { padding: 10px 8px; text-align: left; vertical-align: middle; }
.keys thead th { font: 500 12px 'JetBrains Mono', monospace; color: var(--muted); border-bottom: 1px solid rgb(243 239 231 / 0.12); }
.keys tbody th { font-weight: 500; }
.kbd-set { display: flex; flex-wrap: wrap; gap: 6px; }
.keys tbody td:last-child { color: var(--muted); }
.keys tbody tr:nth-child(even) { background: rgb(255 255 255 / 0.025); }
.keys tr.hl th { color: var(--accent); font-weight: 600; }
.keys tr.hl kbd { border-color: var(--accent); }
.set-keys .set-note { margin: 14px 0 0; }

.btn-danger { border-color: rgb(255 120 110 / 0.45); }
.btn-danger:hover { border-color: #ff786e; background: rgb(255 120 110 / 0.12); }

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
  .keys tbody td:last-child, .keys thead th:last-child { display: none; }
}

/* ---------- onboarding ---------- */
.screen-onboard {
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgb(8 7 12 / 0.6);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.ob-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  grid-template-areas: "stage copy" "nav nav";
  gap: 28px 36px;
  width: min(1040px, 100%);
  padding: 28px;
  border-radius: var(--r-panel);
  background: rgb(21 18 27 / 0.86);
  border: 1px solid rgb(243 239 231 / 0.12);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 40px 120px -30px rgb(0 0 0 / 0.7);
  overflow: hidden;
  animation: ob-enter 0.8s var(--ease) both;
}
.ob-progress { position: absolute; inset: 0 0 auto 0; height: 3px; background: rgb(243 239 231 / 0.08); }
.ob-bar {
  display: block;
  height: 100%;
  width: 25%;
  background: linear-gradient(90deg, var(--glut), var(--frost));
  transition: width 0.6s var(--ease);
}
.ob-stage {
  grid-area: stage;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #0d0b14;
  box-shadow: inset 0 0 0 1px rgb(243 239 231 / 0.08);
}
.ob-stage canvas { display: block; width: 100%; aspect-ratio: 16 / 9; }
.ob-stage.is-switching canvas { animation: ob-iris 0.7s var(--ease) both; }
.ob-keys {
  position: absolute;
  left: 50%;
  bottom: 14px;
  display: flex;
  gap: 8px;
  transform: translateX(-50%);
}
.ob-keys kbd {
  min-width: 40px;
  padding: 9px 12px;
  font-size: 13px;
  background: rgb(11 10 16 / 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.12s var(--ease), background-color 0.12s var(--ease), border-color 0.12s var(--ease), box-shadow 0.12s var(--ease), color 0.12s var(--ease);
}
.ob-keys kbd.is-pressed {
  transform: translateY(2px) scale(0.96);
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 24px -2px var(--accent);
}
.ob-copy { grid-area: copy; align-self: center; }
.ob-copy.ob-in-next > * { animation: ob-slide-next 0.6s var(--ease) both; }
.ob-copy.ob-in-prev > * { animation: ob-slide-prev 0.6s var(--ease) both; }
.ob-copy > *:nth-child(2) { animation-delay: 60ms; }
.ob-copy > *:nth-child(3) { animation-delay: 120ms; }
.ob-copy > *:nth-child(4) { animation-delay: 180ms; }
.ob-step { font: 500 13px 'JetBrains Mono', monospace; color: var(--accent); }
.ob-copy h2 {
  margin-top: 10px;
  font: 800 clamp(28px, 3.4vw, 40px)/1.08 'Unbounded', sans-serif;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.ob-body { margin-top: 16px; max-width: 40ch; font-size: 17px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.ob-touch { margin-top: 12px; font-size: 14px; color: var(--muted); }
.ob-nav {
  grid-area: nav;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}
.ob-buttons { display: flex; justify-content: flex-end; gap: 10px; }
.ob-buttons .icon-btn:disabled { opacity: 0.35; cursor: default; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 0 8px; justify-self: start; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: none; }
.btn-ghost:hover { color: var(--paper); border-color: transparent; }
.ob-dots { display: flex; gap: 8px; }
.ob-dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: var(--r-pill);
  background: rgb(243 239 231 / 0.22);
  cursor: pointer;
  transition: width 0.4s var(--ease), background-color 0.4s var(--ease);
}
.ob-dot[aria-current="step"] { width: 30px; background: var(--accent); }
.ob-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.set-actions { margin-top: 0; animation: none; }

@keyframes ob-enter { from { opacity: 0; transform: translateY(24px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes ob-iris { from { clip-path: circle(0% at 50% 55%); filter: brightness(1.8); } to { clip-path: circle(80% at 50% 55%); filter: none; } }
@keyframes ob-slide-next { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes ob-slide-prev { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .ob-card { grid-template-columns: 1fr; grid-template-areas: "stage" "copy" "nav"; gap: 20px; padding: 20px; }
  .ob-nav { grid-template-columns: 1fr auto; }
  .ob-dots { display: none; }
  .ob-keys { position: static; justify-content: center; transform: none; padding: 12px 0 14px; }
  .ob-body { font-size: 16px; }
}

/* ---------- level select: act headings ---------- */
.act-head {
  grid-column: 1 / -1;
  margin: 18px 4px 2px;
  font: 600 15px 'Unbounded', sans-serif;
  letter-spacing: -0.01em;
  color: var(--muted);
}
.act-head:first-child { margin-top: 0; }

/* pulse levels: a countdown bar under the world pill fills up until the next flip */
.phase-pill.is-pulse::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -7px;
  height: 3px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--accent) calc(var(--pulse, 0) * 100%), rgb(243 239 231 / 0.15) 0);
}

/* ---------- shop: see the block at the end of this file ---------- */

/* ---------- stars ---------- */
.stars-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.star-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 10px;
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.04);
  color: var(--muted);
  font-size: 14px;
}
.star-item i { font-size: 18px; color: rgb(243 239 231 / 0.25); }
.star-item.on { color: var(--paper); }
.star-item.on i { color: #ffd36b; }
.star-item.new i { animation: star-pop 0.6s var(--ease) both; animation-delay: calc(var(--i) * 160ms + 250ms); }
.lc-stars { display: flex; gap: 3px; margin-top: 8px; font-size: 15px; color: rgb(243 239 231 / 0.22); }
.lc-stars .on { color: #ffd36b; }
.unlock-note { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--paper); font-size: 15px; }
.unlock-note i { color: #ffd36b; }
@keyframes star-pop { 0% { transform: scale(0.3) rotate(-30deg); opacity: 0; } 70% { transform: scale(1.35) rotate(8deg); opacity: 1; } 100% { transform: none; } }

/* ---------- key rebinding ---------- */
.key-change {
  margin-left: 4px;
  padding: 5px 10px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(243 239 231 / 0.18);
  background: transparent;
  color: var(--muted);
  font: 500 12px 'Outfit', sans-serif;
  cursor: pointer;
}
.key-change:hover { color: var(--paper); border-color: var(--accent); }
.key-change[aria-pressed="true"] { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.key-change:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- touch extras ---------- */
.ob-keys kbd.is-touch { min-width: 46px; font-size: 18px; display: inline-grid; place-items: center; }
.portrait-hint {
  position: fixed;
  left: 50%;
  top: max(64px, calc(env(safe-area-inset-top) + 56px));
  z-index: var(--z-hud);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 32px);
  padding: 8px 8px 8px 16px;
  border-radius: var(--r-pill);
  background: rgb(21 18 27 / 0.88);
  border: 1px solid rgb(243 239 231 / 0.16);
  font-size: 14px;
  transform: translateX(-50%);
}
.portrait-hint > i { color: var(--accent); font-size: 20px; }

/* gamepad navigation: always show where focus is */
body.gp-nav :is(button, input):focus { outline: 2px solid var(--accent); outline-offset: 3px; }


/* ---------- modals ---------- */
.screen-modal {
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgb(8 7 12 / 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.panel {
  width: min(360px, 100%);
  padding: 32px;
  border-radius: var(--r-panel);
  background: rgb(21 18 27 / 0.82);
  border: 1px solid rgb(243 239 231 / 0.12);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.06), 0 30px 80px -20px rgb(0 0 0 / 0.6);
  animation: pop 0.45s var(--ease) both;
}
.panel-wide { width: min(560px, 100%); }
.panel-lead { margin-top: 10px; color: var(--muted); line-height: 1.5; }
.badge {
  display: inline-block;
  margin-bottom: 14px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--ink);
  font: 700 12px 'JetBrains Mono', monospace;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin-top: 24px;
}
.stats > div { padding: 14px 16px; border-radius: 14px; background: rgb(255 255 255 / 0.04); }
.stat-label { display: block; font-size: 13px; color: var(--muted); }
.stat-val { display: block; margin-top: 6px; font: 700 26px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-hud);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 0 max(18px, env(safe-area-inset-left));
  pointer-events: none;
}
.hud button { pointer-events: auto; }
.hud-group { display: flex; align-items: center; gap: 16px; min-width: 0; }
.hud-right { justify-content: flex-end; gap: 12px; }
.hud-level { font: 600 14px 'Unbounded', sans-serif; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: 700 14px 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 8px rgb(0 0 0 / 0.6);
}
.hud-stat i { color: var(--accent); font-size: 15px; }
/* rule twist of a Hardcore level (Mirror, ...): a small pill next to the shard count, kept on phones */
.hud-twist {
  flex: none;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--accent);
  background: rgb(15 13 20 / 0.6);
  color: var(--accent);
  font: 700 11px 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.shard-glyph { width: 9px; height: 13px; background: var(--paper); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); box-shadow: 0 0 10px var(--accent); }

.phase-pill {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: var(--r-pill);
  background: rgb(15 13 20 / 0.6);
  border: 1px solid rgb(243 239 231 / 0.14);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.phase-thumb {
  position: absolute;
  inset: 4px auto 4px 4px;
  width: calc(50% - 4px);
  border-radius: var(--r-pill);
  background: var(--glut);
  transition: transform 0.35s var(--ease), background-color 0.35s var(--ease);
}
.phase-pill[data-phase="1"] .phase-thumb { transform: translateX(100%); background: var(--frost); }
.phase-opt {
  position: relative;
  padding: 6px 16px;
  font: 700 12px 'JetBrains Mono', monospace;
  text-align: center;
  color: var(--muted);
  transition: color 0.3s var(--ease);
}
.phase-pill[data-phase="0"] .phase-opt[data-p="0"],
.phase-pill[data-phase="1"] .phase-opt[data-p="1"] { color: var(--ink); }

/* ---------- touch ---------- */
/* Touch controls scale with the screen: thumb-sized on phones, larger on tablets.
   Left: one movement pad (slide between left and right). Right: jump in the corner, dash beside it,
   world switch above it, so the thumb rests on jump and reaches the others with a short move. */
.touch {
  --t-size: clamp(68px, 12vmin, 112px);
  --t-jump: clamp(88px, 16vmin, 144px);
  --t-gap: clamp(10px, 2.2vmin, 22px);
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-touch);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 max(var(--t-gap), env(safe-area-inset-right)) max(var(--t-gap), env(safe-area-inset-bottom)) max(var(--t-gap), env(safe-area-inset-left));
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.touch-side { display: flex; gap: var(--t-gap); align-items: flex-end; pointer-events: auto; }
.touch-actions {
  display: grid;
  grid-template-areas: ". swap" "dash jump";
  align-items: end;
  justify-items: center;
}
.t-btn, .t-move {
  position: relative;
  border: 1px solid rgb(243 239 231 / 0.24);
  background: rgb(21 18 27 / 0.45);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--paper);
  touch-action: none;
}
.t-btn {
  display: grid;
  place-items: center;
  width: var(--t-size);
  height: var(--t-size);
  border-radius: var(--r-pill);
  font-size: calc(var(--t-size) * 0.4);
  transition: transform 0.08s var(--ease), background-color 0.08s var(--ease);
}
/* the touch target reaches past the visible button, so a slightly missed tap still counts */
.t-btn::before { content: ""; position: absolute; inset: calc(var(--t-gap) * -0.5); border-radius: inherit; }
.t-btn.is-down { background: rgb(243 239 231 / 0.28); transform: scale(0.94); }
.t-jump { grid-area: jump; width: var(--t-jump); height: var(--t-jump); font-size: calc(var(--t-jump) * 0.38); }
.t-dash { grid-area: dash; }
.t-swap { grid-area: swap; border-color: var(--accent); color: var(--accent); }
.t-move {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: calc(var(--t-size) * 2.3);
  height: calc(var(--t-size) * 1.15);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.t-half { display: grid; place-items: center; font-size: calc(var(--t-size) * 0.42); transition: background-color 0.08s var(--ease); }
.t-half + .t-half { border-left: 1px solid rgb(243 239 231 / 0.14); }
.t-half.is-down { background: rgb(243 239 231 / 0.28); }
/* short landscape phones: one row on the right and see-through buttons laid over the game */
@media (max-height: 520px) {
  .touch-actions { grid-template-areas: "dash swap jump"; }
}
.touch.is-overlay .t-btn, .touch.is-overlay .t-move { background: rgb(21 18 27 / 0.28); }
/* touch devices: HUD buttons meet the 44px minimum target size and never shrink on narrow screens */
.hud .icon-btn { flex: none; }
body.is-touch .hud .icon-btn { width: 44px; height: 44px; font-size: 19px; }

@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .screen-title { grid-template-columns: 1fr; align-content: end; background: linear-gradient(0deg, rgb(11 10 16 / 0.9) 0%, rgb(11 10 16 / 0.4) 60%, transparent); }
  .controls { display: none; }
  .hud-level { display: none; }
  .hud-twist { margin-left: -8px; padding: 2px 6px; font-size: 10px; letter-spacing: 0.04em; }
  .phase-opt { padding: 6px 12px; }
}
@media (max-height: 520px) {
  .lead { display: none; }
  .actions { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0ms !important; transition-duration: 0.01ms !important; }
}
@media (prefers-reduced-transparency: reduce) {
  .btn, .controls, .panel, .phase-pill, .t-btn { background: var(--ink-2); -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ==========================================================================
   Shop: wallet, goal meter, tabs, item cards with tier badges, live preview.
   Shape rules stay the same: controls are pills, cards 20px, nested tiles 14px.
   ========================================================================== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* title button + wallet chip */
.btn-shop { padding-right: 8px; }
.wallet-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: 2px;
  padding: 8px 12px;
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.07);
  border: 1px solid rgb(243 239 231 / 0.12);
  font: 700 13px/1 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
}

.wallet {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: var(--r-pill);
  background: rgb(21 18 27 / 0.82);
  border: 1px solid rgb(243 239 231 / 0.14);
  font: 700 18px/1 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.wallet .shard-glyph { width: 11px; height: 16px; }
.wallet.is-spent { animation: wallet-spend 0.6s var(--ease); }
@keyframes wallet-spend { 35% { transform: scale(0.93); border-color: var(--accent); } }

/* goal meter (shop header and level-complete screen) */
.goal {
  --tc: var(--accent);
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 14px 18px 16px;
  border-radius: var(--r-panel);
  background: rgb(21 18 27 / 0.8);
  border: 1px solid rgb(243 239 231 / 0.12);
}
.goal[data-tier="common"] { --tc: var(--t-common); }
.goal[data-tier="rare"] { --tc: var(--t-rare); }
.goal[data-tier="epic"] { --tc: var(--t-epic); }
.goal[data-tier="legendary"] { --tc: var(--t-legendary); }
.goal-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-width: 0; }
.goal-kicker { font: 700 12px 'JetBrains Mono', monospace; letter-spacing: 0.04em; color: var(--tc); }
.goal-name { font: 600 16px/1.2 'Unbounded', sans-serif; letter-spacing: -0.01em; }
.goal-slot { margin-left: 8px; font: 500 12px 'JetBrains Mono', monospace; letter-spacing: 0; color: var(--muted); }
.goal-num { margin-left: auto; font: 700 14px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; color: var(--muted); }
.goal.is-ready .goal-num { color: var(--tc); }
.goal.is-empty .goal-kicker { color: var(--muted); }
.meter {
  position: relative;
  height: 8px;
  border-radius: var(--r-pill);
  background: rgb(243 239 231 / 0.1);
  overflow: hidden;
}
.meter-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tc) 45%, transparent), var(--tc));
  transform-origin: left center;
  transform: scaleX(var(--p, 0));
  transition: transform 1.1s var(--ease);
}
.goal.is-ready .meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: sheen 2.4s ease-in-out infinite;
}
@keyframes sheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* layout */
.screen-shop .select-wrap { width: min(1240px, 100%); padding-block: 8px; }
.shop-head { margin-bottom: 18px; }
.shop-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}
.shop-preview {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: var(--r-panel);
  background: rgb(21 18 27 / 0.9);
  border: 1px solid rgb(243 239 231 / 0.12);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.shop-stage { position: relative; border-radius: 14px; overflow: hidden; background: #0d0b14; }
.shop-stage canvas { display: block; width: 100%; aspect-ratio: 16 / 10; }
.try-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: var(--r-pill);
  background: rgb(11 10 16 / 0.74);
  border: 1px solid rgb(243 239 231 / 0.16);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font: 700 12px 'JetBrains Mono', monospace;
  animation: pop 0.3s var(--ease) both;
}
.shop-info { --tc: var(--t-common); padding: 2px 6px 6px; min-height: 128px; }
.shop-info[data-tier="rare"] { --tc: var(--t-rare); }
.shop-info[data-tier="epic"] { --tc: var(--t-epic); }
.shop-info[data-tier="legendary"] { --tc: var(--t-legendary); }
.si-kicker { display: flex; align-items: center; gap: 10px; font: 500 13px 'JetBrains Mono', monospace; color: var(--muted); }
.si-name { margin-top: 10px; font: 800 clamp(22px, 2.4vw, 30px)/1.1 'Unbounded', sans-serif; letter-spacing: -0.03em; text-wrap: balance; }
.si-desc { margin-top: 8px; max-width: 44ch; font-size: 16px; line-height: 1.5; color: var(--muted); text-wrap: pretty; }

/* tier badge (cards, preview info) */
.tier-badge {
  --tc: var(--t-common);
  display: inline-block;
  padding: 4px 8px;
  border-radius: var(--r-pill);
  font: 700 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--tc);
  background: color-mix(in srgb, var(--tc) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--tc) 38%, transparent);
}
.tier-badge[data-tier="rare"], .tier-rare .tier-badge { --tc: var(--t-rare); }
.tier-badge[data-tier="epic"], .tier-epic .tier-badge { --tc: var(--t-epic); }
.tier-badge[data-tier="legendary"], .tier-legendary .tier-badge { --tc: var(--t-legendary); }

/* tabs: one tile per slot, owned count underneath */
.tabs {
  display: grid;
  grid-template-columns: repeat(6, minmax(88px, 1fr));
  gap: 8px;
  margin: -4px -4px 10px;
  padding: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 10px 6px 9px;
  border-radius: 14px;
  border: 1px solid rgb(243 239 231 / 0.12);
  background: rgb(21 18 27 / 0.78);
  color: var(--muted);
  font: 600 14px/1.15 'Outfit', sans-serif;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  scroll-snap-align: start;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease), background-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.tab i { font-size: 19px; }
.tab-count { font: 500 11px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; opacity: 0.8; }
.tab:hover { color: var(--paper); border-color: var(--accent); }
.tab:active { transform: scale(0.97); }
.tab[aria-selected="true"] { background: var(--paper); color: var(--ink); border-color: transparent; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* item cards */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; }
.items:focus { outline: none; }
.item {
  --tc: var(--t-common);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 10px 12px;
  border-radius: var(--r-panel);
  background: var(--card);
  border: 1px solid rgb(243 239 231 / 0.1);
  transition: transform 0.3s var(--ease), border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
  animation: rise 0.5s var(--ease) both;
  animation-delay: calc(var(--i) * 35ms);
}
.item.tier-rare { --tc: var(--t-rare); }
.item.tier-epic { --tc: var(--t-epic); border-color: color-mix(in srgb, var(--t-epic) 26%, transparent); }
.item.tier-legendary { --tc: var(--t-legendary); }
.item:focus-within { transform: translateY(-3px); border-color: color-mix(in srgb, var(--tc) 65%, transparent); }
@media (hover: hover) {
  .item:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--tc) 65%, transparent); }
}
.item.is-goal { border-color: color-mix(in srgb, var(--tc) 75%, transparent); }
.item.is-equipped { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent), 0 14px 40px -24px var(--accent); }

/* legendary: a slowly turning foil border, the thing to work towards */
@property --foil { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.item.tier-legendary {
  border: 2px solid transparent;
  padding: 9px 9px 11px;
  background:
    linear-gradient(var(--card), var(--card)) padding-box,
    conic-gradient(from var(--foil), #ffcc4d, #ff8a4c, #ff6fae, #9d8bff, #5ee0ff, #7cf5c4, #ffcc4d) border-box;
  animation: rise 0.5s var(--ease) both, foil 6s linear infinite;
  animation-delay: calc(var(--i) * 35ms), 0s;
}
.item.tier-legendary.is-equipped { box-shadow: 0 0 0 1px var(--accent), 0 14px 40px -24px var(--accent); }
@keyframes foil { to { --foil: 360deg; } }

.item-name { margin-top: 4px; padding-inline: 4px; font: 600 15px/1.2 'Unbounded', sans-serif; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-height: 22px; padding-inline: 4px; }
.item-note { font: 500 12px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; color: var(--muted); }
.is-equipped .item-note { color: var(--accent); }
.is-goal:not(.is-owned) .item-note { color: var(--tc); }

.buy-btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  margin-top: auto;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(243 239 231 / 0.2);
  background: rgb(255 255 255 / 0.05);
  color: var(--paper);
  font: 600 15px/1 'Outfit', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.25s var(--ease);
}
.item-meta + .buy-btn { margin-top: auto; }
.buy-btn .price { font: 700 14px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; }
.buy-btn .shard-glyph { width: 8px; height: 12px; background: currentColor; box-shadow: none; }
.buy-btn:hover { border-color: var(--accent); }
.buy-btn:active { transform: scale(0.97); }
.buy-btn:focus-visible, .goal-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.item:not(.is-owned):not(.is-short) .buy-btn { background: var(--paper); color: var(--ink); border-color: transparent; }
.item.is-pending .buy-btn {
  background: var(--accent);
  color: var(--ink);
  border-color: transparent;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 30px -10px var(--accent);
  animation: confirm 1.3s ease-in-out infinite;
}
@keyframes confirm { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 12%, transparent), 0 10px 30px -10px var(--accent); } }
.item.is-short .buy-btn { color: var(--muted); border-style: dashed; cursor: default; }
.item.is-short .buy-btn:hover { border-color: rgb(243 239 231 / 0.35); }
.item.is-equipped .buy-btn { background: transparent; color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); cursor: default; }

.goal-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(243 239 231 / 0.18);
  background: rgb(11 10 16 / 0.62);
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.goal-btn:hover { color: var(--paper); border-color: var(--tc); }
.goal-btn:active { transform: scale(0.92); }
.goal-btn[aria-pressed="true"] { background: var(--tc); border-color: transparent; color: var(--ink); }

.item.is-denied { animation: deny 0.4s var(--ease); }
@keyframes deny { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* purchase celebration: card pop, expanding ring, spark burst in the tier colour */
.item.is-bought { z-index: 2; animation: bought 0.7s var(--ease); }
.item.is-bought::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 2px solid var(--tc);
  pointer-events: none;
  animation: ring 0.9s var(--ease) forwards;
}
@keyframes bought { 0% { transform: scale(0.94); } 45% { transform: scale(1.05); } 100% { transform: none; } }
@keyframes ring { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(1.12); } }
.burst { position: absolute; left: 50%; top: 60px; width: 0; height: 0; pointer-events: none; filter: drop-shadow(0 0 5px var(--tc)); }
.burst i {
  position: absolute;
  width: 10px;
  height: 16px;
  margin: -8px -5px;
  background: var(--tc);
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
  transform: rotate(var(--a));
  animation: spark 0.95s var(--ease) forwards;
}
.burst i:nth-child(3n) { background: var(--paper); }
.burst i:nth-child(4n) { background: var(--accent); }
@keyframes spark {
  0% { opacity: 1; transform: rotate(var(--a)) translateY(0) scale(1.2); }
  100% { opacity: 0; transform: rotate(var(--a)) translateY(calc(var(--d) * -1)) scale(0.3); }
}

/* item art: a small visual per item, never an image */
.art {
  position: relative;
  display: grid;
  place-items: center;
  height: 100px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 120%, color-mix(in srgb, var(--tc) 24%, transparent), transparent 70%),
    rgb(255 255 255 / 0.03);
  color: var(--paper);
  font-size: 40px;
}
.tier-legendary .art { background: radial-gradient(120% 90% at 50% 120%, color-mix(in srgb, var(--tc) 34%, transparent), transparent 72%), rgb(255 255 255 / 0.04); }

.art-bod {
  position: relative;
  width: 40px;
  height: 52px;
  border-radius: 11px;
  background: var(--c, var(--paper));
  box-shadow: 0 8px 22px -8px var(--c, var(--paper));
}
.art-visor { position: absolute; left: 3px; right: 3px; top: 9px; height: 14px; border-radius: 7px; background: var(--v); }
.art-visor::before, .art-visor::after { content: ""; position: absolute; top: 4px; width: 4px; height: 6px; border-radius: 1px; background: #ffe2c4; }
.art-visor::before { left: 11px; }
.art-visor::after { left: 20px; }
.art-outline .art-bod { box-shadow: 0 0 0 2px var(--accent), 0 8px 26px -8px var(--accent); }
.art-k-shifter .art-bod { background: var(--glut); box-shadow: 0 8px 22px -8px currentColor; animation: shifter 4.5s var(--ease) infinite; }
@keyframes shifter { 0%, 42% { background: var(--glut); } 50%, 92% { background: var(--frost); } 100% { background: var(--glut); } }
.art-k-aurora .art-bod { background: hsl(165 70% 72%); animation: hue 16s linear infinite; }
.art-k-prism .art-bod { background: hsl(330 80% 76%); animation: hue 2s linear infinite; }
.art-k-supernova .art-bod { background: hsl(330 80% 76%); animation: hue 2s linear infinite; box-shadow: 0 0 22px 2px hsl(330 90% 72% / 0.7); }
.art-k-supernova::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 30% 30%, #fff 0 1.5px, transparent 2px),
    radial-gradient(circle at 72% 24%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 78% 70%, #fff 0 1.5px, transparent 2px),
    radial-gradient(circle at 22% 76%, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle at 50% 50%, rgb(255 214 120 / 0.35), transparent 45%);
  animation: halo 1s ease-in-out infinite alternate;
}
@keyframes hue { to { filter: hue-rotate(360deg); } }
@keyframes halo { from { opacity: 0.55; transform: scale(0.96); } to { opacity: 1; transform: scale(1.04); } }

.art-scarf {
  width: 68%;
  height: 15px;
  border-radius: var(--r-pill);
  background: var(--c, var(--accent));
  transform: rotate(-9deg);
  box-shadow: 0 6px 18px -6px var(--c, var(--accent));
}
.art-k-world .art-scarf { background: linear-gradient(90deg, var(--glut) 50%, var(--frost) 50%); }
.art-k-aurora .art-scarf { background: linear-gradient(90deg, #7cf5c4, #5ee0ff 45%, #9d8bff); }
.art-k-starlight .art-scarf { background: radial-gradient(circle, #fff6d6 0 1.2px, transparent 1.7px) 0 0 / 9px 6px, #283063; box-shadow: 0 0 18px -2px rgb(255 246 214 / 0.45); }
.art-k-comet .art-scarf { background: linear-gradient(90deg, #f2fbff, #9fdcff 45%, rgb(159 220 255 / 0)); box-shadow: -4px 0 16px -2px rgb(205 239 255 / 0.7); }
.art-k-rainbow .art-scarf {
  background: linear-gradient(90deg, hsl(0 85% 68%), hsl(60 85% 64%), hsl(120 70% 62%), hsl(180 80% 62%), hsl(240 85% 74%), hsl(300 80% 70%), hsl(360 85% 68%)) 0 0 / 200% 100%;
  animation: flow 3s linear infinite;
}
.art-k-phoenix .art-scarf { background: linear-gradient(90deg, #fff1b0, #ffb03b 30%, #ff5a36 65%, #b0204a); box-shadow: 0 6px 22px -4px #ff7a3d; }
.art-k-phoenix::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 70% 30%, #ffb03b 0 1.5px, transparent 2px),
    radial-gradient(circle at 80% 45%, #ff7a3d 0 1px, transparent 1.6px),
    radial-gradient(circle at 62% 22%, #fff1b0 0 1px, transparent 1.6px);
}
@keyframes flow { to { background-position: -200% 0; } }

.art-trail { position: relative; width: 70%; height: 40px; }
.art-trail i {
  position: absolute;
  top: 50%;
  border-radius: var(--r-pill);
  background: var(--tc);
}
.art-trail i:nth-child(1) { left: 84%; width: 12px; height: 12px; margin-top: -10px; }
.art-trail i:nth-child(2) { left: 64%; width: 10px; height: 10px; margin-top: -2px; opacity: 0.85; }
.art-trail i:nth-child(3) { left: 44%; width: 8px; height: 8px; margin-top: -9px; opacity: 0.65; }
.art-trail i:nth-child(4) { left: 26%; width: 6px; height: 6px; margin-top: 1px; opacity: 0.45; }
.art-trail i:nth-child(5) { left: 10%; width: 4px; height: 4px; margin-top: -6px; opacity: 0.3; }
.art-k-embers .art-trail i { background: #ff8a4c; box-shadow: 0 0 10px #ff8a4c; }
.art-k-embers .art-trail i:nth-child(odd) { background: #ffd38a; }
.art-k-snow .art-trail i { background: #f2fbff; box-shadow: 0 0 8px rgb(205 239 255 / 0.8); }
.art-k-stardust .art-trail i { background: #ffe9a8; clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%); border-radius: 0; transform: scale(1.5); }
.art-k-echo .art-trail i:nth-child(n) { width: 14px; height: 19px; margin-top: -10px; border-radius: 4px; background: var(--accent); }
.art-k-echo .art-trail i:nth-child(1):nth-child(n) { background: var(--paper); }
.art-k-prism .art-trail i { box-shadow: 0 0 10px currentColor; }
.art-k-prism .art-trail i:nth-child(1) { background: hsl(0 85% 70%); }
.art-k-prism .art-trail i:nth-child(2) { background: hsl(55 90% 66%); }
.art-k-prism .art-trail i:nth-child(3) { background: hsl(140 70% 64%); }
.art-k-prism .art-trail i:nth-child(4) { background: hsl(200 85% 66%); }
.art-k-prism .art-trail i:nth-child(5) { background: hsl(280 80% 74%); }

.art-theme { position: absolute; inset: 0; background: linear-gradient(120deg, var(--sky-g) 0 50%, var(--sky-f) 50% 100%); }
.art-theme::before, .art-theme::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 26px;
  height: 26px;
  margin-top: -13px;
  border-radius: var(--r-pill);
  background: var(--g);
  box-shadow: 0 0 24px 2px var(--g);
}
.art-theme::before { left: calc(30% - 13px); }
.art-theme::after { left: calc(70% - 13px); background: var(--f); box-shadow: 0 0 24px 2px var(--f); }

/* level complete: earnings that count up line by line */
.earn { margin-top: 18px; padding: 16px 18px; border-radius: 14px; background: rgb(255 255 255 / 0.04); }
.earn-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.earn-head h3 { font: 600 15px/1.2 'Unbounded', sans-serif; letter-spacing: -0.01em; }
.earn-total { font: 700 26px/1 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; color: var(--accent); }
.earn.is-done .earn-total { animation: total-pop 0.5s var(--ease); }
@keyframes total-pop { 40% { transform: scale(1.12); } }
.earn-lines { display: grid; margin: 10px 0 0; padding: 0; list-style: none; }
.earn-lines li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  font-size: 15px;
  color: var(--muted);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}
.earn-lines li.is-in { opacity: 1; transform: none; }
.el-amt { font: 700 15px 'JetBrains Mono', monospace; font-variant-numeric: tabular-nums; color: var(--paper); }
.el-amt b { font-weight: inherit; }
.earn-foot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid rgb(243 239 231 / 0.08);
}
.wallet-sm { margin: 0; padding: 9px 14px; font-size: 15px; }
.wallet-sm .shard-glyph { width: 9px; height: 13px; }
.goal-compact { margin: 0; padding: 0; gap: 7px; background: none; border: 0; }
.goal-compact .goal-kicker { font-size: 11px; }
.goal-compact .goal-name { font-size: 13px; }
.goal-compact .goal-num { font-size: 12px; }
.goal-compact .meter { height: 6px; }

.unlock-note { transition: opacity 0.4s var(--ease), transform 0.4s var(--ease); }
.unlock-note.is-waiting { visibility: hidden; opacity: 0; transform: translateY(6px); }

/* ---------- level packs: tabs in the level select, Hardcore rewards ---------- */
.pack-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.pack-tab { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; }
.pack-tab[aria-selected="true"] .tab-count { opacity: 1; }
.pack-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.hc-rewards { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 20px; }
.reward-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  border: 1px solid rgb(255 211 107 / 0.4);
  background: rgb(255 211 107 / 0.08);
  color: var(--paper);
  font: 600 14px/1.2 'Outfit', sans-serif;
  touch-action: manipulation;
}
button.reward-chip { cursor: pointer; transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease); }
button.reward-chip:hover { border-color: var(--accent); }
.reward-chip i { color: #ffd36b; font-size: 17px; }
.reward-chip.is-worn { background: rgb(255 211 107 / 0.18); border-color: #ffd36b; }
.reward-chip.is-locked { border-color: rgb(243 239 231 / 0.14); background: rgb(21 18 27 / 0.6); color: var(--muted); }
.reward-chip.is-locked i { color: var(--muted); }
.reward-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.reward { margin-top: 18px; padding: 16px 18px; border-radius: 14px; background: rgb(255 211 107 / 0.07); border: 1px solid rgb(255 211 107 / 0.3); }
.reward-kicker { font: 600 12px/1.2 'JetBrains Mono', monospace; letter-spacing: 0.04em; text-transform: uppercase; color: #ffd36b; }
.reward-name { margin-top: 6px; font: 700 22px/1.15 'Unbounded', sans-serif; letter-spacing: -0.02em; }
.reward-note { margin-top: 6px; color: var(--muted); font-size: 15px; line-height: 1.45; }
@media (max-width: 560px) {
  .select-head { flex-wrap: wrap; }
  .pack-tabs { width: 100%; margin-left: 0; }
}

/* short wide screens (phones in landscape): stats left, earnings right */
@media (min-width: 720px) and (max-height: 620px) {
  .panel-complete {
    width: min(900px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 28px;
    align-items: start;
    padding: 24px;
  }
  .panel-complete > * { grid-column: 1; }
  .panel-complete > .earn, .panel-complete > .reward { grid-column: 2; grid-row: 1 / span 7; margin-top: 0; }
  .panel-complete > .actions { margin-top: 16px; }
  .panel-complete > .unlock-note { margin-top: 14px; font-size: 14px; }
  .panel-complete .stars-row { margin-top: 12px; gap: 6px; }
  .panel-complete .star-item { padding: 6px 10px 6px 8px; font-size: 13px; }
  .panel-complete .stats { margin-top: 14px; gap: 8px; }
  .panel-complete .stats > div { padding: 10px 12px; }
  .panel-complete .stat-val { font-size: 20px; }
  .panel-complete .earn-lines li { padding: 3px 0; font-size: 14px; }
}

/* desktop: header, goal and preview stay put, only the item grid scrolls */
@media (min-width: 901px) and (min-height: 640px) {
  .screen-shop { place-items: stretch center; overflow: hidden; }
  .screen-shop .select-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  .shop-grid { flex: 1; min-height: 0; align-items: stretch; }
  .shop-preview { position: static; align-self: start; }
  .shop-main { display: flex; flex-direction: column; min-height: 0; }
  .items {
    flex: 1;
    min-height: 0;
    align-content: start;
    margin: -6px;
    padding: 6px 10px 28px 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgb(243 239 231 / 0.2) transparent;
    -webkit-mask-image: linear-gradient(transparent, #000 6px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(transparent, #000 6px, #000 calc(100% - 28px), transparent);
  }
}

@media (max-width: 900px) {
  /* the sticky preview must never cover the focused card */
  .screen-shop { scroll-padding-top: calc(var(--preview-h, 0px) + 12px); }
  .shop-grid { grid-template-columns: minmax(0, 1fr); }
  .shop-preview { padding: 10px; gap: 10px; box-shadow: 0 20px 30px -20px rgb(0 0 0 / 0.9); }
  .shop-stage canvas { aspect-ratio: 16 / 7; }
  .shop-info { min-height: 0; padding: 0 4px 2px; }
  .si-name { margin-top: 6px; font-size: 20px; }
  .si-desc { margin-top: 4px; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}
@media (min-width: 561px) and (max-width: 900px) {
  .shop-preview { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: center; }
  .si-desc { -webkit-line-clamp: 3; }
}
@media (max-width: 560px) {
  .screen-shop { padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  .shop-head { gap: 12px; margin-bottom: 14px; }
  .shop-head .wallet { padding: 9px 14px; font-size: 16px; }
  .goal { padding: 12px 14px 14px; margin-bottom: 12px; }
  .goal-name { font-size: 14px; }
  .si-kicker { font-size: 12px; }
  .tabs { grid-template-columns: repeat(6, 86px); }
  .items { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .item { padding: 8px 8px 10px; }
  .item.tier-legendary { padding: 7px 7px 9px; }
  .art { height: 84px; }
  .goal-btn { top: 12px; right: 12px; }
  .item-name { font-size: 14px; }
  .buy-btn { min-height: 44px; padding: 0 8px; font-size: 14px; gap: 5px; }
  .buy-btn .price { font-size: 13px; }
}
@media (max-width: 480px) {
  .panel { padding: 22px; }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats > div { padding: 10px 12px; }
  .stat-val { font-size: 19px; }
  .earn { padding: 14px; }
  .earn-foot { grid-template-columns: 1fr; gap: 12px; }
  .earn-foot .wallet { justify-self: start; }
}

/* infinite loops stop completely with reduced motion (the global rule would make them flicker) */
@media (prefers-reduced-motion: reduce) {
  .art *, .art::before, .art::after, .item, .item.tier-legendary, .item.is-pending .buy-btn, .goal.is-ready .meter-fill::after { animation: none !important; }
}
.reduced-fx .art *, .reduced-fx .art::before, .reduced-fx .art::after, .reduced-fx .item, .reduced-fx .item.tier-legendary,
.reduced-fx .item.is-pending .buy-btn, .reduced-fx .goal.is-ready .meter-fill::after, .reduced-fx .wallet.is-spent,
.reduced-fx .earn.is-done .earn-total { animation: none !important; }
.reduced-fx .meter-fill, .reduced-fx .earn-lines li { transition: none; }
@media (prefers-reduced-transparency: reduce) {
  .shop-preview, .wallet, .goal, .tab { background: var(--ink-2); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
