:root {
  --ink: #1c2446;
  --panel: rgba(28, 36, 70, 0.9);
  --cream: #fff8ea;
  --muted: rgba(255, 248, 234, 0.7);
  --gold: #ffc93c;
  --gold-deep: #d9901a;
  --green: #5fe06a;
  --green-deep: #2f9a4e;
  --blue: #4fb4ff;
  --danger: #ff5a4a;
  --radius: 18px;
  --font-display: 'Lilita One', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--font-body);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  overflow: clip;
}

#scene,
.touch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

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

.joy {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 116px;
  height: 116px;
  margin: -58px 0 0 -58px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 40%, rgba(255, 255, 255, 0.18) 70%, rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
}

.joy.is-active {
  opacity: 1;
}

.joy i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff, #cfe8ff);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.hurt {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(255, 40, 40, 0.55) 100%);
}

.hurt.is-playing {
  animation: fade-out 0.5s ease-out;
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

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

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  padding: calc(var(--safe-top) + 8px) 12px 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity 0.3s ease, transform 0.35s var(--ease-out);
}

.hud.is-visible {
  opacity: 1;
  transform: none;
}

.hud.is-visible button {
  pointer-events: auto;
}

.hud__top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

.round-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.hud__room {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.hud__room span {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud__room b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
}

.hud__coins,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  border-radius: 999px;
  background: var(--panel);
  font-family: var(--font-display);
  font-size: 18px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}

.coin-icon,
.gem-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, var(--gold) 45%, var(--gold-deep));
}

.gem-icon {
  border-radius: 0;
  background: linear-gradient(135deg, #b8f4ff, #4fb4ff 45%, #3a4fd6);
  clip-path: polygon(50% 0, 100% 38%, 50% 100%, 0 38%);
}

.xp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px auto 0;
  width: min(100%, 360px);
}

.xp__level {
  display: grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border-radius: 10px;
  background: linear-gradient(180deg, #7fe8ff, #2f8fd6);
  font-family: var(--font-display);
  font-size: 17px;
  color: #06224a;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.xp__bar {
  flex: 1;
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(10, 14, 32, 0.75);
}

.xp__bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #5fe8ff, #b8ffec);
  transition: width 0.25s ease;
}

.xp.bump .xp__level {
  animation: bump 0.4s var(--spring);
}

@keyframes bump {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

.boss {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 8px auto 0;
  width: min(100%, 360px);
}

.boss[hidden] {
  display: none;
}

.boss__name {
  font-family: var(--font-display);
  font-size: 17px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.boss__track {
  width: 100%;
  height: 16px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(10, 14, 32, 0.8);
  box-shadow: 0 0 0 2px rgba(255, 90, 74, 0.5);
}

.boss__track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff3a2a, #ff8a5a);
  transition: width 0.2s ease;
}

/* ---------------------------------------------------------------- floaters, banner */

.floaters {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.floater {
  position: absolute;
  font-family: var(--font-display);
  font-size: 19px;
  color: #fff;
  /* A thick dark outline drawn with shadows (reliable on iOS), then a drop shadow. */
  text-shadow:
    2px 0 0 #1c1430, -2px 0 0 #1c1430, 0 2px 0 #1c1430, 0 -2px 0 #1c1430,
    1.5px 1.5px 0 #1c1430, -1.5px 1.5px 0 #1c1430, 1.5px -1.5px 0 #1c1430, -1.5px -1.5px 0 #1c1430,
    0 4px 0 rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
}

.floater[data-variant='crit'] {
  color: #ffe45e;
  font-size: 28px;
  text-shadow:
    2.5px 0 0 #a02a00, -2.5px 0 0 #a02a00, 0 2.5px 0 #a02a00, 0 -2.5px 0 #a02a00,
    2px 2px 0 #a02a00, -2px 2px 0 #a02a00, 2px -2px 0 #a02a00, -2px -2px 0 #a02a00,
    0 0 14px rgba(255, 170, 40, 0.9), 0 5px 0 rgba(0, 0, 0, 0.35);
}

.floater[data-variant='hurt'] {
  color: #ff6a5a;
  font-size: 22px;
}

.floater[data-variant='heal'] {
  color: #7dffa8;
}

.floater[data-variant='dot'] {
  color: #ffb070;
  font-size: 15px;
}

.floater[data-variant='info'] {
  color: #bfefff;
  font-size: 19px;
}

.floater.is-playing {
  animation: floater 0.85s var(--ease-out) forwards;
}

.floater[data-variant='crit'].is-playing {
  animation: floater-crit 0.95s var(--ease-out) forwards;
}

@keyframes floater {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
  12% { opacity: 1; transform: translate(-50%, -70%) scale(1.25); }
  24% { transform: translate(-50%, -80%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(0.95); }
}

/* Critical hits punch in big and tilted, then settle. */
@keyframes floater-crit {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(2.2) rotate(-8deg); }
  10% { opacity: 1; transform: translate(-50%, -70%) scale(0.9) rotate(4deg); }
  20% { transform: translate(-50%, -80%) scale(1.15) rotate(-2deg); }
  32% { transform: translate(-50%, -88%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -180%) scale(0.95); }
}

.banner {
  position: absolute;
  top: calc(var(--safe-top) + 120px);
  left: 50%;
  z-index: 4;
  padding: 10px 22px;
  border-radius: 16px;
  background: var(--panel);
  font-family: var(--font-display);
  font-size: 24px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%);
}

.banner small {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--gold);
}

.banner.is-playing {
  animation: banner 2.1s var(--ease-out) forwards;
}

.banner[data-variant='danger'] {
  background: linear-gradient(180deg, #ff7a6a, #c93232);
}

@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -10px) scale(0.85); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  22% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -8px); }
}

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 90px);
  z-index: 2;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(10, 14, 32, 0.7);
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hint.is-visible {
  opacity: 1;
  animation: hint-bob 1.6s ease-in-out infinite;
}

@keyframes hint-bob {
  50% { transform: translate(-50%, -6px); }
}

/* ---------------------------------------------------------------- screens */

.screen {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  padding: calc(var(--safe-top) + 24px) 16px calc(var(--safe-bottom) + 24px);
  background: rgba(14, 18, 40, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
  overflow-y: auto;
  touch-action: pan-y;
}

.screen > :first-child {
  margin-top: auto;
}

.screen > :last-child {
  margin-bottom: auto;
}

.screen.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s;
}

.screen__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 13vw, 64px);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--ink);
}

.screen__text {
  margin: 0;
  max-width: 320px;
  text-align: center;
  color: var(--muted);
}

