:root {
  --pink: #ff4d8d;
  --pink-dark: #d82b6b;
  --cyan: #00d2ff;
  --gold: #ffbe0b;
  --gold-dark: #d97706;
  --ink: #2b1a18;
  --cream: #fff9f0;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a2436;
  font-family: 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', 'Rounded Mplus 1c', 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  touch-action: none;
}

/* Desktop side-fill ambient sunny street pattern; full screen on mobile */
#app-bg {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 196, 112, 0.28), transparent 42%),
    radial-gradient(circle at 82% 76%, rgba(255, 107, 157, 0.28), transparent 45%),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.03) 0px,
      rgba(255, 255, 255, 0.03) 18px,
      transparent 18px,
      transparent 36px
    ),
    linear-gradient(160deg, #27374d 0%, #3d4f6b 50%, #2a3347 100%);
}

#stage-shell {
  position: relative;
  width: min(100vw, calc(100dvh * 9 / 16));
  height: min(100dvh, calc(100vw * 16 / 9));
  max-width: 100vw;
  max-height: 100dvh;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #6f747d;
  box-shadow: 0 0 48px rgba(0, 0, 0, 0.55), 0 0 0 3px rgba(255, 255, 255, 0.14);
}

@media (max-width: 540px) {
  #stage-shell {
    box-shadow: none;
  }
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden {
  display: none !important;
}

/* Top Controls Bar */
#top-bar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: 10px;
  right: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

#hud-left,
#top-right-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

#top-right-controls {
  margin-left: auto;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(27, 20, 32, 0.78);
  border: 2.5px solid rgba(255, 255, 255, 0.92);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
}

.pill-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
}

