* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Global scrollbars — thin track that blends into the page bg, with
   a subtle thumb. Applies to every scrollable element on both pages.
   Firefox uses scrollbar-width/color; Chromium uses ::-webkit-*. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--surface) var(--bg);
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--surface);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}
::-webkit-scrollbar-corner {
  background: var(--bg);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  --bg: #0b0d14;
  --surface: #13151f;
  --surface2: #1a1d2b;
  --border: #252838;
  --text: #e0e0e0;
  --text-dim: #6b7280;
  --accent: #38bdf8;
  --accent-glow: rgba(56, 189, 248, 0.3);
  --gold: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --orange: #fb923c;
}

body {
  font-family:
    "Segoe UI",
    system-ui,
    -apple-system,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
}

.music-btn {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  transition: opacity 0.2s;
}
.music-btn:hover {
  opacity: 0.7;
}

.music-svg {
  display: block;
}

.agent-card.is-self {
  border-color: var(--gold, #fbbf24);
  box-shadow: 0 0 0 1px var(--gold, #fbbf24) inset;
  background: linear-gradient(
    180deg,
    rgba(251, 191, 36, 0.08),
    rgba(251, 191, 36, 0.02)
  );
}
.agent-card.is-self .agent-card-name::after {
  content: "YOU";
  margin-left: 8px;
  font-size: 9px;
  font-weight: 800;
  color: #0b0d14;
  background: var(--gold, #fbbf24);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  vertical-align: middle;
}

/* ─── App layout ──────────────────────────────────────────────────────────── */

.app-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── Map panel (left) ────────────────────────────────────────────────────── */

.map-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 12px;
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 0;
  touch-action: none;
  overscroll-behavior: contain;
}

.ws-blocked-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
.ws-blocked-card {
  max-width: 320px;
  padding: 20px 24px;
  background: rgba(20, 20, 28, 0.95);
  border: 1px solid rgba(248, 113, 113, 0.5);
  border-radius: 10px;
  color: #fff;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.ws-blocked-title {
  font-size: 15px;
  font-weight: 600;
  color: #f87171;
  margin-bottom: 8px;
}
.ws-blocked-text {
  font-size: 13px;
  color: #d4d4d8;
  line-height: 1.5;
}

.follow-indicator {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  backdrop-filter: blur(4px);
}
.follow-indicator .follow-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  animation: follow-pulse 1.5s ease-in-out infinite;
}
@keyframes follow-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.85);
  }
}
.follow-indicator strong {
  color: #38bdf8;
  font-weight: 700;
}
.follow-indicator #follow-unlock,
.follow-indicator #follow-copy {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.follow-indicator #follow-unlock {
  font-size: 16px;
}
.follow-indicator #follow-unlock:hover,
.follow-indicator #follow-copy:hover {
  color: #fff;
}

.follow-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  color: #38bdf8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.follow-btn:hover {
  background: rgba(56, 189, 248, 0.2);
}
.follow-btn.active {
  background: #38bdf8;
  color: #000;
  border-color: #38bdf8;
}
.follow-btn-icon {
  font-size: 13px;
}

#overworld {
  border: 2px solid var(--border);
  border-radius: 10px;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  display: block;
  transition: box-shadow 0.3s;
  touch-action: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#overworld:hover {
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.1);
}

.map-controls {
  flex-shrink: 0;
  position: relative;
  text-align: center;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-dim);
}
.map-logo {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.map-logo img {
  height: 18px;
  width: auto;
  display: block;
}
.controls-mobile {
  display: none;
}
@media (hover: none) and (pointer: coarse) {
  .controls-desktop {
    display: none;
  }
  .controls-mobile {
    display: inline;
  }
}

.map-legend {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
  font-size: 10px;
  justify-content: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ─── Tab panel (right) ───────────────────────────────────────────────────── */

.tab-panel {
  width: 420px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  background: var(--surface);
}

.tab-bar {
  display: flex;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 10px 6px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text);
}
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.tab-content.active {
  display: block;
}

/* ─── Agent directory (tab) ───────────────────────────────────────────────── */

.agent-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  gap: 10px;
  align-items: center;
}

.agent-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--accent-glow);
}

.agent-avatar {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom center;
  image-rendering: pixelated;
}
.agent-avatar img {
  height: 110%;
  width: auto;
  image-rendering: pixelated;
  display: block;
}

.agent-card-info {
  flex: 1;
  min-width: 0;
}
.agent-card-name {
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-card-meta {
  color: var(--text-dim);
  font-size: 10px;
  display: flex;
  gap: 8px;
  margin-top: 2px;
}
.agent-card-score {
  color: var(--green);
  font-weight: 700;
  font-size: 14px;
}
.agent-last-active {
  color: #444;
  font-style: italic;
}

/* ─── Leaderboards tab ────────────────────────────────────────────────────── */

.lb-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.lb-cat {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: all 0.15s;
}

.lb-cat:hover {
  color: var(--text);
  border-color: var(--accent);
}
.lb-cat.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #000;
}

.lb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.lb-row:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.lb-rank {
  width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.lb-row.top-1 .lb-rank {
  color: #ffd24a;
}
.lb-row.top-2 .lb-rank {
  color: #d8d8d8;
}
.lb-row.top-3 .lb-rank {
  color: #d99860;
}

.lb-avatar {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: bottom center;
  image-rendering: pixelated;
}
.lb-avatar img {
  height: 110%;
  width: auto;
  image-rendering: pixelated;
  display: block;
}

.lb-name {
  flex: 1;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-value {
  font-weight: 800;
  font-size: 14px;
  color: var(--green);
  flex-shrink: 0;
}

.lb-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}
.status-dot.exploring {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.status-dot.battling {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: blink 0.6s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

/* Widened variant for interior views - the 800×640 canvas wants ~1120px. */
.modal.modal-interior-open {
  max-width: 1120px;
}

.modal h3 {
  font-size: 12px;
  color: var(--gold);
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.15s;
  z-index: 2;
}
.close-btn:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.close-btn:active {
  transform: scale(0.94);
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
  padding-right: 44px;
}

.modal-avatar {
  width: 50px;
  height: 75px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}
.modal-avatar img {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 800;
}

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 2px;
}
.status-badge.exploring {
  background: rgba(52, 211, 153, 0.15);
  color: var(--green);
}
.status-badge.battling {
  background: rgba(248, 113, 113, 0.15);
  color: var(--red);
}

/* Interact buttons (trade / battle from spectator modal) */
.modal-interact {
  margin: 10px 0 6px;
  padding: 10px 12px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* Current PvP battle panel inside the agent modal. Visual frame comes from
 * the inner .encounter-viewer (shared with the wild-encounter panel); the
 * outer container is just spacing + the section label. */
.modal-current-battle {
  margin: 10px 0 6px;
}
.modal-current-battle .interact-label {
  font-size: 11px;
  color: var(--red);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.modal-current-battle .modal-active-battle {
  cursor: pointer;
  transition: border-color 0.15s;
}
.modal-current-battle .modal-active-battle:hover {
  border-color: var(--accent);
}
.modal-interact .interact-btns {
  display: flex;
  gap: 8px;
}
.modal-interact .interact-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal-interact .interact-msg {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}
.modal-interact .interact-msg.error {
  color: var(--red);
}
.modal-interact .interact-msg.success {
  color: var(--green);
}

/* Post-submit waiting card: shows the offer summary, a countdown, and the
 * resolution verdict (accepted / declined / expired / invalid / cancelled)
 * once the receiver responds or the timer runs out. */
.trade-waiting-summary {
  margin: 6px 0;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trade-waiting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.trade-waiting-dir {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 78px;
  flex-shrink: 0;
}
.trade-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 11px;
}
.trade-waiting-countdown {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.trade-waiting-result {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}
.trade-waiting-result.success {
  background: rgba(74, 222, 128, 0.08);
  border-color: var(--green);
  color: var(--green);
}
.trade-waiting-result.declined,
.trade-waiting-result.invalid {
  background: rgba(248, 113, 113, 0.08);
  border-color: var(--red);
  color: var(--red);
}
.trade-waiting-result.expired,
.trade-waiting-result.cancelled {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-dim);
}

/* Trade picker inside spectator modal */
.modal-trade-picker {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.modal-trade-picker .picker-col-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.modal-trade-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.modal-trade-picker label:hover {
  background: rgba(255, 255, 255, 0.04);
}
.modal-trade-picker .creature-emoji {
  font-size: 16px;
}

/* Interior viewer */
.interior-viewer {
  margin: 12px 0;
  text-align: center;
}
.interior-viewer h3 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
#interior-canvas {
  border: 2px solid var(--border);
  border-radius: 8px;
  background: #1a1d2b;
  max-width: 100%;
  image-rendering: pixelated;
}
.modal-invite-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  text-align: left;
}
.modal-invite-bar input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  font-family: monospace;
  outline: none;
}
.modal-invite-bar .invite-bar-label {
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Compact interior view - shown when opening an agent's profile from inside
 * the standalone interior viewer. Thumbnail scale, clickable to pop the
 * interior view back to full size. */
.modal.modal-interior-compact .interior-viewer {
  float: right;
  margin: 0 0 10px 14px;
  text-align: center;
  cursor: pointer;
  opacity: 0.9;
  transition:
    opacity 0.2s,
    transform 0.2s;
}
.modal.modal-interior-compact .interior-viewer:hover {
  opacity: 1;
  transform: scale(1.02);
}
.modal.modal-interior-compact .interior-viewer h3 {
  font-size: 10px;
  margin-bottom: 4px;
}
.modal.modal-interior-compact #interior-canvas {
  width: 180px;
  height: auto;
  cursor: pointer;
}
.modal.modal-interior-compact .interior-viewer::after {
  content: "↗ click to expand";
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 4px;
}

/* Badges */
.badge-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.3);
  color: var(--gold);
}

/* Stat grid */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stat-item {
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
  text-align: center;
}
.stat-item .stat-label {
  color: var(--text-dim);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-item .stat-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-top: 1px;
}

/* Creature cards */
.creature-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 12px;
  transition: background 0.2s;
}
.creature-card:hover {
  background: var(--surface2);
}
.creature-emoji {
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}
.creature-emoji img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.creature-info {
  flex: 1;
}
.creature-name {
  font-weight: 700;
  font-size: 12px;
}
.creature-stats {
  color: var(--text-dim);
  font-size: 10px;
  font-family: "SF Mono", "Fira Code", monospace;
}

.type-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.type-flame {
  background: #c44b2f;
}
.type-aqua {
  background: #2563eb;
}
.type-leaf {
  background: #16a34a;
}
.type-shock {
  background: #ca8a04;
  color: #000;
}
.type-rock {
  background: #78716c;
}
.type-shadow {
  background: #6b21a8;
}
.type-normal {
  background: #6b7280;
}
.type-mixed {
  background: linear-gradient(135deg, #c44b2f, #2563eb, #16a34a);
}

/* HP bar */
.hp-bar-container {
  width: 100%;
  height: 4px;
  background: #1a1d28;
  border-radius: 2px;
  margin-top: 2px;
}
.hp-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}
.hp-bar.high {
  background: var(--green);
}
.hp-bar.mid {
  background: var(--orange);
}
.hp-bar.low {
  background: var(--red);
}

/* Item display */
.item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.item-name {
  flex: 1;
}
.item-qty {
  color: var(--accent);
  font-weight: 700;
  min-width: 24px;
  text-align: right;
}

/* ─── Gym grid (tab) ──────────────────────────────────────────────────────── */

.gym-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gym-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  transition: all 0.2s;
}
.gym-card:hover {
  border-color: var(--accent);
}

.gym-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.gym-type-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.gym-name {
  font-weight: 800;
  font-size: 14px;
}
.gym-town {
  color: var(--text-dim);
  font-size: 11px;
}
.gym-leader {
  color: var(--text-dim);
  font-size: 11px;
  margin-bottom: 4px;
}

.gym-badge-name {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: var(--gold);
}