.panel {
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn {
  min-height: 54px;
  padding: 0 22px;
  border-radius: 16px;
  background: #2b3566;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.28), 0 2px 0 rgba(0, 0, 0, 0.2);
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.02em;
  transition: transform 0.12s var(--ease-out), filter 0.2s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(2px) scale(0.98);
}

.btn:disabled {
  filter: grayscale(0.9) brightness(0.7);
}

.btn--primary {
  background: linear-gradient(180deg, #74e38f, var(--green-deep));
  color: #0f2d17;
}

.btn--gold {
  background: linear-gradient(180deg, #ffdd6b, var(--gold-deep));
  color: #3a2300;
}

.btn--ghost {
  background: transparent;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.btn--play {
  width: min(100%, 320px);
  min-height: 70px;
  font-size: 32px;
  background: linear-gradient(180deg, #ffdd6b, var(--gold-deep));
  color: #3a2300;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: play-pulse 2s ease-in-out infinite;
}

@keyframes play-pulse {
  50% { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.28), 0 0 26px rgba(255, 201, 60, 0.6); }
}

/* Menu */

.screen--menu {
  padding-bottom: calc(var(--safe-bottom) + 86px);
  background: linear-gradient(180deg, rgba(14, 18, 40, 0.5) 0%, rgba(14, 18, 40, 0) 30%, rgba(14, 18, 40, 0.1) 50%, rgba(14, 18, 40, 0.85) 80%);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.brand {
  text-align: center;
}

.brand__kicker {
  margin: 0;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.brand__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(52px, 15vw, 88px);
  line-height: 0.95;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 12px 24px rgba(0, 0, 0, 0.3);
}

.wallet {
  display: flex;
  gap: 8px;
}

.chapter-card {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(95, 224, 106, 0.35), rgba(28, 36, 70, 0.92));
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.chapter-card__nav {
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  font-family: var(--font-display);
  font-size: 28px;
}

.chapter-card__nav:disabled {
  opacity: 0.25;
}

.chapter-card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.chapter-card__kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

.chapter-card__body b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
}

.chapter-card__body span:last-child {
  font-size: 13px;
  color: var(--muted);
}

.chapter-card.is-locked .chapter-card__body b::after {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-left: 0.3em;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%20512%20512%22%3E%3Cpath%20d%3D%22M254.28%2017.313c-81.048%200-146.624%2065.484-146.624%20146.406V236h49.594v-69.094c0-53.658%2043.47-97.187%2097.03-97.187%2053.563%200%2097.032%2044.744%2097.032%2097.186V236h49.594v-72.28c0-78.856-65.717-146.407-146.625-146.407zM85.157%20254.688c-14.61%2022.827-22.844%2049.148-22.844%2076.78%200%2088.358%2084.97%20161.5%20191.97%20161.5%20106.998%200%20191.968-73.142%20191.968-161.5%200-27.635-8.26-53.95-22.875-76.78H85.155zM254%20278.625c22.34%200%2040.875%2017.94%2040.875%2040.28%200%2016.756-10.6%2031.23-25.125%2037.376l32.72%2098.126h-96.376l32.125-98.125c-14.526-6.145-24.532-20.62-24.532-37.374%200-22.338%2017.972-40.28%2040.312-40.28z%22/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%20512%20512%22%3E%3Cpath%20d%3D%22M254.28%2017.313c-81.048%200-146.624%2065.484-146.624%20146.406V236h49.594v-69.094c0-53.658%2043.47-97.187%2097.03-97.187%2053.563%200%2097.032%2044.744%2097.032%2097.186V236h49.594v-72.28c0-78.856-65.717-146.407-146.625-146.407zM85.157%20254.688c-14.61%2022.827-22.844%2049.148-22.844%2076.78%200%2088.358%2084.97%20161.5%20191.97%20161.5%20106.998%200%20191.968-73.142%20191.968-161.5%200-27.635-8.26-53.95-22.875-76.78H85.155zM254%20278.625c22.34%200%2040.875%2017.94%2040.875%2040.28%200%2016.756-10.6%2031.23-25.125%2037.376l32.72%2098.126h-96.376l32.125-98.125c-14.526-6.145-24.532-20.62-24.532-37.374%200-22.338%2017.972-40.28%2040.312-40.28z%22/%3E%3C/svg%3E") center / contain no-repeat;
}

.menu-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.menu-tabs:empty {
  display: none;
}

.settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(28, 36, 70, 0.72);
  font-size: 13px;
  color: var(--muted);
}

.chip__value {
  margin-left: 3px;
  color: var(--cream);
  font-weight: 800;
}

.credits {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}

/* The play tab leaves the middle of the screen to the hero standing in the landscape. */
#panel-play {
  flex: 1 0 auto;
  margin: 0;
  padding-top: 30px;
  gap: 12px;
}

#panel-play .brand {
  margin-bottom: auto;
}

#panel-play .settings {
  gap: 4px;
}

#panel-play .chip {
  min-height: 28px;
  padding: 0 7px;
  font-size: 11px;
  white-space: nowrap;
}

#panel-play .credits {
  font-size: 10px;
  text-align: center;
  opacity: 0.8;
}

/* Ability choice (1 of 3) */

.screen--choose {
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 201, 60, 0.18), rgba(14, 18, 40, 0.8) 70%);
}

.choose__kicker {
  margin: 0;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.choose__title {
  margin: 0;
  padding: 8px 22px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffdd6b, var(--gold-deep));
  color: #3a2300;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: min(100%, 420px);
}

.cards--two {
  grid-template-columns: repeat(2, 1fr);
  width: min(100%, 300px);
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #f3ffe8, #cfeec0);
  color: var(--ink);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.35);
  transform: translateY(20px) scale(0.9);
  opacity: 0;
}

.screen.is-visible .card {
  animation: card-in 0.45s var(--spring) forwards;
}

@keyframes card-in {
  to { transform: none; opacity: 1; }
}

.card:active {
  transform: scale(0.96);
}

.card__icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(180deg, #7ccf5a, #4d9a35);
  font-size: 34px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.card b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.1;
  text-align: center;
  color: #2a6a1c;
}

.card small {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  color: #3a4a3a;
}

.card__stack {
  font-size: 11px;
  font-weight: 800;
  color: #7a8a6a;
}

.taken {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 380px;
}

.taken span {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 16px;
}

.taken span sup {
  font-size: 10px;
  font-weight: 800;
}

.taken--big span {
  min-width: 40px;
  height: 40px;
  font-size: 22px;
}

/* End screen */

.end-stats {
  width: min(100%, 320px);
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.end-stats div {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--panel);
}

.end-stats dt {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.end-stats dd {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 24px;
}

.loot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 360px;
}

.loot:empty {
  display: none;
}

/* Overlays */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, #33407a, var(--ink) 70%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
}

.overlay.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s;
}

.overlay p {
  margin: 0;
  color: var(--muted);
}

.overlay .overlay__brand {
  font-family: var(--font-display);
  font-size: 52px;
  color: var(--cream);
}

.progress {
  width: min(70vw, 260px);
  height: 12px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--gold));
  transition: width 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}


/* ---------------------------------------------------------------- menu tabs */

.menu-top {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  right: 12px;
  left: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  z-index: 1;
}

.pill--power {
  margin-right: auto;
}

.panel-view {
  display: none;
  width: min(100%, 440px);
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto 0;
  padding-top: 40px;
}

.panel-view.is-active {
  display: flex;
  animation: panel-in 0.3s var(--ease-out);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(10px); }
}

