:root {
  color-scheme: light;
  --bg: #f3efe8;
  --surface: #fffaf1;
  --surface-strong: #ffffff;
  --ink: #1e2b25;
  --muted: #7b817b;
  --line: #d9d2c6;
  --empty: #e9e3d8;
  --empty-2: #ddd7cc;
  --accent: #1f7a67;
  --accent-strong: #155e51;
  --warm: #d68b51;
  --shadow: 0 18px 55px rgba(55, 44, 30, 0.14);
  --display-font: "Kaiti SC", "STKaiti", "Songti SC", "Noto Serif CJK SC", serif;
  --serif-font: "Songti SC", "Kaiti SC", "STSong", "Noto Serif CJK SC", serif;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(31, 122, 103, 0.08), transparent 34%),
    linear-gradient(250deg, rgba(214, 139, 81, 0.1), transparent 38%),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  max-width: 1520px;
  margin: 0 auto;
}

.site-footer {
  display: flex;
  justify-content: center;
  max-width: 1520px;
  margin: 14px auto 0;
}

.visitor-counter {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(135, 119, 93, 0.24);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.72);
  color: rgba(30, 43, 37, 0.72);
  font-family: var(--serif-font);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 10px 28px rgba(55, 44, 30, 0.08);
}

.editor,
.side-panel {
  min-width: 0;
}

.editor {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: calc(100vh - 36px);
  padding: 18px 20px;
  border: 1px solid rgba(135, 119, 93, 0.18);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(34px, 4.4vw, 62px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.counter {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  white-space: nowrap;
}

.counter strong {
  font-size: 28px;
  line-height: 1;
}

.counter span {
  color: var(--muted);
  font-size: 14px;
}

.map-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  margin: 4px 0 10px;
  overflow: hidden;
}

.map-credit {
  align-self: end;
  justify-self: center;
  margin: -12px 0 0;
  color: rgba(123, 129, 123, 0.72);
  font-size: 11px;
}

.map-brand {
  position: absolute;
  right: 18px;
  bottom: 6px;
  margin: 0;
  color: rgba(31, 122, 103, 0.78);
  font-family: var(--serif-font);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
}

#chinaMap {
  width: auto;
  height: min(calc(100vh - 128px), calc(100vw - 420px), 980px);
  min-height: 600px;
  max-width: 100%;
  filter: drop-shadow(0 20px 28px rgba(71, 59, 41, 0.12));
}

.province-path {
  transition:
    fill 180ms ease,
    stroke 180ms ease,
    filter 180ms ease,
    opacity 180ms ease;
}

.province-active-outline {
  pointer-events: none;
}

.province-hit {
  outline: none;
}

.province-hit:hover .province-path,
.province-hit:focus-visible .province-path {
  filter: brightness(1.03);
}

.province-label {
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
  paint-order: stroke;
  stroke: rgba(255, 250, 241, 0.88);
  stroke-width: 4px;
  stroke-linejoin: round;
}

.south-sea-frame {
  fill: rgba(255, 250, 241, 0.86);
  stroke: rgba(135, 119, 93, 0.44);
  stroke-width: 1.4px;
}

.south-sea-title {
  fill: #5d675f;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
}

.south-sea-island {
  stroke-width: 1.55px;
  stroke-linejoin: round;
  transition:
    fill 180ms ease,
    stroke 180ms ease,
    filter 180ms ease;
}

.south-sea-inset:hover .south-sea-island,
.south-sea-inset:focus-visible .south-sea-island {
  filter: brightness(1.04);
}

.region-inset-frame {
  fill: rgba(255, 250, 241, 0.9);
  stroke: rgba(135, 119, 93, 0.44);
  stroke-width: 1.4px;
}

.region-inset-title {
  fill: #5d675f;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0;
  pointer-events: none;
}

.region-inset-shape {
  stroke-width: 1.6px;
  stroke-linejoin: round;
  transition:
    fill 180ms ease,
    stroke 180ms ease,
    filter 180ms ease;
}

.region-inset-label {
  pointer-events: none;
}

.region-inset-hit:hover .region-inset-shape,
.region-inset-hit:focus-visible .region-inset-shape {
  filter: brightness(1.04);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button,
.template-chip,
.upload-button,
.download-link {
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  transition:
    transform 150ms ease,
    background 150ms ease,
    border-color 150ms ease,
    color 150ms ease;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  font-weight: 700;
}

.button:disabled,
.upload-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.button:active,
.template-chip:active,
.upload-button:active {
  transform: translateY(1px);
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel-block {
  padding: 16px;
  border: 1px solid rgba(135, 119, 93, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(55, 44, 30, 0.1);
}

.block-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.block-heading span {
  color: var(--muted);
  font-size: 13px;
}

.block-heading strong {
  font-size: 18px;
  line-height: 1.2;
}

.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 48px;
  background: #1e2b25;
  color: #fff;
  font-weight: 800;
}

.upload-button:hover {
  background: #304239;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  line-height: 1;
}

.adjustments {
  display: grid;
  gap: 12px;
  margin-top: 15px;
}

.adjustments label {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.text-input {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  background: rgba(255, 250, 241, 0.76);
  color: var(--ink);
  line-height: 1.45;
  outline: none;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 103, 0.12);
}

.profile-editor {
  display: grid;
  gap: 10px;
}

.avatar-button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 58px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.78);
  color: var(--ink);
  font-weight: 800;
}

.avatar-button:hover {
  border-color: rgba(31, 122, 103, 0.38);
  background: #fffaf1;
}

.avatar-preview {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border-radius: 50%;
  background:
    linear-gradient(135deg, rgba(31, 122, 103, 0.18), rgba(214, 139, 81, 0.18)),
    #f7f1e8;
  background-size: cover;
  background-position: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.avatar-preview.has-image {
  color: transparent;
}

.text-field {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 250, 241, 0.76);
  color: var(--ink);
  outline: none;
}

.text-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 103, 0.12);
}

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

.template-chip {
  min-height: 40px;
  background: #f7f1e8;
  color: var(--muted);
  font-weight: 800;
}

.template-chip.active {
  background: #1f7a67;
  color: #fff;
}

.poster-block {
  padding-bottom: 14px;
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  background: #f7f1e8;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
}

.download-link.disabled {
  pointer-events: none;
  color: #a8aaa5;
}

.poster-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(31, 122, 103, 0.08), transparent),
    #fffaf1;
  cursor: zoom-in;
}

#posterImage {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.poster-empty {
  color: var(--muted);
  font-size: 14px;
}

.poster-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 28px;
  background: rgba(17, 24, 21, 0.76);
  backdrop-filter: blur(10px);
}

.poster-modal.open {
  display: grid;
}

.poster-modal img {
  max-width: min(92vw, 760px);
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

@media (max-width: 980px) {
  .app-shell {
    padding: 12px;
  }

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

  .editor {
    min-height: auto;
    grid-template-rows: auto auto auto;
    padding: 16px;
  }

  #chinaMap {
    width: min(100%, 980px);
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .poster-block {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: stretch;
  }

  h1 {
    font-size: 34px;
  }

  .counter {
    padding: 8px 10px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar .primary {
    grid-column: 1 / -1;
  }
}
