:root {
  --bg-deep: #050810;
  --bg-panel: rgba(8, 18, 32, 0.82);
  --border: rgba(0, 212, 255, 0.22);
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.45);
  --accent-warm: #ff6b35;
  --text: #e8f4fc;
  --text-muted: #7a9bb8;
  --glow: 0 0 24px rgba(0, 212, 255, 0.15);
  --font-display: "Orbitron", sans-serif;
  --font-body: "Noto Sans SC", sans-serif;
  --panel-width: 320px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 70% 20%, rgba(0, 100, 180, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(0, 212, 255, 0.06), transparent);
  pointer-events: none;
  z-index: 0;
}

.app {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.panel-column {
  position: relative;
  width: var(--panel-width);
  flex-shrink: 0;
  min-height: 0;
  overflow: visible;
  transition: width 0.22s ease;
}

.app.panel-collapsed .panel-column {
  width: 0;
  min-width: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
  box-shadow: var(--glow);
  border-right: 1px solid var(--border);
  overflow: hidden;
  transition: opacity 0.18s ease, border-color 0.22s ease;
}

.app.panel-collapsed .panel {
  border-right-color: transparent;
  opacity: 0;
  pointer-events: none;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.panel-header {
  flex-shrink: 0;
  padding: 18px 14px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(0, 212, 255, 0.14) 0%, rgba(0, 100, 160, 0.06) 45%, transparent 100%);
  box-shadow: inset 0 -1px 0 rgba(0, 212, 255, 0.1);
}

.panel-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  line-height: 1.4;
  color: #f2fbff;
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.65), 0 0 32px rgba(0, 212, 255, 0.3), 0 1px 2px rgba(0, 0, 0, 0.45);
}

.panel-title-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.22em;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0.1em;
  vertical-align: -0.02em;
  text-shadow: 0 0 18px rgba(0, 212, 255, 0.95), 0 0 36px rgba(0, 212, 255, 0.45);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin: 0 0 8px;
  opacity: 0.9;
}

.section-label-sub {
  margin-top: 10px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 400;
}

.panel-body > .control-group {
  margin: 0 10px;
  padding: 10px 10px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 20, 40, 0.5);
}

.panel-body > .control-group[hidden] {
  display: none;
}

.app.panel-collapsed .panel-body {
  display: none;
}

.panel-toggle-btn {
  position: absolute;
  left: 100%;
  top: 50%;
  z-index: 20;
  transform: translateY(-50%);
  width: 28px;
  height: 52px;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  border-radius: 0 8px 8px 0;
  border: 1px solid var(--border);
  border-left: none;
  background: rgba(8, 18, 32, 0.95);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.panel-toggle-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  box-shadow: 4px 0 20px rgba(0, 212, 255, 0.2);
}

.panel-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.panel-select {
  width: 100%;
  padding: 6px 32px 6px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 40, 70, 0.5);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  line-height: 1.25;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2300d4ff' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.panel-select:hover,
.panel-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

.panel-select option {
  background: #0a1828;
  color: var(--text);
}

#terrainGroup > #globalMapLayers {
  margin-top: 4px;
  margin-bottom: 12px;
}

#terrainGroup > #terrainMode {
  display: block;
  margin: 0 0 14px;
}

#terrainGroup > .layer-actions {
  margin-top: 0;
  margin-bottom: 12px;
}

#terrainGroup > #chinaTerrainPanel,
#terrainGroup > #worldTerrainPanel {
  margin-top: 2px;
}

.season-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 0;
  align-items: start;
}

.map-type-presets {
  grid-template-columns: 1fr 1fr 1fr;
}

.preset-season-btn {
  padding: 5px 6px;
  font-size: 0.75rem;
  line-height: 1.25;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(0, 30, 50, 0.5);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.preset-season-btn:hover {
  border-color: rgba(255, 107, 53, 0.65);
  color: var(--accent-warm);
  background: rgba(255, 107, 53, 0.1);
}

.preset-season-btn.preset-season-active {
  border-color: var(--accent-warm);
  color: var(--accent-warm);
  background: rgba(255, 107, 53, 0.18);
  box-shadow: 0 0 12px rgba(255, 107, 53, 0.28);
  font-weight: 600;
}

.layer-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.layer-action-btn {
  flex: 1;
  padding: 5px 7px;
  font-size: 0.72rem;
  line-height: 1.25;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(0, 30, 50, 0.5);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.layer-action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
}

.layer-checkboxes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 10px;
}