.screen--menu .panel-view:not(#panel-play) {
  align-self: stretch;
  margin: 0 auto;
  padding: 44px 12px 16px;
  border-radius: 22px;
  background: rgba(14, 18, 40, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 32px;
}

.panel-subtitle {
  align-self: flex-start;
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
}

.panel-text {
  margin: -8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.nav {
  /* Fixed to the screen: the menu content scrolls under it. */
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(var(--safe-bottom) + 6px);
  background: linear-gradient(180deg, #2a3a78, #1c2446);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 0;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  transition: transform 0.2s var(--spring), background 0.2s ease;
}

.nav button span {
  font-size: 24px;
  line-height: 1.1;
}

.nav button.is-active {
  background: linear-gradient(180deg, #ffdd6b, var(--gold-deep));
  color: #3a2300;
  transform: translateY(-8px) scale(1.08);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.nav .badge-dot::after {
  content: '';
  position: absolute;
  margin: -2px 0 0 18px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
}

.btn--wide {
  width: min(100%, 320px);
}

/* Items */

.slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.inventory {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: 100%;
}

.item {
  --rarity: #b9c3cf;
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--rarity) 45%, transparent), rgba(10, 14, 32, 0.9) 75%);
  box-shadow: inset 0 0 0 2px var(--rarity), inset 0 -4px 0 rgba(0, 0, 0, 0.3);
  font-size: 30px;
}

.item--empty {
  --rarity: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  font-size: 24px;
  opacity: 0.6;
}

.item__level {
  position: absolute;
  left: 4px;
  bottom: 3px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.item__slot {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
}

.item__equipped {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 12px;
}

.item__merge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 12px;
}

.item.is-legendary {
  animation: legendary 2.4s ease-in-out infinite;
}

@keyframes legendary {
  50% { box-shadow: inset 0 0 0 2px var(--rarity), inset 0 -4px 0 rgba(0, 0, 0, 0.3), 0 0 16px var(--rarity); }
}

.stat-line {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
  font-size: 13px;
  font-weight: 800;
}

.stat-line span {
  color: var(--muted);
}

.stat-line b {
  color: var(--cream);
}

/* Talents */

.talents {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
}

.talent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  text-align: center;
}

.talent span:first-child {
  font-size: 28px;
}

.talent b {
  font-size: 13px;
}

.talent small {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}

.talent em {
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
}

.talent.is-new {
  animation: talent-pop 0.8s var(--spring);
  box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(255, 201, 60, 0.6);
}

@keyframes talent-pop {
  0% { transform: scale(1.3); }
  100% { transform: none; }
}

/* Heroes */

.heroes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 2px transparent;
  text-align: center;
}

.hero-card.is-selected {
  box-shadow: inset 0 0 0 3px var(--gold);
  background: rgba(255, 201, 60, 0.12);
}

.hero-card__face {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: var(--hero, #3fa9ff);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
}

.hero-card b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
}

.hero-card small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}

.hero-card .btn {
  min-height: 40px;
  margin-top: 4px;
  font-size: 16px;
  padding: 0 14px;
}

/* Shop */

.shop {
  display: grid;
  gap: 10px;
  width: 100%;
}

.shop-card {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
}

.shop-card__icon {
  font-size: 44px;
  text-align: center;
}

.shop-card b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
}

.shop-card small {
  font-size: 12px;
  color: var(--muted);
}

.shop-card .btn {
  min-height: 44px;
  padding: 0 14px;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Popup (item details, chest reward) */

.popup {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 10, 24, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.popup[hidden] {
  display: none;
}

.popup__card {
  --rarity: #b9c3cf;
  width: min(100%, 340px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--rarity) 30%, #1c2446), #1c2446 60%);
  box-shadow: inset 0 0 0 3px var(--rarity), 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
  animation: popup-in 0.35s var(--spring);
}

@keyframes popup-in {
  from { transform: scale(0.8); opacity: 0; }
}

.popup__icon {
  font-size: 64px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4));
}

.popup__card.is-reveal .popup__icon {
  animation: reveal 0.9s var(--spring);
}

@keyframes reveal {
  0% { transform: scale(0) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(8deg); }
  100% { transform: none; }
}

.popup__rarity {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--rarity);
}

.popup__name {
  margin: -6px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
}

.popup__text {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.popup__stats {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 14px;
  font-weight: 800;
}

.popup__stats .next {
  color: var(--green);
  font-size: 12px;
}

.popup__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.popup__actions .btn {
  min-height: 46px;
  font-size: 16px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.popup__actions .btn--full {
  grid-column: 1 / -1;
}

/* ================================================================ premium skin (v2)
   Vector icons, lit badges, framed panels and glossy buttons. */

:root {
  --ink: #121833;
  --frame: rgba(255, 226, 150, 0.55);
  --frame-soft: rgba(255, 255, 255, 0.12);
  --glass: linear-gradient(180deg, rgba(40, 52, 104, 0.94), rgba(18, 24, 52, 0.96));
}

.ico {
  width: 1em;
  height: 1em;
  fill: currentColor;
  vertical-align: -0.14em;
  flex: none;
}

/* An item's picture from the sprite sheet rendered in Blender (tools/blender/items.py). */
.art {
  display: inline-block;
  width: 1em;
  height: 1em;
  background-image: url(assets/icons/items.webp);
  background-repeat: no-repeat;
  vertical-align: -0.14em;
  flex: none;
}

.item .art.item__ico {
  width: 72%;
  height: 72%;
}

.art--xl {
  font-size: 120px;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--rarity, #fff) 55%, transparent));
}

.toast .art {
  font-size: 30px;
}

/* Round badge: coloured light from the top, dark rim, glossy highlight. */
.badge {
  --a: #ffe28a;
  --b: #d98a12;
  --c: #5a2f00;
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, var(--a), var(--b) 62%, var(--c));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.28), inset 0 -4px 6px rgba(0, 0, 0, 0.3), 0 3px 8px rgba(0, 0, 0, 0.45);
  color: #fffdf6;
  font-size: 26px;
  flex: none;
}

