:root {
  --bg-0: #070b16;
  --bg-1: #0d1526;
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.15);
  --text: #e6eefc;
  --text-dim: #7c8aa5;
  --panel: rgba(13, 21, 38, 0.72);
  --panel-border: rgba(56, 189, 248, 0.18);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #142139 0%, transparent 60%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1));
  color: var(--text);
}

/* Scene fills the entire viewport; HUD windows float above it. */
#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
}

/* ---- Draggable window chrome -------------------------------------------- */
.window {
  position: fixed;
  z-index: 200;
  display: flex;
  flex-direction: column;
  /* width: 232px; */
  max-height: calc(100vh - 32px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.25),
    0 24px 60px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  user-select: none;
  overflow: hidden;
}

/* Default anchor positions (overridden once a window is dragged). */
#win-telemetry { top: 16px; left: 16px; }
#win-party { top: 16px; right: 16px; }
#win-bag { top: 16px; left: 50%; transform: translateX(-50%); }
#win-help { bottom: 16px; left: 16px; width: auto; }
#win-noise { bottom: 16px; right: 16px; }
#win-map {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100vw - 32px));
}
#win-skills {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
}

.window[hidden] { display: none; }

.window.is-dragging {
  cursor: grabbing;
  box-shadow:
    0 0 0 1px var(--accent),
    0 30px 70px rgba(0, 0, 0, 0.6);
}

.window__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  cursor: grab;
  touch-action: none;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.12), rgba(56, 189, 248, 0.02));
  border-bottom: 1px solid var(--panel-border);
}

.window.is-dragging .window__bar { cursor: grabbing; }

.window__title {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.window__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.window__collapse {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  font-size: 15px;
  line-height: 1;
  color: var(--text-dim);
  background: transparent;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.window__collapse:hover {
  color: var(--text);
  background: var(--accent-soft);
}

.window__body {
  padding: 14px 16px;
  overflow-y: auto;
}

.window.is-collapsed .window__body { display: none; }

.hud__row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  padding: 3px 0;
  color: var(--text-dim);
}

.hud__row b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hud__control {
  margin-top: 0;
}

.hud__control-label {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.hud__control-label b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.hud__control input[type="range"],
.noise__row input[type="range"] {
  width: 100%;
  height: 4px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--accent-soft);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}

.hud__control input[type="range"]::-webkit-slider-thumb,
.noise__row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b1526;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

.hud__control input[type="range"]::-moz-range-thumb,
.noise__row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #0b1526;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

/* --- World noise controls --- */
#win-noise { width: 300px; }

.noise__group {
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.noise__group:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.noise__row {
  margin-bottom: 9px;
}

.noise__field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.noise__field input[type="range"] {
  flex: 1;
  min-width: 0;
}

.noise__field input[type="number"] {
  width: 76px;
  flex-shrink: 0;
  padding: 4px 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  outline: none;
}

.noise__field input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.25);
}

.noise__label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.noise__label b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.noise__actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}

.noise__btn {
  flex: 1;
  padding: 7px 6px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.noise__btn:hover {
  color: #0b1526;
  background: var(--accent);
}

.hud__modes {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
  display: grid;
  gap: 12px;
}

.hud__mode-block {
  --poke: var(--accent);
  position: relative;
  display: grid;
  gap: 8px;
  padding: 10px 12px 12px 14px;
  border-radius: 12px;
  background: rgba(9, 15, 28, 0.55);
  border: 1px solid var(--panel-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

/* Colored spine on the left keyed to each pokemon's color. */
.hud__mode-block::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--poke);
}

.hud__mode-block.is-fused {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(250, 204, 21, 0.25);
}

.hud__mode-block.is-recalled {
  opacity: 0.72;
}

.hud__mode-block.is-recalled:not(.is-fainted) .hud__skills {
  opacity: 0.55;
}

.hud__mode-block.is-fainted {
  opacity: 0.85;
}

.hud__ball-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.65);
  color: var(--muted);
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

.hud__ball-toggle svg {
  width: 16px;
  height: 16px;
}

.hud__ball-toggle.is-out {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.hud__ball-toggle.is-in-ball {
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.45);
}

.hud__ball-toggle:hover:not(:disabled) {
  background: rgba(30, 41, 59, 0.85);
}

.hud__ball-toggle:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hud__mode-btn.is-disabled,
.hud__mode-btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.hud__mode-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* Minimap species portrait (party HUD + mode picker). */
.pokemon-icon {
  --icon-size: 32px;
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 10px color-mix(in srgb, var(--poke, var(--accent)) 35%, transparent);
}