.gym-team {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.gym-team-member {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* ─── Battle list (tab) ───────────────────────────────────────────────────── */

.battles-section {
  margin-bottom: 18px;
}
.battles-heading {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}
.battles-count {
  background: var(--surface2);
  color: var(--text);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
  margin-left: auto;
}

.active-battles-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.active-battles-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 14px;
  font-style: italic;
}

.active-battle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--red);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  animation: livePulse 1.5s ease-in-out infinite;
}
.active-battle:hover {
  border-color: var(--accent);
}
.active-battle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.active-battle-name {
  font-weight: 700;
  color: var(--text);
}
.active-battle-name.ab-left {
  text-align: right;
  flex: 1;
}
.active-battle-name.ab-right {
  flex: 1;
}
.active-battle-vs {
  color: var(--red);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
}
.active-battle-meta {
  display: flex;
  justify-content: space-between;
  color: var(--text-dim);
  font-size: 10px;
  margin-top: 4px;
}
.ab-fighter {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--text-dim);
  font-size: 10px;
}
.ab-sprite {
  width: 18px;
  height: 18px;
  object-fit: contain;
  image-rendering: pixelated;
}
.ab-hp-bar {
  height: 3px;
  background: var(--surface2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
}
.ab-hp-fill {
  height: 100%;
  background: var(--green);
  transition: width 0.3s;
}
.ab-hp-fill.low {
  background: var(--orange);
}
.ab-hp-fill.crit {
  background: var(--red);
}

.battle-list {
  display: flex;
  flex-direction: column;
}

.battle-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.battle-item .vs {
  color: var(--text-dim);
  font-size: 10px;
}
.battle-winner {
  color: var(--green);
  font-weight: 700;
}
.battle-loser {
  color: var(--red);
}
.battle-score {
  margin-left: auto;
  color: var(--gold);
  font-weight: 700;
  font-size: 11px;
}
.battle-time {
  color: #444;
  font-size: 10px;
  min-width: 50px;
  text-align: right;
}

/* ─── Join tab ────────────────────────────────────────────────────────────── */

.sidebar-join-blurb {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 14px;
  text-align: center;
}
.sidebar-join-cta {
  width: 100%;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
  justify-content: center;
}
.sidebar-join-login-link {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
}
.sidebar-join-login-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
.sidebar-join-agent-details {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-join-agent-details > summary {
  font-size: 12px;
}

/* ─── Join wizard modal ──────────────────────────────────────────────────── */
.join-wizard-modal {
  max-width: 720px;
  width: 100%;
}
.join-wizard-header {
  text-align: center;
  margin-bottom: 18px;
}
.join-wizard-title {
  font-size: 22px;
  margin: 0 0 6px;
  color: var(--text);
}
.join-wizard-subtitle {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
}
.join-wizard-pills {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.join-wizard-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.join-wizard-pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}
.join-wizard-pill.done {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #22c55e;
}
.join-wizard-modal .welcome-step-panel {
  border-top: none;
  padding: 14px 0 4px;
}
.join-wizard-sent {
  text-align: center;
  padding: 18px 8px 8px;
}
.join-wizard-sent .sent-icon {
  font-size: 36px;
  margin-bottom: 10px;
}
.join-wizard-sent .sent-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.join-wizard-sent .sent-body {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 6px;
}
.join-wizard-sent .sent-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  margin-bottom: 12px;
}
.join-wizard-sent #join-wizard-sent-email {
  color: var(--gold);
  font-weight: 600;
  word-break: break-all;
}
.join-wizard-login-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: none;
}
.join-wizard-login-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ─── Signup success modal ──────────────────────────────────────────────── */
.signup-success-modal {
  max-width: 540px;
  text-align: center;
}
.signup-success-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.signup-success-eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  border-radius: 999px;
  padding: 4px 12px;
}
.signup-success-title {
  font-size: 24px;
  margin: 4px 0 0;
  color: var(--text);
}
.signup-success-title span {
  color: var(--accent);
}
.signup-success-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.55;
  margin: 0 0 8px;
  max-width: 420px;
}
.signup-success-cards {
  display: flex;
  gap: 14px;
  justify-content: center;
  width: 100%;
  margin: 6px 0 10px;
}
.signup-success-card {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.signup-success-card-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.signup-success-trainer {
  width: 56px;
  height: 84px;
  image-rendering: pixelated;
}
.signup-success-creature {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
}
.signup-success-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.signup-success-cta {
  margin-top: 4px;
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 700;
}
.signup-success-secondary {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  text-decoration: none;
}
.signup-success-secondary:hover {
  color: var(--accent);
  text-decoration: underline;
}

.join-hero {
  text-align: center;
  margin-bottom: 20px;
}
.join-hero h3 {
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 10px;
}

.join-prompt {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.join-prompt a {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}
.join-copy-btn {
  margin-top: 10px;
  padding: 6px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.join-copy-btn:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

.join-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.join-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
}

.join-step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.join-setup-guide {
  margin-top: 16px;
}
.join-setup-guide h4 {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.join-tool {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  background: var(--bg);
}
.join-tool summary {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  list-style: none;
}
.join-tool summary::before {
  content: "\25B6";
  margin-right: 8px;
  font-size: 10px;
  display: inline-block;
  transition: transform 0.2s;
}
.join-tool[open] summary::before {
  transform: rotate(90deg);
}
.join-tool summary:hover {
  color: var(--accent);
}
.join-tool p {
  padding: 0 14px 8px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0;
}
.join-tool pre {
  margin: 4px 14px 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  overflow-x: auto;
}
.join-tool code {
  font-size: 12px;
  color: var(--accent);
  font-family: "SF Mono", "Fira Code", monospace;
}
.join-tool em {
  color: var(--text-dim);
  font-size: 12px;
}

/* ─── Compendium (tab) ────────────────────────────────────────────────────── */

.compendium-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
}
.filter-btn:hover,
.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

.compendium-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.compendium-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  transition: all 0.2s;
  position: relative;
  cursor: pointer;
}
.compendium-card:hover {
  border-color: var(--accent);
}
.compendium-id {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 9px;
  color: #333;
  font-weight: 700;
}
.compendium-emoji {
  font-size: 24px;
  margin-bottom: 2px;
}
.compendium-name {
  font-weight: 700;
  font-size: 11px;
  margin-bottom: 2px;
}
.compendium-meta {
  font-size: 9px;
  color: var(--text-dim);
  margin-top: 2px;
}
.compendium-evo {
  font-size: 9px;
  color: #555;
  margin-top: 2px;
}

.rarity-common {
  color: #9ca3af;
}
.rarity-uncommon {
  color: var(--green);
}
.rarity-rare {
  color: var(--accent);
}
.rarity-epic {
  color: #a78bfa;
}
.rarity-legendary {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

/* ─── Agent Detail Enhancements ──────────────────────────────────────────── */

.compendium-summary {
  font-size: 11px;
  color: var(--text-dim);
  padding: 4px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.held-item-label {
  font-size: 9px;
  color: var(--gold);
  background: rgba(251, 191, 36, 0.1);
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
}
.creature-status {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 8px;
  margin-left: 4px;
}
.status-poison {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.15);
}
.status-burn {
  color: var(--orange);
  background: rgba(251, 146, 60, 0.15);
}
.status-paralyze {
  color: var(--gold);
  background: rgba(251, 191, 36, 0.15);
}
.status-sleep {
  color: var(--text-dim);
  background: rgba(107, 114, 128, 0.2);
}
.status-freeze {
  color: #67e8f9;
  background: rgba(103, 232, 249, 0.15);
}

/* ─── Battle Replay ──────────────────────────────────────────────────────── */

.battle-replay {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 4px 0 8px;
  padding: 8px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 1.6;
}
.replay-entry {
  padding: 2px 4px;
  border-radius: 3px;
}
.replay-entry:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}
.replay-faint {
  color: var(--red);
  font-weight: 700;
}
.replay-super {
  color: var(--green);
}
.replay-weak {
  color: var(--text-dim);
}
.replay-status {
  color: var(--orange);
  font-style: italic;
}
.replay-end {
  color: var(--gold);
  font-weight: 700;
  text-align: center;
  margin-top: 4px;
}
.replay-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* ─── Event Feed ─────────────────────────────────────────────────────────── */

.event-feed {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
}
.event-item {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.event-time {
  color: var(--text-dim);
  font-size: 10px;
  min-width: 48px;
  flex-shrink: 0;
}
.event-msg {
  flex: 1;
}
.event-battle {
  border-left: 2px solid var(--red);
}
.event-catch {
  border-left: 2px solid var(--green);
}
.event-gym_win {
  border-left: 2px solid var(--gold);
}
.event-evolve {
  border-left: 2px solid #a78bfa;
}
.event-trade {
  border-left: 2px solid var(--accent);
}
.event-world_event {
  border-left: 2px solid var(--orange);
}
.event-heal {
  border-left: 2px solid #67e8f9;
}

/* ─── World Events Bar ──────────────────────────────────────────────────── */

.world-events-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
  margin-bottom: 4px;
}
.world-event-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  font-size: 11px;
}
.we-emoji {
  font-size: 14px;
}
.we-name {
  font-weight: 700;
  color: var(--gold);
}
.we-loc {
  color: var(--text-dim);
}
.we-timer {
  color: var(--orange);
  font-size: 10px;
}

/* ─── Encounter Viewer (in agent modal) ──────────────────────────────────── */

