.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translate(-50%, -16px);
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.45);
  color: #f8fafc;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 2600;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Shooting Tiny Balls - style.css (no frameworks, no external fonts) */
:root {
  --bg: #0b1020;
  --panel: #111827cc;
  --panel-solid: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent2: #22c55e;
  --warn: #ef4444;
  --hud: #0f172acc;
  --pill: #1f2937cc;
  --xp: #fbbf24cc;
  --brand-text: 'brand';
  --balls-text: 'balls';
  /* translucent XP */
}

@font-face {
  font-family: "brand";
  src: url("assets/fonts/brand.woff"), url("assets/fonts/brand.woff2");
}

@font-face {
  font-family: "balls";
  src: url("assets/fonts/balls.woff"), url("assets/fonts/balls.woff2");
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.2 system-ui, Segoe UI, Roboto, Arial, sans-serif
}

#app {
  display: flex;
  gap: 16px;
  max-width: 100%;
  margin: 0 auto;
  padding: 16px;
  height: 92vh;
  min-height: 560px;
  align-items: flex-start;
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
  background: #050812;
  touch-action: none;
}

/* HUD */
.hud {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 8px
}

.hud .left,
.hud .right {
  display: flex;
  gap: 8px;
  align-items: center
}

.hud .right {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.pill {
  background: var(--pill);
  padding: 4px 8px;
  border-radius: 10px;
  color: #dbeafe
}

.xp-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--pill);
  color: #dbeafe;
  border-radius: 10px;
}

.xp-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.xp-pill .xpWrap {
  flex: none;
  width: min(240px, 32vw);
  min-width: 160px;
  max-width: 260px;
  height: 10px;
  background: #0b1220aa;
  border-radius: 8px;
  overflow: hidden;
}

.hp-wrap {
  position: relative;
  width: 180px;
  height: 10px;
  background: #0b1220aa;
  border-radius: 8px;
  overflow: hidden
}

.hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #10b981, #22c55e)
}

.hp-pct {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #e2e8f0
}

.xpWrap {
  width: 32vw;
  min-width: 200px;
  max-width: 460px;
  height: 10px;
  background: #0b1220aa;
  border-radius: 8px;
  overflow: hidden
}

.xpBar {
  height: 100%;
  width: 0%;
  background: var(--xp)
}

.bossHud {
  display: flex;
  align-items: center;
  gap: 8px
}

.bossHud.hidden {
  display: none
}

.bossName {
  font-size: 12px;
  color: #fecaca
}

.bossBarWrap {
  width: 240px;
  height: 8px;
  background: #0b1220aa;
  border-radius: 8px;
  overflow: hidden
}

.bossBar {
  height: 100%;
  width: 0%;
  background: #ef4444
}

.mute {
  pointer-events: auto;
  background: #0b122088;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: #020617cc;
  backdrop-filter: blur(2px);
  z-index: 1400;
}

.overlay.show {
  display: grid
}

.core_count {
  font-size: 2rem;
  margin: 1rem auto;
}

.panel {
  background: var(--panel);
  border: 1px solid #334155;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  border-radius: 16px;
  padding: 16px 18px;
  max-width: 720px;
  width: 92%;
  text-align: center;
}

.start-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 100%;
  width: min(100%, 96vw);
  text-align: center;
}

.start-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-direction: column;
}

.start-heading h1,
.start-heading h2 {
  margin: 0;
}

.start-heading h1 {
  font-size: clamp(3.8rem, 5vw, 5.4rem);
}

.start-heading h2 {
  font-size: clamp(2rem, 3.2vw, 3rem);
}

.start-donate {
  margin: 0;
  white-space: nowrap;
}

.start-body {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: stretch;
}

.start-hero {
  flex: 1 1 340px;
  min-width: 280px;
  display: flex;
}

.start-hero-card {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 100%;
}

.leaderboard-column {
  flex: 0 1 280px;
  min-width: 25%;
  display: flex;
  height:48vh;
}

