:root {
  --bg: #0f172a;
  --panel: #111827;
  --tile: #1f2937;
  --tile-hover: #334155;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --danger: #ef4444;
  --sidebar-w: 240px;
}

* {
  box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

body {
  margin: 0;
  font-family: 'Ubuntu Sans', Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top left, #1e293b 0%, var(--bg) 60%);
  color: var(--text);
  font-size: 15px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--sidebar-w);
  grid-template-rows: minmax(0, 1fr) 260px;
  position: relative;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: auto;
  height: auto;
  min-height: 0;
  background: rgba(17, 24, 39, 0.97);
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 53;
  padding-bottom: 20px;
}

.sidebar-left {
  grid-column: 1;
  grid-row: 1;
  border-right: 1px solid #1e293b;
}

.sidebar-right {
  grid-column: 3;
  grid-row: 1;
  border-left: 1px solid #1e293b;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #1e293b;
  letter-spacing: 0.01em;
  color: var(--accent);
}

.sidebar-section {
  padding: 12px 14px;
  border-bottom: 1px solid #1e293b;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

/* Stats */
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid #1e293b;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: var(--muted);
  font-size: 0.875rem;
}

.stat-value {
  font-weight: 700;
  color: var(--text);
}

.mono {
  font-family: 'Ubuntu Sans Mono', monospace;
}

/* Tool grid */
.tool-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0px;
  padding: 16px 0;
}

.tool-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 3px;
  white-space: nowrap;
  padding: 4px 16px;
  font-family: 'Ubuntu Sans', sans-serif;
  font-size: 0.85rem;
  width: 100%;
}

.tool-btn:hover {
  color: var(--text);
}

.tool-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.25) inset;
}

/* Spawn timers */
.special-timer {
  font-size: 0.8rem;
  font-weight: 700;
  font-family: 'Ubuntu Sans Mono', monospace;
}

.gold-timer-text {
  color: #fcd34d;
}

.diamond-timer-text {
  color: #93c5fd;
}

/* Traders */
.traders-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trader-panel {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}

.trader-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #475569;
}

.trader-title {
  margin-top: 8px;
  font-weight: 700;
  font-size: 0.9rem;
}

.trader-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.trader-timer {
  margin-top: 6px;
  font-size: 0.8rem;
  color: #fcd34d;
  font-weight: 700;
  font-family: 'Ubuntu Sans Mono', monospace;
}

/* Purchased Upgrades grid */
.upgrades-details {
  width: 100%;
}

.upgrades-details summary::-webkit-details-marker {
  display: none;
}

.purchased-upgrades-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.upgrade-square {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #000;
  cursor: help;
}

/* ── Main content ──────────────────────────────────────── */
.app {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  min-width: 0;
  min-height: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  overflow-y: auto;
  position: relative;
  z-index: 40;
}

/* Grid */
.grid-wrap {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 14px;
  width: 100%;
  max-width: 700px;
  position: relative;
  z-index: 56;
}

.grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(80px, 1fr));
  gap: 8px;
}

.tile {
  aspect-ratio: 1 / 1;
  background: var(--tile);
  border: 1px solid #334155;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s ease, transform 0.05s ease;
  overflow: hidden;
  position: relative;
}

.tile:hover {
  background: var(--tile-hover);
}

.tile:active {
  transform: translateY(1px);
}

.tile-empty-label {
  color: #cbd5e1;
  font-weight: 700;
  font-size: 0.95rem;
}

.tile-cover-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-overlay {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(2, 6, 23, 0.8);
  border: 1px solid rgba(100, 116, 139, 0.7);
  border-radius: 6px;
  padding: 2px 7px;
  color: #e2e8f0;
  font-size: 0.78rem;
  font-weight: 700;
  font-family: 'Ubuntu Sans Mono', monospace;
  z-index: 1;
}

.ready {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35) inset;
}

.gold-ready {
  border-color: #facc15;
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.4) inset;
}