.encounter-viewer {
  margin: 12px 0;
  background: linear-gradient(135deg, #1a2a1a 0%, #0d1117 50%, #1a1a2a 100%);
  border: 1px solid #2d4a2d;
  border-radius: 8px;
  padding: 16px;
}

.encounter-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.encounter-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.encounter-sprite {
  font-size: 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.encounter-sprite img {
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Wild creature sits on the left facing the agent's lead (right). Sprites
 * ship facing right by default, so mirror the wild side horizontally. */
.encounter-wild .encounter-sprite img {
  transform: scaleX(-1);
}

.encounter-vs {
  font-weight: bold;
  font-size: 18px;
  color: var(--red);
  text-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
  padding: 0 8px;
}

.encounter-info {
  width: 100%;
  text-align: center;
}

.encounter-name {
  font-size: 13px;
  font-weight: 600;
  color: #e0e0e0;
  margin-bottom: 4px;
}

.encounter-hp-bar {
  width: 100%;
  height: 8px;
  background: #1a1d2b;
  border-radius: 4px;
  overflow: hidden;
}

.encounter-hp-fill {
  height: 100%;
  border-radius: 4px;
  transition:
    width 0.5s ease,
    background 0.5s ease;
}

.encounter-wild .encounter-hp-fill {
  background: var(--red);
}
.encounter-agent .encounter-hp-fill {
  background: var(--green);
}

.encounter-hp-text {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ─── Battle Modal ───────────────────────────────────────────────────────── */

.battle-modal {
  max-width: 700px;
  width: 95vw;
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
  border-radius: 14px;
  background: var(--surface);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
}
.battle-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 24px;
  background: linear-gradient(135deg, #141627, #1e2035, #1a1d2b);
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.battle-trainer-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}
.battle-trainer {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.battle-trainer.winner {
  color: var(--gold);
}
.battle-team-roster {
  display: flex;
  gap: 4px;
  align-items: center;
}
.roster-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition:
    background 0.3s,
    opacity 0.3s;
}
.roster-dot.fainted {
  background: var(--red);
  opacity: 0.5;
}
.roster-dot.active {
  box-shadow: 0 0 6px var(--accent);
  border-color: var(--accent);
}
.battle-vs-badge {
  flex-shrink: 0;
}
.battle-vs-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--red);
  background: rgba(248, 113, 113, 0.12);
  padding: 3px 12px;
  border-radius: 12px;
  letter-spacing: 2px;
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.battle-result-bar {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.5px;
  background: linear-gradient(
    90deg,
    rgba(251, 191, 36, 0.1),
    rgba(251, 191, 36, 0.05)
  );
  border-bottom: 1px solid var(--border);
  color: var(--gold);
  flex-shrink: 0;
}
.battle-scene {
  background: #000;
  display: flex;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  position: relative;
  flex-shrink: 0;
}
.battle-scene canvas {
  width: 100%;
  max-height: 320px;
  image-rendering: auto;
}
.battle-hud {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  gap: 10px;
  background: var(--bg);
  flex-shrink: 0;
}
.battle-hud-left,
.battle-hud-right {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.3s;
}
.battle-hud-left.taking-damage,
.battle-hud-right.taking-damage {
  border-color: var(--red);
}
.bh-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.bh-name {
  font-weight: 700;
  font-size: 13px;
}
.bh-level {
  color: var(--text-dim);
  font-weight: 400;
  font-size: 11px;
}
.bh-type {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: auto;
}
.bh-hp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bh-hp-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
}
.bh-hp-track {
  flex: 1;
  height: 8px;
  background: #111320;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid #2a2d3a;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.4);
}
.bh-hp-fill {
  height: 100%;
  border-radius: 4px;
  transition:
    width 0.3s ease,
    background 0.3s ease;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.3);
}
.bh-hp-fill.mid {
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.3);
}
.bh-hp-fill.low {
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.3);
}
.bh-hp-num {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 55px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.battle-narration {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  background: linear-gradient(180deg, var(--surface), var(--surface2));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  overflow: hidden;
}
.bt-narration-icon {
  color: var(--accent);
  font-size: 10px;
  flex-shrink: 0;
  opacity: 0.7;
}
.bt-narration-text {
  flex: 1;
}
.battle-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--bg);
  flex-shrink: 0;
}
.battle-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.battle-controls button:hover {
  background: var(--surface);
  border-color: var(--accent);
  color: var(--accent);
}
.battle-controls button:active {
  transform: scale(0.92);
}
.bt-speed-btn {
  font-size: 11px !important;
  font-weight: 700;
  min-width: 36px;
  width: auto !important;
  padding: 0 6px;
}
.bt-speed-btn.speed-2x {
  color: var(--gold);
  border-color: rgba(251, 191, 36, 0.3);
}
.bt-speed-btn.speed-3x {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.3);
}
.battle-progress {
  flex: 1;
  height: 6px;
  background: #111320;
  border-radius: 3px;
  overflow: hidden;
  margin: 0 6px;
  cursor: pointer;
  border: 1px solid #1e2030;
}
.battle-progress:hover {
  border-color: var(--accent);
}
.battle-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 3px;
  transition: width 0.2s;
}
.battle-turn-counter {
  font-size: 10px;
  color: var(--text-dim);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.battle-log-text {
  height: 120px;
  min-height: 120px;
  max-height: 120px;
  overflow-y: auto;
  padding: 8px 16px;
  font-size: 11px;
  line-height: 1.7;
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.battle-log-text::-webkit-scrollbar {
  width: 4px;
}
.battle-log-text::-webkit-scrollbar-track {
  background: transparent;
}
.battle-log-text::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}
.bl-entry {
  padding: 2px 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  animation: blFadeIn 0.15s ease-out;
}
@keyframes blFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.bl-icon {
  font-size: 10px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
.bl-text {
  flex: 1;
}
.bl-faint {
  color: var(--red);
  font-weight: 700;
}
.bl-attack {
  color: var(--text);
}
.bl-end {
  color: var(--gold);
  font-weight: 700;
}
.bl-status {
  color: var(--orange);
  font-style: italic;
}
.bl-heal {
  color: var(--green);
}
.bl-stat {
  color: #a78bfa;
}
.bl-miss {
  color: var(--text-dim);
  font-style: italic;
}

/* ─── Live Battle Indicator ─────────────────────────────────────────────── */

.battle-live {
  border-left: 3px solid var(--red);
  padding-left: 5px;
  animation: livePulse 1.5s ease-in-out infinite;
}
@keyframes livePulse {
  0%,
  100% {
    background: transparent;
  }
  50% {
    background: rgba(248, 113, 113, 0.06);
  }
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
  animation: dotPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes dotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */

/* ─── Mobile drawer (≤900px) ──────────────────────────────────────────────
   The right-hand .tab-panel is repurposed as a bottom sheet on mobile.
   Two snap states:
     • peek  — handle + status strip visible (~PEEK_PX)
     • full  — sheet covers the screen behind a translucent map glimpse
   The map fills the viewport behind the sheet. Drag is bound to the
   handle only (see app.js) so we never fight content scrolling. */

.drawer-handle {
  display: none;
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
    height: 100vh;
  }
  .app-layout {
    flex-direction: column;
    overflow: hidden;
    position: relative;
    height: 100%;
  }

  /* Map fills the viewport behind the drawer. Bottom padding leaves
     room for the peek strip so map-controls aren't occluded. */
  .map-panel {
    flex: 1;
    min-height: 0;
    height: auto;
    padding: 8px 8px var(--drawer-peek, 96px);
  }
  .map-controls {
    font-size: 10px;
    margin-top: 4px;
  }
  .map-logo img {
    height: 16px;
  }
  .map-legend {
    display: none;
  }

  /* Drawer shell */
  .tab-panel {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    width: 100%;
    height: 100vh;
    border-left: none;
    border-top: none;
    z-index: 50;
    background: var(--surface);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    transform: translateY(calc(100vh - var(--drawer-peek, 96px)));
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
    touch-action: none;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-panel.is-full {
    transform: translateY(0);
  }
  .tab-panel.is-dragging {
    transition: none;
  }

  /* Drawer handle / status strip — the only drag target. */
  .drawer-handle {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-shrink: 0;
    padding: 6px 14px 8px;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
  }
  .drawer-handle:active {
    cursor: grabbing;
  }
  .drawer-grip {
    width: 36px;
    height: 4px;
    margin: 0 auto 6px;
    border-radius: 999px;
    background: var(--border);
  }
  .drawer-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 28px;
    font-size: 11px;
    color: var(--text-dim);
    overflow: hidden;
  }
  .drawer-status-hint {
    flex: 1;
    text-align: center;
    color: var(--text-dim);
    font-size: 12px;
  }
  .drawer-status-companion {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .drawer-status-companion.is-tappable {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.08);
  }
  .drawer-status-companion.is-tappable:active {
    opacity: 0.7;
  }
  .drawer-status-companion-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
  }
  .drawer-status-companion-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    font-weight: 700;
  }
  .drawer-status-companion-state {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
  }
  .drawer-status-companion-stamina-text {
    font-size: 10px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .drawer-status-companion-state[data-driver="bot"],
  .drawer-status-companion-state[data-driver="agent"] {
    color: var(--green);
  }
  .drawer-status-companion-state[data-driver="paused"] {
    color: var(--gold);
  }
  .drawer-status-companion-state[data-driver="drained"],
  .drawer-status-companion-state[data-driver="pending-blackout"],
  .drawer-status-companion-state[data-driver="locked-out"] {
    color: var(--red);
  }
  .drawer-status-stamina-bar {
    width: 100%;
    height: 4px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
  }
  .drawer-status-stamina-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--green);
    transition:
      width 0.2s,
      background 0.2s;
  }
  .drawer-status-stamina-fill[data-level="mid"] {
    background: var(--gold);
  }
  .drawer-status-stamina-fill[data-level="low"] {
    background: var(--red);
  }
  .drawer-status-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
    flex-shrink: 0;
    font-size: 10px;
    line-height: 1.2;
  }
  .drawer-status-loc {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .drawer-status-gold {
    color: var(--gold);
    font-weight: 700;
  }

  .tab-bar {
    /* Tab bar lives just under the handle in the drawer. */
    border-bottom: 1px solid var(--border);
  }
  .tab-content {
    max-height: none;
    /* Allow scrolling inside the drawer once it's open. */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .compendium-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .battle-modal {
    max-width: 100vw;
  }
  .battle-scene canvas {
    max-height: 200px;
  }
}

@media (max-width: 600px) {
  /* Tabs */
  .tab-btn {
    padding: 10px 4px;
    font-size: 11px;
    letter-spacing: 0;
  }
  .tab-content {
    padding: 10px;
    max-height: none;
  }

  /* Agent cards */
  .agent-card {
    padding: 10px 8px;
    gap: 8px;
  }
  .agent-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .agent-card-name {
    font-size: 12px;
  }
  .agent-card-meta {
    font-size: 9px;
    gap: 6px;
  }

  /* Modals */
  .modal {
    width: 96%;
    max-height: 90vh;
    padding: 16px;
    border-radius: 10px;
  }
  .modal-avatar {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  .modal-header h2 {
    font-size: 16px;
  }
  .modal-header {
    gap: 10px;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }
  .stat-item {
    padding: 6px 8px;
  }
  .stat-item .stat-value {
    font-size: 15px;
  }

  /* Battle modal */
  .battle-modal {
    width: 100vw;
    max-width: 100vw;
    border-radius: 0;
    max-height: 100vh;
  }
  .battle-header {
    padding: 10px 12px;
    gap: 10px;
  }
  .battle-trainer {
    font-size: 13px;
  }
  .battle-scene canvas {
    max-height: 180px;
  }
  .battle-hud {
    padding: 6px 10px;
    gap: 8px;
  }
  .bh-name {
    font-size: 11px;
  }
  .battle-narration {
    padding: 8px 12px;
    font-size: 12px;
  }
  .battle-controls {
    padding: 6px 10px;
    gap: 4px;
  }
  .battle-controls button {
    width: 36px;
    height: 36px;
  }
  .battle-log-text {
    padding: 6px 10px;
    font-size: 10px;
    max-height: 120px;
  }

  /* Encounter viewer */
  .encounter-viewer {
    padding: 10px;
  }
  .encounter-sprite {
    font-size: 36px;
    height: 48px;
  }
  .encounter-sprite img {
    width: 48px;
    height: 48px;
  }

  /* Join tab */
  .join-hero h3 {
    font-size: 15px;
  }
  .join-prompt {
    font-size: 12px;
    padding: 10px;
  }
  .join-step {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Creature cards */
  .creature-card {
    padding: 6px 8px;
    gap: 8px;
  }
  .creature-emoji {
    font-size: 18px;
    width: 26px;
    height: 26px;
  }
  .creature-emoji img {
    width: 26px;
    height: 26px;
  }
  .creature-name {
    font-size: 11px;
  }

  /* Compendium */
  .compendium-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  /* Welcome modal mobile */
  .welcome-modal {
    padding: 20px;
  }
  .welcome-logo {
    font-size: 40px;
  }
  .welcome-title {
    font-size: 20px;
  }
  .welcome-step {
    padding: 14px 18px;
  }
  .welcome-step p {
    font-size: 12px;
  }
}

/* ─── Welcome Modal ─────────────────────────────────────────────────────── */

.welcome-modal {
  max-width: 520px;
  text-align: center;
}

.welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.welcome-logo {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 4px;
}

.welcome-title {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
}

.welcome-subtitle {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin: 0;
}

.welcome-desc {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 420px;
  margin: 8px 0 4px;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin: 12px 0;
  text-align: left;
}

.welcome-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 18px 24px;
}

.welcome-step-num {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.welcome-step strong {
  display: block;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 2px;
}

.welcome-step p {
  font-size: 15px;
  color: var(--text-dim);
  margin: 0;
}

.welcome-step a {
  color: var(--accent);
  text-decoration: none;
}
.welcome-step a:hover {
  text-decoration: underline;
}

.welcome-copy-btn {
  margin-top: 6px;
  padding: 5px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.welcome-copy-btn:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

.welcome-human-section {
  width: 100%;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 4px;
}

.welcome-human-section strong {
  font-size: 14px;
  color: var(--gold);
}

.welcome-human-section p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 4px 0 0;
}

.welcome-human-section a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.welcome-human-section a:hover {
  text-decoration: underline;
}

.welcome-cta {
  margin-top: 8px;
  padding: 12px 32px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}
.welcome-cta:hover {
  background: #5ccbfa;
  transform: translateY(-1px);
}
.welcome-cta:active {
  transform: translateY(0);
}

/* ─── Sidebar dashboard (My Agent tab) ─────────────────────────────────────── */

.sidebar-hero {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.sidebar-hero:hover {
  border-color: var(--accent, #6aa9ff);
  background: var(--bg-hover, var(--bg));
}
.sidebar-hero-sprite {
  flex-shrink: 0;
  width: 40px;
  height: 60px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sidebar-hero-sprite img {
  width: 32px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.sidebar-hero-info {
  flex: 1;
  min-width: 0;
}
.sidebar-hero-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-hero-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-dim);
}
.sidebar-hero-loc {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.sidebar-hero-loc-info {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border, #252838);
  background: var(--bg, #0b0d14);
  color: var(--text-dim, #9ca3af);
  font-family: ui-serif, Georgia, serif;
  font-size: 11px;
  font-style: italic;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.sidebar-hero-loc-info:hover {
  color: #0b0d14;
  background: var(--accent, #38bdf8);
  border-color: var(--accent, #38bdf8);
}
.area-details-modal {
  max-width: 520px;
}
.area-details-modal .area-details-loading,
.area-details-modal .area-details-error {
  padding: 12px;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
  text-align: center;
}
.area-details-modal .area-details-error {
  color: #f87171;
}
.sidebar-hero-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.3px;
}
.sidebar-hero-status.exploring {
  color: var(--green);
}
.sidebar-hero-status.battling {
  color: var(--red);
}
.sidebar-hero-status.offline {
  color: var(--text-dim);
}
.sidebar-hero-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar-hero-status.exploring .sidebar-hero-status-dot {
  background: var(--green);
  box-shadow: 0 0 4px var(--green);
}
.sidebar-hero-status.battling .sidebar-hero-status-dot {
  background: var(--red);
  box-shadow: 0 0 4px var(--red);
  animation: blink 0.6s infinite;
}
.sidebar-hero-status.offline .sidebar-hero-status-dot {
  background: var(--text-dim);
}
.sidebar-hero-stats {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-dim);
}
.sidebar-hero-stats strong {
  color: var(--gold);
  font-weight: 700;
}

.sidebar-section {
  margin-bottom: 14px;
}
.sidebar-section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inline "link-style" button inside the auto-trading note. Reset
   button defaults so it reads as a hyperlink. */
.sidebar-autotrade-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
}
.sidebar-autotrade-link:hover {
  color: var(--gold);
}

/* Sidebar footer — secondary navigation below the primary sections. */
.sidebar-dash-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.sidebar-dash-footer .sidebar-dash-link {
  margin-bottom: 0;
}

/* Companion sidebar block — title + compact state pill on one row. */
.sidebar-companion-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.sidebar-companion-header-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
.sidebar-companion-header-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
}
.sidebar-companion-header-pills .companion-mode-pill,
.sidebar-companion-header-pills .companion-area-pill,
.sidebar-companion-header-pills .companion-driver-pill {
  margin-left: 0;
}
.sidebar-companion-header .sidebar-section-title {
  margin: 0;
  padding: 0;
  border: none;
}
.sidebar-companion-header .sidebar-companion-state {
  font-size: 11px;
}

/* Compact creature list for sidebar */
.sidebar-creature {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: 6px;
  font-size: 11px;
  transition: background 0.15s;
}
.sidebar-creature:hover {
  background: var(--surface2);
}
.sidebar-creature-sprite {
  width: 24px;
  height: 24px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.sidebar-creature-info {
  flex: 1;
  min-width: 0;
}
.sidebar-creature-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-creature-meta {
  font-size: 10px;
  color: var(--text-dim);
}
.sidebar-creature-hp {
  width: 50px;
  height: 4px;
  background: #1a1d28;
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-creature-hp-fill {
  height: 100%;
  border-radius: 2px;
}

/* Sidebar Team section — mirrors the /dashboard Team block so the
   reorder buttons, sprite, name, and HP bar render identically.
   The .creature-row styles live above; these rules re-apply the
   dashboard-scoped sizes for the `#sidebar-team` context (which
   doesn't get body.page-dashboard). */
.sidebar-team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sidebar-team-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sidebar-team-btn {
  padding: 6px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1;
}
.sidebar-team-btn .compendium-summary-stat {
  margin-left: 0;
  font-size: 12px;
  line-height: 1;
  color: inherit;
  opacity: 0.75;
}
#sidebar-team .creature-emoji {
  font-size: 24px;
  width: 36px;
  text-align: center;
}
#sidebar-team .creature-sprite {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}
#sidebar-team .creature-name {
  font-weight: 600;
  font-size: 13px;
}
#sidebar-team .creature-meta {
  font-size: 11px;
  color: var(--text-dim);
}
#sidebar-team .hp-bar-container {
  width: 70px;
  height: 6px;
  background: #1a1d28;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-team-msg {
  margin-top: 6px;
  font-size: 12px;
  color: var(--green);
}
.sidebar-team-msg.err {
  color: var(--red);
}

/* Compact activity for sidebar */
.sidebar-activity {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-activity-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 3px 4px;
  font-size: 11px;
  line-height: 1.4;
  border-radius: 4px;
}
.sidebar-activity-item:hover {
  background: var(--surface2);
}
.sidebar-activity-icon {
  font-size: 10px;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}
.sidebar-activity-text {
  flex: 1;
  color: var(--text-dim);
}
.sidebar-activity-time {
  font-size: 9px;
  color: #444;
  white-space: nowrap;
}

/* Sidebar invite */
.sidebar-invite-buttons {
  display: flex;
  gap: 8px;
}
.sidebar-invite-btn {
  flex: 1;
  padding: 6px 0;
  font-size: 12px;
  justify-content: center;
}
.sidebar-invite-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.sidebar-invite-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-dim);
}
.sidebar-invite-note a {
  color: var(--gold);
  text-decoration: underline;
}
.sidebar-invite-active {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 11px;
}
.sidebar-invite-active input {
  width: 100%;
  padding: 5px 8px;
  margin: 6px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent);
  font-size: 11px;
  font-family: monospace;
  outline: none;
}
.sidebar-invite-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.sidebar-invite-actions button {
  flex: 1;
  padding: 4px 0;
  font-size: 11px;
  justify-content: center;
}
.sidebar-invite-waiting {
  color: var(--text-dim);
  font-size: 10px;
  margin-top: 4px;
}

.sidebar-dash-empty {
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
  font-style: italic;
}
.sidebar-dash-link {
  display: block;
  text-align: center;
  padding: 8px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition:
    border-color 0.2s,
    background 0.2s;
}
.sidebar-dash-link:hover {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.06);
}
.sidebar-dash-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.sidebar-dash-links .sidebar-dash-link {
  margin-bottom: 0;
}
.sidebar-dash-link-help {
  background: rgba(56, 189, 248, 0.08);
  border-style: dashed;
}
/* Legacy class kept for any remaining callers. */
.sidebar-dash-link-secondary {
  color: var(--text-dim, #9ca3af);
  margin-top: -6px;
}
.sidebar-dash-link-secondary:hover {
  color: var(--accent);
}
.welcome-tutorial-link {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px dashed rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  color: var(--text-dim, #9ca3af);
  font-size: 13px;
  line-height: 1.45;
}
.welcome-tutorial-link a {
  color: var(--accent, #38bdf8);
  font-weight: 600;
  text-decoration: none;
}
.welcome-tutorial-link a:hover {
  text-decoration: underline;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Login page
   ═══════════════════════════════════════════════════════════════════════════ */

body.page-login {
  height: auto;
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100vh;
}

.page-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  max-width: 1000px;
  margin: 0 auto;
  min-height: calc(100vh - 40px);
  padding-top: 20px;
}

/* Loading spinner */
.login-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 300px;
  width: 100%;
  max-width: 400px;
}
.login-loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.login-loading-text {
  color: var(--text-dim);
  font-size: 14px;
}

/* Login card */
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  flex: 1 1 360px;
}

/* Hero branding */
.login-hero {
  text-align: center;
  margin-bottom: 28px;
}
.login-hero-sprites {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  margin-bottom: 16px;
  height: 56px;
}
.login-hero-sprites img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.4));
}
.login-hero-sprites img:nth-child(1) {
  width: 40px;
  height: 40px;
}
.login-hero-sprites img:nth-child(2) {
  width: 56px;
  height: 56px;
}
.login-hero-sprites img:nth-child(3) {
  width: 40px;
  height: 40px;
}
.login-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
}
.login-logo a {
  color: var(--gold);
  text-decoration: none;
  display: inline-block;
}
.login-logo img {
  height: 56px;
  width: auto;
  display: block;
  image-rendering: auto;
}
.login-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 4px;
}