.leaderboard-card {
  background: rgba(11, 18, 32, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 100%;
}

.leaderboard-card-header h3 {
  margin: 0;
}

.leaderboard-card-header .sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
}

.start-seed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.start-seed input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(11, 17, 32, 0.9);
  color: var(--text);
  padding: 10px 14px;
  font-size: 0.95rem;
}

.start-primary-btn {
  align-self: flex-start;
  padding: 1rem 1.6rem;
  font-size: 2rem;
  margin: 0 auto;
}

.tip-span {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.start-tip {
  margin: 4px 0 0;
  font-size: 1.2rem;
  color: #cbd5f5;
  min-height: 1.8em;
}

.start-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.stat-card {
  background: rgba(11, 18, 32, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
}

.start-feed {
  flex: 0 0 260px;
  min-width: 25%;
  background: rgba(11, 18, 32, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
}

.start-feed-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.start-feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 40vh;
  overflow-y: auto;
}

.start-feed-item {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  margin-right: 1rem;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.start-feed-item.badge {
  border-color: rgba(34, 197, 94, 0.35);
}

.start-feed-item.color {
  border-color: rgba(244, 114, 182, 0.35);
}

.start-feed-item.codex {
  border-color: rgba(56, 189, 248, 0.35);
}

.shop-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.shop-section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

button.shop-tab.selected {
  background: rgba(96, 165, 250, 0.25);
  border-color: rgba(96, 165, 250, 0.65);
  color: #e0f2fe;
}

button.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  text-align: center;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 14px;
  color: #e2e8f0;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

button.shop-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.45);
}

button.shop-card.selected {
  border-color: rgba(96, 165, 250, 0.85);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.5), 0 16px 32px rgba(15, 23, 42, 0.55);
  background: rgba(15, 23, 42, 0.98);
}

button.shop-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.shop-card-thumb {
  width: 78px;
  height: 78px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.4));
}

.shop-card-preview {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(96, 165, 250, 0.45);
  overflow: hidden;
}

.shop-card-preview::after {
  content: '';
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.2);
}

.shop-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #f8fafc;
}

.shop-card-price {
  font-size: 0.8rem;
  color: var(--muted);
}

.feed-item-title {
  font-weight: 600;
  color: var(--text);
}

.feed-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.start-feed-empty {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.start-actions .btn {
  flex: 0 1 auto;
}

body.modal-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2800;
}

.modal.open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
}

.modal-dialog {
  position: relative;
  z-index: 1;
  width: min(960px, 92vw);
  max-height: 90vh;
  background: rgba(11, 17, 32, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 18px;
  box-shadow: 0 28px 60px rgba(2, 6, 23, 0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-header h3 {
  margin: 0;
}

.modal-body {
  padding: 20px 22px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.meta-dialog .modal-body {
  gap: 20px;
}

.shop-dialog {
  width: min(720px, 90vw);
}

.shop-body {
  gap: 18px;
}

.achievements-dialog,
.codex-dialog {
  width: min(960px, 95vw);
}

.modal-close {
  white-space: nowrap;
}

.panel h1 {
  margin: 6px 0 4px;
  font-size: 5.6rem;
  font-family: var(--balls-text);
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 3rem;
}

.sub {
  color: var(--muted);
  margin: 4px 0 12px
}

.small {
  font-size: 1rem
}

.control-text {
  font-size: 1.4rem;
  margin-bottom: 1rem;
}

.brand-text {
  font-family: var(--brand-text);
}

hr {
  margin: 0 auto 2rem auto;
  width: 60%;
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin: 1rem 0
}

input#seedInput {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(11, 17, 32, 0.9);
  color: var(--text);
  width: 100%;
  text-align: left;
}

.btn {
  pointer-events: auto;
  border: 1px solid #475569;
  background: #1f2937;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: .15s transform, .2s background
}

.btn:hover {
  background: #283548
}

.btn:active {
  transform: scale(.98)
}

.primary {
  background: var(--accent);
  border-color: #525dff
}

.primary:hover {
  background: #7b83ff
}

.meta {
  margin-top: 8px;
  padding: 10px;
  border-radius: 12px;
  background: #0b1220cc;
  border: 1px solid #334155
}

.tab-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 0;
    justify-content: center;
}

.tab-btn {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid #475569;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.tab-btn[aria-selected="true"] {
  background: #283548;
  border-color: #5b6b83;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.35);
}

.tab-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.tab-btn.has-new {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35) inset, 0 0 18px rgba(56, 189, 248, 0.3);
  animation: tabPulse 1.6s ease-in-out infinite;
}

@keyframes tabPulse {

  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35) inset, 0 0 18px rgba(56, 189, 248, 0.3);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.55) inset, 0 0 24px rgba(56, 189, 248, 0.5);
  }
}

