:root {
  --ink: #13222c;
  --ink-soft: #4f6776;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.9);
  --surface-card: rgba(255, 255, 255, 0.8);
  --line: rgba(20, 64, 84, 0.18);
  --line-strong: rgba(20, 64, 84, 0.26);
  --mint: #28d8bc;
  --sky: #63b9ff;
  --sun: #ffbe5f;
  --rose: #ff8d80;
  --good: #1fba6a;
  --bad: #d84f4f;
  --tone-auth: #46c2ff;
  --tone-steps: #28cfb3;
  --tone-provider: #8fa3ff;
  --tone-loot: #f3b246;
  --tone-events: #ff937e;
  --tone-wallet: #5ac57d;
  --shell-shadow: 0 22px 60px rgba(13, 33, 45, 0.18);
  --card-shadow: 0 14px 32px rgba(18, 45, 60, 0.14);
  --press-shadow: 0 8px 16px rgba(17, 36, 47, 0.18);
  --map-water: #d5e9f6;
  --dock-bg: rgba(249, 253, 255, 0.82);
  --dock-line: rgba(15, 54, 75, 0.2);
  --dock-active: rgba(38, 211, 184, 0.26);
  --console-bg: #0f2532;
  --console-ink: #c9f6f4;
}

body[data-theme="dark"] {
  --ink: #e8f2f8;
  --ink-soft: #9bb0bc;
  --surface: rgba(16, 26, 35, 0.72);
  --surface-strong: rgba(16, 26, 35, 0.92);
  --surface-card: rgba(13, 22, 31, 0.82);
  --line: rgba(137, 173, 195, 0.22);
  --line-strong: rgba(137, 173, 195, 0.38);
  --mint: #2cf4d2;
  --sky: #6ab7ff;
  --sun: #ffc56a;
  --rose: #ff8f87;
  --good: #49d888;
  --bad: #ff7373;
  --tone-auth: #61c2ff;
  --tone-steps: #28cfb3;
  --tone-provider: #95a6ff;
  --tone-loot: #f8be61;
  --tone-events: #ff9c88;
  --tone-wallet: #6fd58f;
  --shell-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  --card-shadow: 0 14px 34px rgba(0, 0, 0, 0.33);
  --press-shadow: 0 10px 16px rgba(0, 0, 0, 0.36);
  --map-water: #162839;
  --dock-bg: rgba(8, 15, 22, 0.86);
  --dock-line: rgba(152, 186, 208, 0.3);
  --dock-active: rgba(44, 244, 210, 0.22);
  --console-bg: #061019;
  --console-ink: #bfeef0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Bricolage Grotesque", sans-serif;
  background:
    radial-gradient(1200px 600px at -10% -18%, rgba(99, 185, 255, 0.3), transparent 65%),
    radial-gradient(900px 560px at 106% -8%, rgba(255, 190, 95, 0.3), transparent 64%),
    radial-gradient(820px 360px at 54% 118%, rgba(40, 216, 188, 0.22), transparent 66%),
    linear-gradient(168deg, #edf8ff 0%, #fff1dc 52%, #fff7f1 100%);
  padding-bottom: calc(98px + env(safe-area-inset-bottom));
  transition: background 220ms ease, color 220ms ease;
}

body[data-theme="dark"] {
  background:
    radial-gradient(1200px 600px at -10% -20%, rgba(56, 126, 191, 0.34), transparent 64%),
    radial-gradient(900px 560px at 108% -10%, rgba(215, 129, 54, 0.22), transparent 64%),
    radial-gradient(820px 380px at 50% 120%, rgba(30, 147, 130, 0.2), transparent 66%),
    linear-gradient(165deg, #060d14 0%, #0b1722 48%, #101a28 100%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  background-image: radial-gradient(currentColor 0.5px, transparent 0.5px);
  background-size: 3px 3px;
  color: rgba(20, 42, 56, 0.34);
  mix-blend-mode: soft-light;
}

body[data-theme="dark"] .grain {
  color: rgba(193, 217, 233, 0.22);
}

.halo {
  position: fixed;
  right: -130px;
  bottom: -130px;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(40, 216, 188, 0.42), transparent 65%);
  filter: blur(1px);
}

.glow-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  animation: drift 12s ease-in-out infinite;
}