/* Form elements */
.login-card label {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-card input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.login-card input[type="email"]:focus {
  border-color: var(--accent);
}

#submit-btn {
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
#submit-btn:hover {
  background: #f59e0b;
}
#submit-btn:disabled {
  background: #4b5563;
  color: var(--text-dim);
  cursor: not-allowed;
}

.message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  text-align: center;
  display: none;
}
.message.success {
  display: block;
  background: #064e3b;
  color: #6ee7b7;
  border: 1px solid #065f46;
}
.message.error {
  display: block;
  background: #450a0a;
  color: #fca5a5;
  border: 1px solid #7f1d1d;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 20px;
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  padding: 0;
  font-family: inherit;
}
.back-link:hover {
  text-decoration: underline;
  background: none;
}

/* Sent state */
.sent-state {
  display: none;
  text-align: center;
}
.sent-state.visible {
  display: block;
}
.sent-icon {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 16px;
}
.sent-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}
.sent-body {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.sent-email {
  color: var(--gold);
  font-weight: 500;
  word-break: break-all;
}
.sent-hint {
  color: #6b7280;
  font-size: 12px;
  margin-top: 16px;
}

/* Join card (login page) */
.join-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 440px;
  flex: 1 1 400px;
}
.join-card h2 {
  color: var(--gold);
  font-size: 18px;
  margin-bottom: 14px;
  text-align: center;
}
.join-blurb {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  margin-bottom: 18px;
  line-height: 1.5;
}
.join-card label {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.join-card input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.join-card input[type="email"]:focus {
  border-color: var(--accent);
}
#join-btn {
  width: 100%;
  padding: 12px;
  margin-top: 20px;
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
#join-btn:hover {
  background: #f59e0b;
}
#join-btn:disabled {
  background: #4b5563;
  color: var(--text-dim);
  cursor: not-allowed;
}