.tab-panel.hidden {
  display: none;
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  height: 18px;
  border-radius: 999px;
  background: #f97316;
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.tab-badge.hidden {
  display: none;
}

.achievements-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 440px;
}

.achievements-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.achievements-header-main h3 {
  margin: 0;
}

.achievements-filters {
  display: inline-flex;
  gap: 8px;
}

.achievements-filters .filter-btn {
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
}

.achievements-filters .filter-btn.selected {
  background: #334155;
  border-color: #475569;
}

.achievements-search input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1220;
  color: #e5e7eb;
  font-size: 0.85rem;
}

.achievements-search input::placeholder {
  color: #64748b;
}

.achievements-list {
  max-height: 360px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.achievement-card {
  background: #0b1220dd;
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-card.unlocked {
  border-color: #2563eb88;
  box-shadow: 0 0 0 1px #2563eb33 inset;
}

.achievement-card--new {
  border-color: #38bdf888;
  box-shadow: 0 0 0 1px #38bdf855 inset;
}

.achievement-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.achievement-card-category {
  font-weight: 600;
  letter-spacing: 0.05em;
}

.achievement-card-status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.achievement-card-new {
  font-size: 0.7rem;
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
}

.achievement-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e2e8f0;
}

.achievement-card-desc {
  font-size: 0.85rem;
  color: #cbd5f5;
}

.achievement-progress {
  display: flex;
  align-items: center;
  gap: 10px;
}

.achievement-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #1f2937;
  overflow: hidden;
}

.achievement-progress-fill {
  height: 100%;
  width: 0;
  background: #38bdf8;
  transition: width 0.2s ease;
}

.achievement-card.unlocked .achievement-progress-fill {
  background: #22c55e;
}

.achievement-progress-text {
  font-size: 0.75rem;
  color: #94a3b8;
  min-width: 60px;
  text-align: right;
}

.achievement-card-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: #facc15;
}

.achievement-card.unlocked .achievement-card-status {
  color: #34d399;
}

.achievement-card--new .achievement-card-status {
  color: #38bdf8;
}

.achievements-empty {
  padding: 20px;
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
}

.codex-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.codex-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.codex-header-main h3 {
  margin: 0;
}

.codex-header-main .sub {
  display: block;
  margin-top: 4px;
  color: #94a3b8;
}

.codex-view-toggle {
  display: inline-flex;
  gap: 8px;
}

.codex-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.codex-filters {
  display: inline-flex;
  gap: 8px;
}

.codex-filters .btn.selected,
.codex-view-toggle .btn.selected {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
}

.codex-search input {
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 6px 10px;
  color: #e2e8f0;
  min-width: 200px;
}

.codex-search input::placeholder {
  color: #64748b;
}

.codex-search input:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.codex-empty {
  padding: 24px;
  text-align: center;
  border-radius: 12px;
  border: 1px dashed rgba(148, 163, 184, 0.25);
  color: #94a3b8;
  font-size: 0.95rem;
}