.pokemon-icon__img {
  width: 88%;
  height: 88%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.pokemon-icon.is-loaded .pokemon-icon__img {
  display: block;
}

.pokemon-icon.is-missing::after {
  content: "?";
  font-size: calc(var(--icon-size) * 0.42);
  font-weight: 700;
  color: var(--text-dim);
}

/* Name grows so controls sit flush to the right edge. */
.hud__mode-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud__mode-types {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* Shared type shield icon host (see ui/typeIcon.js). */
.type-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  cursor: help;
  border-radius: 4px;
  outline: none;
  min-width: 14px;
  min-height: 14px;
}

/* Color fallback while the shield sheet loads (or if it fails). */
.type-icon::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 50%;
  background: var(--type, #64748b);
  opacity: 0.85;
  z-index: 0;
}

.type-icon.is-loaded::before {
  display: none;
}

.type-shield-icon {
  position: relative;
  z-index: 1;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.type-icon:focus-visible {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.55);
}
/* Compact button that reflects the active mode and opens the picker. */
.hud__mode-current {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  color: var(--text-dim);
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.hud__mode-current svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud__mode-current:hover {
  color: var(--text);
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.5);
}

.hud__mode-current.is-picker-open {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.55);
}

.hud__mode-current.is-symbiosis {
  color: #fef08a;
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.55);
}

/* Floating AI mode picker (opens from party HUD). */
.mode-picker {
  position: fixed;
  z-index: 1200;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 16px));
  padding: 10px;
  border-radius: 12px;
  background: rgba(6, 10, 20, 0.97);
  border: 1px solid var(--panel-border);
  box-shadow:
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(56, 189, 248, 0.08);
}

.mode-picker__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 2px 4px 8px;
  border-bottom: 1px solid var(--panel-border);
}

.mode-picker__icon .pokemon-icon {
  --icon-size: 28px;
}

.mode-picker__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-picker__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-picker__option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: var(--text-dim);
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s,
    color 0.15s,
    border-color 0.15s,
    transform 0.1s;
}

.mode-picker__glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.mode-picker__glyph svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-picker__label {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.mode-picker__option:hover:not(:disabled) {
  color: var(--text);
  background: rgba(56, 189, 248, 0.14);
  transform: translateY(-1px);
}

.mode-picker__option.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.mode-picker__option.is-active.is-symbiosis {
  color: #fef08a;
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.55);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.25);
}

.mode-picker__option:disabled,
.mode-picker__option.is-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.hud__mode-moves {
  font-size: 11px;
  color: var(--text-dim);
  opacity: 0.85;
  letter-spacing: 0.02em;
}

/* Per-pokemon HP bar shown in the party list. */
.hud__hp {
  display: grid;
  gap: 3px;
}

.hud__hp-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud__hp-value {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.hud__hp-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(2, 6, 16, 0.6);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.hud__hp-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--hp, 1));
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: transform 0.15s linear, background 0.2s;
}

.hud__hp.is-low .hud__hp-fill {
  background: linear-gradient(90deg, #f97316, #fbbf24);
}

.hud__hp.is-down .hud__hp-value {
  color: #f87171;
}

.hud__hp.is-down .hud__hp-fill {
  background: #7f1d1d;
}

.hud__exp {
  display: grid;
  gap: 3px;
}

.hud__exp-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud__exp-value {
  font-variant-numeric: tabular-nums;
  color: #fde68a;
}

.hud__exp-track {
  position: relative;
  height: 5px;
  border-radius: 999px;
  background: rgba(2, 6, 16, 0.6);
  border: 1px solid var(--panel-border);
  overflow: hidden;
}

.hud__exp-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  transform: scaleX(var(--exp, 0));
  border-radius: inherit;
  background: linear-gradient(90deg, #ca8a04, #facc15);
  transition: transform 0.2s linear;
}

.hud__exp.is-max .hud__exp-fill {
  background: linear-gradient(90deg, #a855f7, #e879f9);
}

.hud__mode-block.is-level-up {
  animation: level-up-flash 1.2s ease-out;
}

@keyframes level-up-flash {
  0% {
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.85);
    filter: brightness(1.35);
  }
  35% {
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.35);
  }
  100% {
    box-shadow: none;
    filter: none;
  }
}