.join-agent-details {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.join-agent-details > summary {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  list-style: none;
  padding: 4px 0;
  user-select: none;
  transition: color 0.15s;
}
.join-agent-details > summary::-webkit-details-marker {
  display: none;
}
.join-agent-details > summary::before {
  content: "▸ ";
  display: inline-block;
  margin-right: 4px;
  transition: transform 0.15s;
}
.join-agent-details[open] > summary::before {
  transform: rotate(90deg);
}
.join-agent-details > summary:hover {
  color: var(--accent);
}
.join-agent-details[open] > summary {
  margin-bottom: 14px;
}

/* Login responsive */
@media (max-width: 600px) {
  body.page-login {
    padding: 12px;
  }
  .login-card,
  .join-card {
    padding: 24px;
  }
  .login-hero-sprites img:nth-child(1),
  .login-hero-sprites img:nth-child(3) {
    width: 32px;
    height: 32px;
  }
  .login-hero-sprites img:nth-child(2) {
    width: 44px;
    height: 44px;
  }
  .login-hero-sprites {
    height: 44px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Dashboard page
   ═══════════════════════════════════════════════════════════════════════════ */

body.page-dashboard {
  height: auto;
  overflow: auto;
  display: block;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo {
  color: var(--gold);
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.topbar-logo img {
  height: 32px;
  width: auto;
  display: block;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-name {
  color: var(--text-dim);
  font-size: 14px;
}

/* Gear button — square icon-only trigger for the Settings modal.
   `.btn.topbar-gear-btn` to out-specify the plain `.btn` rule below
   (which otherwise wins on source order and shrinks the glyph). */
.btn.topbar-gear-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}

/* Settings modal — reuses .modal-overlay / .modal. Slightly wider so
   the agent-token row doesn't wrap on desktop. */
.settings-modal-box {
  max-width: 640px;
}
.settings-modal-header {
  margin-bottom: 10px;
  padding-right: 40px; /* room for the close button */
}
.settings-modal-header h2 {
  margin: 0;
}
/* Drop the bottom border off the last settings group inside the
   modal (the original inline layout used it as a divider between
   stacked groups). */
.settings-modal-box .settings-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

/* Shared button system */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  line-height: 1;
}
.btn-primary {
  background: var(--gold);
  color: var(--bg);
}
.btn-primary:hover {
  background: #f59e0b;
}
.btn-danger {
  background: #dc2626;
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover {
  background: #333750;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px;
}

/* ─── Hero card ───────────────────────────────────────────────────────────── */

.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.hero-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.1);
}
.hero-card::after {
  content: "View on map \2192";
  position: absolute;
  right: 20px;
  bottom: 12px;
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.2s;
}
.hero-card:hover::after {
  opacity: 1;
}

.hero-sprite {
  flex-shrink: 0;
  width: 80px;
  height: 120px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--surface2);
  border-radius: 10px;
  border: 2px solid var(--border);
  padding: 8px 4px 4px;
}
.hero-sprite img {
  width: 64px;
  height: 96px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.hero-info {
  flex: 1;
  min-width: 0;
}
.hero-name {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.2;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.hero-status.exploring {
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
}
.hero-status.battling {
  background: rgba(248, 113, 113, 0.12);
  color: var(--red);
}
.hero-status.offline {
  background: rgba(107, 114, 128, 0.15);
  color: var(--text-dim);
}

.hero-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hero-status.exploring .hero-status-dot {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
  animation: heroPulse 1.5s ease-in-out infinite;
}
.hero-status.battling .hero-status-dot {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
  animation: heroBlink 0.6s infinite;
}
.hero-status.offline .hero-status-dot {
  background: var(--text-dim);
}

@keyframes heroPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}
@keyframes heroBlink {
  50% {
    opacity: 0.3;
  }
}

.hero-location {
  font-size: 13px;
  color: var(--text-dim);
}
.hero-location strong {
  color: var(--text);
}

.hero-stats-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.hero-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
}
.hero-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

/* Companion strip inside the hero card — compact snapshot of who's driving +
   stamina. Full controls live in the Companion section below. */
.hero-companion {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border, #252838);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hero-companion-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-companion-state {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.hero-companion-state[data-driver="bot"] {
  color: #38bdf8;
}
.hero-companion-state[data-driver="agent"] {
  color: #22c55e;
}
.hero-companion-state[data-driver="paused"] {
  color: #fbbf24;
}
.hero-companion-state[data-driver="drained"] {
  color: #ef4444;
}
.hero-companion-sub {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.45;
}
.hero-companion-stamina {
  margin-top: 4px;
  max-width: 320px;
}

/* ─── Dashboard two-column layout ─────────────────────────────────────────── */

.dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.dash-col {
  min-width: 0;
}

/* Half-width row under Team — Shop card + Companion card side by
   side. align-items: stretch so the two cards line up at the same
   height even when their contents differ. */
.dash-quick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 24px;
}
.dash-quick-row > .section {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ─── Dashboard sections ──────────────────────────────────────────────────── */

body.page-dashboard .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
body.page-dashboard .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
body.page-dashboard .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gold);
}

.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
.section h2 {
  color: var(--accent);
  font-size: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.creature-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.creature-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
}
/* Dashboard overrides for shared class names (spectator defines smaller sizes) */
body.page-dashboard .creature-emoji {
  font-size: 24px;
  width: 36px;
  height: auto;
  text-align: center;
}
body.page-dashboard .creature-sprite {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}
body.page-dashboard .creature-name {
  font-weight: 600;
  font-size: 14px;
}
body.page-dashboard .creature-meta {
  font-size: 12px;
  color: var(--text-dim);
}
.team-order-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  margin-right: 4px;
}
.team-order-btn {
  width: 28px;
  padding: 2px 0;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 4px;
  color: var(--text-dim, #9ca3af);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s;
}
.team-order-btn:hover:not(:disabled) {
  color: var(--text, #e0e0e0);
  border-color: var(--accent, #38bdf8);
}
.team-order-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.team-order-btn.team-order-lead {
  font-size: 10px;
  font-weight: 600;
  width: auto;
  padding: 2px 6px;
}
body.page-dashboard .hp-bar-container {
  width: 100px;
  height: 8px;
  background: var(--border);
}
body.page-dashboard .hp-bar {
  height: 100%;
}
.hp-high {
  background: var(--green);
}
.hp-mid {
  background: var(--gold);
}
.hp-low {
  background: var(--red);
}

/* Storage swap UI - compact tiles in an auto-fill grid so the PC box can
   show many creatures at once. Lives inside a modal. */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.section-header h2 {
  margin: 0 0 16px 0;
}
.storage-modal-box {
  max-width: 880px;
}
.storage-subhead {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 8px 0;
}
.storage-hint {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 12px 0;
}
.storage-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}
.storage-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 6px;
  background: var(--surface2);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
  text-align: center;
  position: relative;
}
.storage-tile.locked {
  background: rgba(248, 113, 113, 0.08);
}
.storage-tile-lock {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition:
    opacity 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.storage-tile-lock:hover {
  opacity: 1;
  border-color: var(--gold);
}
.storage-tile-lock.locked {
  opacity: 1;
  color: var(--red);
  border-color: var(--red);
  background: rgba(248, 113, 113, 0.12);
}
.storage-tile:hover {
  border-color: var(--border);
}
.storage-tile.selected {
  border-color: var(--gold);
  background: rgba(234, 179, 8, 0.1);
}
.storage-tile.disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.storage-tile img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: pixelated;
}
.storage-tile-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--text);
  word-break: break-word;
}
.storage-tile-meta {
  font-size: 11px;
  color: var(--text-dim);
}
.storage-tile-hp {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.storage-tile-hp-fill {
  height: 100%;
  border-radius: 2px;
}
.storage-empty {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--text-dim);
  padding: 10px 12px;
  background: var(--surface2);
  border-radius: 8px;
  text-align: center;
}
.storage-message-error {
  color: var(--red);
}
.storage-message-success {
  color: var(--green);
}
.storage-deposit-bar {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.storage-deposit-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.storage-deposit-btn:hover:not(:disabled) {
  border-color: var(--gold);
  background: rgba(234, 179, 8, 0.1);
}
.storage-deposit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Dashboard trade/battle modal - promotes the private-room flow from the
   Trade/Battle buttons and from deep-link routes (/dashboard/trade,
   /dashboard/battle, /invite). Auto-opens when a room is active. */
.dash-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 24px;
  z-index: 100;
  overflow-y: auto;
}
.dash-modal-box {
  position: relative;
  background: #13151f;
  border: 1px solid #252838;
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  padding: 24px 24px 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}
.dash-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: none;
  color: #9ca3af;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.dash-modal-close:hover {
  background: #1a1d2b;
  color: #e0e0e0;
}
.dash-modal-close:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.dash-modal-title {
  margin: 0 0 4px;
  font-size: 20px;
  color: #fbbf24;
}
.dash-modal-subtitle {
  color: #9ca3af;
  font-size: 13px;
  margin-bottom: 16px;
}

.token-section {
  margin-top: 0;
}
.token-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.token-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.warning {
  background: #451a03;
  border: 1px solid #78350f;
  color: var(--gold);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-top: 12px;
}

.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-dim);
  font-size: 16px;
}

.badge-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.badge-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--gold);
}

.stats-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 14px;
}
.stats-row span {
  color: var(--text-dim);
}
.stats-row strong {
  color: var(--text);
}

/* Compendium header — Caught / Seen / Completion row. Lives inside
   the shared modal, so the rule is global (not scoped to
   body.page-dashboard) so it renders the same on / and /dashboard. */
.compendium-header {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.compendium-header > span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.compendium-header strong {
  color: var(--gold);
  font-weight: 700;
}
.compendium-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 16px;
}
.compendium-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 0.4s;
}

.compendium-filter {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.compendium-filter.active {
  background: #1e293b;
  border-color: var(--accent);
  color: var(--accent);
}

body.page-dashboard .compendium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}

.dex-slot {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 4px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
  position: relative;
  min-height: 96px;
}
.dex-slot.caught {
  border-color: var(--green);
  background: #102018;
}
.dex-slot.seen {
  border-color: #3b4b6b;
}
.dex-slot.unseen {
  opacity: 0.55;
}

.dex-num {
  font-size: 10px;
  color: #6b7280;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.dex-slot.caught .dex-num {
  color: var(--green);
}

.dex-sprite {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  object-fit: contain;
}
.dex-sprite.silhouette {
  filter: brightness(0) saturate(100%);
}

.dex-placeholder {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #374151;
  font-size: 22px;
  font-weight: 700;
}

.dex-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.dex-slot.seen .dex-name,
.dex-slot.unseen .dex-name {
  color: #6b7280;
}

.dex-type {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  padding: 1px 5px;
  background: var(--border);
  border-radius: 3px;
}
.dex-caught-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.6);
}
.dex-empty {
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

/* Collapsible sections */
.section.collapsible {
  cursor: default;
}
.section.collapsible > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.section.collapsible > summary::-webkit-details-marker {
  display: none;
}
.section.collapsible > summary h2 {
  display: flex;
  align-items: center;
  gap: 8px;
}
.section.collapsible > summary h2::before {
  content: "\25B6";
  font-size: 10px;
  color: var(--text-dim);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.section.collapsible[open] > summary h2::before {
  transform: rotate(90deg);
}
.compendium-summary-stat {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: auto;
}

/* Team section header actions — Compendium + Manage Storage. The
   Compendium button shows its caught/total pill inline. */
.team-header-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
#compendium-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  line-height: 1;
}
#compendium-open-btn .compendium-summary-stat {
  margin-left: 0;
  font-size: 13px;
  line-height: 1;
  color: inherit;
  opacity: 0.75;
}

/* Compendium modal — wide so the dex grid breathes, and pinned to
   a fixed 85vh height so switching filters (All → Caught → Unseen)
   doesn't collapse the modal around a shorter grid. The grid itself
   scrolls inside the modal via .modal's overflow-y: auto. */
.compendium-modal-box {
  max-width: 960px;
  width: 90%;
  height: 85vh;
}
.compendium-modal-header {
  margin-bottom: 14px;
  padding-right: 40px; /* room for the close button */
}
.compendium-modal-header h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Settings groups inside a collapsible section */
.settings-group {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.settings-group:first-of-type {
  padding-top: 8px;
}
.settings-group:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}
.settings-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  text-transform: none;
  letter-spacing: 0;
}