.codex-list {
  display: grid;
  gap: 12px;
}

@media (min-width: 880px) {
  .codex-list {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

.codex-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 12px;
  padding: 18px;
  min-height: 190px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.45);
}

.codex-card-header {
  display: flex;
  gap: 12px;
  align-items: center;
}

.codex-card-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: #0f172a;
  background: linear-gradient(135deg, #334155, #1e293b);
  border: 1px solid rgba(148, 163, 184, 0.25);
  text-transform: uppercase;
}

.codex-card-title {
  font-weight: 600;
  color: #e2e8f0;
  font-size: 1.05rem;
}

.codex-card-state {
  font-size: 0.8rem;
  color: #94a3b8;
}

.codex-tag {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  font-size: 0.72rem;
  font-weight: 600;
}

.codex-tag.new {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
}

.codex-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.88rem;
  color: #cbd5f5;
}

.codex-card-body p {
  margin: 0;
}

.codex-card-body .codex-desc {
  color: #e2e8f0;
}

.codex-statline {
  color: #94a3b8;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.codex-notes {
  margin: 0;
  padding-left: 18px;
  color: #a5b4fc;
  font-size: 0.8rem;
}

.codex-notes li {
  margin-bottom: 4px;
}

.codex-advanced {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  padding-top: 8px;
  font-size: 0.8rem;
  color: #bfdbfe;
}

.codex-advanced .locked {
  color: #94a3b8;
}

.codex-card.state-unseen {
  opacity: 0.6;
}

.codex-card.state-unseen .codex-card-title {
  color: #94a3b8;
}