.orb-a {
  width: 280px;
  height: 280px;
  left: -90px;
  bottom: 12%;
  background: radial-gradient(circle, rgba(99, 185, 255, 0.3), transparent 70%);
}

.orb-b {
  width: 320px;
  height: 320px;
  right: -120px;
  top: 18%;
  animation-delay: 2.6s;
  background: radial-gradient(circle, rgba(255, 141, 128, 0.24), transparent 72%);
}

.shell {
  width: min(1240px, calc(100% - 22px));
  margin: 12px auto 0;
  display: grid;
  gap: 14px;
}

.hud {
  position: sticky;
  top: 8px;
  z-index: 30;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, var(--surface-strong), var(--surface));
  box-shadow: var(--shell-shadow);
  backdrop-filter: blur(10px);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.hud-main {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.hud-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.menu-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  color: #093934;
  border: 1px solid rgba(18, 69, 69, 0.2);
  background: linear-gradient(135deg, rgba(40, 216, 188, 0.95), rgba(110, 215, 255, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
  flex: 0 0 auto;
}

body[data-theme="dark"] .brand-mark {
  color: #032f2a;
}

.menu-title {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  font-weight: 800;
}

.menu-subtitle {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-toggle {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  min-height: 36px;
  padding: 7px 11px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(236, 246, 255, 0.82));
  color: #15384a;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

body[data-theme="dark"] .theme-toggle {
  color: var(--ink);
  background: linear-gradient(135deg, rgba(27, 41, 55, 0.95), rgba(16, 27, 37, 0.88));
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 16px rgba(14, 39, 54, 0.16);
}

.theme-toggle:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: var(--press-shadow);
}

.theme-toggle-icon {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] .theme-toggle-icon {
  background: rgba(255, 255, 255, 0.14);
}

.theme-toggle-label {
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.settings-btn {
  position: relative;
  overflow: hidden;
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: #1e485c;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  font-family: "Bricolage Grotesque", sans-serif;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}

body[data-theme="dark"] .settings-btn {
  color: #d8e9f4;
  background: rgba(16, 27, 37, 0.88);
}

.settings-btn:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 16px rgba(14, 39, 54, 0.16);
}

.settings-btn:active {
  transform: translateY(1px) scale(0.98);
}

.settings-btn-ico {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
}

.settings-btn-ico svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-btn-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.menu-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.menu-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  color: #2f5568;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
}

body[data-theme="dark"] .menu-pill {
  color: #c7dbe7;
  background: rgba(20, 34, 46, 0.7);
}

.menu-pill.ok {
  border-color: rgba(31, 186, 106, 0.45);
  color: #1f754a;
  background: rgba(31, 186, 106, 0.14);
}

body[data-theme="dark"] .menu-pill.ok {
  color: #72e2ac;
}

.menu-pill.err {
  border-color: rgba(216, 79, 79, 0.5);
  color: #8e2f2f;
  background: rgba(216, 79, 79, 0.14);
}

body[data-theme="dark"] .menu-pill.err {
  color: #ff9f9f;
}

.section-target {
  scroll-margin-top: 86px;
}

.territory-stage,
.hero,
.card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(135deg, var(--surface-strong), var(--surface-card));
  box-shadow: var(--shell-shadow);
  animation: lift 420ms ease;
}

.territory-stage {
  padding: 14px;
  display: grid;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.territory-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(340px 180px at 76% -10%, rgba(99, 185, 255, 0.22), transparent 72%),
    radial-gradient(320px 160px at -5% 108%, rgba(40, 216, 188, 0.16), transparent 74%);
}

.territory-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.territory-head h2 {
  margin: 4px 0 6px;
  font-size: clamp(24px, 4.6vw, 38px);
  line-height: 1.04;
}

.kicker {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.territory-subtitle {
  margin: 0;
  font-size: 13px;
  max-width: 800px;
  color: var(--ink-soft);
}

.territory-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.territory-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  padding: 8px 12px;
  font-size: 12px;
  color: #2e5568;
}

body[data-theme="dark"] .territory-badge {
  color: #bfd8e7;
  background: rgba(12, 25, 35, 0.7);
}

.territory-badge strong {
  margin-left: 3px;
}

.territory-layout {
  display: grid;
  grid-template-columns: 1.85fr 1fr;
  gap: 12px;
}

.territory-map-wrap {
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  min-height: 460px;
  background: var(--map-water);
  box-shadow: var(--card-shadow);
  position: relative;
  transition: box-shadow 260ms ease, border-color 260ms ease, transform 220ms ease;
}

.territory-map-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 220ms ease;
}

