.tw-territory-config-shell {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(320px, 1.4fr);
  gap: 14px;
  grid-column: 1 / -1;
}

.tw-territory-mode-card,
.tw-territory-rule-card,
.tw-territory-field-card,
.tw-territory-admin-panel,
.tw-territory-admin-card {
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.34);
  box-shadow: 0 14px 34px rgba(2, 6, 23, 0.18);
}

.tw-territory-mode-card {
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.78), rgba(14, 165, 233, 0.62)),
    rgba(15, 23, 42, 0.86);
}

.tw-territory-eyebrow {
  margin-bottom: 8px;
  color: rgba(219, 234, 254, 0.94);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.tw-territory-mode-card h3 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.4rem;
}

.tw-territory-mode-card p,
.tw-territory-rule-card li {
  color: rgba(226, 232, 240, 0.9);
  line-height: 1.55;
  font-size: 0.88rem;
}

.tw-territory-rule-card {
  margin-top: 12px;
  padding: 14px 16px;
}

.tw-territory-rule-card h4 {
  margin: 0 0 8px;
  color: var(--text-main, #f8fafc);
}

.tw-territory-rule-card ol {
  margin: 0;
  padding-left: 18px;
}

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

.tw-territory-field-card {
  padding: 14px;
}

.tw-territory-field-card label {
  display: block;
}

.tw-territory-field-card input,
.tw-territory-field-card select {
  width: 100%;
}

.tw-territory-field-hint {
  margin-top: 7px;
  color: var(--text-sub, #94a3b8);
  font-size: 0.78rem;
  line-height: 1.35;
}

.tw-territory-battlefield {
  border-color: rgba(96, 165, 250, 0.28);
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 255, 0.9)),
    rgba(248, 250, 252, 0.92);
  color: #0f172a;
}

.tw-territory-battlefield .territory-board-head {
  color: #0f172a;
}

.tw-territory-battlefield .territory-board-head span {
  color: #475569;
}

.tw-territory-battlefield .territory-board-state {
  border-color: rgba(37, 99, 235, 0.18);
  background: rgba(219, 234, 254, 0.86);
  color: #1e3a8a;
}

.tw-territory-battlefield .territory-grid {
  border-color: rgba(148, 163, 184, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(241, 245, 249, 0.72)),
    rgba(248, 250, 252, 0.9);
}

.tw-territory-cell {
  border-radius: 0;
  clip-path: polygon(50% 3%, 95% 26%, 95% 74%, 50% 97%, 5% 74%, 5% 26%);
}

.tw-territory-cell .territory-cell-surface,
.tw-territory-cell .territory-cell-glow {
  border-radius: 0;
  clip-path: inherit;
}

.tw-territory-cell.neutral .territory-cell-surface {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, rgba(246, 234, 215, 0.95), rgba(226, 207, 174, 0.9));
}

.tw-territory-cell.neutral {
  border-color: rgba(177, 137, 86, 0.55);
  color: rgba(120, 80, 34, 0.6);
}