/* ── Alerts ────────────────────────────────────────────── */
.gold-alert {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(133, 77, 14, 0.94);
  border: 1px solid #facc15;
  color: #fef3c7;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
  z-index: 60;
}

.gold-alert.visible {
  opacity: 1;
}

.diamond-alert {
  position: fixed;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 64, 175, 0.94);
  border: 1px solid #60a5fa;
  color: #dbeafe;
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease;
  z-index: 60;
}

.diamond-alert.visible {
  opacity: 1;
}

/* ── Weather text states ────────────────────────────────── */
.weather-rain {
  color: #60a5fa;
}

.weather-thunderstorm {
  color: #facc15;
}

.timer-rain {
  color: #60a5fa !important;
}

.electrified {
  text-shadow: 0 0 5px #facc15;
  color: #fef08a !important;
}

.weather-fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 52;
  overflow: hidden;
}

.weather-fx canvas.sparticles {
  display: block;
  width: 100%;
  height: 100%;
}

.lightning-flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 74;
  transition: opacity 0.55s ease-out;
}

.lightning-flash.strike {
  opacity: 0.92;
  transition: none;
}

/* ── Modals ────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.65);
  z-index: 18;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 16px;
  z-index: 65;
}

.modal h2 {
  margin-top: 0;
}

.item-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 14px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}

.item-btn,
.ghost-btn {
  border: 1px solid #475569;
  background: #1f2937;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: 'Ubuntu Sans', sans-serif;
  font-size: 15px;
}

.item-btn:hover,
.ghost-btn:hover {
  background: #273548;
}

.item-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.item-name {
  font-weight: 700;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.popup-item-image {
  width: 42px;
  height: 42px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid #475569;
  flex: 0 0 auto;
}

.popup-item-image.placeholder {
  background: #374151;
}

.item-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 3px;
  font-family: 'Ubuntu Sans Mono', monospace;
}

.shop-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #93c5fd;
  margin-top: 8px;
  text-transform: uppercase;
}

.ghost-btn {
  width: 100%;
  text-align: center;
}

.hidden {
  display: none !important;
}

/* ── Dialog (changelog) ─────────────────────────────────── */
.game-dialog {
  margin: auto;
  width: min(440px, calc(100vw - 32px));
  max-height: 85vh;
  background: var(--panel);
  border: 1px solid #475569;
  border-radius: 12px;
  padding: 0;
  color: var(--text);
  overflow: hidden;
  font-family: 'Ubuntu Sans', sans-serif;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.game-dialog::backdrop {
  background: rgba(2, 6, 23, 0.75);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #334155;
  background: rgba(30, 41, 59, 0.5);
}

.dialog-body {
  overflow-y: auto;
  max-height: calc(85vh - 70px);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}

.changelog-title {
  font-weight: 700;
}

.changelog-entry {
  border-top: 1px solid #1e293b;
  padding-top: 8px;
}

.changelog-version {
  color: #93c5fd;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: 'Ubuntu Sans Mono', monospace;
}

.changelog-text {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 0.875rem;
}

.close-panel-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  line-height: 1;
}

.close-panel-btn:hover {
  color: #e2e8f0;
}

/* ── Settings ───────────────────────────────────────────── */
.settings-list {
  margin: 8px 0 12px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #334155;
  cursor: pointer;
}

.save-migration {
  margin: 12px 0;
  padding-top: 12px;
  border-top: 1px solid #334155;
}

.save-migration-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.save-migration-hint {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.4;
}

.save-migration-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.save-import-label {
  cursor: pointer;
  margin: 0;
}

.save-import-input {
  display: none;
}

/* ── Bouncing logo ──────────────────────────────────────── */
.bouncing-logo {
  position: fixed;
  top: 0;
  left: 0;
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  z-index: 60;
  pointer-events: none;
  border: 2px solid var(--accent);
  backdrop-filter: blur(4px);
}

/* ── Save toast ─────────────────────────────────────────── */
.save-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel);
  border: 1px solid #334155;
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: 'Ubuntu Sans', sans-serif;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 70;
}