.layer-checkboxes > label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.layer-checkboxes > label.layer-check-full {
  grid-column: 1 / -1;
}

.layer-checkboxes input[type="checkbox"] {
  flex-shrink: 0;
  width: auto;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.terrain-layer-checkboxes .layer-group-title {
  grid-column: 1 / -1;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  color: var(--accent-dim);
}

.panel-tip {
  margin: 8px 0 0;
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.copyright-entry {
  flex-shrink: 0;
  margin-top: auto;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(0, 212, 255, 0.35);
  background: linear-gradient(180deg, rgba(0, 212, 255, 0.06) 0%, rgba(0, 50, 90, 0.28) 100%);
}

.app.panel-collapsed .copyright-entry {
  display: none;
}

.copyright-text-btn {
  display: block;
  width: 100%;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: #e8fcff;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.22) 0%, rgba(0, 100, 170, 0.32) 55%, rgba(0, 60, 110, 0.38) 100%);
  border: 1px solid rgba(0, 212, 255, 0.5);
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  text-shadow: 0 0 14px rgba(0, 212, 255, 0.45);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.copyright-text-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.35) 0%, rgba(0, 120, 190, 0.42) 100%);
  box-shadow: 0 0 28px rgba(0, 212, 255, 0.28);
}

main.stage-wrap {
  min-width: 0;
  min-height: 0;
}

.stage-wrap {
  position: relative;
  min-height: 0;
  height: 100%;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #03070d;
  isolation: isolate;
}

.stage-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 58% 48% at 74% 14%, rgba(0, 180, 220, 0.13), transparent 62%),
    radial-gradient(ellipse 52% 42% at 14% 78%, rgba(0, 212, 255, 0.1), transparent 58%),
    linear-gradient(168deg, #071018 0%, #050c14 42%, #03070d 72%, #020508 100%);
}

.stage-bg-grid {
  position: absolute;
  left: -40%;
  right: -40%;
  bottom: -8%;
  height: 62%;
  opacity: 0.42;
  background-image:
    linear-gradient(rgba(0, 212, 255, 0.11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 255, 0.11) 1px, transparent 1px);
  background-size: 44px 44px;
  transform: perspective(480px) rotateX(72deg);
  transform-origin: center top;
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 82%);
}

.map-viewport-window {
  flex: 1 1 auto;
  min-height: 200px;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.map-viewport-window.is-single-world .map-stage {
  flex: 0 0 auto;
}

.map-stage {
  flex: 1 1 auto;
  min-height: 200px;
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.map-stage.single-world-clip {
  background: #03070d;
}

/* 遮罩左右重复的世界地图副本，只保留中间一幅 */
.world-side-mask {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 18;
  pointer-events: none;
  background: linear-gradient(168deg, #071018 0%, #050c14 42%, #03070d 72%, #020508 100%);
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.45);
}

.world-side-mask--left {
  left: 0;
}

.world-side-mask--right {
  right: 0;
}

.map-stage .tdt-container,
.map-stage .tdt-map {
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}

.map-stage .tdt-control-copyright,
.map-stage .tdt-control-logo {
  opacity: 0.75;
}

/* 隐藏天地图横向循环渲染的重复瓦片 */
.map-stage .tdt-tile--offworld,
.map-stage img.tdt-tile--offworld {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

.map-search-dock {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 22;
  width: min(360px, calc(100% - 32px));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 15, 28, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--glow);
  pointer-events: auto;
}

.map-search-label {
  display: block;
  margin-bottom: 6px;
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.map-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.map-search-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(0, 40, 70, 0.55);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.map-search-input::placeholder {
  color: var(--text-muted);
}

.map-search-input:hover,
.map-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

.map-search-btn {
  flex-shrink: 0;
  padding: 7px 14px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: rgba(0, 212, 255, 0.14);
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.map-search-btn:hover {
  color: #fff;
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.28);
}

.map-search-status {
  margin: 8px 0 0;
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.map-search-status[hidden],
.map-search-results[hidden] {
  display: none !important;
}

.map-search-results {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid rgba(0, 212, 255, 0.16);
  border-radius: 6px;
  background: rgba(0, 20, 40, 0.45);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-dim) transparent;
}

.map-search-result-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-bottom: 1px solid rgba(0, 212, 255, 0.1);
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.2s;
}

.map-search-result-item:last-child {
  border-bottom: none;
}

.map-search-result-item:hover,
.map-search-result-item:focus-visible {
  background: rgba(0, 212, 255, 0.12);
  outline: none;
}

.map-search-result-name {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #e8f4fc;
}

.map-search-result-meta {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.stage-loading,
.stage-error {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 18, 28, 0.72);
  backdrop-filter: blur(6px);
}

.stage-loading[hidden],
.stage-error[hidden] {
  display: none !important;
}

.stage-loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(0, 212, 255, 0.2);
  border-top-color: var(--accent);
  animation: map-spin 0.9s linear infinite;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}

.stage-loading p,
.stage-error p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  max-width: 480px;
  line-height: 1.6;
  white-space: pre-line;
}