.cat-pill {
  background: linear-gradient(135deg, #ff5e95, #ff2e73);
  font-size: 16px;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cat-pill.bump {
  transform: scale(1.24);
}

.wave-pill {
  background: linear-gradient(135deg, #00a8ff, #0077cc);
  font-size: 12px;
  padding: 6px 9px;
}

.coin-pill {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.icon-btn {
  appearance: none;
  border: 2.5px solid #fff;
  border-radius: 999px;
  background: rgba(31, 24, 41, 0.82);
  color: #fff;
  font-weight: 900;
  font-size: 13px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.38);
  transition: transform 0.1s ease;
}

.icon-btn:active {
  transform: translateY(2px) scale(0.95);
}

.lang-btn {
  background: linear-gradient(135deg, #6c5ce7, #4834d4);
  font-size: 11px;
  letter-spacing: 0.4px;
  padding: 0 9px;
}

#stage-progress-wrap {
  position: absolute;
  top: calc(50px + var(--safe-top));
  left: 10px;
  right: 10px;
  z-index: 25;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.progress-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: rgba(24, 18, 34, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.88);
  overflow: visible;
}

.progress-track.boss-mode {
  height: 20px;
  border-color: #ffbe0b;
  box-shadow: 0 0 12px rgba(255, 42, 122, 0.65);
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #00e5ff, #ffbe0b, #ff3b82);
  transition: width 0.12s linear;
}

.progress-track.boss-mode .progress-fill {
  background: linear-gradient(90deg, #ff1e56, #ff7b00, #ffe066);
}

.boss-bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
  letter-spacing: 0.5px;
}

.progress-paw {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.6));
  transition: left 0.15s linear;
}

.progress-boss {
  position: absolute;
  top: 50%;
  right: -4px;
  transform: translateY(-52%);
  font-size: 16px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
}

.sub-hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.score-chip,
.skills-chip {
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(25, 19, 34, 0.68);
  color: #fff8dc;
  font-size: 11px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.skills-chip:empty {
  display: none;
}

/* Ultimate Skill Floating Button */
.ult-btn {
  position: absolute;
  right: 12px;
  bottom: calc(18px + var(--safe-bottom));
  z-index: 28;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3.5px solid #fff;
  background: rgba(28, 20, 42, 0.85);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease;
}

.ult-btn:disabled {
  opacity: 0.82;
  cursor: default;
}

.ult-btn.ready {
  background: linear-gradient(135deg, #ffbe0b, #ff006e, #00e5ff);
  box-shadow: 0 0 24px rgba(255, 200, 30, 0.9), 0 6px 14px rgba(0, 0, 0, 0.45);
  animation: ultPulse 0.85s ease-in-out infinite alternate;
}

.ult-btn:active:not(:disabled) {
  transform: scale(0.92);
}

@keyframes ultPulse {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.ult-ring {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  pointer-events: none;
}

.ult-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, rgba(255, 224, 102, 0.65), rgba(255, 60, 130, 0.78));
  transition: height 0.15s ease;
}

.ult-icon {
  position: relative;
  z-index: 2;
  font-size: 24px;
  line-height: 1;
}

.ult-label {
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 900;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

/* Title Stage Selector */
.stage-selector {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(24, 18, 38, 0.84);
  border: 2.5px solid #ffe066;
  border-radius: 18px;
  padding: 8px 10px;
  margin-top: auto;
  margin-bottom: 10px;
  backdrop-filter: blur(4px);
}

.stage-arrow {
  appearance: none;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 2px solid #fff;
  background: linear-gradient(180deg, #ff70a6, #d81b60);
  color: #fff;
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.stage-arrow:disabled {
  background: #555a6e;
  opacity: 0.45;
  cursor: not-allowed;
}

.stage-sel-center {
  text-align: center;
  flex: 1;
}

.stage-sel-title {
  color: #fff59d;
  font-size: 17px;
  font-weight: 900;
}

.stage-sel-boss {
  color: #ffd6e7;
  font-size: 11px;
  font-weight: 800;
  margin-top: 2px;
}

/* Shop Tabs & Pedigree Cards */
.shop-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.shop-tab {
  appearance: none;
  border: 2.5px solid var(--ink);
  border-radius: 14px;
  padding: 8px 6px;
  background: #f0e4d8;
  color: #5a4642;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
}

.shop-tab.active {
  background: linear-gradient(180deg, #ff70a6, #ff2e73);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.upg-cat-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
  background: #fff5ec;
  border: 2px solid #e8cbb5;
  border-radius: 12px;
  padding: 3px;
}

.stage-sel-area {
  color: #72efdd;
  font-size: 11px;
  font-weight: 900;
  margin-bottom: 1px;
}

.combo-tag {
  font-style: normal;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 8px;
  background: #ff2a85;
  color: #fff68f;
  font-weight: 900;
  font-size: 11px;
}

.compact-btn {
  font-size: 14px;
  padding: 11px 10px;
}

.gallery-btn {
  background: linear-gradient(180deg, #9d4edd 0%, #6a1b9a 100%);
  box-shadow: 0 5px 0 #3c096c;
}

/* Mid-stage 3-card Roguelike Perk Picker */
.perk-modal-card {
  background: linear-gradient(180deg, #fffdf7, #ffeef6);
}

.perk-choices {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.perk-btn {
  appearance: none;
  width: 100%;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(43, 26, 24, 0.25);
  transition: transform 0.1s ease;
}

.perk-btn:active {
  transform: translateY(2px) scale(0.98);
}

.perk-icon {
  font-size: 26px;
  flex-shrink: 0;
}

.perk-title {
  display: block;
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
}

.perk-desc {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #6b4e4a;
  margin-top: 2px;
}

/* Ending CG Showcase & Collection Gallery */
.ending-showcase {
  margin: 8px 0;
  background: #231934;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 8px;
  color: #fff;
  text-align: center;
}

.ending-new-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffbe0b, #ff006e);
  color: #fff;
  margin-bottom: 5px;
}

.ending-cg-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 168px;
  object-fit: cover;
  border-radius: 10px;
  border: 2.5px solid rgba(255, 255, 255, 0.65);
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.ending-cg-img.large-cg {
  max-height: 192px;
}

.ending-cg-title {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 900;
  color: #ffe066;
}

.ending-cg-desc {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #f3e8ff;
  line-height: 1.35;
}

.compact-grid {
  margin: 8px 0;
  gap: 6px;
}

.compact-grid .result-item {
  padding: 6px;
}

.compact-grid .result-val {
  font-size: 16px;
}

.gallery-modal-card {
  max-height: 90dvh;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  overflow-y: auto;
  padding: 2px;
}

.gallery-card {
  appearance: none;
  background: #fff;
  border: 2.5px solid #d9c3b0;
  border-radius: 14px;
  padding: 6px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gallery-card.unlocked {
  border-color: #ff4d8d;
  background: #fff9fc;
}

.gallery-card.selected {
  border-color: #ffbe0b;
  box-shadow: 0 0 0 2.5px #ffbe0b;
}

.gallery-card.tier-top {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #fffdf0 0%, #fff0f6 55%, #fff8d6 100%);
  border: 3px solid #f59e0b;
}

.gallery-card.tier-bottom {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #eef2f7 0%, #dde4ee 100%);
  border: 3px solid #5c677d;
}

.gallery-card.tier-top .gallery-thumb,
.gallery-card.tier-top .gallery-locked-box,
.gallery-card.tier-bottom .gallery-thumb,
.gallery-card.tier-bottom .gallery-locked-box {
  aspect-ratio: 16 / 8.5;
}

.gallery-tier-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 10px;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  background: #6c757d;
}

.gallery-card.tier-top .gallery-tier-badge {
  background: linear-gradient(90deg, #f59e0b, #ff006e);
}

.gallery-card.tier-bottom .gallery-tier-badge {
  background: linear-gradient(90deg, #33415c, #5c677d);
}

.gallery-thumb {
  width: 100%;
  aspect-ratio: 16 / 11;
  object-fit: cover;
  border-radius: 8px;
  background: #2b2338;
}

.gallery-locked-box {
  width: 100%;
  aspect-ratio: 16 / 11;
  border-radius: 8px;
  background: repeating-linear-gradient(45deg, #2d253c, #2d253c 10px, #231c30 10px, #231c30 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.55);
}

.gallery-card-title {
  font-size: 11px;
  font-weight: 900;
  color: var(--ink);
  line-height: 1.2;
}

.gallery-card-hint {
  font-size: 10px;
  font-weight: 700;
  color: #7c625e;
  line-height: 1.25;
}

.clear-card {
  border-color: #d97706;
  background: linear-gradient(180deg, #fffdf4, #fff3d4);
}

/* Dynamic Event Banner */
#event-banner {
  position: absolute;
  top: calc(88px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  width: 90%;
  text-align: center;
  padding: 9px 14px;
  border-radius: 16px;
  font-weight: 900;
  font-size: 15px;
  color: #fff;
  border: 3px solid #fff;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: bannerPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#event-banner.boss {
  background: linear-gradient(90deg, #ff1e56, #ff6b00, #ff1e56);
}

#event-banner.fever {
  background: linear-gradient(90deg, #ffb703, #fb5607, #ff006e);
}

#event-banner.victory {
  background: linear-gradient(90deg, #00b4d8, #2ec4b6, #ffb703);
}

@keyframes bannerPop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Drag Hint */
#drag-hint {
  position: absolute;
  bottom: calc(22% + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(25, 18, 35, 0.78);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  pointer-events: none;
  animation: hintFloat 1.4s ease-in-out infinite;
}

@keyframes hintFloat {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-6px); }
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.overlay.active {
  display: flex;
}

/* Loading Screen */
#loading-screen {
  z-index: 50;
  background: linear-gradient(180deg, #ff7eb3 0%, #ffb86c 100%);
}

.loading-box {
  width: 78%;
  background: rgba(255, 255, 255, 0.94);
  border: 4px solid var(--ink);
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 10px 0 rgba(43, 26, 24, 0.25);
}

.loading-paw {
  font-size: 42px;
  animation: bouncePaw 0.7s infinite alternate;
}

@keyframes bouncePaw {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(-10px) scale(1.12); }
}

.loading-text {
  margin: 10px 0 14px;
  color: var(--ink);
  font-weight: 900;
  font-size: 16px;
}

.loading-bar-bg {
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: #ffe3ec;
  border: 3px solid var(--ink);
  overflow: hidden;
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ff4d8d, #ffbe0b);
  transition: width 0.15s ease;
}

/* Title Screen */
#title-screen {
  z-index: 22;
}

.title-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
}

.title-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(22, 18, 38, 0.72) 0%,
    rgba(22, 18, 38, 0.24) 30%,
    rgba(22, 18, 38, 0.10) 56%,
    rgba(22, 18, 38, 0.84) 100%
  );
}

.title-content {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  padding: calc(56px + var(--safe-top)) 18px calc(26px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.title-logo-wrap {
  text-align: center;
  margin-top: 6px;
}

.logo-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #00d2ff, #ff4d8d);
  color: #fff;
  font-weight: 900;
  font-size: 11px;
  letter-spacing: 1px;
  border: 2px solid #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
  margin-bottom: 8px;
}

.game-title {
  font-size: clamp(28px, 7.6vw, 38px);
  font-weight: 900;
  line-height: 1.12;
  color: #fff59d;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow:
    0 4px 0 var(--ink),
    0 7px 16px rgba(255, 77, 141, 0.7);
}

.game-subtitle {
  margin-top: 6px;
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(43, 26, 24, 0.78);
  color: #fff;
  font-weight: 800;
  font-size: clamp(12px, 3.2vw, 14px);
  border: 2px solid rgba(255, 224, 130, 0.85);
}

.title-stats {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat-chip {
  background: rgba(25, 19, 36, 0.78);
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 14px;
  padding: 7px 6px;
  text-align: center;
  backdrop-filter: blur(4px);
}

.stat-label {
  display: block;
  font-size: 10px;
  font-weight: 800;
  color: #ffd6e7;
}

.stat-value {
  display: block;
  margin-top: 2px;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.title-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

button {
  touch-action: manipulation;
}

/* Arcade Buttons */
.arcade-btn {
  appearance: none;
  width: 100%;
  border: 3.5px solid var(--ink);
  border-radius: 20px;
  padding: 14px 18px;
  font-size: 19px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  transition: transform 0.1s ease, filter 0.1s ease;
}

.arcade-btn:active {
  transform: translateY(3px) scale(0.98);
}

.primary-btn {
  background: linear-gradient(180deg, #ff70a6 0%, #ff2e73 55%, #d81b60 100%);
  box-shadow: 0 6px 0 #7a0c35, 0 10px 22px rgba(255, 46, 115, 0.45);
}

.gold-btn {
  background: linear-gradient(180deg, #ffe066 0%, #ffae00 55%, #e67e00 100%);
  color: #2b1a18;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65);
  box-shadow: 0 5px 0 #8a4300, 0 8px 18px rgba(255, 174, 0, 0.35);
}

.secondary-btn {
  background: linear-gradient(180deg, #6c7a96 0%, #4b566e 100%);
  box-shadow: 0 5px 0 #262c3a;
  font-size: 16px;
  padding: 12px 16px;
}

.pulse-anim {
  animation: btnPulse 1.6s ease-in-out infinite;
}

@keyframes btnPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Modals */
.modal-overlay {
  z-index: 35;
  background: rgba(16, 13, 28, 0.72);
  backdrop-filter: blur(5px);
  padding: 18px;
}

.modal-card {
  width: 100%;
  max-width: 390px;
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 26px;
  padding: 20px 18px;
  box-shadow: 0 10px 0 rgba(25, 15, 14, 0.45);
  text-align: center;
  animation: modalPop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalPop {
  from { transform: scale(0.82); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 21px;
  font-weight: 900;
  color: var(--ink);
}

.modal-sub {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: #6b4e4a;
}

.gameover-emoji {
  font-size: 34px;
  margin-bottom: 4px;
}

.result-grid {
  margin: 14px 0 12px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.result-item {
  background: #fff;
  border: 2.5px solid #f0d7c4;
  border-radius: 14px;
  padding: 9px 8px;
}

.result-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #8c6a64;
}

.result-val {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 900;
  color: var(--ink);
}

.earned-coin-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(90deg, #fff3c4, #ffe082);
  border: 2.5px solid #d97706;
  border-radius: 14px;
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 15px;
  font-weight: 900;
  color: #5c3100;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Upgrade Shop */
.upgrade-card {
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.upgrade-header .modal-title {
  font-size: 18px;
  text-align: left;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.upg-item {
  background: #fff;
  border: 3px solid #ead4c3;
  border-radius: 18px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.upg-info {
  flex: 1;
  min-width: 0;
}

.upg-top {
  display: flex;
  align-items: center;
  gap: 6px;
}

.upg-icon {
  font-size: 20px;
}

.upg-name {
  font-size: 15px;
  font-weight: 900;
  color: var(--ink);
}

.upg-lv {
  font-size: 11px;
  font-weight: 900;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ffe3ec;
  color: #c2185b;
}

.upg-desc {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #6f5652;
  line-height: 1.3;
}

.upg-stat {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  color: #0077b6;
}

.upg-buy-btn {
  appearance: none;
  flex-shrink: 0;
  min-width: 92px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 8px 10px;
  background: linear-gradient(180deg, #ffe066, #ff9f1c);
  color: var(--ink);
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-shadow: 0 4px 0 #8a4300;
}

.upg-buy-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.upg-buy-btn:disabled {
  background: #d8d4d0;
  color: #777;
  box-shadow: 0 3px 0 #999;
  cursor: not-allowed;
}

.upg-cost {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 13px;
}

.upg-cost img {
  width: 15px;
  height: 15px;
}

/* =====================================================================
   DOPAMINE UPDATE: rarity cards, badges, records, count-up pops
   ===================================================================== */

/* Level-up cards slide in one after another */
.perk-btn {
  position: relative;
  overflow: hidden;
  animation: perkIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes perkIn {
  from { transform: translateX(-30px) scale(0.85); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

.perk-rarity {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: #fff;
  background: #4c8dff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.perk-btn.rar-sr {
  border-color: #9d4edd;
  background: linear-gradient(135deg, #fff, #f3e8ff);
  box-shadow: 0 4px 0 #5a189a, 0 0 14px rgba(157, 78, 221, 0.45);
}

.perk-btn.rar-sr .perk-rarity {
  background: linear-gradient(90deg, #9d4edd, #c77dff);
}

.perk-btn.rar-ssr {
  border-color: #e09f00;
  background: linear-gradient(135deg, #fffbe6, #ffe8a3, #fff6d6);
  box-shadow: 0 4px 0 #8a5a00, 0 0 22px rgba(255, 196, 0, 0.75);
}

.perk-btn.rar-ssr .perk-rarity {
  background: linear-gradient(90deg, #ff006e, #ffbe0b, #00e5ff, #ff006e);
  background-size: 300% 100%;
  animation: rainbowSlide 1.2s linear infinite;
  font-size: 12px;
}

.perk-btn.rar-ssr::after {
  content: '';
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  animation: shine 1.6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes rainbowSlide {
  from { background-position: 0% 0; }
  to { background-position: 300% 0; }
}

@keyframes shine {
  0% { left: -60%; }
  60%, 100% { left: 130%; }
}

/* "!" notification badge when an upgrade is affordable */
.arcade-btn.has-badge {
  position: relative;
}

.arcade-btn.has-badge::after {
  content: '!';
  position: absolute;
  top: -9px;
  right: -6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ff1e56;
  color: #fff;
  border: 2.5px solid #fff;
  font-size: 15px;
  font-weight: 900;
  line-height: 19px;
  text-align: center;
  text-shadow: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  animation: badgeBounce 0.9s ease-in-out infinite;
}

@keyframes badgeBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.12); }
}

/* Result screen */
.result-item {
  position: relative;
}

.new-record {
  position: absolute;
  top: -10px;
  right: -6px;
  padding: 2px 7px;
  border-radius: 8px;
  background: linear-gradient(90deg, #ff006e, #ffbe0b);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  transform: rotate(6deg);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  animation: badgeBounce 0.8s ease-in-out infinite;
}

.result-val.count-done {
  animation: countPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes countPop {
  0% { transform: scale(1); color: var(--ink); }
  40% { transform: scale(1.3); color: #ff2e73; }
  100% { transform: scale(1); color: var(--ink); }
}

/* FEVER button reads louder */
.ult-btn.ready .ult-label {
  font-size: 13px;
  letter-spacing: 0.5px;
}

.combo-tag {
  font-size: 12px;
}

/* =====================================================================
   COMMERCIAL UPDATE: intro card, tutorial, toasts, revive, missions,
   login bonus, settings, stars, title buttons
   ===================================================================== */

/* Title: tighter vertical rhythm to fit the extra row */
.title-content { padding-top: calc(50px + var(--safe-top)); padding-bottom: calc(18px + var(--safe-bottom)); }
.title-stats { margin-bottom: 8px; gap: 6px; }
.stat-chip { padding: 5px 6px; }
.title-actions { gap: 8px; }
.title-actions .compact-btn { padding: 9px 8px; font-size: 14px; border-radius: 16px; }
.title-actions #btn-start { padding: 12px 18px; }
.stage-selector { margin-bottom: 8px; padding: 6px 10px; }

.stage-sel-stars { margin-top: 2px; font-size: 15px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.28); }
.stage-sel-stars span.on { color: #ffd60a; text-shadow: 0 0 6px rgba(255, 214, 10, 0.8); }
.stage-sel-stars em { margin-left: 6px; font-style: normal; font-size: 10px; letter-spacing: 0; color: #fff59d; font-weight: 900; }

.endless-btn {
  background: linear-gradient(180deg, #4cc9f0 0%, #4361ee 60%, #3a0ca3 100%);
  box-shadow: 0 5px 0 #240b6b;
}
.endless-btn.locked { filter: grayscale(0.8) brightness(0.85); }
.mission-btn {
  background: linear-gradient(180deg, #06d6a0 0%, #04a37a 100%);
  box-shadow: 0 5px 0 #035c45;
}
.ad-btn {
  background: linear-gradient(180deg, #8338ec 0%, #5a189a 100%);
  box-shadow: 0 5px 0 #2d0a52;
  font-size: 15px;
  padding: 11px 14px;
}

/* Top-bar settings gear */
#btn-settings { font-size: 17px; }

/* Stage intro card */
#stage-intro {
  position: absolute;
  inset: 0;
  z-index: 27;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(20, 12, 36, 0.35), rgba(20, 12, 36, 0.72));
  animation: introFade 0.3s ease-out;
}
#stage-intro.hidden { display: none; }
@keyframes introFade { from { opacity: 0; } to { opacity: 1; } }
.intro-card {
  width: 84%;
  text-align: center;
  color: #fff;
  animation: introSlam 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes introSlam {
  from { transform: scale(1.8) rotate(-4deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
.intro-area { font-size: 13px; font-weight: 900; color: #72efdd; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6); }
.intro-stage {
  margin-top: 4px;
  font-size: 52px;
  font-weight: 900;
  line-height: 1.05;
  color: #fff59d;
  -webkit-text-stroke: 3px #2b1614;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 #2b1614, 0 0 26px rgba(255, 77, 141, 0.8);
}
.intro-boss { margin-top: 6px; font-size: 14px; font-weight: 900; color: #ffd6e7; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7); }
.intro-goals {
  margin: 14px auto 0;
  max-width: 290px;
  background: rgba(25, 18, 38, 0.82);
  border: 2.5px solid #ffd60a;
  border-radius: 16px;
  padding: 8px 12px;
  text-align: left;
}
.intro-goals:empty { display: none; }
.intro-goals-title { font-size: 12px; font-weight: 900; color: #ffd60a; margin-bottom: 4px; text-align: center; }
.intro-goal { font-size: 12px; font-weight: 800; color: rgba(255, 255, 255, 0.85); padding: 2px 0; }
.intro-goal span { display: inline-block; width: 20px; color: rgba(255, 255, 255, 0.4); }
.intro-goal.got span { color: #ffd60a; }
.intro-tap {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  opacity: 0.9;
  animation: handBob 1.2s ease-in-out infinite;
}
.ach-tiers i { font-style: normal; color: #d9c7bb; }

/* Tutorial tip */
#tut-tip {
  position: absolute;
  z-index: 29;
  left: 50%;
  transform: translateX(-50%);
  width: 82%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  animation: bannerPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#tut-tip.hidden { display: none; }
#tut-tip.pos-move { bottom: calc(26% + var(--safe-bottom)); }
#tut-tip.pos-gate { top: 23%; }
#tut-tip.pos-boss { top: 48%; }
#tut-tip.pos-fever { bottom: calc(110px + var(--safe-bottom)); left: auto; right: 10px; transform: none; width: 70%; align-items: flex-end; }
.tut-text {
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  border: 3px solid #ff4d8d;
  border-radius: 16px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.tut-hand { font-size: 36px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5)); }
#tut-tip.pos-move .tut-hand { order: 2; animation: handSwipe 1.3s ease-in-out infinite; }
#tut-tip.pos-gate .tut-hand { order: 2; animation: handBob 0.8s ease-in-out infinite; }
#tut-tip.pos-fever .tut-hand { order: 2; margin-right: 18px; animation: handBob 0.8s ease-in-out infinite; }
#tut-tip.pos-boss .tut-hand { order: 2; animation: handSwipe 1s ease-in-out infinite; }
@keyframes handSwipe { 0%, 100% { transform: translateX(-60px); } 50% { transform: translateX(60px); } }
@keyframes handBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(10px); } }

/* Toasts */
#toast-stack {
  position: absolute;
  z-index: 60;
  top: calc(118px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  width: 86%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.toast {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(90deg, #06d6a0, #118ab2);
  border: 2.5px solid #fff;
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.toast-ach { background: linear-gradient(90deg, #ffbe0b, #fb5607); }
.toast-info { background: linear-gradient(90deg, #4b566e, #6c7a96); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { transform: translateY(-16px) scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }

/* Revive */
.revive-card { border-color: #ff4d8d; background: linear-gradient(180deg, #fff7fb, #ffe3ef); }
.revive-emoji { font-size: 44px; animation: bouncePaw 0.6s infinite alternate; }
.revive-timer { margin: 12px 0 4px; height: 10px; border-radius: 999px; background: #f3d3e0; overflow: hidden; border: 2px solid var(--ink); }
.revive-timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff2e73, #ffbe0b); }
#btn-revive-coin .upg-cost { margin-left: 6px; background: rgba(255, 255, 255, 0.6); border-radius: 10px; padding: 1px 8px; font-size: 14px; }
#btn-revive-coin:disabled { filter: grayscale(0.9); opacity: 0.7; }

/* Missions */
.msn-item { align-items: center; gap: 10px; }
.msn-item.ready { border-color: #06d6a0; box-shadow: 0 0 0 2px rgba(6, 214, 160, 0.35); }
.msn-item.bonus { background: linear-gradient(135deg, #fffbe6, #ffefc2); border-color: #ffbe0b; }
.msn-icon { font-size: 26px; flex-shrink: 0; width: 34px; text-align: center; }
.msn-title { font-size: 13px; font-weight: 900; color: var(--ink); text-align: left; line-height: 1.25; }
.ach-tiers { color: #ffbe0b; font-size: 11px; letter-spacing: 1px; white-space: nowrap; }
.msn-bar { position: relative; margin-top: 5px; height: 14px; border-radius: 999px; background: #f1e3d6; overflow: hidden; }
.msn-bar-fill { height: 100%; background: linear-gradient(90deg, #06d6a0, #4cc9f0); border-radius: 999px; }
.msn-bar span { position: absolute; inset: 0; font-size: 10px; font-weight: 900; color: var(--ink); line-height: 14px; text-align: center; }
.msn-note { font-size: 11px; font-weight: 700; color: #8c6a64; padding: 4px 0; }
.claim-btn:not(:disabled) { animation: btnPulse 1s ease-in-out infinite; }

/* Login bonus */
.login-card { background: linear-gradient(180deg, #fffdf4, #fff0d1); border-color: #d97706; }
.login-grid { margin: 12px 0 14px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.login-cell { background: #fff; border: 2.5px solid #ead4c3; border-radius: 12px; padding: 6px 2px; }
.login-cell.big { grid-column: span 2; background: linear-gradient(135deg, #fff3b0, #ffd166); }
.login-cell.past { opacity: 0.55; }
.login-cell.today { border-color: #ff2e73; box-shadow: 0 0 0 3px rgba(255, 46, 115, 0.3); transform: scale(1.06); animation: btnPulse 1s ease-in-out infinite; }
.login-day { font-size: 10px; font-weight: 900; color: #8c6a64; }
.login-icon { font-size: 22px; line-height: 1.2; }
.login-amt { font-size: 12px; font-weight: 900; color: var(--ink); }

/* Settings */
.settings-card { text-align: left; }
.settings-card .modal-title { text-align: center; margin-bottom: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 2px dashed #ead4c3; }
.set-label { font-size: 14px; font-weight: 900; color: var(--ink); flex-shrink: 0; }
.set-row input[type=range] { flex: 1; max-width: 190px; accent-color: #ff2e73; height: 26px; }
.set-toggle {
  appearance: none; border: 2.5px solid var(--ink); border-radius: 999px; padding: 6px 16px;
  font-weight: 900; font-size: 13px; color: #fff; background: linear-gradient(180deg, #06d6a0, #04a37a); cursor: pointer;
}
.set-toggle.off { background: #9aa0ae; }
.set-toggle.lang-btn { background: linear-gradient(135deg, #6c5ce7, #4834d4); }
.seg { display: flex; border: 2.5px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { appearance: none; border: 0; background: #fff; padding: 6px 9px; font-weight: 900; font-size: 12px; color: #5a4642; cursor: pointer; }
.seg button + button { border-left: 2px solid #ead4c3; }
.seg button.active { background: linear-gradient(180deg, #ff70a6, #ff2e73); color: #fff; }
.danger-link { appearance: none; border: 0; background: none; margin: 12px auto 0; display: block; color: #d62828; font-weight: 900; font-size: 12px; text-decoration: underline; cursor: pointer; }
.set-version { text-align: center; font-size: 10px; color: #b39c94; margin: 6px 0 10px; font-weight: 700; }

/* Result stars */
.stars-row { display: flex; justify-content: center; gap: 6px; margin: 2px 0 0; }
.star-slot { font-size: 38px; line-height: 1; color: #e7d5c8; -webkit-text-stroke: 2px #b39c94; paint-order: stroke fill; }
.star-slot.lit { animation: starPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes starPop {
  0% { transform: scale(0.2) rotate(-60deg); color: #e7d5c8; }
  60% { transform: scale(1.45) rotate(10deg); color: #ffd60a; }
  100% { transform: scale(1) rotate(0); color: #ffd60a; -webkit-text-stroke: 2px #b36b00; text-shadow: 0 0 12px rgba(255, 214, 10, 0.8); }
}
.star-goals { font-size: 11px; font-weight: 800; color: #8c6a64; margin: 2px 0 4px; }
.star-goal.ok { color: #0a9396; }
.star-new { margin-top: 3px; display: inline-block; padding: 2px 10px; border-radius: 999px; background: linear-gradient(90deg, #ffbe0b, #ff006e); color: #fff; font-weight: 900; font-size: 12px; animation: badgeBounce 0.8s ease-in-out infinite; }

/* Test-only fake ad overlay (?fakeAds=1) */
.fake-ad { position: fixed; inset: 0; z-index: 999; display: flex; align-items: center; justify-content: center; background: #000; color: #fff; font: 900 22px sans-serif; }

/* Result cards: never taller than the screen */
.clear-card,
.gameover-card {
  max-height: calc(100% - 16px);
  overflow-y: auto;
  padding-top: 14px;
  padding-bottom: 14px;
}
.clear-card .ending-cg-img { max-height: 118px; }
.clear-card .ending-showcase,
.gameover-card .ending-showcase { margin: 6px 0; padding: 6px; }
.clear-card .modal-actions,
.gameover-card .modal-actions { gap: 8px; margin-top: 8px; }
.clear-card .arcade-btn,
.gameover-card .arcade-btn { padding-top: 10px; padding-bottom: 10px; }
.clear-card .star-slot { font-size: 34px; }

/* =====================================================================
   v3 "PRODUCER CUT": title hub, level, gacha, roulette, cut-ins, FX
   ===================================================================== */

/* ---- Title hub layout ---- */
.title-content {
  padding-top: calc(62px + var(--safe-top));
  padding-bottom: calc(78px + var(--safe-bottom));
}
.title-bottom { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.title-bottom .stage-selector { margin: 0; }
.title-bottom .title-stats { margin: 0; }
.title-stats .stat-chip { padding: 3px 6px; }
.title-stats .stat-value { font-size: 14px; }
.start-row { display: grid; grid-template-columns: 1fr 96px; gap: 8px; }
.start-row #btn-start { font-size: 21px; padding: 14px 10px; }
.start-row #btn-endless { flex-direction: column; gap: 0; padding: 6px 4px; font-size: 11px; line-height: 1.15; border-radius: 18px; }
.start-row #btn-endless .endless-ic { font-size: 22px; }
.stage-sel-center { cursor: pointer; }
.sel-list-hint { font-size: 12px; opacity: 0.7; margin-left: 2px; }
.stage-sel-mods { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; margin-top: 3px; }
.stage-sel-mods:empty { display: none; }
.mod-chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 900;
  color: #fff; background: linear-gradient(90deg, #7b2ff7, #f107a3); border: 1.5px solid rgba(255, 255, 255, 0.8);
}
#stage-shell.w2-title .title-scrim { background: linear-gradient(180deg, rgba(20, 10, 60, 0.8), rgba(30, 10, 80, 0.35) 40%, rgba(20, 8, 50, 0.9)); }
#stage-shell.w2-title .stage-selector { border-color: #c77dff; box-shadow: 0 0 18px rgba(157, 78, 221, 0.6); }

/* ---- Player level badge ---- */
.player-level {
  position: absolute; z-index: 3; top: calc(9px + var(--safe-top)); left: 10px;
  display: flex; align-items: center; gap: 6px; max-width: 46%;
}
.lv-badge {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, #fff59d, #ffbe0b 55%, #e07a00);
  border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 12px rgba(255, 190, 11, 0.6);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; color: #5c2a00;
}
.lv-badge small { font-size: 9px; font-weight: 900; }
.lv-badge b { font-size: 17px; font-weight: 900; }
.lv-info { display: flex; flex-direction: column; gap: 3px; min-width: 82px; }
.xp-bar { height: 9px; border-radius: 999px; background: rgba(20, 14, 30, 0.8); border: 2px solid #fff; overflow: hidden; }
#pl-xp-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #06d6a0, #4cc9f0); transition: width 0.4s ease; }
.ticket-chip { align-self: flex-start; font-size: 11px; font-weight: 900; color: #fff; background: rgba(20, 14, 30, 0.78); border-radius: 999px; padding: 1px 8px; border: 1.5px solid rgba(255, 255, 255, 0.7); }

/* ---- Bottom navigation ---- */
.bottom-nav {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  padding: 6px 8px calc(8px + var(--safe-bottom));
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: linear-gradient(180deg, rgba(25, 16, 40, 0.0), rgba(25, 16, 40, 0.92) 30%);
}
.nav-btn {
  appearance: none; position: relative; border: 2.5px solid #fff; border-radius: 16px; padding: 5px 2px 6px;
  background: linear-gradient(180deg, #3d2b5c, #241838); color: #fff; font-weight: 900; font-size: 11px;
  display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45); transition: transform 0.1s ease;
}
.nav-btn:active { transform: translateY(2px) scale(0.96); }
.nav-ic { font-size: 22px; line-height: 1.1; }
.nav-gacha { background: linear-gradient(180deg, #ff70a6, #c9184a); animation: gachaGlow 1.6s ease-in-out infinite; }
#btn-upgrade-title.nav-btn { background: linear-gradient(180deg, #ffbe0b, #d97706); color: #3a1d00; }
@keyframes gachaGlow { 0%, 100% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 0 rgba(255, 77, 141, 0); } 50% { box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45), 0 0 16px rgba(255, 77, 141, 0.9); } }
.nav-btn.has-badge::after {
  content: '!'; position: absolute; top: -8px; right: -4px; width: 20px; height: 20px; border-radius: 50%;
  background: #ff1e56; color: #fff; border: 2px solid #fff; font-size: 13px; line-height: 16px; text-align: center;
  animation: badgeBounce 0.9s ease-in-out infinite;
}

/* ---- Intro modifiers ---- */
.intro-mods { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-bottom: 6px; }
.intro-mods .mod-chip { font-size: 12px; padding: 2px 9px; }

/* ---- XP bar on result cards ---- */
.xp-result { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.xp-result.hidden { display: none; }
.xpr-lv { font-size: 13px; font-weight: 900; color: #b36b00; min-width: 46px; text-align: left; }
.xpr-lv.pop { animation: countPop 0.4s ease; }
.xpr-bar { flex: 1; height: 12px; border-radius: 999px; background: #efe0d2; border: 2px solid var(--ink); overflow: hidden; }
.xpr-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #06d6a0, #4cc9f0); }
.xpr-gain { font-size: 12px; font-weight: 900; color: #0a9396; }

/* ---- Screen wipe ---- */
#wipe { position: absolute; inset: 0; z-index: 45; pointer-events: none; background: radial-gradient(circle, transparent 0%, transparent 0%, #1a1030 0%); opacity: 0; }
#wipe.go { animation: wipeIris 0.7s ease-out forwards; }
@keyframes wipeIris {
  0% { opacity: 1; background: radial-gradient(circle at 50% 70%, transparent 0%, #1a1030 1%); }
  40% { opacity: 1; background: radial-gradient(circle at 50% 70%, transparent 25%, #1a1030 26%); }
  100% { opacity: 0; background: radial-gradient(circle at 50% 70%, transparent 90%, #1a1030 91%); }
}

/* ---- Boss cut-in ---- */
#boss-cutin { position: absolute; inset: 0; z-index: 28; pointer-events: none; display: none; overflow: hidden; }
#boss-cutin.show { display: block; }
.cutin-band {
  position: absolute; left: -10%; right: -10%; top: 34%; height: 150px; transform: skewY(-8deg);
  background: repeating-linear-gradient(45deg, #ff1e56 0 18px, #c9184a 18px 36px);
  border-top: 5px solid #ffd60a; border-bottom: 5px solid #ffd60a;
  animation: bandIn 1.9s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}
#cutin-img {
  position: absolute; top: 27%; left: 4%; height: 200px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.6));
  animation: cutinImg 1.9s cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}
.cutin-text { position: absolute; top: 39%; right: 5%; width: 56%; text-align: right; color: #fff; animation: cutinText 1.9s cubic-bezier(0.2, 0.9, 0.2, 1) forwards; }
.cutin-warn { font-size: 30px; font-weight: 900; color: #ffd60a; -webkit-text-stroke: 2px #2b1614; paint-order: stroke fill; letter-spacing: 1px; }
.cutin-sub { font-size: 12px; font-weight: 900; opacity: 0.9; }
.cutin-name { font-size: 19px; font-weight: 900; line-height: 1.2; -webkit-text-stroke: 1.5px #2b1614; paint-order: stroke fill; }
@keyframes bandIn { 0% { transform: skewY(-8deg) scaleY(0); } 12% { transform: skewY(-8deg) scaleY(1); } 82% { transform: skewY(-8deg) scaleY(1); opacity: 1; } 100% { transform: skewY(-8deg) scaleY(0); opacity: 0; } }
@keyframes cutinImg { 0% { transform: translateX(-140%); } 15% { transform: translateX(0); } 80% { transform: translateX(10px); opacity: 1; } 100% { transform: translateX(-140%); opacity: 0; } }
@keyframes cutinText { 0% { transform: translateX(140%); } 15% { transform: translateX(0); } 80% { transform: translateX(-8px); opacity: 1; } 100% { transform: translateX(140%); opacity: 0; } }

/* ---- FX canvas ---- */
#fx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 70; pointer-events: none; }

/* ---- Level up ---- */
.levelup-card { position: relative; overflow: hidden; background: linear-gradient(180deg, #fffbe6, #ffe08a); border-color: #b36b00; }
.lvup-burst { position: absolute; inset: -50%; background: repeating-conic-gradient(rgba(255, 255, 255, 0.55) 0 10deg, transparent 10deg 20deg); animation: spin 6s linear infinite; pointer-events: none; }
.lvup-title, .lvup-level, .lvup-rewards, #btn-lvup-ok { position: relative; }
.lvup-title { font-size: 40px; font-weight: 900; color: #ff2e73; -webkit-text-stroke: 2.5px #fff; paint-order: stroke fill; text-shadow: 0 4px 0 #7a0c35; animation: introSlam 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.lvup-level { font-size: 24px; font-weight: 900; color: var(--ink); margin: 4px 0 10px; }
.lvup-level b { font-size: 46px; color: #e07a00; }
.lvup-rewards { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.lvup-reward { display: flex; align-items: center; gap: 4px; background: #fff; border: 2.5px solid #e0b25c; border-radius: 14px; padding: 6px 10px; font-weight: 900; font-size: 15px; color: var(--ink); }
.lvup-reward img { width: 22px; height: 22px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Roulette ---- */
.roulette-card { background: linear-gradient(180deg, #fff7e0, #ffe0a3); border-color: #b36b00; }
.roulette-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 12px 0 8px; }
.rl-cell {
  padding: 10px 0; border-radius: 12px; background: #fff; border: 3px solid #e0c08a; font-weight: 900; font-size: 18px; color: #8a5a00;
  transition: transform 0.06s ease;
}
.rl-cell.big { color: #d00060; }
.rl-cell.jackpot { color: #fff; background: linear-gradient(135deg, #ff006e, #ffbe0b); border-color: #fff; }
.rl-cell.on { transform: scale(1.14); border-color: #ff2e73; box-shadow: 0 0 14px rgba(255, 46, 115, 0.8); background: #fff0f6; }
.rl-cell.jackpot.on { background: linear-gradient(135deg, #ff4d8d, #ffe066); }
.rl-cell.win { animation: btnPulse 0.5s ease-in-out infinite; }
.roulette-result { min-height: 34px; font-size: 26px; font-weight: 900; color: #ff2e73; opacity: 0; }
.roulette-result span { font-size: 17px; color: #0a9396; }
.roulette-result.show { opacity: 1; animation: introSlam 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.roulette-result.big { font-size: 34px; }

/* ---- Gacha ---- */
.gacha-card { max-height: 94%; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; background: linear-gradient(180deg, #fff5fa, #ffe1ee); border-color: #c9184a; }
.gacha-info { display: flex; justify-content: space-between; font-size: 12px; font-weight: 900; color: #7a0c35; }
.gacha-stage { position: relative; min-height: 210px; display: flex; align-items: center; justify-content: center; }
.gacha-machine { position: relative; width: 150px; height: 200px; }
.gm-dome {
  position: absolute; top: 0; left: 10px; width: 130px; height: 120px; border-radius: 50% 50% 20px 20px;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), rgba(200, 240, 255, 0.55) 40%, rgba(120, 200, 255, 0.35));
  border: 4px solid #2b1614; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 22px; line-height: 1.4;
}
.gm-body { position: absolute; top: 108px; left: 0; width: 150px; height: 88px; border-radius: 18px; background: linear-gradient(180deg, #ff4d8d, #c9184a); border: 4px solid #2b1614; display: flex; align-items: center; justify-content: center; font-size: 34px; }
.gm-capsule { position: absolute; left: 55px; top: 150px; width: 40px; height: 40px; border-radius: 50%; border: 3px solid #2b1614; background: linear-gradient(180deg, #fff 50%, #9aa0ae 50%); opacity: 0; }
.gacha-machine.shaking { animation: machineShake 0.12s linear infinite; }
.gacha-machine.dropped .gm-capsule { opacity: 1; animation: capsuleDrop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.gacha-machine.cap-r .gm-capsule { background: linear-gradient(180deg, #fff 50%, #4c8dff 50%); }
.gacha-machine.cap-sr .gm-capsule { background: linear-gradient(180deg, #fff 50%, #9d4edd 50%); box-shadow: 0 0 20px #c77dff; }
.gacha-machine.cap-ssr .gm-capsule { background: linear-gradient(180deg, #fff 50%, #ffbe0b 50%); box-shadow: 0 0 30px #ffd60a; }
.gacha-machine.rainbow .gm-capsule { animation: capsuleDrop 0.6s forwards, rainbowCap 0.3s linear infinite; }
.gacha-machine.opened { display: none; }
@keyframes machineShake { 0% { transform: translate(-3px, 1px) rotate(-2deg); } 50% { transform: translate(3px, -1px) rotate(2deg); } 100% { transform: translate(-3px, 1px) rotate(-2deg); } }
@keyframes capsuleDrop { 0% { transform: translateY(-30px) scale(0.6); } 100% { transform: translateY(30px) scale(1.6); } }
@keyframes rainbowCap { 0% { filter: hue-rotate(0deg) brightness(1.2); } 100% { filter: hue-rotate(360deg) brightness(1.2); } }
.gacha-results { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; width: 100%; }
.gacha-results.hidden { display: none; }
.gacha-results:has(.g-card:only-child) { grid-template-columns: 1fr; justify-items: center; }
.g-card {
  position: relative; background: #fff; border: 3px solid #9aa0ae; border-radius: 12px; padding: 6px 2px 4px; text-align: center;
  opacity: 0; transform: scale(0.4) rotateY(90deg); transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
}
.g-card.show { opacity: 1; transform: none; }
.g-card img { width: 100%; max-width: 64px; height: 50px; object-fit: contain; }
.gacha-results:has(.g-card:only-child) .g-card { width: 150px; padding: 10px; }
.gacha-results:has(.g-card:only-child) .g-card img { max-width: 110px; height: 90px; }
.g-rar { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); padding: 0 6px; border-radius: 6px; font-size: 10px; font-weight: 900; color: #fff; background: #9aa0ae; }
.g-name { font-size: 9px; font-weight: 900; color: var(--ink); line-height: 1.15; }
.g-sub { font-size: 9px; font-weight: 900; color: #0a9396; }
.g-card.cap-r { border-color: #4c8dff; } .g-card.cap-r .g-rar { background: #4c8dff; }
.g-card.cap-sr { border-color: #9d4edd; background: linear-gradient(180deg, #fff, #f3e8ff); } .g-card.cap-sr .g-rar { background: #9d4edd; }
.g-card.cap-ssr { border-color: #ffbe0b; background: linear-gradient(180deg, #fffbe6, #ffe8a3); box-shadow: 0 0 14px rgba(255, 196, 0, 0.9); }
.g-card.cap-ssr .g-rar { background: linear-gradient(90deg, #ff006e, #ffbe0b, #00e5ff); }
.g-card.is-new .g-sub { color: #ff006e; animation: badgeBounce 0.8s ease-in-out infinite; }
.gacha-note { font-size: 11px; font-weight: 800; color: #7a0c35; }
.gacha-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gacha-buttons .arcade-btn { flex-direction: column; gap: 0; font-size: 14px; padding: 9px 4px; }
.gacha-buttons .arcade-btn:disabled { filter: grayscale(0.8); opacity: 0.6; }
.g-cost { font-size: 12px; opacity: 0.95; }

/* ---- Stage grid ---- */
.stage-grid-card { max-height: 92%; overflow-y: auto; }
.sg-world { font-size: 11px; font-weight: 900; color: #8c6a64; margin: 4px 0 8px; }
.stage-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
.sg-cell {
  appearance: none; border: 2.5px solid var(--ink); border-radius: 12px; padding: 6px 0 4px; cursor: pointer;
  background: linear-gradient(180deg, #ffe8a3, #ffbe0b); display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.sg-cell b { font-size: 16px; font-weight: 900; color: var(--ink); }
.sg-cell span { font-size: 9px; color: #b36b00; letter-spacing: -1px; }
.sg-cell.w2 { background: linear-gradient(180deg, #c77dff, #5a189a); }
.sg-cell.w2 b { color: #fff; }
.sg-cell.w2 span { color: #ffd60a; }
.sg-cell.locked { filter: grayscale(1); opacity: 0.45; cursor: default; }
.sg-cell.sel { box-shadow: 0 0 0 3px #ff2e73; transform: scale(1.06); }

/* =====================================================================
   v4 "BUZZ": daily challenge, share, milestones
   ===================================================================== */
.daily-btn {
  appearance: none; width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 12px; border-radius: 16px; border: 2.5px solid #fff; cursor: pointer; color: #fff; text-align: left;
  background: linear-gradient(90deg, #7209b7, #f72585); box-shadow: 0 4px 0 #3c096c, 0 0 18px rgba(247, 37, 133, 0.55);
  animation: dailyGlow 2s ease-in-out infinite;
}
.daily-btn.done { background: linear-gradient(90deg, #3c096c, #7209b7); animation: none; }
.daily-btn.locked { filter: grayscale(0.85); animation: none; }
@keyframes dailyGlow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.daily-left { display: flex; align-items: center; gap: 5px; font-weight: 900; font-size: 14px; white-space: nowrap; }
.daily-cal { font-size: 18px; }
.daily-tag { font-size: 12px; }
#daily-num { font-size: 16px; color: #fff59d; }
#daily-mods { font-size: 15px; }
.daily-sub { font-size: 10px; font-weight: 800; text-align: right; line-height: 1.2; opacity: 0.95; }

.share-btn {
  position: relative; background: linear-gradient(180deg, #00b4d8 0%, #0077b6 100%); box-shadow: 0 5px 0 #023e8a;
  font-size: 16px; padding: 10px 14px;
}
.share-bonus { position: absolute; top: -9px; right: 8px; font-size: 11px; background: #ff1e56; color: #fff; border: 2px solid #fff; border-radius: 999px; padding: 0 6px; text-shadow: none; }

.daily-card { background: linear-gradient(180deg, #fff5fd, #f3e1ff); border-color: #7209b7; position: relative; }
.dr-badge { display: inline-block; margin-bottom: 4px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 900; color: #fff; background: #9aa0ae; }
.dr-badge.official { background: linear-gradient(90deg, #f72585, #7209b7); }
.dr-result { font-size: 30px; font-weight: 900; margin: 4px 0; animation: introSlam 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }
.dr-result.win { color: #f72585; }
.dr-result.lose { color: #6c7a96; }
.dr-emoji { font-size: 24px; letter-spacing: 1px; margin: 4px 0; background: rgba(43, 26, 24, 0.85); border-radius: 14px; padding: 6px 4px; }
.dr-title { font-size: 18px; font-weight: 900; color: #7209b7; margin: 6px 0; }
.dr-stats { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 6px; }
.dr-stats div { background: #fff; border: 2.5px solid #e0c3f5; border-radius: 12px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; }
.dr-stats span { font-size: 16px; }
.dr-stats b { font-size: 15px; font-weight: 900; color: var(--ink); }
.dr-streak { margin-top: 6px; font-size: 13px; font-weight: 900; color: #ff6d00; }
.dr-reward { font-size: 13px; font-weight: 900; color: #0a9396; min-height: 16px; }

.share-card { max-height: 94%; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.share-preview { width: 70%; align-self: center; border-radius: 14px; border: 3px solid var(--ink); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
.share-text { white-space: pre-wrap; font-family: inherit; font-size: 11px; font-weight: 700; text-align: left; background: #fff; border: 2px dashed #ead4c3; border-radius: 10px; padding: 6px 8px; color: var(--ink); max-height: 110px; overflow-y: auto; }
.share-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.share-actions .arcade-btn { font-size: 12px; padding: 9px 4px; border-radius: 14px; }
.x-btn { background: linear-gradient(180deg, #333, #000); box-shadow: 0 4px 0 #555; }

/* Toasts sit just under the top bar so they never cover result titles */
#toast-stack { top: calc(52px + var(--safe-top)); }
.toast { padding: 6px 14px; font-size: 12px; }

/* =====================================================================
   v5 "KAWAII": bundled rounded font, cat-ear cards, squishy buttons
   ===================================================================== */
@font-face {
  font-family: 'NyankoRound';
  src: url('../fonts/NyankoRound.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

html, body, button, input, pre {
  font-family: 'NyankoRound', 'Hiragino Maru Gothic ProN', 'Yu Gothic UI', 'Rounded Mplus 1c', 'Noto Sans JP', system-ui, sans-serif;
}

/* Squishy, glossy buttons */
.arcade-btn, .nav-btn, .upg-buy-btn, .perk-btn, .daily-btn, .stage-arrow, .sg-cell {
  position: relative;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.1s ease;
}
.arcade-btn::before {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  top: 4px;
  height: 38%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.arcade-btn:active, .nav-btn:active, .daily-btn:active, .sg-cell:active { transform: scale(0.94, 0.88) translateY(3px); }
.arcade-btn:not(:disabled):hover { filter: brightness(1.06); }

/* Cat ears on the pop-up cards */
.revive-card, .roulette-card, .login-card, .settings-card, .daily-card, .perk-modal-card, #pause-screen .modal-card, .chest-card { position: relative; margin-top: 30px; }
.revive-card::before, .revive-card::after, .roulette-card::before, .roulette-card::after, .login-card::before, .login-card::after, .settings-card::before, .settings-card::after, .daily-card::before, .daily-card::after, .perk-modal-card::before, .perk-modal-card::after, #pause-screen .modal-card::before, #pause-screen .modal-card::after, .chest-card::before, .chest-card::after {
  content: '';
  position: absolute;
  top: -38px;
  width: 56px;
  height: 42px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 42'><path d='M3 41 L21 7 Q26 -1 31 7 L53 41' fill='%23fff9f0' stroke='%232b1614' stroke-width='4' stroke-linejoin='round'/><path d='M15 40 L24 18 Q26.5 13 29 18 L41 40 Z' fill='%23ffb3cf'/></svg>") no-repeat center / contain;
  pointer-events: none;
}
.revive-card::before, .roulette-card::before, .login-card::before, .settings-card::before, .daily-card::before, .perk-modal-card::before, #pause-screen .modal-card::before, .chest-card::before { left: 26px; transform: rotate(-12deg); }
.revive-card::after, .roulette-card::after, .login-card::after, .settings-card::after, .daily-card::after, .perk-modal-card::after, #pause-screen .modal-card::after, .chest-card::after { right: 26px; transform: rotate(12deg) scaleX(-1); }
.chest-card { overflow: visible; }

/* Paw-print speckle on cream cards */
.modal-card {
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 140, 180, 0.12) 0 6px, transparent 7px),
    radial-gradient(circle at 88% 82%, rgba(255, 140, 180, 0.12) 0 6px, transparent 7px);
}
.modal-title::before { content: '🐾 '; font-size: 0.8em; }
.upgrade-header .modal-title::before, .gacha-card .modal-title::before { content: ''; }

/* Bigger, clearer HUD */
.cat-pill { font-size: 19px; padding: 5px 12px 5px 6px; }
.cat-pill .pill-icon { width: 26px; height: 26px; }
.score-chip { font-size: 12px; padding: 3px 10px; }
#hud-score { font-size: 14px; color: #fff59d; }

/* Title: compact stats line + next-goal hint + chest shelf */
.title-mini-stats { margin-top: 6px; display: inline-flex; gap: 10px; padding: 3px 12px; border-radius: 999px; background: rgba(25, 16, 40, 0.7); color: #fff; font-size: 11px; font-weight: 800; }
.title-mini-stats b { color: #fff59d; }
.title-hint {
  appearance: none; width: 100%; border: 0; border-radius: 12px; padding: 5px 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.92); color: #c9184a; font-weight: 900; font-size: 12px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25); animation: hintBob 1.6s ease-in-out infinite;
}
.title-hint:empty { display: none; }
@keyframes hintBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.chest-shelf { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.chest-slot {
  appearance: none; position: relative; height: 58px; border-radius: 14px; border: 2.5px dashed rgba(255, 255, 255, 0.55);
  background: rgba(25, 16, 40, 0.55); color: #fff; font-weight: 900; font-size: 10px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.1;
}
.chest-slot.filled { border-style: solid; border-color: #fff; }
.chest-slot.silver { background: linear-gradient(180deg, #e9eef5, #9aa7b8); color: #2b2b3a; }
.chest-slot.gold { background: linear-gradient(180deg, #fff3b0, #f4a300); color: #4a2600; }
.chest-slot.rainbow { background: linear-gradient(135deg, #ff8fab, #ffd166, #72efdd, #c77dff); color: #2b1614; }
.chest-slot .ch-ic { font-size: 24px; }
.chest-slot.ready { animation: chestReady 0.7s ease-in-out infinite; box-shadow: 0 0 16px rgba(255, 214, 10, 0.95); }
.chest-slot.unlocking .ch-time { color: #c9184a; }
@keyframes chestReady { 0%, 100% { transform: rotate(-4deg) scale(1.03); } 50% { transform: rotate(4deg) scale(1.08); } }

/* Chest opening */
.chest-card { background: linear-gradient(180deg, #fffbe6, #ffe1a8); border-color: #b36b00; position: relative; }
.chest-big { font-size: 96px; margin: 10px 0; cursor: pointer; filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.35)); }
.chest-big.shake { animation: machineShake 0.1s linear infinite; }
.chest-big.pop { animation: introSlam 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.chest-rewards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 12px; }
.chest-rewards .g-card { opacity: 1; transform: none; animation: introSlam 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.chest-tap { font-size: 13px; font-weight: 900; color: #b36b00; animation: hintBob 1s ease-in-out infinite; }

/* Near-miss nudges */
.near-miss { margin: 4px auto; display: inline-block; padding: 3px 10px; border-radius: 999px; background: #fff0f6; border: 2px solid #ff4d8d; color: #c9184a; font-size: 12px; font-weight: 900; animation: hintBob 1.2s ease-in-out infinite; }
.near-miss:empty { display: none; }

/* v5: on result screens, toasts move to the bottom so they never cover the near-miss line */
body:has(#clear-screen.active) #toast-stack,
body:has(#gameover-screen.active) #toast-stack {
  top: auto;
  bottom: calc(18px + var(--safe-bottom, 0px));
}

/* v5.1: hero cats are gacha-only */
.ped-gacha-note {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 2px 0 10px; padding: 10px 12px; border-radius: 16px; text-align: center;
  background: linear-gradient(135deg, #fff4c2, #ffd6ec); border: 2px dashed #ff8fc7; color: #5b2a4a;
}
.ped-gacha-note b { font-size: 15px; }
.ped-gacha-note span { font-size: 12px; opacity: .85; }
.ped-gacha-note .arcade-btn { margin-top: 4px; min-width: 150px; }
.upg-cat-thumb.locked { filter: brightness(0) opacity(.35); }
.ped-item.is-locked .upg-name { letter-spacing: 2px; }
.ped-pips { display: flex; gap: 3px; margin-top: 4px; }
.ped-pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(0,0,0,.12); }
.ped-pips i.on { background: linear-gradient(90deg, #ffbe0b, #ff6fb5); }
.ped-gacha-btn { background: linear-gradient(180deg, #ffe066, #ffb703) !important; color: #5b3a00 !important; }
.ped-gacha-btn span { font-size: 12px; line-height: 1.2; }
.mod-chip.assist-chip { background: linear-gradient(135deg, #b9fbc0, #98f5e1); color: #0b5345; border-color: #2ec4b6; }