.save-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Responsive ─────────────────────────────────────────── */
.mobile-nav {
  display: none;
}

.sidebar-scrim {
  display: none;
}

@media (max-width: 1100px) {
  :root {
    --sidebar-w: 210px;
  }

  .grid {
    grid-template-columns: repeat(6, minmax(56px, 1fr));
    gap: 6px;
  }
}

@media (max-width: 900px) {
  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .mobile-nav {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(17, 24, 39, 0.96);
    border-bottom: 1px solid #1e293b;
  }

  .mobile-nav-btn {
    flex: 1;
    border: 1px solid #475569;
    background: #1f2937;
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: 'Ubuntu Sans', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
  }

  .mobile-nav-btn[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 35;
  }

  .sidebar-scrim.hidden {
    display: none !important;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) 260px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    width: min(300px, 86vw);
    height: 100dvh;
    transition: transform 0.2s ease;
    z-index: 60;
  }

  .sidebar-left {
    left: 0;
    grid-column: auto;
    grid-row: auto;
    transform: translateX(-105%);
  }

  .sidebar-right {
    right: 0;
    grid-column: auto;
    grid-row: auto;
    transform: translateX(105%);
  }

  .sidebar-left.open,
  .sidebar-right.open {
    transform: translateX(0);
  }

  .app {
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding: 14px 12px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
  }

  #pet-playpen {
    grid-column: 1;
    grid-row: 2;
  }

  .grid-wrap {
    max-width: 100%;
  }

  .grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .modal {
    width: min(420px, calc(100% - 16px));
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
  }

  .item-list {
    max-height: min(50dvh, 360px);
  }
}

@media (max-width: 700px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #joe-wrap .grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)) !important;
  }
}

/* ── Achievements ───────────────────────────────────────── */
.achievement-locked {
  filter: grayscale(1);
  opacity: 0.7;
}

.achievement-unlocked {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.05);
}

.modal-section-title {
  margin: 16px 0 8px;
  font-size: 0.95rem;
  font-weight: 700;
}

.modal-hint {
  margin: 0 0 10px;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.4;
}

.titles-list {
  max-height: 220px;
  overflow-y: auto;
}

.title-item {
  text-align: left;
}

.title-item.title-equipped {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.35);
}

.title-reward {
  color: #cbd5e1;
  font-style: italic;
}