.territory-map-wrap.is-tracking {
  border-color: rgba(40, 216, 188, 0.68);
  box-shadow:
    0 0 0 1px rgba(40, 216, 188, 0.35),
    0 0 26px rgba(40, 216, 188, 0.22),
    var(--card-shadow);
  transform: translateY(-1px);
}

.territory-map-wrap.is-tracking::after {
  opacity: 1;
  animation: map-pulse 1.7s ease-in-out infinite;
  background: radial-gradient(circle at 50% 35%, rgba(40, 216, 188, 0.24), transparent 66%);
}

.territory-map-wrap.capture-flash::after {
  opacity: 1;
  animation: capture-flash 700ms ease-out;
  background: radial-gradient(circle at 50% 50%, rgba(255, 190, 95, 0.34), rgba(40, 216, 188, 0.08) 56%, transparent 74%);
}

#territoryMap {
  width: 100%;
  min-height: 460px;
}

.territory-side {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.65);
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
}

body[data-theme="dark"] .territory-side {
  background: rgba(9, 18, 27, 0.7);
}

.loot-quick {
  --card-tone: var(--tone-loot);
  --card-tone-ring: rgba(243, 178, 70, 0.22);
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 8px 18px rgba(17, 40, 55, 0.14);
}

.territory-side .loot-quick h3 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.territory-stats {
  display: grid;
  gap: 7px;
}

.territory-stat {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

body[data-theme="dark"] .territory-stat {
  background: rgba(12, 24, 34, 0.76);
}

.territory-stat span {
  font-size: 12px;
  color: var(--ink-soft);
}

.territory-stat strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.territory-msg {
  margin: 0;
  min-height: 20px;
  font-size: 12px;
  color: var(--ink-soft);
}

.territory-msg.ok {
  color: var(--good);
}

.territory-msg.err {
  color: var(--bad);
}

.territory-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: var(--ink-soft);
}

.territory-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.mine {
  background: var(--mint);
}

.dot.enemy {
  background: var(--sky);
}

.hero {
  position: relative;
  padding: 18px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  top: -120px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(99, 185, 255, 0.28), transparent 66%);
}

.hero h1 {
  margin: 6px 0 8px;
  font-size: clamp(30px, 5.2vw, 48px);
  line-height: 1.02;
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0 0 12px;
  color: var(--ink-soft);
  max-width: 880px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chip {
  border-radius: 999px;
  border: 1px solid rgba(40, 216, 188, 0.45);
  color: #155b52;
  background: rgba(40, 216, 188, 0.14);
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
}

body[data-theme="dark"] .chip {
  color: #7ef2e0;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--card-shadow);
  padding: 11px 12px;
}

body[data-theme="dark"] .metric {
  background: rgba(12, 24, 34, 0.74);
}

.metric-label {
  margin-bottom: 7px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.metric-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
}

.status {
  margin: 10px 0 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

.status.ok {
  color: var(--good);
}

.status.err {
  color: var(--bad);
}

.layout {
  display: grid;
  grid-template-columns: 1.72fr 1fr;
  gap: 14px;
}

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

.side-col {
  display: grid;
  gap: 12px;
  height: fit-content;
}

.card {
  --card-tone: var(--tone-auth);
  --card-tone-ring: rgba(70, 194, 255, 0.24);
  box-shadow: var(--card-shadow);
  padding: 14px;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--card-tone), transparent 76%);
}