/* Two rows of three icon buttons. */
.hud__mode-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.hud__mode-btn {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  padding: 0;
  color: var(--text-dim);
  background: rgba(56, 189, 248, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}

.hud__mode-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud__mode-btn:hover {
  color: var(--text);
  background: rgba(56, 189, 248, 0.14);
  transform: translateY(-1px);
}

.hud__mode-btn:active {
  transform: translateY(0);
}

.hud__mode-btn.is-active {
  color: var(--text);
  background: var(--accent-soft);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.hud__mode-btn.is-active.is-symbiosis {
  color: #fef08a;
  background: rgba(250, 204, 21, 0.18);
  border-color: rgba(250, 204, 21, 0.55);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.28);
}

/* --- Bag: ball selector -------------------------------------------------- */
.bag {
  display: grid;
  gap: 8px;
}

.bag__item {
  --ball: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  color: var(--text);
  background: rgba(9, 15, 28, 0.55);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.bag__item:hover {
  background: rgba(56, 189, 248, 0.1);
  transform: translateY(-1px);
}

.bag__item.is-active {
  border-color: var(--ball);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 0 1px var(--ball), 0 0 14px -4px var(--ball);
}

.bag__item.is-empty {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Two-tone pokeball dot: top half tinted, split by a dark equator. */
.bag__ball {
  position: relative;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: #f8fafc;
  border: 1.5px solid #0b0f19;
  box-shadow: 0 0 8px -2px var(--ball);
}

.bag__ball::before {
  content: "";
  position: absolute;
  inset: 0 0 50% 0;
  background: var(--ball);
  border-bottom: 1.5px solid #0b0f19;
}

.bag__ball::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #f8fafc;
  border: 1.5px solid #0b0f19;
}

.bag__key {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  width: 12px;
  text-align: center;
}

.bag__name {
  flex: 1;
  font-size: 13px;
  white-space: nowrap;
}

.bag__count {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

.bag__item.is-active .bag__count {
  color: var(--text);
}

.bag__section-title {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.bag__berries {
  display: grid;
  gap: 6px;
}

.bag__berry {
  --berry: #22c55e;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: rgba(9, 15, 28, 0.45);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
}

.bag__berry-dot {
  position: relative;
  width: 14px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.55), var(--berry) 58%);
  border: 1px solid rgba(11, 15, 25, 0.7);
  box-shadow: 0 0 8px -3px var(--berry);
}

.bag__berry-dot::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 55%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #166534;
}

.bag__caught {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--panel-border);
}

/* --- Global world map ---------------------------------------------------- */
.window--map .window__body {
  padding: 10px;
}

.map__viewport {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.16);
  background: #060a14;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}

.map__canvas {
  display: block;
  width: 100%;
  height: 560px;
  cursor: grab;
  touch-action: none;
}

.map__canvas:active {
  cursor: grabbing;
}

.map__compass {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: rgba(7, 11, 22, 0.72);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  pointer-events: none;
}

.map__footer {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-dim);
}

.map__footer b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.map__recenter {
  margin-left: auto;
  padding: 4px 10px;
  font: inherit;
  font-size: 11px;
  color: var(--text);
  background: rgba(9, 15, 28, 0.65);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.map__recenter:hover {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
}

.map__toggle.is-active {
  color: #f8fafc;
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
}

.map__hint {
  margin-top: 8px;
}

/* Shared floating tooltip (see ui/tooltip.js). */
.tooltip {
  position: fixed;
  z-index: 1000;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: rgba(9, 15, 28, 0.96);
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

.tooltip[hidden] {
  display: none;
}

.hud__symbiosis-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

.hud__stats {
  font-size: 10px;
  line-height: 1.35;
  color: var(--text-dim);
  margin: 4px 0 2px;
}

/* Per-pokemon cooldown chips shown in the party list. */
.hud__skills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.skill-chip {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 2px;
  padding: 5px 8px;
  border-radius: 7px;
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid var(--panel-border);
}

.skill-chip__kind {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Elemental type shield icon in the chip's top-right. */
.skill-chip__type {
  position: absolute;
  top: 4px;
  right: 5px;
  z-index: 1;
  line-height: 0;
}

.skill-chip__name {
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 22px;
}

/* Cooldown sweep: overlay collapses left-to-right as the move recharges. */
.skill-chip__cooldown {
  position: absolute;
  inset: 0;
  transform-origin: right center;
  transform: scaleX(var(--cd, 0));
  background: rgba(2, 6, 16, 0.66);
  pointer-events: none;
  transition: transform 0.05s linear;
}

.skill-chip__bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: rgba(56, 189, 248, 0.25);
}

.skill-chip.is-ready {
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.18) inset;
}

.skill-chip.is-ready .skill-chip__bar {
  background: #4ade80;
}

/* Skill HUD content (lives inside the draggable Symbiosis window). */
.window--skills .window__bar {
  background: linear-gradient(180deg, rgba(250, 204, 21, 0.16), rgba(250, 204, 21, 0.02));
  border-bottom-color: rgba(250, 204, 21, 0.4);
}

.window--skills .window__title {
  color: #fde047;
}

.skill-hud {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.skill-hud__title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding-right: 12px;
  border-right: 1px solid var(--panel-border);
}

.skill-hud__title small {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(250, 204, 21, 0.85);
}

.skill-hud__title b {
  font-size: 15px;
  color: var(--text);
}

.skill-hud__types {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.skill-slot {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid var(--panel-border);
}

/* Radial cooldown wheel driven by --cd (0 ready .. 1 just used). */
.skill-slot__dial {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background:
    conic-gradient(rgba(2, 6, 16, 0.72) calc(var(--cd, 0) * 360deg), transparent 0),
    radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.25), rgba(56, 189, 248, 0.08));
  display: grid;
  place-items: center;
  border: 1px solid var(--panel-border);
}