.title-preview-rainbow,
.leaderboard-title-rainbow .leaderboard-title-label,
.leaderboard-title-rainbow .leaderboard-player-name,
.leaderboard-title-rainbow .leaderboard-stat {
  background: linear-gradient(90deg, #ff0000, #ff6a00, #ffbf00, #00ff00, #0062ff, #8300fd, #ff0000);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-rainbow-shift 4s linear infinite;
}

.title-preview-shimmer,
.leaderboard-title-shimmer .leaderboard-title-label,
.leaderboard-title-shimmer .leaderboard-player-name,
.leaderboard-title-shimmer .leaderboard-stat {
  background: linear-gradient(90deg, #ffe944, #ffd500, #ffb90a, #fff9a5);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-rainbow-shift 2.5s linear infinite;
}

.title-preview-dedication,
.leaderboard-title-dedication .leaderboard-title-label,
.leaderboard-title-dedication .leaderboard-player-name,
.leaderboard-title-dedication .leaderboard-stat {
  background: linear-gradient(90deg, #7e22ce, #14532d, #a855f7, #166534, #7e22ce);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-rainbow-shift 3.5s linear infinite;
}

.title-preview-filthy,
.leaderboard-title-filthy .leaderboard-title-label,
.leaderboard-title-filthy .leaderboard-player-name,
.leaderboard-title-filthy .leaderboard-stat {
  background: linear-gradient(90deg, #22c55e, #facc15, #166534, #f97316, #22c55e);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: title-rainbow-shift 3s linear infinite;
}

.title-preview-custom-solid,
.app-nav-title.title-preview-custom-solid,
.leaderboard-title-custom-solid .leaderboard-title-label,
.leaderboard-title-custom-solid .leaderboard-player-name,
.leaderboard-title-custom-solid .leaderboard-stat {
  color: var(--title-c1, #fde68a);
}

.title-preview-custom-gradient,
.app-nav-title.title-preview-custom-gradient,
.leaderboard-title-custom-gradient .leaderboard-title-label,
.leaderboard-title-custom-gradient .leaderboard-player-name,
.leaderboard-title-custom-gradient .leaderboard-stat,
.title-preview-custom-animated,
.app-nav-title.title-preview-custom-animated,
.leaderboard-title-custom-animated .leaderboard-title-label,
.leaderboard-title-custom-animated .leaderboard-player-name,
.leaderboard-title-custom-animated .leaderboard-stat {
  background-image: var(--title-gradient, linear-gradient(90deg, #fde68a, #f59e0b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.title-preview-custom-gradient,
.app-nav-title.title-preview-custom-gradient,
.leaderboard-title-custom-gradient .leaderboard-title-label,
.leaderboard-title-custom-gradient .leaderboard-player-name,
.leaderboard-title-custom-gradient .leaderboard-stat {
  background-size: 100% auto;
}

.title-preview-custom-animated,
.app-nav-title.title-preview-custom-animated,
.leaderboard-title-custom-animated .leaderboard-title-label,
.leaderboard-title-custom-animated .leaderboard-player-name,
.leaderboard-title-custom-animated .leaderboard-stat {
  background-size: 200% auto;
  animation: title-rainbow-shift 3s linear infinite;
}

.title-color-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-color: #1e293b var(--bg);
}

.title-color-list::-webkit-scrollbar {
  width: 8px;
}

.title-color-list::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 8px;
}

.title-color-list::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 8px;
  border: 2px solid var(--bg);
}

.title-color-list::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

.title-color-item {
  display: flex;
  align-items: end;
  gap: 8px;
}

.title-color-label {
  flex: 1;
  margin: 0;
}

.title-color-input {
  min-height: 40px;
  padding: 4px;
}

.title-color-actions {
  margin-bottom: 12px;
}

.title-preview-box {
  margin: 12px 0 16px;
  padding: 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.55);
  color: var(--muted);
  font-size: 0.85rem;
}

.title-preview-box #title-preview {
  margin-left: 6px;
  font-weight: 700;
  font-size: 1rem;
}

@keyframes title-rainbow-shift {
  to {
    background-position: 200% center;
  }
}

.leaderboard-title-label {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
}

.leaderboard-player-name {
  font-weight: 600;
}

.maze-pick-btn {
  background: var(--tile);
  border: 2px solid #334155;
  border-radius: 10px;
  padding: 10px;
  color: white;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s, border-color 0.2s;
  font-family: inherit;
}

.maze-pick-btn:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}

.maze-pick-btn.selected {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.2);
}

#maze-container canvas {
  display: block;
}

.maze-mode-btn {
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
}

.maze-mode-btn:hover {
  background: #475569 !important;
  transform: translateY(-1px);
}

.maze-mode-btn:active {
  transform: translateY(0);
}

.maze-mode-btn.selected {
  background: var(--accent) !important;
  border-color: #fef08a !important;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.modal-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

#feather-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
}

.harvest-feather {
  position: fixed;
  pointer-events: auto;
  border: none;
  background: transparent;
  font-size: 1.35rem;
  cursor: default;
  padding: 0;
  line-height: 1;
  min-width: 1.5rem;
  min-height: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
  z-index: 61;
  transform-origin: center center;
}

#pet-playpen {
  grid-column: 1 / -1;
  grid-row: 2;
  position: relative;
  height: 260px;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  background: linear-gradient(180deg, rgb(15, 42, 29), rgba(13, 37, 19, 0.85));
}

#meal-deal-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 57;
  cursor: pointer;
  transition: transform 0.2s;
}

.pet-sprite {
  position: absolute;
  left: 0;
  top: 0;
  object-fit: contain;
  pointer-events: auto;
  cursor: pointer;
  image-rendering: pixelated;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.5));
  transform-origin: center bottom;
}