.codex-card.state-unseen .codex-card-icon {
  background: linear-gradient(135deg, #1e1b4b, #0f172a);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.3);
}

.codex-card.state-seen .codex-card-body {
  color: #94a3b8;
}

.codex-card.state-seen .codex-card-icon {
  background: linear-gradient(135deg, #0ea5e9, #1d4ed8);
  color: #0f172a;
}

.codex-card.state-seen .codex-card-body strong {
  color: #e2e8f0;
}

.codex-card.state-discovered,
.codex-card.state-defeated {
  border-color: rgba(56, 189, 248, 0.25);
  box-shadow: 0 16px 30px rgba(56, 189, 248, 0.05);
}

.codex-card.state-discovered .codex-card-icon,
.codex-card.state-defeated .codex-card-icon {
  border-color: rgba(56, 189, 248, 0.35);
}

.codex-card .codex-meta {
  font-size: 0.78rem;
  color: #94a3b8;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.codex-card .codex-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.codex-icon.enemy-charger {
  background: linear-gradient(135deg, #06b6d4, #22d3ee);
}

.codex-icon.enemy-fast {
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
}

.codex-icon.enemy-tank {
  background: linear-gradient(135deg, #f97316, #fb7185);
}

.codex-icon.enemy-splitter {
  background: linear-gradient(135deg, #a855f7, #ec4899);
}

.codex-icon.enemy-mini {
  background: linear-gradient(135deg, #facc15, #f97316);
}

.codex-icon.enemy-shooter {
  background: linear-gradient(135deg, #f59e0b, #f97316);
}

.codex-icon.enemy-heavyshooter {
  background: linear-gradient(135deg, #ef4444, #f87171);
}

.codex-icon.enemy-harrier {
  background: linear-gradient(135deg, #22d3ee, #6366f1);
}

.codex-icon.boss-spectral {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
}

.codex-icon.boss-hydra {
  background: linear-gradient(135deg, #34d399, #22d3ee);
}

.codex-icon.boss-colossus {
  background: linear-gradient(135deg, #fbbf24, #fb7185);
}

.codex-icon.boss-revenant {
  background: linear-gradient(135deg, #a855f7, #6366f1);
}

.codex-icon.boss-duelist {
  background: linear-gradient(135deg, #f472b6, #c084fc);
}

.codex-icon.boss-obelisk {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
}

.codex-icon.boss-starlance {
  background: linear-gradient(135deg, #fde047, #f97316);
}

.codex-icon.boss-architect {
  background: linear-gradient(135deg, #fda4af, #fb7185);
}

.codex-icon.boss-terraformer {
  background: linear-gradient(135deg, #fb7185, #f97316);
}

.codex-toast {
  background: rgba(37, 99, 235, 0.92);
}

.codex-toast.show {
  right: 24px;
  opacity: 1;
}

.toast.achievement-toast {
  top: auto;
  bottom: 32px;
}

.toast.achievement-toast strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.toast.achievement-toast div {
  font-size: 0.8rem;
}

.meta.hidden {
  display: none
}

.meta .grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px
}

.metaItem {
  background: #0f172acc;
  border: 1px solid #334155;
  padding: 10px;
  border-radius: 12px;
  display: grid;
  gap: 6px
}

.metaFoot {
  font-size: 11px;
  color: #94a3b8
}

.dim {
  color: #94a3b8
}

.buy {
  /* justify-self: start */
  display: block;
  margin: 0 auto;
}

.choices {
  max-width: 960px
}

.choicesGrid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 8px
}

@media(min-width:760px) {
  .choicesGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.panel.center {
  text-align: center
}

span#bossIncomingName {
  font-size: 2.4rem;
}

/* Tooltips (simple) */
[title] {
  position: relative
}

[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 120%;
  left: 0;
  background: #111827;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #334155;
  white-space: nowrap;
  color: #e5e7eb;
  font-size: 11px;
  opacity: .95;
  display: none;
}

.leaderboard {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.leaderboard-header {
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  font-size: 16px;
}

.leaderboard-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(241, 245, 249, 0.65);
  margin: 0 8px 0 6px;
  box-shadow: 0 0 12px rgba(148, 163, 184, 0.45);
  overflow: hidden;
  flex-shrink: 0;
}

.leaderboard-avatar-badge {
  width: 80%;
  height: 80%;
  object-fit: contain;
  opacity: 0.95;
}



.leaderboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  font-size: 1rem;
  color: #e2e8f0;
  flex: 1;
}

.leaderboard-list li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 1rem;
}

.leaderboard-list li span {
  font-feature-settings: "tnum";
  display: flex;
  flex-direction: row;
  align-items: center;
}

.leaderboard-list li.leaderboard-empty {
  justify-content: center;
  color: var(--muted);
}

.donation-link {
  display: inline-block;
  margin: 0 0 12px 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: #c7d2fe;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.donation-link:hover {
  background: rgba(99, 102, 241, 0.28);
  transform: translateY(-1px);
}

.donation-link:focus-visible {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}


.score-entry {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 12px auto 4px;
  width: 100%;
  max-width: 340px;
}

.score-entry input {
  flex: 1;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #e2e8f0;
}

.score-entry input::placeholder {
  color: #64748b;
}

.sidebar {
  width: 25%;
  background: var(--panel);
  border: 1px solid #1e293b;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.main-area {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.main-area canvas#game {
  flex: 1;
}

.touch-controls {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px;
  pointer-events: none;
  z-index: 1200;
}

.touch-controls.hidden {
  display: none;
}

.touch-controls .stick {
  position: relative;
  width: min(32vw, 120px);
  min-width: 74px;
  aspect-ratio: 1 / 1;
  pointer-events: auto;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.touch-controls .stick-ring {
  width: 80%;
  height: 80%;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.55);
  border: 2px solid rgba(148, 163, 184, 0.45);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.touch-controls .stick-thumb {
  position: absolute;
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.7);
  border: 2px solid rgba(125, 211, 252, 0.8);
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
  transition: transform 0.08s ease, background 0.15s ease;
  box-shadow: 0 8px 18px rgba(14, 116, 144, 0.35);
}

.touch-controls .stick-label {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.9);
}

.touch-controls .stick.active .stick-ring {
  border-color: rgba(56, 189, 248, 0.75);
  background: rgba(30, 64, 175, 0.35);
}

.touch-controls .stick.active .stick-thumb {
  background: rgba(14, 165, 233, 0.9);
}

.touch-controls .touch-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.35);
  font-size: 0.8rem;
  color: #e2e8f0;
  pointer-events: none;
  white-space: nowrap;
}

.touch-controls .touch-hint.hidden {
  display: none;
}

@media (max-width: 1024px) {
  #app {
    flex-direction: column;
    align-items: stretch;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    gap: 12px;
  }

  .main-area {
    width: 100%;
    flex: 1;
    min-height: 0;
    height: auto;
  }

  .main-area canvas#game {
    flex: 1 0 auto;
    height: min(100vh, 560px);
  }

  .hud {
    padding: 10px;
  }

  .hud .right {
    gap: 6px;
  }

  .start-body {
    flex-direction: column;
  }

  .leaderboard-column {
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
  }

  .leaderboard-card {
    min-height: 0;
  }

  .leaderboard-list {
    max-height: 260px;
  }

  .modal-dialog {
    width: 92vw;
    max-height: 92vh;
  }

  .start-feed {
    flex: 1 1 auto;
    max-height: none;
    order: 2;
  }

  .start-feed-list {
    max-height: 40vh;
  }

  .xpWrap {
    width: 50vw;
  }

  .start-hero {
    order: 0;
  }
}

@media (max-width: 720px) {
  body {
    font-size: 13px;
  }

  #app {
    padding: 10px;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .main-area {
    height: auto;
  }

  .main-area canvas#game {
    height: min(72vh, 520px);
  }

  .hud {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
  }

  .hud .left,
  .hud .right {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }

  .hp-wrap {
    width: 150px;
  }

  .xpWrap {
    width: clamp(130px, 60vw, 220px);
  }

  .touch-controls .stick {
    min-width: 70px;
  }

  .touch-controls .stick-label {
    font-size: 11px;
  }

  .start-panel {
    gap: 16px;
  }

  .start-heading h1 {
    font-size: clamp(3.2rem, 8vw, 4.2rem);
  }

  .start-heading h2 {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
  }

  .start-body {
    gap: 16px;
  }

  .start-feed-list {
    max-height: 200px;
  }
}

@media (max-width: 540px) {
  #app {
    padding: 8px;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .main-area {
    flex: 1;
    min-height: 0;
  }

  .main-area canvas#game {
    height: min(75vh, 460px);
  }

  canvas#game {
    border-radius: 12px;
  }

  .hud {
    padding: 6px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
  }

  .hud .left,
  .hud .right {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    flex-wrap: wrap;
  }

  .touch-controls {
    padding: 16px;
  }

  .touch-controls .stick {
    width: min(38vw, 100px);
  }

  .touch-controls .touch-hint {
    bottom: 12px;
    font-size: 0.72rem;
  }

  .mute {
    font-size: 11px;
  }

  .start-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .start-donate {
    align-self: stretch;
    text-align: center;
  }

  .start-feed {
    width: 100%;
  }

  .start-stats {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
}

.dev-panel {
  position: fixed;
  right: 24px;
  top: 24px;
  width: 260px;
  padding: 16px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  box-shadow: 0 18px 32px rgba(2, 6, 23, 0.45);
  z-index: 2000;
  color: #e2e8f0;
  pointer-events: auto;
}

.dev-panel.hidden {
  display: none;
}

.dev-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dev-grid label {
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dev-grid input,
.dev-grid select {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(71, 85, 105, 0.6);
  border-radius: 6px;
  padding: 6px 8px;
  color: #e2e8f0;
}

.dev-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.dev-panel .btn.sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.dev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.dev-panel .dev-status,
.dev-panel .sub {
  color: #94a3b8;
}