.stage-error p {
  color: #e8a090;
}

.stage-tool-btn {
  position: fixed;
  top: 14px;
  z-index: 20;
  font-family: var(--font-body);
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(5, 15, 28, 0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.stage-tool-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
  box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}

.stage-reset-btn {
  right: 126px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 36px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.stage-fullscreen-btn {
  right: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 6px 12px;
  font-size: 0.72rem;
}

html.app-page-fullscreen,
html.app-page-fullscreen body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #03070d;
}

html.app-page-fullscreen .app {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr !important;
}

html.app-page-fullscreen .panel-column,
html.app-page-fullscreen .panel-toggle-btn {
  display: none !important;
}

.stage-corner-stack {
  position: absolute;
  right: 16px;
  bottom: 12px;
  z-index: 22;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  max-width: min(92vw, 400px);
  pointer-events: auto;
}

.hint-bar {
  align-self: flex-end;
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(5, 15, 28, 0.88);
  backdrop-filter: blur(8px);
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.feature-info-card {
  position: relative;
  width: min(360px, calc(100vw - 48px));
  padding: 14px 36px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(5, 15, 28, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: var(--glow);
  pointer-events: auto;
}

.feature-info-card[hidden] {
  display: none !important;
}

.feature-info-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.feature-info-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.65;
  color: #ffffff;
  white-space: pre-line;
  max-height: 240px;
  overflow-y: auto;
}

.feature-info-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.feature-info-close:hover {
  color: var(--accent);
  background: rgba(0, 212, 255, 0.1);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal-dialog {
  width: 100%;
  max-width: 440px;
  padding: 18px 16px;
  border-radius: 8px;
  background: rgba(8, 18, 32, 0.98);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.modal-title {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  color: var(--accent);
  text-align: center;
}

.copyright-note {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text);
  text-align: center;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  justify-content: center;
}

.modal-btn {
  padding: 8px 18px;
  font-size: 0.84rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: rgba(0, 40, 70, 0.6);
  color: var(--text);
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.modal-btn-primary {
  border-color: var(--accent);
  color: var(--accent);
}

.modal-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 212, 255, 0.12);
}

@media (max-width: 1000px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .panel-column {
    width: 100%;
    max-width: none;
  }

  .app.panel-collapsed .panel-column {
    width: 100%;
    max-height: 0;
  }

  .panel {
    max-height: 48vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .app.panel-collapsed .panel {
    max-height: 0;
    opacity: 0;
  }

  .panel-toggle-btn {
    left: auto;
    right: 12px;
    top: auto;
    bottom: 12px;
    transform: none;
    border-radius: 8px;
    border-left: 1px solid var(--border);
    width: 36px;
    height: 36px;
  }

  .hint-bar {
    white-space: normal;
    text-align: center;
  }
}