#pet-raffle {
  position: relative;
  margin-bottom: 12px;
}

#pet-raffle-viewport {
  overflow: hidden;
  border: 2px solid #334155;
  border-radius: 10px;
  background: #0f172a;
  height: 150px;
}

#pet-raffle-track {
  display: flex;
  align-items: center;
  height: 100%;
  will-change: transform;
}

.pet-raffle-item {
  flex: 0 0 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  text-align: center;
}

.pet-raffle-item img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  image-rendering: pixelated;
}

.pet-raffle-item span {
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.2;
}

#pet-raffle-marker {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 150px;
  background: #fde68a;
  box-shadow: 0 0 10px rgba(253, 230, 138, 0.65);
  pointer-events: none;
}

.pet-raffle-result {
  min-height: 2.5rem;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.pet-raffle-result strong {
  color: #fde68a;
}

#pet-summon-btn {
  width: 100%;
  margin-bottom: 8px;
}

.pet-info-tooltip {
  position: fixed;
  left: 50%;
  bottom: 220px;
  transform: translateX(-50%) translateY(8px);
  min-width: 220px;
  max-width: min(90vw, 360px);
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid #334155;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 65;
  text-align: center;
}

.pet-info-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pet-info-tooltip strong {
  display: block;
  margin-bottom: 4px;
  color: #fde68a;
  font-size: 0.95rem;
}

.pet-info-tooltip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.pet-info-tooltip .pet-level {
  margin-bottom: 6px;
  color: #93c5fd;
  font-weight: 700;
  font-size: 0.78rem;
}

.pet-info-tooltip .pet-buffs {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #334155;
  color: #cbd5e1;
  font-size: 0.78rem;
  text-align: left;
}

.auth-page {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 24px;
  scrollbar-color: #1e293b var(--bg);
}

.auth-page::-webkit-scrollbar {
  width: 8px;
}

.auth-page::-webkit-scrollbar-track {
  background: var(--bg);
}

.auth-page::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 8px;
  border: 2px solid var(--bg);
}

.auth-page::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

.auth-card {
  width: min(100%, 420px);
  background: rgba(17, 24, 39, 0.97);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
}

.auth-card-wide {
  width: min(100%, 900px);
}

.auth-title {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 1.4rem;
}

.auth-subtitle {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.auth-tab.active {
  border-color: var(--accent);
  background: rgba(34, 197, 94, 0.12);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.auth-input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0f172a;
  color: var(--text);
  font: inherit;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-export-save {
  width: 100%;
}

.auth-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.auth-message {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.auth-message-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fecaca;
}

.auth-message-success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
}

.auth-footer {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.85rem;
}

.auth-footer a {
  color: var(--accent);
}

.app-nav {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #1e293b;
}

.app-nav-user {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.app-nav-title {
  font-weight: 700;
  margin-right: 4px;
}

.app-nav-title:not([class*="title-preview-custom"]) {
  color: #fde68a;
}

.app-nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.app-nav-link {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid #334155;
  color: var(--text);
  text-decoration: none;
  font-size: 0.72rem;
}

.app-nav-link.active {
  border-color: var(--accent);
  color: var(--accent);
}

.leaderboard-table-wrap {
  overflow-x: auto;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #1e293b;
  text-align: left;
}

.leaderboard-table th {
  color: var(--muted);
  font-weight: 600;
}

.leaderboard-sort {
  color: inherit;
  text-decoration: none;
}

.leaderboard-sort.active {
  color: var(--accent);
}

.leaderboard-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

.leaderboard-user-title {
  color: #fde68a;
}

.users-table .users-title-input {
  width: 100%;
  min-width: 140px;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.users-admin-cell {
  white-space: nowrap;
}

.users-admin-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text);
}

.users-save-btn {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.sidebar .app-nav {
  padding: 0;
  margin: 0;
}

.sidebar .app-nav-links {
  flex-direction: column;
}

.sidebar .app-nav-link {
  display: block;
  text-align: center;
}