.tw-territory-cell.owned .territory-cell-surface {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, color-mix(in srgb, var(--cell-color, #2563eb) 32%, white), color-mix(in srgb, var(--cell-color, #2563eb) 24%, #0f172a));
}

.tw-territory-cell.claim-valid {
  border-color: rgba(37, 99, 235, 0.92);
  box-shadow:
    0 0 0 2px rgba(37, 99, 235, 0.24),
    0 0 22px rgba(37, 99, 235, 0.3);
}

.tw-territory-cell.claim-valid .territory-cell-frontier {
  color: #1d4ed8;
  text-shadow: 0 0 10px rgba(191, 219, 254, 0.8);
}

.tw-territory-team-row {
  color: #334155;
}

.tw-territory-battlefield .territory-phase-note {
  color: #475569;
}

.tw-territory-admin-panel {
  padding: 16px;
  width: 100%;
}

.tw-territory-admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.tw-territory-admin-title {
  color: var(--text-main, #f8fafc);
  font-weight: 900;
  font-size: 1rem;
}

.tw-territory-admin-sub {
  margin-top: 3px;
  color: var(--text-sub, #94a3b8);
  font-size: 0.84rem;
}

.tw-territory-team-banners {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tw-territory-team-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 12px 14px;
  border-radius: 12px;
  color: #f8fafc;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--team-color, #2563eb) 82%, #0f172a), color-mix(in srgb, var(--team-color, #2563eb) 55%, #020617));
}

.tw-territory-team-banner span {
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0.9;
}

.tw-territory-team-banner strong {
  font-size: 1.4rem;
}

.tw-territory-admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.5fr) minmax(240px, 0.8fr);
  gap: 12px;
  align-items: start;
}

.tw-territory-event-log {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tw-territory-event-log li {
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
  padding: 8px 0;
  color: var(--text-sub, #cbd5e1);
  font-size: 0.83rem;
  line-height: 1.45;
}

.tw-territory-event-log li:first-child {
  color: #93c5fd;
  font-weight: 800;
}

body.live-mode-territory_war .team-stage-board.territory {
  border-color: rgba(37, 99, 235, 0.25);
}

body.live-mode-territory_war .team-stage-board.territory .territory-board {
  box-shadow: none;
}

body.live-mode-territory_war .boss-stage-quiz-dock[data-state="territory-claim"] {
  pointer-events: none;
}

body.territory-lab-active .boss-stage-quiz-dock,
body.live-mode-territory_war .boss-stage-quiz-dock[data-state="territory-lab"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(28px) scale(0.96);
}

body.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .boss-stage-boss-wrap,
body.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .live-stage-renderer-mount {
  opacity: 0;
  pointer-events: none;
}

body.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .team-stage-objective-board {
  top: 24px;
  left: 50%;
  width: min(1180px, calc(100vw - 56px));
  max-height: calc(100vh - 48px);
  transform: translateX(-50%);
  overflow: visible;
  pointer-events: auto;
}

body.boss-stage-desktop-rail.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .team-stage-objective-board {
  left: calc(20px + var(--boss-stage-rail-width) + 18px);
  width: min(1160px, calc(100vw - var(--boss-stage-rail-width) - 58px));
  transform: none;
}

.tw-territory-lab-shell {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(239, 247, 255, 0.82)),
    radial-gradient(circle at 14% 18%, rgba(96, 165, 250, 0.22), transparent 34%),
    radial-gradient(circle at 86% 14%, rgba(249, 115, 22, 0.18), transparent 32%);
  color: #0f172a;
}

.tw-territory-lab-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.tw-territory-lab-title {
  display: grid;
  gap: 2px;
}

.tw-territory-lab-title span {
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.tw-territory-lab-title strong {
  color: #0f172a;
  font-size: clamp(1.18rem, 2vw, 1.55rem);
}

.tw-territory-lab-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.tw-territory-lab-chips span,
.tw-territory-mini-stats span {
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #334155;
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 900;
}

.tw-territory-feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 16px;
  border: 1px solid rgba(59, 130, 246, 0.18);
  background: rgba(219, 234, 254, 0.72);
  padding: 9px 12px;
}

.tw-territory-feedback strong {
  color: #1d4ed8;
  font-size: 1rem;
}

.tw-territory-feedback span {
  color: #475569;
  font-size: 0.9rem;
  font-weight: 800;
}

.tw-territory-feedback.claim {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(220, 252, 231, 0.78);
}

.tw-territory-feedback.claim strong {
  color: #15803d;
}

.tw-territory-feedback.locked {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(254, 243, 199, 0.78);
}

.tw-territory-lab-main {
  display: grid;
  grid-template-columns: minmax(300px, 0.85fr) minmax(460px, 1.25fr);
  gap: 14px;
  align-items: stretch;
}

.tw-territory-question-panel,
.tw-territory-claim-zone {
  min-width: 0;
  border: 1px solid rgba(203, 213, 225, 0.78);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.08);
}

.tw-territory-question-panel {
  display: grid;
  align-content: start;
  padding: 14px;
}

.tw-territory-question-panel.is-claiming {
  opacity: 0.78;
  pointer-events: none;
}

.tw-territory-question-panel.is-claiming .options-list,
.tw-territory-question-panel.is-claiming .question-multi-actions,
.tw-territory-question-panel.is-claiming .question-selection-hint {
  display: none;
}

.tw-territory-lab-question-card {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
}

.tw-territory-lab-question-card .question-text {
  color: #0f172a;
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  line-height: 1.35;
}

.tw-territory-lab-question-card .options-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.tw-territory-lab-question-card .option-item {
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(248, 250, 252, 0.92);
  color: #0f172a;
  min-height: 50px;
}

.tw-territory-lab-question-card .option-item:hover,
.tw-territory-lab-question-card .option-item:focus-within {
  border-color: rgba(59, 130, 246, 0.7);
  background: rgba(239, 246, 255, 0.98);
}

.tw-territory-claim-zone {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 12px;
}

.tw-territory-claim-copy {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.tw-territory-claim-copy strong {
  display: block;
  color: #0f172a;
  font-size: 1rem;
}

.tw-territory-claim-copy span {
  color: #64748b;
  font-size: 0.86rem;
  font-weight: 800;
}

.tw-territory-mini-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.tw-territory-board-stage {
  min-height: 0;
  display: grid;
  place-items: center;
}

.tw-territory-lab-empty {
  color: #64748b;
  font-weight: 900;
  padding: 20px;
  text-align: center;
}

.tw-territory-hex-shell {
  display: grid;
  gap: 8px;
  width: 100%;
}

.tw-territory-hex-shell .territory-grid-inner {
  display: block;
  width: 100%;
}

.tw-territory-axis-top {
  display: none;
}

.tw-territory-hex-grid {
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  width: 100%;
  padding: 4px;
  margin-bottom: 0;
  border: 0;
  background: transparent;
}

.tw-territory-hex-svg {
  display: block;
  width: min(100%, 760px);
  height: auto;
  max-height: min(58vh, 520px);
  filter: drop-shadow(0 18px 30px rgba(15, 23, 42, 0.16));
}

.tw-territory-hex-svg.compact {
  width: min(100%, 360px);
  max-height: 260px;
}

.tw-territory-hex-svg .territory-cell {
  display: block;
  width: auto;
  height: auto;
  overflow: visible;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  transform: none;
  outline: none;
}

.tw-territory-hex-svg .territory-cell.mine {
  transform: none;
  box-shadow: none;
}

.tw-territory-hex-svg .territory-cell[data-clickable="1"] {
  cursor: pointer;
}

.tw-hex-shape {
  fill: #f2eadb;
  stroke: #c9ad83;
  stroke-width: 1.35;
  transition: fill 0.16s ease, stroke 0.16s ease, filter 0.16s ease, opacity 0.16s ease;
}

.tw-territory-hex-svg .territory-cell.owned .tw-hex-shape {
  fill: color-mix(in srgb, var(--cell-color, #2563eb) 24%, #eff6ff);
  stroke: color-mix(in srgb, var(--cell-color, #2563eb) 82%, #1e293b);
  stroke-width: 1.8;
}

.tw-territory-hex-svg .territory-cell.castle .tw-hex-shape {
  fill: color-mix(in srgb, var(--cell-color, #2563eb) 38%, #ffffff);
  stroke-width: 2.4;
}

.tw-territory-hex-svg .territory-cell.claim-dim {
  opacity: 0.42;
}

.tw-territory-hex-svg .territory-cell.claim-valid .tw-hex-shape {
  fill: #dbeafe;
  stroke: #2563eb;
  stroke-width: 3;
  filter: drop-shadow(0 0 9px rgba(37, 99, 235, 0.45));
}

.tw-territory-hex-svg .territory-cell.claim-pending .tw-hex-shape {
  fill: #bbf7d0;
  stroke: #16a34a;
}

.tw-territory-hex-svg .territory-cell.recent-capture .tw-hex-shape {
  filter: drop-shadow(0 0 8px rgba(34, 197, 94, 0.42));
}

.tw-territory-hex-svg .territory-cell.castle-danger .tw-hex-shape {
  stroke: #dc2626;
  filter: drop-shadow(0 0 8px rgba(220, 38, 38, 0.38));
}

.tw-hex-banner,
.tw-hex-icon {
  fill: #0f172a;
  font-size: 10px;
  font-weight: 1000;
  pointer-events: none;
  user-select: none;
}

.tw-hex-claim-dot {
  fill: #2563eb;
  pointer-events: none;
  animation: twClaimPulse 0.9s ease-in-out infinite;
}

@keyframes twClaimPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.82); }
  50% { opacity: 1; transform: scale(1.18); }
}

@media (max-width: 980px) {
  .tw-territory-config-shell,
  .tw-territory-admin-grid,
  .tw-territory-lab-main {
    grid-template-columns: 1fr;
  }

  .tw-territory-setting-grid,
  .tw-territory-team-banners {
    grid-template-columns: 1fr;
  }

  body.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .team-stage-objective-board,
  body.boss-stage-desktop-rail.territory-lab-active .boss-stage-shell[data-stage-mode="territory_war"] .team-stage-objective-board {
    top: 14px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: calc(100vh - 28px);
    transform: none;
  }

  .tw-territory-lab-top,
  .tw-territory-claim-copy {
    align-items: flex-start;
    flex-direction: column;
  }

  .tw-territory-lab-chips,
  .tw-territory-mini-stats {
    justify-content: flex-start;
  }

  .tw-territory-hex-svg {
    max-height: 42vh;
  }
}