/* ── Companion section (dashboard) ───────────────────────────────────────── */
.companion-driver-pill {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 999px;
  background: var(--surface2, #1a1d2b);
  color: var(--text-dim, #9ca3af);
  border: 1px solid var(--border, #252838);
  vertical-align: middle;
}
.companion-driver-pill.is-clickable {
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
}
.companion-driver-pill.is-clickable:hover {
  filter: brightness(1.25);
  transform: translateY(-1px);
}
.companion-driver-pill.is-clickable:active {
  transform: translateY(0);
}
.companion-driver-pill[data-driver="bot"] {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.companion-driver-pill[data-driver="agent"] {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.4);
}
.companion-driver-pill[data-driver="paused"] {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
}
.companion-driver-pill[data-driver="idle-waiting"] {
  background: rgba(156, 163, 175, 0.12);
  color: #9ca3af;
}

/* Mode + area pills — sit next to the driver pill, click to open the
   Companion configure modal. Empty (no textContent) → hidden. */
.companion-mode-pill,
.companion-area-pill {
  display: none;
  margin-left: 6px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 999px;
  background: var(--surface2, #1a1d2b);
  color: var(--text-dim, #9ca3af);
  border: 1px solid var(--border, #252838);
  vertical-align: middle;
  cursor: pointer;
  transition:
    filter 0.15s ease,
    transform 0.15s ease;
}
.companion-mode-pill:not(:empty),
.companion-area-pill:not(:empty) {
  display: inline-block;
}
.companion-mode-pill:hover,
.companion-area-pill:hover {
  filter: brightness(1.25);
  transform: translateY(-1px);
}
.companion-mode-pill:active,
.companion-area-pill:active {
  transform: translateY(0);
}
.companion-mode-pill {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border-color: rgba(168, 85, 247, 0.4);
}
.companion-area-pill {
  background: rgba(244, 114, 182, 0.15);
  color: #f472b6;
  border-color: rgba(244, 114, 182, 0.4);
}

/* Stamina meter — shared by the dashboard hero card and the sidebar. */
.companion-stamina {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.companion-stamina-bar {
  height: 6px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 3px;
  overflow: hidden;
}
.companion-stamina-fill {
  height: 100%;
  width: 100%;
  background: #22c55e;
  transition: width 1s ease, background 0.3s ease;
}
.companion-stamina-fill[data-level="mid"] {
  background: #fbbf24;
}
.companion-stamina-fill[data-level="low"] {
  background: #ef4444;
}
/* Rest-stop flash: bar extends via the width transition above, then
   this animation pulses brightness once the extension lands. The
   0.5s delay matches the width transition so the flash hits at the
   end of the fill. */
.companion-stamina-fill.is-resting {
  animation: stamina-rest-flash 1.3s ease-out 1s 1;
}
/* Confetti burst from the Rest button. JS spawns these as fixed-
   position children of <body> at the button center and animates
   each one outward via the Web Animations API. */
.confetti-piece {
  position: fixed;
  width: 8px;
  height: 12px;
  border-radius: 1px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}
@keyframes stamina-rest-flash {
  0% {
    filter: brightness(1) saturate(1);
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  }
  35% {
    filter: brightness(1.85) saturate(1.4);
    box-shadow: inset 0 0 10px 2px rgba(255, 255, 255, 0.75);
  }
  100% {
    filter: brightness(1) saturate(1);
    box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0);
  }
}
.companion-stamina-label {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.companion-stamina-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.companion-stamina-refill {
  padding: 4px 10px;
  font-size: 11px;
}

/* Dashboard Companion section — compact since the strategy UI
   moved into the shared modal. Head = title + driver pill; the
   Configure button sits alongside Enable/Pause/Resume in the
   .companion-actions row below. */
.companion-section-compact .companion-section-head {
  margin-bottom: 0;
}
.companion-section-compact .companion-section-head h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Companion modal — wider than the default .modal so the area
   details card and gym team list fit without wrapping. Reuses
   .modal-overlay / .modal base styles. */
.companion-modal-box {
  max-width: 760px;
}
.companion-modal-header {
  margin-bottom: 14px;
  padding-right: 40px; /* leave room for the close button */
}
.companion-modal-header h2 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.companion-modal-blurb {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
}

/* Sidebar companion "Configure" button — sits beside the play/pause icon
   button on the same row; Configure takes the remaining space so it
   reads as the dominant action. */
.sidebar-companion-configure {
  flex: 1;
}

/* Primary action bar */
.companion-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.companion-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  min-height: 38px;
  box-sizing: border-box;
}
.companion-action-icon {
  font-size: 11px;
  line-height: 1;
  opacity: 0.9;
}

/* Inline status messages */
.companion-inline-msg {
  margin: 6px 0 14px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}
.companion-inline-msg.err {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* Strategy block */
.companion-strategy {
  padding-top: 14px;
  border-top: 1px solid var(--border, #252838);
}
.companion-strategy-header {
  margin-bottom: 12px;
}
.companion-strategy-blurb {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  margin: 0;
}
.companion-config-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 14px;
}
.companion-config-field {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 14px;
}
.companion-config-field-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.companion-config-field-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.companion-config-field-default {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}
.companion-config-field-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.companion-config-field-hint {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.35;
}
.companion-config-field input[type="text"],
.companion-config-field input[type="number"] {
  padding: 7px 10px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.companion-config-field input:focus {
  border-color: var(--accent, #38bdf8);
}
.companion-config-field input::placeholder {
  color: #4b5563;
  font-style: italic;
}
.companion-config-field-dim {
  opacity: 0.55;
}
.companion-config-field-override {
  color: #fbbf24 !important;
  font-style: italic;
}
.companion-config-towns {
  display: flex;
  gap: 8px;
}
.companion-config-towns input {
  flex: 1;
}
.companion-config-slider-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.companion-config-slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent, #38bdf8);
}
.companion-config-slider-row .companion-config-slider-value {
  min-width: 48px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: var(--text, #e0e0e0);
}
.companion-config-slider-row .companion-config-clear {
  background: none;
  border: none;
  color: var(--text-dim, #9ca3af);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.companion-config-slider-row .companion-config-clear:hover {
  color: var(--text, #e0e0e0);
}
/* ── Companion rescue (pending blackout / lockout) ─────────────────────── */
.companion-rescue {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.companion-rescue-msg {
  font-size: 13px;
  color: var(--text, #e0e0e0);
  line-height: 1.4;
}
.companion-rescue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.companion-rescue-hint {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}

/* ── Rest stop modal (shared between dashboard + in-game) ────────── */
.rest-stop-modal {
  max-width: 420px;
}
.rest-stop-modal-box {
  max-width: 420px;
}
.rest-stop-body {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text, #e0e0e0);
}
.rest-stop-list {
  margin: 0 0 16px;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.6;
}
.rest-stop-lockout {
  margin: 0 0 14px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-left-width: 3px;
  border-radius: 5px;
  font-size: 12px;
  color: #fca5a5;
  line-height: 1.45;
}
.rest-stop-lockout strong {
  color: #fff;
}
.rest-stop-suppress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  cursor: pointer;
  user-select: none;
  margin-bottom: 14px;
}
.rest-stop-suppress input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent, #38bdf8);
}
.rest-stop-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Dashboard shop ──────────────────────────────────────────────── */
/* Compact shop section on /dashboard — the full grid moved into
   the shared Shop modal. Title + gold pill on the first row;
   "Open shop" button drops below the text. */
.shop-section-compact .shop-section-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 0;
}
.shop-section-compact .shop-section-head h2 {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.shop-open-btn {
  align-self: flex-start;
}

/* Shop modal — wider than the default .modal so item cards fit in
   a comfortable grid. Reuses .modal-overlay / .modal base styles. */
.shop-modal-box {
  max-width: 860px;
}
.shop-modal-header {
  margin-bottom: 14px;
  padding-right: 40px; /* room for the close button */
}
.shop-modal-header h2 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.shop-modal-blurb {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
}

/* Sidebar Shop button — the gold pill lives inside the button so
   the player sees their balance without opening the modal. */
.sidebar-shop-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.shop-blurb {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  margin: 0 0 12px;
  line-height: 1.4;
}
.shop-gold-pill {
  display: inline-block;
  margin-left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #2a1f06;
  border: 1px solid #6b4a0e;
  color: #facc15;
  font-size: 12px;
  font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.shop-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.shop-filter-btn {
  padding: 5px 11px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text-dim, #9ca3af);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.shop-filter-btn:hover {
  color: var(--text, #e0e0e0);
  border-color: #3a3f55;
}
.shop-filter-btn.active {
  background: var(--accent, #38bdf8);
  border-color: var(--accent, #38bdf8);
  color: #0b0d14;
  font-weight: 600;
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 6px;
}
.shop-empty {
  grid-column: 1 / -1;
  padding: 16px;
  text-align: center;
  color: var(--text-dim, #9ca3af);
  font-size: 13px;
}
.shop-empty.err {
  color: #f87171;
}
.shop-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 10px;
  transition: border-color 0.12s;
}
.shop-card:hover {
  border-color: #3a3f55;
}
.shop-card.locked {
  opacity: 0.55;
}
.shop-card[data-rarity="emergency"] {
  background: linear-gradient(
    90deg,
    rgba(239, 68, 68, 0.08),
    rgba(239, 68, 68, 0)
  );
}
.shop-card[data-rarity="emergency"] .shop-card-rarity {
  color: #fca5a5;
  font-weight: 700;
}
.shop-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.shop-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}
.shop-card-owned {
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 999px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.shop-card-inbag {
  margin-left: auto;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
}
.shop-card-price {
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #facc15;
  white-space: nowrap;
}
.shop-card.locked .shop-card-price {
  color: #9ca3af;
}
.shop-card-meta {
  display: flex;
  gap: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim, #9ca3af);
}
.shop-card-rarity {
  font-weight: 600;
}
.shop-card-desc {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.4;
}
.shop-card-lock {
  font-size: 11px;
  color: #f59e0b;
  font-style: italic;
}
.shop-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border, #252838);
}
.shop-card-qty {
  width: 60px;
  padding: 5px 8px;
  background: #0b0d14;
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 13px;
  outline: none;
}
.shop-card-qty:focus {
  border-color: var(--accent, #38bdf8);
}
.shop-card-buy {
  flex: 1;
}
.shop-card.unaffordable .shop-card-price {
  color: #f87171;
}

.companion-config-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.companion-config-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.companion-config-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border, #252838);
  transition: background 0.15s;
}
.companion-config-toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e0e0e0;
  transition: transform 0.15s;
}
.companion-config-toggle-input:checked + .companion-config-toggle-track {
  background: var(--accent, #38bdf8);
}
.companion-config-toggle-input:checked + .companion-config-toggle-track::after {
  transform: translateX(16px);
}
.companion-config-toggle-input:focus-visible + .companion-config-toggle-track {
  outline: 2px solid var(--accent, #38bdf8);
  outline-offset: 2px;
}
.companion-config-toggle-text {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
}
.companion-config-area-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.companion-config-area-select {
  padding: 7px 10px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 13px;
  outline: none;
  min-width: 220px;
}
.companion-config-area-select:focus {
  border-color: var(--accent, #38bdf8);
}
.companion-config-area-select option[disabled] {
  color: #4b5563;
  font-style: italic;
}
.companion-area-details {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
}
.companion-area-empty {
  padding: 10px 12px;
  background: var(--bg, #0b0d14);
  border: 1px dashed var(--border, #252838);
  border-radius: 6px;
  font-style: italic;
}
.companion-area-card {
  padding: 12px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.companion-area-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.companion-area-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #1a1d2b;
  border: 1px solid var(--border, #252838);
  color: var(--text-dim, #9ca3af);
}
.companion-area-pill-ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.4);
  color: #86efac;
}
.companion-area-pill-warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}
.companion-area-pill-locked {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.companion-area-pill-neutral {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
}
.companion-area-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text, #e0e0e0);
  line-height: 1.45;
}
.companion-area-meta {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}
.companion-area-section {
  padding: 8px 10px;
  background: rgba(15, 17, 26, 0.6);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.companion-area-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text, #e0e0e0);
}
.companion-area-gym-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.companion-area-gym-leader {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.companion-area-gym-title {
  font-size: 11px;
  font-style: italic;
  color: var(--text-dim, #9ca3af);
}
.companion-area-gym-team {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px;
  margin-top: 4px;
}
.companion-area-gym-member {
  padding: 6px 8px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.companion-area-gym-member-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.companion-area-gym-member-meta {
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
}
.companion-area-enc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.companion-area-enc {
  padding: 6px 8px;
  background: var(--bg, #0b0d14);
  border: 2px solid var(--border, #252838);
  border-radius: 5px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.companion-area-enc[data-rarity="common"] {
  border-color: #22c55e;
}
.companion-area-enc[data-rarity="uncommon"] {
  border-color: #3b82f6;
}
.companion-area-enc[data-rarity="rare"] {
  border-color: #a855f7;
}
.companion-area-enc[data-rarity="legendary"] {
  border-color: #f97316;
}
.companion-area-enc-sprite {
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.companion-area-enc-sprite-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a1d2b;
  border: 1px solid var(--border, #252838);
  border-radius: 4px;
  color: var(--text-dim, #9ca3af);
  font-weight: 700;
  font-size: 14px;
  font-style: italic;
}
.companion-area-enc-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.companion-area-enc.unknown .companion-area-enc-name {
  color: var(--text-dim, #9ca3af);
  font-style: italic;
}
.companion-area-enc.caught .companion-area-enc-state {
  color: #86efac;
}
.companion-area-enc-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.companion-area-enc-meta {
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
  text-transform: lowercase;
}
.companion-area-enc-state {
  font-size: 10px;
  color: var(--text-dim, #9ca3af);
  font-weight: 600;
}
.companion-config-mode {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.companion-config-mode-btn {
  padding: 6px 12px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text-dim, #9ca3af);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.companion-config-mode-btn:hover {
  color: var(--text, #e0e0e0);
  border-color: #3a3f55;
}
.companion-config-mode-btn.active {
  background: var(--accent, #38bdf8);
  border-color: var(--accent, #38bdf8);
  color: #0b0d14;
}
.companion-config-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 640px) {
  .companion-config-field {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* ── Welcome / onboarding page ─────────────────────────────────────── */
.welcome-loading {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--text-dim, #9ca3af);
  font-size: 14px;
}
.welcome-shell {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg, #0b0d14);
}
.welcome-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface, #11141f);
  border: 1px solid var(--border, #252838);
  border-radius: 14px;
  padding: 36px 36px 30px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}
.welcome-header {
  text-align: center;
  margin-bottom: 26px;
}
.welcome-header .login-logo img {
  width: 220px;
  height: auto;
  max-width: 100%;
  margin: 0 auto;
}
.welcome-title {
  font-size: 26px;
  margin: 14px 0 4px;
  color: var(--text, #e0e0e0);
}
.welcome-subtitle {
  color: var(--text-dim, #9ca3af);
  font-size: 14px;
  margin: 0 0 16px;
}
.welcome-steps {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 6px;
}
#welcome-steps .welcome-step {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface2, #1a1d2b);
  border: 1px solid var(--border, #252838);
  color: var(--text-dim, #9ca3af);
}
#welcome-steps .welcome-step.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
}
#welcome-steps .welcome-step.done {
  background: rgba(34, 197, 94, 0.15);
  border-color: rgba(34, 197, 94, 0.4);
  color: #22c55e;
}
.welcome-step-panel {
  padding: 24px 0 8px;
  border-top: 1px solid var(--border, #252838);
}
.welcome-step-panel h2 {
  margin: 0 0 6px;
  font-size: 19px;
  color: var(--text, #e0e0e0);
}
.welcome-blurb {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.5;
}
.welcome-hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
}
.welcome-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #252838);
  font-size: 13px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.55;
}
.welcome-footer h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.welcome-footer ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.welcome-footer strong {
  color: var(--text, #e0e0e0);
}
.welcome-footer code {
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  color: var(--accent, #38bdf8);
}
.welcome-footer a {
  color: var(--accent, #38bdf8);
  text-decoration: none;
}
.welcome-footer a:hover {
  text-decoration: underline;
}
.welcome-name-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.welcome-name-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 8px;
  color: var(--text, #e0e0e0);
  font-size: 15px;
  outline: none;
}
.welcome-name-row input:focus {
  border-color: var(--accent, #38bdf8);
}
.welcome-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}
.welcome-actions .btn-secondary {
  margin-right: auto;
}
.welcome-msg {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #22c55e;
}
.welcome-msg.err {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #ef4444;
}
.welcome-sprite-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}
.welcome-sprite-tile {
  background: var(--surface2, #1a1d2b);
  border: 2px solid var(--border, #252838);
  border-radius: 10px;
  padding: 10px 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.welcome-sprite-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.4);
}
.welcome-sprite-tile.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}
.welcome-sprite-img {
  width: 32px;
  height: 48px;
  image-rendering: pixelated;
}
.welcome-sprite-name {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
}
.welcome-sprite-tile.selected .welcome-sprite-name {
  color: #38bdf8;
}
.welcome-starter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.welcome-starter-tile {
  background: var(--surface2, #1a1d2b);
  border: 2px solid var(--border, #252838);
  border-radius: 10px;
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.1s ease, border-color 0.15s ease;
  color: var(--text, #e0e0e0);
}
.welcome-starter-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.4);
}
.welcome-starter-tile.selected {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}
.welcome-starter-img {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
}
.welcome-starter-name {
  font-size: 17px;
  font-weight: 700;
}
.welcome-starter-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.welcome-starter-type.type-leaf {
  background: rgba(34, 197, 94, 0.18);
  color: #22c55e;
}
.welcome-starter-type.type-flame {
  background: rgba(239, 68, 68, 0.18);
  color: #fb7185;
}
.welcome-starter-type.type-aqua {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
}
.welcome-starter-desc {
  font-size: 12px;
  color: var(--text-dim, #9ca3af);
  line-height: 1.4;
}

/* ── Companion mini-controls on front-page sidebar ──────────────────────── */
.sidebar-companion {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-companion-state {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
}
.sidebar-companion-state[data-driver="bot"] {
  color: #38bdf8;
}
.sidebar-companion-state[data-driver="agent"] {
  color: #22c55e;
}
.sidebar-companion-state[data-driver="paused"] {
  color: #fbbf24;
}
.sidebar-companion-state[data-driver="drained"] {
  color: #ef4444;
}
.sidebar-companion-stamina {
  margin: 2px 0 4px;
}
.sidebar-companion-stamina .companion-stamina-label {
  font-size: 10px;
}
.sidebar-companion-buttons {
  display: flex;
  gap: 6px;
}
.sidebar-companion-btn {
  flex: 1;
  padding: 0 10px;
  font-size: 12px;
  line-height: 1;
  height: 32px;
  justify-content: center;
  box-sizing: border-box;
}
/* Icon variant — fixed square, same height so it lines up with
   Configure. Bigger glyph since the text label is gone. */
.sidebar-companion-icon {
  flex: 0 0 32px;
  width: 32px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}
.sidebar-companion-status {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sidebar-companion-status .companion-driver-pill {
  margin-left: 0;
  padding: 1px 8px;
  font-size: 10px;
}

/* ─── Activity feed ───────────────────────────────────────────────────────── */

.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface2);
  border-radius: 6px;
  font-size: 13px;
  animation: activitySlide 0.25s ease-out;
  border-left: 3px solid var(--border);
}
@keyframes activitySlide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.activity-item.act-catch {
  border-left-color: var(--green);
}
.activity-item.act-battle {
  border-left-color: var(--red);
}
.activity-item.act-level {
  border-left-color: var(--accent);
}
.activity-item.act-evolve {
  border-left-color: #a78bfa;
}
.activity-item.act-gym {
  border-left-color: var(--gold);
}
.activity-icon {
  font-size: 16px;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}
.activity-text {
  flex: 1;
  color: var(--text);
}
.activity-time {
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}
.activity-empty {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 12px;
  font-style: italic;
}

/* ─── In-room PvP battle UI ───────────────────────────────────────────────── */

.rbattle-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.rbattle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.rbattle-side {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rbattle-side-right {
  align-items: flex-end;
}
.rbattle-trainer {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
}
.rbattle-vs {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
}
.rbattle-roster {
  display: flex;
  gap: 3px;
}
.rbattle-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border);
  border: 1px solid transparent;
}
.rbattle-dot.active {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent);
}
.rbattle-dot.fainted {
  background: var(--red);
  opacity: 0.4;
}

.rbattle-canvas {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  image-rendering: pixelated;
  background: #0e1018;
}

.rbattle-hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rbattle-hud-card {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rbattle-hud-name {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.rbattle-hud-lvl {
  color: var(--text-dim);
  font-size: 11px;
}
.rbattle-hp-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rbattle-hp-label {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 700;
}
.rbattle-hp-track {
  flex: 1;
  height: 8px;
  background: #0b0d14;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.rbattle-hp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.rbattle-hp-num {
  font-size: 10px;
  color: var(--text-dim);
  font-family: monospace;
}

.rbattle-controls {
  min-height: 40px;
}
.rbattle-moves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rbattle-move-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition:
    border-color 0.15s,
    background 0.15s;
  text-align: left;
}
.rbattle-move-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1a1d2b;
}
.rbattle-move-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.rbattle-move-name {
  font-weight: 700;
  font-size: 13px;
}
.rbattle-move-meta {
  display: flex;
  gap: 8px;
  font-size: 11px;
  color: var(--text-dim);
}
.rbattle-move-type {
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}
.rbattle-waiting {
  padding: 10px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

.rbattle-narration {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  color: var(--text);
  min-height: 32px;
}

.rbattle-switch-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.rbattle-switch-btn:hover {
  border-color: var(--accent);
  background: #1a1d2b;
}

.rbattle-switch-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rbattle-switch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-dim);
}
.rbattle-switch-back {
  padding: 4px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.rbattle-switch-back:hover {
  border-color: var(--accent);
}
.rbattle-switch-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  font-style: italic;
}
.rbattle-switch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.rbattle-switch-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.rbattle-switch-card:hover {
  border-color: var(--accent);
  background: #1a1d2b;
}
.rbattle-switch-name {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
}
.rbattle-switch-lvl {
  color: var(--text-dim);
  font-size: 11px;
}
.rbattle-switch-type {
  align-self: flex-start;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.rbattle-log {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  scrollbar-width: thin;
}
.rbattle-log-entry {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  color: var(--text);
}
.rbattle-log-icon {
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.rbattle-conclusion {
  text-align: center;
  padding: 16px;
  border-radius: 8px;
}
.rbattle-conclusion.rbattle-win {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.rbattle-conclusion.rbattle-loss {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.3);
}
.rbattle-concl-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rbattle-win .rbattle-concl-title {
  color: var(--green);
}
.rbattle-loss .rbattle-concl-title {
  color: var(--red);
}
.rbattle-concl-detail {
  font-size: 13px;
  color: var(--text);
}

/* ─── Dashboard toast ─────────────────────────────────────────────────────── */

.dash-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: #16a34a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-12px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: none;
  z-index: 200;
}
.dash-toast.show {
  opacity: 1;
  transform: translateY(0);
}
.dash-toast.err {
  background: #dc2626;
}

/* ─── Dashboard responsive ────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .dash-columns {
    grid-template-columns: 1fr;
  }
  .dash-quick-row {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 600px) {
  .topbar {
    padding: 10px 14px;
  }
  .topbar-right {
    gap: 8px;
  }
  .topbar-name {
    display: none;
  }
  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }
  .container {
    padding: 16px 12px;
  }
  .hero-card {
    flex-direction: column;
    text-align: center;
    gap: 16px;
    padding: 20px;
  }
  .hero-sprite {
    width: 64px;
    height: 96px;
  }
  .hero-sprite img {
    width: 48px;
    height: 72px;
  }
  .hero-meta {
    justify-content: center;
  }
  .hero-stats-row {
    justify-content: center;
  }
  .hero-name {
    font-size: 20px;
  }
  .hero-card::after {
    display: none;
  }
  body.page-dashboard .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Tutorial page ─────────────────────────────────────────────── */
body.page-tutorial {
  background: var(--bg, #0b0d14);
  color: var(--text, #e0e0e0);
  font-size: 14px;
  line-height: 1.55;
  /* Override the global body lock (height:100vh; overflow:hidden) used
     by the map page so the tutorial can actually scroll. */
  height: auto;
  min-height: 100vh;
  overflow: auto;
  overscroll-behavior: auto;
  display: block;
}
.tutorial-shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 20px 80px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}
.tutorial-toc {
  position: sticky;
  top: 24px;
  padding: 14px 12px;
  background: #0f1118;
  border: 1px solid var(--border, #252838);
  border-radius: 10px;
}
.tutorial-toc-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim, #9ca3af);
  margin-bottom: 8px;
}
.tutorial-toc-filter {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 10px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 6px;
  color: var(--text, #e0e0e0);
  font-size: 12px;
  outline: none;
}
.tutorial-toc-filter:focus {
  border-color: var(--accent, #38bdf8);
}
.tutorial-toc nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tutorial-toc a {
  display: block;
  padding: 5px 8px;
  border-radius: 5px;
  color: var(--text-dim, #9ca3af);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.12s, background 0.12s;
}
.tutorial-toc a:hover {
  color: var(--text, #e0e0e0);
  background: rgba(56, 189, 248, 0.1);
}
.tutorial-main {
  min-width: 0;
}
.tutorial-hero {
  padding: 22px 24px;
  margin-bottom: 28px;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.08),
    rgba(168, 85, 247, 0.08)
  );
  border: 1px solid var(--border, #252838);
  border-radius: 12px;
}
.tutorial-hero h1 {
  margin: 0 0 8px;
  font-size: 26px;
  color: var(--text, #e0e0e0);
}
.tutorial-subtitle {
  margin: 0;
  color: var(--text-dim, #9ca3af);
  font-size: 14px;
  line-height: 1.55;
}
.tutorial-main section {
  margin-bottom: 36px;
  padding-top: 4px;
  scroll-margin-top: 16px;
}
.tutorial-main section h2 {
  margin: 0 0 10px;
  font-size: 20px;
  color: var(--text, #e0e0e0);
  border-bottom: 1px solid var(--border, #252838);
  padding-bottom: 6px;
}
.tutorial-main p {
  margin: 8px 0;
  color: var(--text-dim, #9ca3af);
}
.tutorial-main code {
  padding: 1px 6px;
  background: #1a1d2b;
  border: 1px solid var(--border, #252838);
  border-radius: 4px;
  font-size: 12px;
  color: #a5f3fc;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tutorial-main a {
  color: #38bdf8;
  text-decoration: none;
}
.tutorial-main a:hover {
  text-decoration: underline;
}
.tutorial-steps {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-dim, #9ca3af);
}
.tutorial-steps strong {
  color: var(--text, #e0e0e0);
}
.tutorial-list {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-dim, #9ca3af);
}
.tutorial-list strong,
.tutorial-list em {
  color: var(--text, #e0e0e0);
  font-style: normal;
}
.tutorial-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 8px;
  font-size: 13px;
  background: #0f1118;
  border: 1px solid var(--border, #252838);
  border-radius: 8px;
  overflow: hidden;
}
.tutorial-table thead {
  background: #151823;
}
.tutorial-table th,
.tutorial-table td {
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border, #252838);
}
.tutorial-table tbody tr:last-child td {
  border-bottom: none;
}
.tutorial-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim, #9ca3af);
  font-weight: 600;
}
.tutorial-table td {
  color: var(--text-dim, #9ca3af);
}
.tutorial-table td strong {
  color: var(--text, #e0e0e0);
}
.tutorial-table-wide th:first-child,
.tutorial-table-wide td:first-child {
  width: 180px;
}
.tutorial-table-wide td:last-child,
.tutorial-table-wide th:last-child {
  width: 110px;
  text-align: center;
}
.tutorial-note {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid rgba(245, 158, 11, 0.5);
  border-radius: 4px;
  color: #fbbf24;
  font-size: 12px;
}
.tutorial-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #252838);
}
.tutorial-footer p {
  color: var(--text-dim, #9ca3af);
  margin: 0 0 12px;
}
.tutorial-footer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
@media (max-width: 900px) {
  .tutorial-shell {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .tutorial-toc {
    position: static;
  }
  .tutorial-table-wide th:first-child,
  .tutorial-table-wide td:first-child {
    width: auto;
  }
}

/* ── Companion recent-activity panel ─────────────────────────────── */
.companion-recent-wrap {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--bg, #0b0d14);
  border: 1px solid var(--border, #252838);
  border-radius: 8px;
}
.companion-recent-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text, #e0e0e0);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  list-style: none;
}
.companion-recent-summary::-webkit-details-marker {
  display: none;
}
.companion-recent-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.12s;
  color: var(--text-dim, #9ca3af);
}
.companion-recent-wrap[open] .companion-recent-summary::before {
  transform: rotate(90deg);
}
.companion-recent-count {
  margin-left: 6px;
  font-weight: 400;
  color: var(--text-dim, #9ca3af);
  text-transform: none;
  letter-spacing: 0;
}
.companion-recent-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}
.companion-recent-empty {
  padding: 10px;
  text-align: center;
  color: var(--text-dim, #9ca3af);
  font-size: 12px;
  font-style: italic;
}
.companion-recent-row {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 8px;
  padding: 5px 8px;
  background: #0f1118;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.35;
}
.companion-recent-time {
  color: var(--text-dim, #9ca3af);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: nowrap;
}
.companion-recent-msg {
  color: var(--text, #e0e0e0);
  word-break: break-word;
}
.companion-recent-row.companion-recent-warn {
  border-left: 2px solid #facc15;
}
.companion-recent-row.companion-recent-error {
  border-left: 2px solid #ef4444;
  background: rgba(239, 68, 68, 0.06);
}

/* ── Team rotation info strip ────────────────────────────────────── */
.team-rotation-info {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  font-style: italic;
  padding-left: 4px;
}

/* ─── While You Were Out modal ─────────────────────────────────────────── */
.wywo-modal {
  max-width: 640px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
  padding: 0;
  background: linear-gradient(
    180deg,
    rgba(56, 189, 248, 0.08) 0%,
    var(--surface) 220px
  );
}

.wywo-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.wywo-hero-sprite {
  width: 64px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 12px;
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.15);
}
.wywo-hero-sprite img {
  width: 40px;
  height: 60px;
  image-rendering: pixelated;
  object-fit: contain;
}
.wywo-hero-text {
  flex: 1;
  min-width: 0;
}
.wywo-hero-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
}
.wywo-hero-title {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--text);
}
.wywo-hero-sub {
  font-size: 13px;
  color: var(--text-dim);
}

.wywo-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px 4px;
}
.wywo-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}
.wywo-stat-icon {
  font-size: 14px;
}
.wywo-stat-value {
  color: var(--accent);
}
.wywo-stat[data-tone="gold"] .wywo-stat-value {
  color: var(--gold);
}
.wywo-stat[data-tone="green"] .wywo-stat-value {
  color: var(--green);
}
.wywo-stat[data-tone="red"] .wywo-stat-value {
  color: var(--red);
}

.wywo-section {
  padding: 14px 24px 4px;
}
.wywo-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.wywo-section-icon {
  font-size: 16px;
}
.wywo-section-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text);
  background: var(--surface2);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* Badge cards — gym wins are the headline event, so they get the most space */
.wywo-badge-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.wywo-badge-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: linear-gradient(
    135deg,
    rgba(251, 191, 36, 0.12),
    rgba(251, 191, 36, 0.04)
  );
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 12px;
  box-shadow: 0 0 24px rgba(251, 191, 36, 0.08);
}
.wywo-badge-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  background: rgba(251, 191, 36, 0.15);
  border-radius: 50%;
  flex-shrink: 0;
}
.wywo-badge-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--gold);
  margin-bottom: 2px;
}
.wywo-badge-sub {
  font-size: 12px;
  color: var(--text-dim);
}

/* Creature catch grid — pixel sprites, "NEW!" pin on first compendium entries */
.wywo-creature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
}
.wywo-creature-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 6px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease;
}
.wywo-creature-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.wywo-creature-tile.is-new {
  border-color: rgba(52, 211, 153, 0.6);
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.15);
}
.wywo-creature-sprite {
  width: 56px;
  height: 56px;
  image-rendering: pixelated;
  margin-bottom: 4px;
}
.wywo-creature-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
  line-height: 1.2;
}
.wywo-creature-level {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}
.wywo-new-pin {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--green);
  color: #0b0d14;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(52, 211, 153, 0.4);
}

/* Evolution rows — from-sprite arrow to-sprite */
.wywo-evolve-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wywo-evolve-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.wywo-evolve-sprite {
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.wywo-evolve-arrow {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
}
.wywo-evolve-text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
}
.wywo-evolve-text strong {
  color: var(--accent);
}

/* Battle rows — your sprite vs opponent sprite, W/L tag, score delta */
.wywo-battle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wywo-battle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.wywo-battle-row.is-win {
  border-left: 3px solid var(--green);
}
.wywo-battle-row.is-loss {
  border-left: 3px solid var(--red);
}
.wywo-battle-result {
  display: inline-block;
  width: 22px;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 0;
  border-radius: 4px;
  flex-shrink: 0;
}
.wywo-battle-row.is-win .wywo-battle-result {
  background: rgba(52, 211, 153, 0.18);
  color: var(--green);
}
.wywo-battle-row.is-loss .wywo-battle-result {
  background: rgba(248, 113, 113, 0.18);
  color: var(--red);
}
.wywo-battle-sprite {
  width: 24px;
  height: 36px;
  image-rendering: pixelated;
  flex-shrink: 0;
  object-fit: contain;
}
.wywo-battle-vs {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
}
.wywo-battle-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wywo-battle-delta {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}
.wywo-battle-row.is-win .wywo-battle-delta {
  color: var(--green);
}
.wywo-battle-row.is-loss .wywo-battle-delta {
  color: var(--red);
}

/* Misc events (heals, fled catches, trades) */
.wywo-misc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.wywo-misc-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.wywo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 22px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
.wywo-suppress {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.wywo-suppress input {
  accent-color: var(--accent);
}

@media (max-width: 540px) {
  .wywo-hero {
    padding: 18px 16px 14px;
  }
  .wywo-stats,
  .wywo-section,
  .wywo-actions {
    padding-left: 16px;
    padding-right: 16px;
  }
  .wywo-creature-grid {
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  }
  .wywo-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
}

/* WYWO additions: pending moves, count-up flicker, sprite fallback,
   "+N more" footer, suppress dropdown */
.wywo-pending {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wywo-pending-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  font-size: 13px;
}
.wywo-pending-icon {
  font-size: 18px;
}
.wywo-pending-text {
  flex: 1;
  min-width: 0;
}
.wywo-pending-text strong {
  color: var(--accent);
}

.wywo-creature-multi {
  position: absolute;
  bottom: -6px;
  right: -6px;
  background: var(--accent);
  color: #0b0d14;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(56, 189, 248, 0.4);
}

.wywo-section-more {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  font-style: italic;
}

.wywo-battle-row.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.wywo-battle-row.is-clickable:hover {
  border-color: var(--accent);
}

.wywo-stat-value {
  font-variant-numeric: tabular-nums;
}

.wywo-creature-sprite-fallback,
.wywo-evolve-sprite-fallback,
.wywo-battle-sprite-fallback,
.wywo-hero-sprite-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface2);
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-weight: 700;
  flex-shrink: 0;
}

.wywo-suppress {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wywo-suppress select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 12px;
}

/* ─── Companion catch celebration modal ──────────────────────────────────
   Reuses the .wywo-modal hero styling at a smaller width so each catch
   feels like a quick celebration toast rather than a full-screen recap. */
.catch-modal {
  max-width: 380px;
  width: calc(100% - 32px);
  max-height: none;
  background: linear-gradient(
    180deg,
    rgba(52, 211, 153, 0.12) 0%,
    var(--surface) 180px
  );
  animation: catch-modal-pop 0.25s ease-out;
}
@keyframes catch-modal-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
}
.catch-modal .wywo-hero {
  padding: 20px 22px 16px;
}
.catch-modal-actions {
  justify-content: flex-end;
  padding: 12px 22px 16px;
}
.catch-modal--win {
  background: linear-gradient(
    180deg,
    rgba(250, 204, 21, 0.18) 0%,
    var(--surface) 180px
  );
}
.catch-modal--loss {
  background: linear-gradient(
    180deg,
    rgba(248, 113, 113, 0.16) 0%,
    var(--surface) 180px
  );
}
.result-modal-emoji {
  font-size: 48px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