.skill-slot__key {
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
}

.skill-slot__meta {
  display: grid;
  gap: 2px;
}

.skill-slot__kind {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.skill-slot__name {
  font-size: 13px;
  color: var(--text);
}

.skill-slot__status {
  font-size: 10px;
  color: var(--text-dim);
}

.skill-slot__type {
  position: absolute;
  top: 6px;
  right: 8px;
  line-height: 0;
}

.skill-slot.is-ready {
  border-color: rgba(74, 222, 128, 0.5);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.2);
}

.skill-slot.is-ready .skill-slot__status {
  color: #4ade80;
}

.help__body {
  display: grid;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.help__row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .window {
    width: min(232px, calc(100vw - 24px));
  }

  .skill-hud {
    flex-wrap: wrap;
  }
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 12px;
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

/* Zone banner (area enter) */
.zone-banner {
  position: fixed;
  top: 18%;
  left: 50%;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 28px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.zone-banner--show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.zone-banner__name {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.65);
}

.zone-banner__type {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 10px;
  border-radius: 999px;
  color: #f8fafc;
  background: rgba(100, 116, 139, 0.75);
}

.zone-banner__type[data-type="city"] {
  background: rgba(201, 176, 122, 0.85);
  color: #1e293b;
}

.zone-banner__type[data-type="route"] {
  background: rgba(34, 87, 54, 0.85);
}

.zone-banner__type[data-type="wilderness"] {
  background: rgba(71, 85, 105, 0.85);
}

.hub-prompt {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 160;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  font-size: 0.9rem;
  color: var(--text);
  background: rgba(13, 21, 38, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  pointer-events: none;
}

.mart__body {
  padding: 12px 14px;
}

.mart__placeholder {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.window--mart {
  width: 260px;
}

/* ── MMO login overlay ── */
.mmo-login[hidden] {
  display: none !important;
}

.mmo-login:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 18, 0.82);
  backdrop-filter: blur(8px);
}

.mmo-login__panel {
  width: min(420px, calc(100vw - 32px));
  padding: 28px 24px 22px;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(165deg, rgba(16, 26, 46, 0.96), rgba(8, 14, 28, 0.94));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.mmo-login__lang {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-switch--compact .lang-switch__select {
  min-width: 118px;
  padding: 4px 8px;
  font-size: 0.72rem;
}

.lang-switch__label {
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

.lang-switch__select {
  min-width: 148px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(4, 8, 18, 0.75);
  color: var(--text);
  font-size: 0.84rem;
  cursor: pointer;
}

.lang-switch__select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.18);
}

.mmo-login__title {
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.mmo-login__subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 20px;
}

.mmo-login__form {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.mmo-login__label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.mmo-login__input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(7, 11, 22, 0.9);
  color: var(--text);
  font-size: 1rem;
}

.mmo-login__input:focus {
  outline: 2px solid rgba(56, 189, 248, 0.45);
  border-color: var(--accent);
}

.mmo-login__offline--solo {
  width: 100%;
  margin-top: 14px;
}

.mmo-login__auth-copy {
  color: var(--text-dim);
  margin-bottom: 14px;
}

.mmo-login__auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 8px;
}

.mmo-login__link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
}

.mmo-login__submit,
.mmo-login__offline {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.mmo-login__submit {
  border: none;
  color: #041018;
  background: linear-gradient(135deg, #38bdf8, #22d3ee);
}

.mmo-login__offline {
  margin-top: 4px;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  background: transparent;
}

.mmo-login__submit:hover {
  filter: brightness(1.06);
}

.mmo-login__offline:hover {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.35);
}

.mmo-login__status {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--accent);
}

.mmo-login__status--error {
  color: #f87171;
}