.card:hover {
  transform: perspective(900px) rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)) translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 20px 34px rgba(15, 37, 50, 0.2);
}

.tone-auth {
  --card-tone: var(--tone-auth);
  --card-tone-ring: rgba(70, 194, 255, 0.22);
}

.tone-steps {
  --card-tone: var(--tone-steps);
  --card-tone-ring: rgba(40, 207, 179, 0.22);
}

.tone-provider {
  --card-tone: var(--tone-provider);
  --card-tone-ring: rgba(143, 163, 255, 0.22);
}

.tone-loot {
  --card-tone: var(--tone-loot);
  --card-tone-ring: rgba(243, 178, 70, 0.22);
}

.tone-events {
  --card-tone: var(--tone-events);
  --card-tone-ring: rgba(255, 147, 126, 0.22);
}

.tone-wallet {
  --card-tone: var(--tone-wallet);
  --card-tone-ring: rgba(90, 197, 125, 0.22);
}

.grid .card:nth-child(2) {
  animation-delay: 65ms;
}

.grid .card:nth-child(3) {
  animation-delay: 115ms;
}

.grid .card:nth-child(4) {
  animation-delay: 165ms;
}

.grid .card:nth-child(5) {
  animation-delay: 215ms;
}

.grid .card:nth-child(6) {
  animation-delay: 265ms;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h2::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--card-tone);
  box-shadow: 0 0 0 4px var(--card-tone-ring);
}

.card-note {
  margin: -2px 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-soft);
}

.provider-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.provider-link {
  text-decoration: none;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #285369;
  background: rgba(255, 255, 255, 0.7);
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease;
}

.provider-link:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  box-shadow: 0 8px 14px rgba(16, 39, 52, 0.12);
}

body[data-theme="dark"] .provider-link {
  color: #c8deeb;
  background: rgba(10, 20, 30, 0.7);
}

.field-row,
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.field-row:last-child,
.btn-row:last-child {
  margin-bottom: 0;
}

input,
select {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  padding: 10px 12px;
  min-width: 130px;
  outline: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

body[data-theme="dark"] input,
body[data-theme="dark"] select {
  background: rgba(8, 17, 25, 0.88);
}

input:focus,
select:focus {
  border-color: rgba(40, 216, 188, 0.78);
  box-shadow: 0 0 0 3px rgba(40, 216, 188, 0.26);
}

.btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid transparent;
  border-radius: 12px;
  min-height: 40px;
  padding: 10px 13px;
  font-family: "Bricolage Grotesque", sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition:
    transform 130ms ease,
    box-shadow 130ms ease,
    filter 130ms ease,
    border-color 130ms ease;
}

.btn::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.32) 35%, transparent 58%);
  transform: translateX(-120%);
  transition: transform 260ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px rgba(15, 40, 54, 0.18);
}

.btn:hover::before {
  transform: translateX(105%);
}

.btn:active {
  transform: translateY(1px) scale(0.985);
  box-shadow: var(--press-shadow);
}

.btn:disabled {
  opacity: 0.8;
  cursor: not-allowed;
  filter: saturate(0.82);
}

.btn.is-loading::after {
  content: "";
  position: absolute;
  top: 0;
  left: -40%;
  width: 30%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: btn-sheen 900ms linear infinite;
}