.badge::after {
  content: '';
  position: absolute;
  inset: 3px 8px auto;
  height: 38%;
  border-radius: 50% / 60% 60% 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.badge .ico {
  filter: drop-shadow(0 2px 1px rgba(0, 0, 0, 0.45));
}

.badge--gold { --a: #ffe9a0; --b: #e2a126; --c: #5c3200; }
.badge--fire { --a: #ffc27a; --b: #f0561e; --c: #5a1000; }
.badge--ice { --a: #bff0ff; --b: #2f9be0; --c: #0b2d5c; }
.badge--poison { --a: #c6ff9a; --b: #3fae3a; --c: #0d3b12; }
.badge--arcane { --a: #e6c8ff; --b: #8a4fe0; --c: #2a0f5a; }
.badge--blood { --a: #ffb0bc; --b: #e0304e; --c: #54081a; }
.badge--wind { --a: #d4fff0; --b: #2fb79a; --c: #08403a; }
.badge--lg { width: 60px; height: 60px; font-size: 36px; }
.badge--xl { width: 92px; height: 92px; font-size: 56px; }

/* Framed panels. */
.panel-view,
.chapter-card,
.shop-card,
.hero-card,
.talent {
  background: var(--glass);
  box-shadow: inset 0 0 0 1px var(--frame-soft), inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 26px rgba(0, 0, 0, 0.38);
}

.chapter-card {
  background: linear-gradient(160deg, rgba(95, 224, 106, 0.3), rgba(24, 32, 66, 0.96) 55%);
  box-shadow: inset 0 0 0 1.5px var(--frame), inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 12px 30px rgba(0, 0, 0, 0.4);
}

.panel-title,
.brand__title,
.choose__title,
.screen__title {
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 22px rgba(255, 210, 120, 0.25);
}

/* Buttons: gloss on top, darker lip at the bottom, pressed state. */
.btn {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #3a4786, #232c5c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -4px 0 rgba(0, 0, 0, 0.3), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn::before {
  content: '';
  position: absolute;
  left: 6px;
  right: 6px;
  top: 3px;
  height: 42%;
  border-radius: 12px 12px 40% 40%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.btn:disabled::before {
  opacity: 0.3;
}

.btn:not(:disabled):active {
  transform: translateY(2px) scale(0.98);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), inset 0 -2px 0 rgba(0, 0, 0, 0.3), 0 2px 5px rgba(0, 0, 0, 0.3);
}

.btn--primary { background: linear-gradient(180deg, #8af0a0, #2fa04f 55%, #1f7a3a); }
.btn--gold { background: linear-gradient(180deg, #ffe88a, #f0a526 55%, #c47510); }
.btn--ghost {
  background: rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22);
}

.btn--play {
  background: linear-gradient(180deg, #fff09a, #f5b12e 50%, #d0800f);
  color: #3a2300;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), inset 0 -6px 0 rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(255, 236, 170, 0.35), 0 10px 26px rgba(240, 165, 38, 0.45);
}

/* Bottom navigation: glass bar, active tab lifted into a gold medallion. */
.nav {
  background: linear-gradient(180deg, rgba(32, 42, 92, 0.96), rgba(12, 16, 36, 0.98));
  box-shadow: inset 0 1px 0 var(--frame), 0 -6px 20px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.nav button .ico {
  font-size: 26px;
  margin-bottom: 2px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.4));
}

.nav button.is-active {
  background: radial-gradient(circle at 50% 25%, #fff0b0, #f0a526 60%, #b86a0c);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5), 0 8px 18px rgba(240, 165, 38, 0.45);
}

.pill .ico {
  font-size: 18px;
  color: #ffd57a;
}

/* Ability cards: dark framed cards, lit badge, gold rim. */
.card {
  position: relative;
  padding: 16px 8px 14px;
  background: linear-gradient(180deg, #34427f, #1a2148 70%);
  color: var(--cream);
  box-shadow: inset 0 0 0 2px rgba(255, 214, 120, 0.7), inset 0 2px 0 rgba(255, 255, 255, 0.25), 0 14px 30px rgba(0, 0, 0, 0.5), 0 0 24px rgba(255, 200, 90, 0.12);
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 18%, rgba(255, 225, 150, 0.28), transparent 55%);
  pointer-events: none;
}

.card .card__icon {
  width: 68px;
  height: 68px;
  font-size: 40px;
  border-radius: 50%;
}

.card b {
  color: #ffe9b0;
}

.card small {
  color: rgba(236, 240, 255, 0.82);
}

.taken span {
  background: none;
  min-width: 0;
  padding: 0;
}

.taken .badge {
  width: 30px;
  height: 30px;
  font-size: 18px;
}

/* Items and talents. */
.item {
  font-size: 34px;
  color: #fff8ea;
}

.item .item__ico {
  font-size: 38px;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 10px color-mix(in srgb, var(--rarity) 60%, transparent));
}

.item--empty .item__ico {
  opacity: 0.35;
  filter: none;
}

.item__equipped .ico,
.item__merge .ico {
  font-size: 13px;
  vertical-align: 0;
}

.talent .badge {
  width: 40px;
  height: 40px;
  font-size: 24px;
  margin-bottom: 2px;
}

.shop-card__icon {
  display: grid;
  place-items: center;
}

.hero-card__face {
  background: none;
  box-shadow: none;
}

.hero-card__face .badge {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3), 0 0 0 3px var(--hero), 0 6px 14px rgba(0, 0, 0, 0.45);
}

.portrait {
  display: block;
  width: 94%;
  height: 94%;
  border-radius: 50%;
  background:
    var(--face) center top / cover no-repeat,
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--hero) 55%, #fff) 0, var(--hero) 45%, color-mix(in srgb, var(--hero) 45%, #120e24) 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.3), 0 0 0 3px var(--hero), 0 6px 14px rgba(0, 0, 0, 0.45);
}

.popup__icon {
  filter: none;
}

.popup__stats .next .ico,
.loot .ico {
  color: #ffd57a;
}

/* The play tab floats over the 3D scene: no panel behind it. */
#panel-play.panel-view {
  background: none;
  box-shadow: none;
}

/* ---------------------------------------------------------------- progression (v3) */

.banner[data-variant='gold'] {
  background: linear-gradient(180deg, #ffd66a, #d88a1c);
  color: #3a2000;
}

.banner[data-variant='gold'] small {
  color: #5a3400;
}

/* Account level: laurel, level number and a thin experience bar. */
.pill--level {
  position: relative;
  gap: 4px;
  padding-right: 10px;
  overflow: hidden;
}

.pill--level .ico {
  color: var(--gold);
}

.level-bar {
  position: absolute;
  right: 8px;
  bottom: 3px;
  left: 8px;
  height: 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.35);
}

.level-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #8af07a, #3fd0ff);
}

.pill--gold {
  background: linear-gradient(180deg, #ffd66a, #c88418);
  color: #3a2000;
}

/* Side button on the play screen (quests). */
.side-btn {
  position: absolute;
  top: 34%;
  left: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 64px;
  padding: 8px 0 6px;
  border-radius: 18px;
  background: var(--glass);
  box-shadow: inset 0 0 0 1.5px var(--frame), inset 0 -3px 0 rgba(0, 0, 0, 0.3), 0 8px 18px rgba(0, 0, 0, 0.35);
  font-size: 11px;
  font-weight: 800;
  color: var(--cream);
}

.side-btn .ico {
  width: 30px;
  height: 30px;
  color: var(--gold);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

.side-btn.badge-dot::after {
  content: '';
  position: absolute;
  top: 5px;
  right: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(14, 18, 40, 0.8);
}

/* Mode selector (Normal / Héroïque / Infini). */
.modes {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 4px;
  width: min(100%, 380px);
  padding: 4px;
  border-radius: 14px;
  background: rgba(14, 18, 40, 0.72);
  box-shadow: inset 0 0 0 1px var(--frame-soft);
}

.modes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 32px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--muted);
}

.modes button .ico {
  width: 16px;
  height: 16px;
}

.modes button.is-active {
  background: linear-gradient(180deg, #4a5ab0, #2a3470);
  color: var(--cream);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.modes button[data-mode='heroic'].is-active {
  background: linear-gradient(180deg, #e0603a, #8a2020);
}

.modes button[data-mode='daily'].is-active {
  background: linear-gradient(180deg, #2ac0b0, #146a78);
}

.modes button {
  position: relative;
}

.modes__more.is-active {
  background: linear-gradient(180deg, #9a6aff, #4a2a9a);
  color: var(--cream);
}

.modes__more[data-current='heroic'].is-active { background: linear-gradient(180deg, #e0603a, #8a2020); }
.modes__more[data-current='survival'].is-active { background: linear-gradient(180deg, #ff9a3a, #a2401a); }
.modes__more[data-current='bossrush'].is-active { background: linear-gradient(180deg, #e8405a, #7a1030); }
.modes__more[data-current='tower'].is-active { background: linear-gradient(180deg, #7a5ac8, #2a1a5a); }

/* A daily challenge still to win today. */
.modes__dot {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(14, 18, 40, 0.8);
  animation: pulse-dot 1.4s ease-in-out infinite;
}

.modes__dot[hidden] {
  display: none;
}

@keyframes pulse-dot {
  50% { transform: scale(1.3); }
}

.modes button.is-locked {
  opacity: 0.45;
}

.chapter-card[data-mode='heroic'] {
  background: linear-gradient(160deg, rgba(255, 110, 70, 0.4), rgba(40, 18, 30, 0.96) 55%);
}

.chapter-card[data-mode='endless'] {
  background: linear-gradient(160deg, rgba(160, 110, 255, 0.4), rgba(22, 16, 56, 0.96) 55%);
}
.chapter-card[data-mode='daily'] {
  background: linear-gradient(160deg, rgba(42, 200, 180, 0.42), rgba(10, 30, 44, 0.96) 55%);
}

.chapter-card[data-mode='survival'] {
  background: linear-gradient(160deg, rgba(255, 150, 60, 0.42), rgba(44, 18, 12, 0.96) 55%);
}

.chapter-card[data-mode='bossrush'] {
  background: linear-gradient(160deg, rgba(232, 64, 90, 0.42), rgba(40, 10, 22, 0.96) 55%);
}

.chapter-card[data-mode='tower'] {
  background: linear-gradient(160deg, rgba(122, 90, 200, 0.45), rgba(14, 10, 34, 0.96) 55%);
}

/* Mode picker. */
.mode-list {
  width: 100%;
  display: grid;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 2px;
}

.mode-card {
  --mode: #4fb4ff;
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  text-align: left;
  background: linear-gradient(110deg, color-mix(in srgb, var(--mode) 26%, transparent), rgba(255, 255, 255, 0.05));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--mode) 40%, transparent);
}

.mode-card[data-mode='heroic'] { --mode: #ff6a3a; }
.mode-card[data-mode='daily'] { --mode: #2ac8b4; }
.mode-card[data-mode='survival'] { --mode: #ff9a3a; }
.mode-card[data-mode='bossrush'] { --mode: #ff4a64; }
.mode-card[data-mode='tower'] { --mode: #9a7aff; }
.mode-card[data-mode='endless'] { --mode: #b07aff; }

.mode-card.is-current {
  box-shadow: inset 0 0 0 2px var(--gold);
}

.mode-card.is-locked {
  opacity: 0.5;
}

.mode-card__icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, color-mix(in srgb, var(--mode) 85%, white), color-mix(in srgb, var(--mode) 70%, black));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.mode-card__icon .ico {
  width: 28px;
  height: 28px;
  color: #fff;
}

.mode-card__body b {
  display: block;
  font-size: 16px;
}

.mode-card__body small {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--muted);
}

.mode-card__body em {
  display: inline-block;
  margin-top: 4px;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
  color: var(--gold);
}

/* Tabs inside a panel (talents, quests). */
.tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  width: 100%;
  padding: 4px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
}

.tabs button {
  min-height: 34px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
}

.tabs button.is-active {
  background: linear-gradient(180deg, #4a5ab0, #2a3470);
  color: var(--cream);
}

.talent-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.talent-view[hidden] {
  display: none;
}

/* Talent tree: three columns of five nodes. */
.tree {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
}

.branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 10px;
  border-radius: 16px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--branch) 22%, transparent), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--branch) 45%, transparent);
}

.branch__name {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  color: var(--branch);
}

.branch__name small {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--muted);
}

.node {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 100%;
  padding: 7px 2px 5px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.node .ico {
  width: 30px;
  height: 30px;
  color: var(--muted);
}

.node small {
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.node em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.node.is-learned {
  background: color-mix(in srgb, var(--branch) 30%, rgba(0, 0, 0, 0.3));
  box-shadow: inset 0 0 0 1.5px var(--branch);
}

.node.is-learned .ico {
  color: var(--branch);
}

.node.is-max em {
  color: var(--gold);
}

.node.is-ready {
  box-shadow: inset 0 0 0 1.5px var(--gold), 0 0 12px rgba(255, 200, 60, 0.35);
}

.node.is-closed {
  opacity: 0.5;
}

.node.is-new {
  animation: talent-pop 0.5s var(--ease-out);
}

.node__need {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 9px;
  font-style: normal;
  color: var(--muted);
}

/* Quests: missions and achievements. */
.quests {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.quest {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
}

.quest b {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.quest small {
  font-size: 12px;
  color: var(--muted);
}

.quest__text {
  display: block;
}

.quest__bar {
  display: block;
  height: 7px;
  margin: 5px 0 2px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.quest__bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #ffd66a, #ff9a3a);
}

.quest.is-done {
  opacity: 0.6;
}

.quest .btn {
  min-width: 74px;
  min-height: 40px;
  padding: 0 10px;
  font-size: 14px;
}

.quest--bonus {
  background: linear-gradient(135deg, rgba(255, 200, 60, 0.22), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 0 0 1px rgba(255, 200, 60, 0.4);
}

.quest__tiers {
  display: inline-flex;
  gap: 3px;
}

.quest__tiers i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.quest__tiers i.is-on {
  background: var(--gold);
}

/* Sets being worn (equipment tab) and in the item sheet. */
.sets {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.sets:empty {
  display: none;
}

.set,
.popup__set,
.popup__power {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 3px 0 0 var(--set, var(--gold));
  font-size: 12px;
  text-align: left;
  color: var(--muted);
}

.set b,
.popup__set b,
.popup__power b {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--set, var(--gold));
}

.set b small {
  color: var(--muted);
}

.set .is-on,
.popup__set .is-on {
  color: var(--cream);
  font-weight: 800;
}

.popup__power span {
  color: var(--muted);
}

.popup__power.is-on span {
  color: var(--cream);
  font-weight: 800;
}

.popup__power .ico {
  width: 14px;
  height: 14px;
}

.popup__stars {
  display: inline-flex;
  gap: 4px;
}

.popup__stars i {
  color: rgba(255, 255, 255, 0.2);
}

.popup__stars i.is-on {
  color: var(--gold);
  filter: drop-shadow(0 0 4px rgba(255, 200, 60, 0.6));
}

.popup__stars .ico {
  width: 20px;
  height: 20px;
}

.item__stars {
  position: absolute;
  top: 3px;
  left: 50%;
  display: flex;
  transform: translateX(-50%);
  color: var(--gold);
}

.item__stars .ico {
  width: 11px;
  height: 11px;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.6));
}

/* ---------------------------------------------------------------- spells (HUD) */

.spellbar {
  position: absolute;
  right: calc(12px + env(safe-area-inset-right, 0px));
  bottom: calc(var(--safe-bottom) + 22px);
  z-index: 3;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity 0.3s ease, transform 0.35s var(--ease-out);
}

.spellbar.is-visible {
  opacity: 1;
  transform: none;
}

.spellbar.is-visible .spell {
  pointer-events: auto;
}

/* The first spell is the big one, the others sit above it. */
.spell {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--spell) 55%, #fff) 0%, var(--spell) 45%, color-mix(in srgb, var(--spell) 35%, #101830) 100%);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 0 3px rgba(255, 255, 255, 0.85);
  touch-action: none;
  overflow: hidden;
  transition: transform 0.15s var(--spring), filter 0.2s ease;
}

.spell:first-child {
  width: 74px;
  height: 74px;
}

.spell__icon .ico {
  width: 34px;
  height: 34px;
  fill: #fff;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.spell__cd {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(rgba(10, 14, 32, 0.72) calc(var(--cd, 0) * 360deg), transparent 0);
  pointer-events: none;
}

.spell__time {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.spell__rank {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.spell:not(.is-ready) {
  filter: saturate(0.55) brightness(0.85);
}

.spell.is-ready {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45), inset 0 -4px 0 rgba(0, 0, 0, 0.25), 0 0 0 3px #fff, 0 0 18px 4px color-mix(in srgb, var(--spell) 70%, transparent);
}

.spell.is-flash {
  animation: spell-ready 0.5s var(--spring);
}

.spell.is-cast {
  animation: spell-cast 0.3s var(--ease-out);
}

.spell.is-denied {
  animation: spell-denied 0.3s ease;
}

@keyframes spell-ready {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes spell-cast {
  0% { transform: scale(0.82); }
  100% { transform: scale(1); }
}

@keyframes spell-denied {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Loot notices. */

.toasts {
  position: absolute;
  top: calc(var(--safe-top) + 96px);
  left: 50%;
  z-index: 4;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 8px;
  border-radius: 999px;
  background: rgba(16, 22, 48, 0.86);
  box-shadow: inset 0 0 0 2px var(--toast), 0 0 18px color-mix(in srgb, var(--toast) 50%, transparent), 0 6px 14px rgba(0, 0, 0, 0.4);
  font-size: 14px;
  white-space: nowrap;
  animation: toast-in 2.6s var(--ease-out) forwards;
}

.toast .ico {
  width: 24px;
  height: 24px;
  fill: var(--toast);
}

.toast b {
  color: var(--toast);
}

@keyframes toast-in {
  0% { opacity: 0; transform: translateY(-10px) scale(0.9); }
  10% { opacity: 1; transform: none; }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-6px); }
}

/* ---------------------------------------------------------------- hero sheet */

.hero-card {
  cursor: pointer;
  transition: transform 0.15s var(--spring), box-shadow 0.2s ease;
}

.hero-card.is-viewed {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  transform: translateY(-2px);
}

.hero-card.is-selected.is-viewed {
  box-shadow: inset 0 0 0 3px var(--gold), 0 0 18px rgba(255, 201, 60, 0.3);
}

.hero-card__face {
  position: relative;
}

.hero-card__level {
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 15px;
  background: linear-gradient(#ffe07a, var(--gold-deep));
  color: #3a2200;
  box-shadow: 0 0 0 2px #fff, 0 3px 6px rgba(0, 0, 0, 0.4);
}

.hero-detail {
  width: 100%;
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.hero-sheet {
  padding: 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--hero) 35%, rgba(20, 26, 56, 0.9)), rgba(20, 26, 56, 0.9));
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--hero) 60%, transparent);
  display: grid;
  gap: 8px;
}

.hero-sheet__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-sheet__head b {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
}

.hero-sheet__head small,
.hero-sheet__bonus {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.hero-sheet__level {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  color: #3a2200;
  background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold) 50%, var(--gold-deep));
  box-shadow: 0 0 0 3px #fff, 0 0 20px rgba(255, 201, 60, 0.5);
}

.hero-sheet__xp {
  position: relative;
  height: 18px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.hero-sheet__xp i {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #6ff0ff, #4fb4ff);
  box-shadow: 0 0 12px rgba(111, 240, 255, 0.6);
}

.hero-sheet__xp span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.runes-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: rgba(192, 112, 255, 0.2);
  color: #e0c0ff;
}

.runes-pill .ico,
.spell-row .btn .ico {
  width: 16px;
  height: 16px;
  fill: #d0a0ff;
}

.spell-list {
  display: grid;
  gap: 8px;
}

.spell-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 3px 0 0 var(--spell);
}

.spell-row.is-locked {
  opacity: 0.6;
}

.spell-row.is-bumped {
  animation: talent-pop 0.4s var(--spring);
}

.spell-row__body {
  min-width: 0;
}

.spell-row__body b {
  font-size: 15px;
}

.spell-row__body small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  margin-top: 2px;
}

.spell-row__pips {
  display: inline-flex;
  gap: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

.spell-row__pips i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
}

.spell-row__pips i.is-on {
  background: var(--spell);
  box-shadow: 0 0 6px var(--spell);
}

.spell-row__lock {
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.spell-row__lock .ico {
  width: 14px;
  height: 14px;
}

.btn--small {
  min-height: 38px;
  padding: 0 10px;
  font-size: 13px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.btn--small .coin-icon {
  width: 14px;
  height: 14px;
}

.badge--md {
  width: 44px;
  height: 44px;
}

.badge--md .ico {
  width: 26px;
  height: 26px;
}

.class-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.class-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px;
  border-radius: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.07);
}

.class-card.is-active {
  background: rgba(255, 201, 60, 0.14);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.class-card b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
}

.class-card small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  flex: 1;
}

.hero-sheet__tip {
  font-size: 12px;
  text-align: center;
}

.end-loot-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
}

.end-loot-list .item {
  width: 56px;
  height: 56px;
}

/* Compact hero picker: five portraits in a row, the sheet below. */
.heroes {
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.heroes .hero-card {
  padding: 8px 2px 6px;
  gap: 4px;
  border-radius: 14px;
}

.heroes .hero-card__face {
  width: 52px;
  height: 52px;
}

.heroes .hero-card__face .badge--lg {
  width: 48px;
  height: 48px;
}

.heroes .hero-card b {
  font-size: 14px;
}

.heroes .hero-card.is-locked .hero-card__face {
  filter: grayscale(0.7) brightness(0.8);
}

.hero-card__level {
  min-width: 22px;
  height: 22px;
  font-size: 13px;
}

.hero-card__level--lock {
  background: linear-gradient(#c8d0dc, #7a8494);
}

.hero-card__level--lock .ico {
  width: 12px;
  height: 12px;
  fill: #20283a;
}

.hero-sheet__name {
  flex: 1;
  min-width: 0;
}

.spell-row {
  grid-template-columns: auto 1fr;
}

.spell-row > .btn,
.spell-row > .spell-row__lock {
  grid-column: 2;
  justify-self: start;
}

/* World map button (under the quests one) and the chapter list. */
.side-btn--map {
  left: auto;
  right: 12px;
}

.chapter-card__body {
  cursor: pointer;
}

.popup__card--list {
  width: min(100%, 380px);
  max-height: min(86vh, 720px);
}

.chapter-list {
  width: 100%;
  display: grid;
  gap: 6px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 2px;
}

.chapter-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.07);
}

.chapter-row.is-current {
  box-shadow: inset 0 0 0 2px var(--gold);
  background: rgba(255, 201, 60, 0.12);
}

.chapter-row.is-locked {
  opacity: 0.45;
}

.chapter-row__num {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  background: linear-gradient(#4fb4ff, #2a6ad0);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.chapter-row.is-done .chapter-row__num {
  background: linear-gradient(#ffe07a, var(--gold-deep));
  color: #3a2200;
}

.chapter-row__name {
  font-size: 15px;
  line-height: 1.2;
}

.chapter-row__name small {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.chapter-row__state {
  display: inline-flex;
  gap: 2px;
  font-size: 13px;
  color: var(--muted);
}

.chapter-row__state .ico {
  width: 18px;
  height: 18px;
  fill: var(--gold);
}

.btn-recycle {
  justify-self: center;
  margin: -4px 0 8px;
}

.popup__card--list .chapter-list {
  flex: 1;
  min-height: 0;
}

/* ================================================================ HUD juice */

/* Every button sinks under the thumb and springs back. */
.btn,
.chip,
.nav button,
.side-btn,
.round-btn,
.modes button,
.tabs button,
.item,
.chapter-card__nav {
  transition: transform 0.16s var(--spring), filter 0.2s ease, box-shadow 0.2s ease;
}

.btn:active:not(:disabled),
.chip:active,
.nav button:active,
.side-btn:active,
.round-btn:active,
.modes button:active,
.tabs button:active,
.item:active,
.chapter-card__nav:active:not(:disabled) {
  transform: scale(0.92);
  filter: brightness(1.12);
  transition-duration: 0.06s;
}

/* The Play button: a light sweep across it now and then. */
.btn--play {
  position: relative;
  overflow: hidden;
}

.btn--play::after {
  content: '';
  position: absolute;
  inset: -20% auto -20% -40%;
  width: 34%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.65), transparent);
  transform: skewX(-18deg);
  animation: sheen 3.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sheen {
  0%, 55% { left: -40%; }
  85%, 100% { left: 120%; }
}

/* XP bar: a moving shine and a bright head. */
.xp__bar {
  position: relative;
  overflow: hidden;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.35);
}

.xp__bar i {
  position: relative;
  background: linear-gradient(90deg, #3fc8ff, #6ff0ff 60%, #d8fff4);
  box-shadow: 0 0 10px rgba(111, 240, 255, 0.7);
  transition: width 0.45s var(--spring);
  overflow: hidden;
}

.xp__bar i::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.7) 50%, transparent 80%);
  background-size: 60px 100%;
  background-repeat: no-repeat;
  animation: xp-shine 1.8s linear infinite;
}

@keyframes xp-shine {
  from { background-position: -60px 0; }
  to { background-position: calc(100% + 60px) 0; }
}

.xp.bump .xp__level {
  animation: level-pop 0.6s var(--spring);
}

.xp.bump .xp__bar {
  animation: bar-flash 0.6s ease-out;
}

@keyframes level-pop {
  0% { transform: scale(1.8) rotate(-10deg); box-shadow: 0 0 0 0 rgba(111, 240, 255, 0.9); }
  60% { box-shadow: 0 0 0 14px rgba(111, 240, 255, 0); }
  100% { transform: scale(1); }
}

@keyframes bar-flash {
  0% { filter: brightness(2.2); }
  100% { filter: none; }
}

/* Coins: the counter bounces when a coin lands. */
.hud__coins.is-bump {
  animation: coin-bump 0.28s var(--spring);
}

.hud__coins.is-bump .coin-icon {
  animation: coin-spin 0.35s ease-out;
}

@keyframes coin-bump {
  0% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes coin-spin {
  0% { transform: scaleX(0.2); filter: brightness(1.8); }
  100% { transform: none; }
}

.flyers {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.flyer {
  position: absolute;
  left: -9px;
  top: -9px;
  opacity: 0;
  box-shadow: 0 0 10px rgba(255, 210, 80, 0.8);
  will-change: transform;
}

/* Boss bar: a white chip lags behind the damage, the bar shakes on hits. */
.boss__track {
  position: relative;
  height: 18px;
  box-shadow: 0 0 0 2px rgba(255, 90, 74, 0.6), 0 0 18px rgba(255, 60, 40, 0.35);
}

.boss__track i {
  position: absolute;
  inset: 2px auto 2px 2px;
  max-width: calc(100% - 4px);
}

.boss__track #boss-fill {
  background: linear-gradient(180deg, #ff7a5a, #e0281a 60%, #a01408);
  transition: width 0.12s ease-out;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.35);
}

.boss__track .boss__chip {
  background: #fff4e0;
  transition: width 0.5s cubic-bezier(0.3, 0, 0.3, 1);
}

.boss__track .boss__half {
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 0;
}

.boss.is-hit .boss__track {
  animation: boss-shake 0.18s linear;
}

.boss.is-enraged .boss__name {
  color: #ff9a7a;
  animation: enraged 0.9s ease-in-out infinite;
}

@keyframes boss-shake {
  25% { transform: translate(-2px, 1px); }
  50% { transform: translate(2px, -1px); }
  75% { transform: translate(-1px, 0); }
}

@keyframes enraged {
  50% { text-shadow: 0 0 12px rgba(255, 80, 40, 0.9), 0 2px 0 rgba(0, 0, 0, 0.5); }
}

/* Low life: the screen edges beat red. */
.hurt.is-low {
  opacity: 1;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(255, 30, 30, 0.42) 100%);
  animation: heartbeat 1s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { opacity: 0.55; }
  15% { opacity: 1; }
  30% { opacity: 0.6; }
  45% { opacity: 0.95; }
}

/* Kill combo, under the XP bar on the right. */
.combo {
  position: absolute;
  top: calc(var(--safe-top) + 104px);
  right: 12px;
  z-index: 3;
  display: grid;
  justify-items: end;
  pointer-events: none;
  opacity: 0;
  transform: translateX(30px);
  transition: opacity 0.25s ease, transform 0.3s var(--spring);
}

.combo.is-visible {
  opacity: 1;
  transform: none;
}

.combo b {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 38px;
  line-height: 0.9;
  color: #fff;
  text-shadow: 2px 0 0 #1c1430, -2px 0 0 #1c1430, 0 2px 0 #1c1430, 0 -2px 0 #1c1430, 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 16px var(--combo, rgba(111, 240, 255, 0.8));
}

.combo b::before {
  content: '×';
  font-size: 24px;
  margin-right: 2px;
}

.combo span {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--combo-c, #9ff0ff);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
}

.combo > i {
  display: block;
  width: 70px;
  height: 5px;
  margin-top: 3px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.combo > i > i {
  display: block;
  height: 100%;
  background: var(--combo-c, #9ff0ff);
  transform-origin: left;
}

.combo[data-tier='1'] { --combo: rgba(255, 210, 80, 0.9); --combo-c: #ffd25a; }
.combo[data-tier='2'] { --combo: rgba(255, 110, 60, 0.95); --combo-c: #ff8a4a; }
.combo[data-tier='3'] { --combo: rgba(220, 110, 255, 1); --combo-c: #e0a0ff; }

.combo.is-pop b {
  animation: combo-pop 0.25s var(--spring);
}

@keyframes combo-pop {
  0% { transform: scale(1.5) rotate(-6deg); }
  100% { transform: none; }
}

.combo em {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  font-style: normal;
  font-family: var(--font-display);
  font-size: 22px;
  white-space: nowrap;
  color: var(--combo-c, #ffd25a);
  text-shadow: 2px 0 0 #1c1430, -2px 0 0 #1c1430, 0 2px 0 #1c1430, 0 -2px 0 #1c1430;
  opacity: 0;
}

.combo em.is-playing {
  animation: combo-tag 1.4s var(--ease-out) forwards;
}

@keyframes combo-tag {
  0% { opacity: 0; transform: scale(2.4) rotate(-8deg); }
  12% { opacity: 1; transform: scale(0.9) rotate(3deg); }
  22% { transform: scale(1.05) rotate(0deg); }
  80% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* Ability cards: flip in one after another, the chosen one lifts, the others fall. */
.screen.is-visible .card {
  animation: card-flip 0.55s var(--spring) forwards;
}

@keyframes card-flip {
  0% { opacity: 0; transform: perspective(600px) rotateY(80deg) translateY(30px) scale(0.8); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

.card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.35) 45%, transparent 60%);
  background-size: 250% 100%;
  background-position: 120% 0;
  animation: card-shine 2.6s ease-in-out 0.6s infinite;
  pointer-events: none;
}

@keyframes card-shine {
  0%, 60% { background-position: 120% 0; }
  100% { background-position: -40% 0; }
}

.cards.is-picking .card:not(.is-picked) {
  animation: card-drop 0.22s ease-in forwards !important;
}

.cards .card.is-picked {
  animation: card-pick 0.23s var(--spring) forwards !important;
  z-index: 1;
}

@keyframes card-drop {
  to { opacity: 0; transform: translateY(40px) scale(0.85); }
}

@keyframes card-pick {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.12) translateY(-10px); box-shadow: inset 0 0 0 3px #ffe07a, 0 0 40px rgba(255, 210, 90, 0.8); }
}

/* End screen: rewards pop in one after another. */
.screen.is-visible #end-loot > * {
  animation: reward-pop 0.45s var(--spring) both;
}

#end-loot > *:nth-child(1) { animation-delay: 0.25s; }
#end-loot > *:nth-child(2) { animation-delay: 0.35s; }
#end-loot > *:nth-child(3) { animation-delay: 0.45s; }
#end-loot > *:nth-child(4) { animation-delay: 0.55s; }
#end-loot > *:nth-child(5) { animation-delay: 0.65s; }
#end-loot > *:nth-child(6) { animation-delay: 0.75s; }
#end-loot > *:nth-child(7) { animation-delay: 0.85s; }
#end-loot > *:nth-child(n + 8) { animation-delay: 0.95s; }

@keyframes reward-pop {
  0% { opacity: 0; transform: scale(0.4) translateY(14px); }
  100% { opacity: 1; transform: none; }
}

.screen.is-visible #end-title {
  animation: title-in 0.6s var(--spring) both;
}

@keyframes title-in {
  0% { opacity: 0; transform: scale(1.8); letter-spacing: 0.2em; }
  100% { opacity: 1; transform: none; }
}

/* Room banner: slams in. */
.banner.is-playing {
  animation-timing-function: var(--spring);
}

/* Menu tabs slide in from the side of the tab you came from. */
.panel-view.is-active {
  animation: panel-in 0.32s var(--spring);
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
}

/* Spell buttons: a ripple on each cast. */
.spell::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 0 var(--spell);
  opacity: 0;
  pointer-events: none;
}

.spell.is-cast::after {
  animation: spell-ripple 0.5s ease-out;
}

@keyframes spell-ripple {
  0% { opacity: 1; box-shadow: 0 0 0 0 var(--spell); }
  100% { opacity: 0; box-shadow: 0 0 0 22px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .btn--play::after,
  .xp__bar i::after,
  .card::after {
    animation: none;
  }
}

.spell {
  overflow: visible;
}

.hint {
  white-space: normal;
  width: max-content;
  max-width: min(78vw, 300px);
  text-align: center;
  border-radius: 18px;
  line-height: 1.3;
}

.hurt.is-low {
  background: radial-gradient(ellipse at center, transparent 48%, rgba(255, 20, 20, 0.62) 100%);
}

/* Arrows toward monsters out of view. */
.markers {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.marker {
  position: absolute;
  left: -11px;
  top: -9px;
  width: 22px;
  height: 18px;
  background: #ff4a3a;
  clip-path: polygon(100% 50%, 0 0, 28% 50%, 0 100%);
  filter: drop-shadow(0 0 6px rgba(255, 60, 40, 0.9));
  animation: marker-pulse 0.8s ease-in-out infinite;
}

.marker.is-boss {
  left: -16px;
  top: -13px;
  width: 32px;
  height: 26px;
  background: #ffb03a;
}

@keyframes marker-pulse {
  50% { opacity: 0.55; }
}

/* Shown while the 3D view is being restored after iOS dropped it. */
.gl-lost {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: rgba(10, 14, 32, 0.9);
  font-family: var(--font-display);
  font-size: 22px;
  text-align: center;
}

.gl-lost[hidden] {
  display: none;
}

/* Recommended weapons, class ranks, class spell. */
.popup__reco,
.hero-sheet__reco {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.popup__reco.is-mine {
  color: #9ff0a8;
}

.popup__reco .ico,
.hero-sheet__reco .ico {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.hero-sheet__reco b {
  color: var(--cream);
}

.class-card__spell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #ffd57a !important;
}

.class-card__spell .ico {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.class-rank {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 201, 60, 0.1);
  box-shadow: inset 0 0 0 2px rgba(255, 201, 60, 0.35);
}

.class-rank b {
  font-size: 15px;
}

.class-rank small {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.spell-row--class {
  background: linear-gradient(90deg, rgba(255, 201, 60, 0.14), rgba(255, 255, 255, 0.05));
  box-shadow: inset 3px 0 0 var(--spell), inset 0 0 0 1.5px rgba(255, 201, 60, 0.3);
}

/* Recommended for the selected hero: a small green check on the tile. */
.item__reco {
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #3fcf6a;
  box-shadow: 0 0 0 1.5px rgba(10, 30, 16, 0.8), 0 0 8px rgba(80, 230, 120, 0.6);
}

.item__reco .ico {
  width: 11px;
  height: 11px;
  fill: #0d2a14;
}

.hero-reco {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(63, 207, 106, 0.08);
  box-shadow: inset 0 0 0 1.5px rgba(63, 207, 106, 0.3);
  font-size: 13px;
}

.hero-reco__title {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #9ff0a8;
}

.hero-reco__title .ico {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.hero-reco em {
  font-style: normal;
  color: var(--muted);
  margin-right: 4px;
}

.hero-reco small {
  color: #9ff0a8;
  font-size: 11px;
  margin-left: 4px;
}

/* The Daily challenge's card lists its three mutations: smaller to fit on one or two lines. */
.chapter-card[data-mode='daily'] #chapter-name {
  font-size: 19px;
  line-height: 1.25;
}