.mmo-login__hint {
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.mmo-login__hint code {
  font-size: 0.76rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(7, 11, 22, 0.85);
  border: 1px solid var(--panel-border);
}

.mmo-login--connecting .mmo-login__submit {
  opacity: 0.65;
  pointer-events: none;
}

/* ── PvP duel UI ── */
.duel-toast {
  position: fixed;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9000;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(24, 16, 8, 0.88);
  color: #fde68a;
  font-size: 0.92rem;
  font-weight: 600;
  pointer-events: none;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.duel-toast[hidden],
.duel-offer[hidden] {
  display: none !important;
}

.duel-offer:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 18, 0.55);
}

.duel-offer__panel {
  width: min(380px, calc(100vw - 32px));
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: linear-gradient(165deg, rgba(30, 20, 10, 0.96), rgba(12, 10, 8, 0.94));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.duel-offer__title {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: #fde68a;
}

.duel-offer__text {
  color: var(--text-dim);
  margin-bottom: 16px;
}

.duel-offer__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.duel-offer__accept,
.duel-offer__decline {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  border: none;
}

.duel-offer__accept {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #1c1004;
}

.duel-offer__decline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
}

/* ── MMO area chat ───────────────────────────────────────────── */

.mmo-chat[hidden],
.trade-offer[hidden],
.trade-window[hidden] {
  display: none !important;
}

.mmo-chat {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 8500;
  width: min(340px, calc(100vw - 24px));
  border-radius: 12px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: rgba(8, 12, 24, 0.9);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.mmo-chat--collapsed .mmo-chat__log,
.mmo-chat--collapsed .mmo-chat__form {
  display: none;
}

.mmo-chat__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(96, 165, 250, 0.18);
}

.mmo-chat__title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #93c5fd;
}

.mmo-chat__toggle {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid rgba(96, 165, 250, 0.25);
  background: transparent;
  color: #bfdbfe;
  cursor: pointer;
}

.mmo-chat__log {
  max-height: 160px;
  overflow-y: auto;
  padding: 8px 10px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.mmo-chat__line {
  margin: 0 0 6px;
  color: var(--text-dim);
  word-break: break-word;
}

.mmo-chat__line strong {
  color: #dbeafe;
}

.mmo-chat__form {
  display: flex;
  padding: 8px;
  border-top: 1px solid rgba(96, 165, 250, 0.12);
}

.mmo-chat__input {
  flex: 1;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(96, 165, 250, 0.22);
  background: rgba(4, 8, 18, 0.75);
  color: var(--text);
  font-size: 0.84rem;
}

/* ── MMO trading ─────────────────────────────────────────────── */

.trade-offer:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 9600;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 18, 0.55);
}

.trade-offer__panel {
  width: min(380px, calc(100vw - 32px));
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: linear-gradient(165deg, rgba(10, 24, 20, 0.96), rgba(8, 12, 10, 0.94));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.trade-offer__title {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: #6ee7b7;
}

.trade-offer__text {
  color: var(--text-dim);
  margin-bottom: 16px;
}

.trade-offer__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.trade-offer__accept,
.trade-offer__decline,
.trade-window__confirm,
.trade-window__cancel,
.trade-window__slot {
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.trade-offer__accept,
.trade-window__confirm {
  background: linear-gradient(135deg, #34d399, #10b981);
  color: #052e1a;
  border: none;
}

.trade-offer__decline,
.trade-window__cancel {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
}

.trade-window:not([hidden]) {
  position: fixed;
  inset: 0;
  z-index: 9650;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 18, 0.6);
}

.trade-window__panel {
  width: min(520px, calc(100vw - 32px));
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: linear-gradient(165deg, rgba(10, 24, 20, 0.97), rgba(8, 12, 10, 0.95));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.trade-window__title {
  font-size: 1.2rem;
  color: #6ee7b7;
  margin-bottom: 4px;
}

.trade-window__partner {
  color: var(--text-dim);
  margin-bottom: 16px;
}

.trade-window__columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.trade-window__side-title {
  font-size: 0.9rem;
  color: #a7f3d0;
  margin-bottom: 8px;
}

.trade-window__slots {
  display: grid;
  gap: 6px;
}

.trade-window__slot {
  text-align: left;
  background: rgba(4, 12, 10, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--text);
}

.trade-window__slot--selected {
  border-color: rgba(52, 211, 153, 0.75);
  box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.35);
}

.trade-window__their-offer {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(4, 12, 10, 0.7);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--text);
  margin-bottom: 8px;
}

.trade-window__status {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.trade-window__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.trade-window__confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