.btn-main {
  color: #07342d;
  background: linear-gradient(130deg, #1fd7bd, #94f3e2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.btn-alt {
  color: #4f2a00;
  background: linear-gradient(130deg, #ffb64e, #ffd79d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.btn-soft {
  color: #224c61;
  background: linear-gradient(130deg, #dbf2ff, #f1f9ff);
  border-color: rgba(24, 72, 95, 0.2);
}

body[data-theme="dark"] .btn-soft {
  color: #d2e7f4;
  background: linear-gradient(130deg, #18374a, #214a62);
  border-color: rgba(149, 186, 208, 0.28);
}

.btn-warn {
  color: #581b17;
  background: linear-gradient(130deg, #ff9f92, #ffc7b0);
}

.btn-ripple {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.7);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 580ms ease-out forwards;
}

.ico {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.12);
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  flex: 0 0 auto;
}

body[data-theme="dark"] .ico {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.16);
}

.ico svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.guide {
  --card-tone: var(--tone-steps);
  --card-tone-ring: rgba(40, 207, 179, 0.22);
}

.legend {
  --card-tone: #9e88ff;
  --card-tone-ring: rgba(158, 136, 255, 0.22);
}

.legend-grid {
  display: grid;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #2f5062;
}

body[data-theme="dark"] .legend-item {
  color: #bbd2df;
}

.legend-mark {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend-main {
  background: linear-gradient(120deg, #1fd7bd, #8cf2df);
}

.legend-alt {
  background: linear-gradient(120deg, #ffb347, #ffd08f);
}

.legend-soft {
  background: linear-gradient(120deg, #d8f0ff, #eff9ff);
}

.steps-list {
  margin: 0 0 10px;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.45;
  color: #2d4f61;
}

body[data-theme="dark"] .steps-list {
  color: #bfd5e3;
}

.steps-list li {
  margin: 0 0 8px;
}

.mini-note {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.mini-note.ok {
  color: var(--good);
}

.mini-note.err {
  color: var(--bad);
}

.journey {
  --card-tone: var(--tone-provider);
  --card-tone-ring: rgba(143, 163, 255, 0.22);
}

.journey-progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(27, 52, 68, 0.13);
  margin-bottom: 10px;
  overflow: hidden;
}

.journey-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(120deg, var(--mint), var(--sky));
  transition: width 260ms ease;
}

.journey-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.journey-list li {
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  color: #35596b;
  background: rgba(255, 255, 255, 0.66);
}

body[data-theme="dark"] .journey-list li {
  background: rgba(9, 21, 31, 0.7);
}

.journey-list li::before {
  content: "○";
  margin-right: 8px;
  color: #90a8b4;
}

.journey-list li.active {
  border-color: rgba(99, 185, 255, 0.5);
  background: rgba(99, 185, 255, 0.12);
}

.journey-list li.active::before {
  content: "◐";
  color: var(--sky);
}

.journey-list li.done {
  border-color: rgba(31, 186, 106, 0.45);
  background: rgba(31, 186, 106, 0.12);
  color: #1f6a48;
}

body[data-theme="dark"] .journey-list li.done {
  color: #7ee2af;
}

.journey-list li.done::before {
  content: "✓";
  color: var(--good);
}

.console-wrap {
  --card-tone: var(--tone-events);
  --card-tone-ring: rgba(255, 147, 126, 0.22);
  position: sticky;
  top: 8px;
  height: fit-content;
}

.console {
  margin: 6px 0 0;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--console-bg);
  color: var(--console-ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-x: auto;
}

.bottom-dock {
  position: fixed;
  left: 50%;
  bottom: max(10px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(960px, calc(100% - 16px));
  z-index: 60;
  border-radius: 20px;
  border: 1px solid var(--dock-line);
  background: linear-gradient(140deg, var(--dock-bg), rgba(255, 255, 255, 0.5));
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 36px rgba(7, 26, 37, 0.26);
  display: flex;
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
}

.menu-link {
  position: relative;
  overflow: hidden;
  text-decoration: none;
  border-radius: 14px;
  border: 1px solid transparent;
  color: #254b5e;
  padding: 7px 10px;
  min-width: 88px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.menu-link:hover {
  transform: translateY(-1px);
  border-color: var(--line);
}

.menu-link:active {
  transform: translateY(1px) scale(0.985);
}

.menu-link.active {
  border-color: rgba(40, 216, 188, 0.55);
  background: var(--dock-active);
  color: var(--ink);
}

.dock-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: rgba(22, 60, 80, 0.14);
}

.dock-ico svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-link.active .dock-ico {
  background: rgba(40, 216, 188, 0.32);
}

body[data-theme="dark"] .bottom-dock {
  background: linear-gradient(140deg, var(--dock-bg), rgba(7, 14, 22, 0.72));
}

body[data-theme="dark"] .menu-link {
  color: #c4dbea;
}

body[data-theme="dark"] .dock-ico {
  background: rgba(255, 255, 255, 0.14);
}

.dock-label {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

body[data-theme="dark"] .leaflet-control-zoom a,
body[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(9, 18, 27, 0.85);
  color: #d5e6f1;
  border-color: rgba(136, 173, 194, 0.25);
}

.theme-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: end center;
  pointer-events: none;
}

.theme-panel[aria-hidden="false"] {
  pointer-events: auto;
}

.theme-panel-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(5, 11, 18, 0.52);
  opacity: 0;
  transition: opacity 220ms ease;
}

.theme-panel[aria-hidden="false"] .theme-panel-backdrop {
  opacity: 1;
}

.theme-sheet {
  position: relative;
  width: min(620px, calc(100% - 14px));
  border-radius: 20px 20px 0 0;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--surface-strong), var(--surface));
  box-shadow: 0 -20px 44px rgba(7, 20, 29, 0.28);
  padding: 14px;
  transform: translateY(102%);
  transition: transform 260ms ease;
}

.theme-panel[aria-hidden="false"] .theme-sheet {
  transform: translateY(0);
}

.theme-sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.theme-sheet-head h3 {
  margin: 4px 0 0;
  font-size: 24px;
}

.theme-sheet-close {
  position: relative;
  overflow: hidden;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

body[data-theme="dark"] .theme-sheet-close {
  background: rgba(9, 19, 29, 0.75);
}

.theme-sheet-subtitle {
  margin: 8px 0 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.theme-option {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  padding: 12px 10px;
  text-align: left;
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

body[data-theme="dark"] .theme-option {
  background: rgba(9, 19, 29, 0.72);
}

.theme-option:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(11, 29, 41, 0.17);
}

.theme-option.is-active {
  border-color: rgba(40, 216, 188, 0.65);
  background: rgba(40, 216, 188, 0.14);
}

.theme-option-title {
  font-size: 14px;
  font-weight: 800;
}

.theme-option-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.theme-current {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.loot-open-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.loot-open-modal[aria-hidden="false"] {
  pointer-events: auto;
}

.loot-open-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  background: rgba(4, 8, 13, 0.66);
  opacity: 0;
  transition: opacity 220ms ease;
}

.loot-open-modal[aria-hidden="false"] .loot-open-backdrop {
  opacity: 1;
}

.loot-open-sheet {
  position: relative;
  width: min(760px, calc(100% - 16px));
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, var(--surface-strong), var(--surface));
  box-shadow: 0 24px 48px rgba(6, 15, 23, 0.4);
  padding: 14px;
  transform: translateY(20px) scale(0.98);
  opacity: 0;
  transition: transform 240ms ease, opacity 240ms ease;
}

.loot-open-modal[aria-hidden="false"] .loot-open-sheet {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.loot-open-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.loot-open-head h3 {
  margin: 4px 0 8px;
  font-size: clamp(20px, 4vw, 30px);
}

.loot-reel-window {
  position: relative;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  padding: 12px 0;
  overflow: hidden;
}

body[data-theme="dark"] .loot-reel-window {
  background: rgba(8, 17, 25, 0.74);
}

.loot-pointer {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 14px solid #ffb347;
  z-index: 2;
}

.loot-reel-track {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 16px 14px 8px;
  transition: transform 4.2s cubic-bezier(0.08, 0.84, 0.18, 1);
  will-change: transform;
}

.loot-reel-item {
  min-width: 118px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  padding: 10px 8px;
  display: grid;
  gap: 6px;
  text-align: center;
}

body[data-theme="dark"] .loot-reel-item {
  background: rgba(11, 22, 32, 0.82);
}

.loot-reel-item .item-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(0, 0, 0, 0.08);
}

.loot-reel-item .item-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.loot-reel-item .item-rarity {
  font-size: 11px;
  color: var(--ink-soft);
}

.loot-reel-item.rarity-common {
  border-color: rgba(125, 158, 178, 0.4);
}

.loot-reel-item.rarity-rare {
  border-color: rgba(90, 184, 255, 0.5);
  box-shadow: inset 0 0 0 1px rgba(90, 184, 255, 0.12);
}

.loot-reel-item.rarity-epic {
  border-color: rgba(158, 136, 255, 0.58);
  box-shadow: inset 0 0 0 1px rgba(158, 136, 255, 0.16);
}

.loot-reel-item.rarity-legendary {
  border-color: rgba(255, 179, 71, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 179, 71, 0.22);
}

.loot-open-result {
  margin: 10px 2px 2px;
  min-height: 18px;
  font-size: 13px;
  color: var(--ink-soft);
}

@media (max-width: 1100px) {
  .territory-layout {
    grid-template-columns: 1fr;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .console-wrap {
    position: static;
  }

  .side-col {
    order: 2;
  }

  .console {
    min-height: 260px;
  }
}

@media (max-width: 860px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .quick-stats {
    grid-template-columns: 1fr;
  }

  .theme-toggle-label {
    display: none;
  }

  .settings-btn-label {
    display: none;
  }

  .territory-map-wrap,
  #territoryMap {
    min-height: 340px;
  }
}

@media (max-width: 640px) {
  .shell {
    width: calc(100% - 12px);
    margin: 8px auto 0;
    gap: 10px;
  }

  .hud {
    padding: 10px;
    gap: 8px;
  }

  .menu-subtitle {
    max-width: 210px;
  }

  .theme-options {
    grid-template-columns: 1fr;
  }

  .loot-open-sheet {
    padding: 10px;
    border-radius: 16px;
  }

  .loot-reel-item {
    min-width: 94px;
    padding: 8px 6px;
  }

  .loot-reel-track {
    gap: 8px;
    padding: 14px 10px 8px;
  }

  .territory-stage,
  .hero,
  .card {
    border-radius: 18px;
    padding: 12px;
  }

  .territory-map-wrap,
  #territoryMap {
    min-height: 300px;
  }

  .btn,
  input,
  select {
    width: 100%;
    justify-content: center;
  }

  .field-row,
  .btn-row {
    align-items: stretch;
  }

  .menu-link {
    min-width: 80px;
    padding: 6px 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0ms !important;
  }
}

@keyframes lift {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.995);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes btn-sheen {
  from {
    left: -40%;
  }
  to {
    left: 110%;
  }
}

@keyframes ripple {
  from {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(0);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(16);
  }
}

@keyframes map-pulse {
  0% {
    opacity: 0.4;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.02);
  }
  100% {
    opacity: 0.45;
    transform: scale(1);
  }
}

@keyframes capture-flash {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  28% {
    opacity: 1;
    transform: scale(1.01);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes drift {
  0% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(16px, -10px) scale(1.03);
  }
  100% {
    transform: translate(0, 0) scale(1);
  }
}
