:root {
  --bg: #07080f;
  --ink: #eef1f8;
  --ink-soft: #9aa3b5;
  --fog: #141824;
  --sea: #4f8cff;
  --sea-deep: #ff6b81;
  --glow-warm: #ff4d6a;
  --glow-teal: rgba(79, 140, 255, 0.55);
  --glow-amber: rgba(255, 77, 106, 0.45);
  --line: rgba(238, 241, 248, 0.12);
  --glass: rgba(255, 255, 255, 0.04);
  --glass-strong: rgba(255, 255, 255, 0.08);
  --radius: 14px;
  --font-display: "Fraunces", "Noto Serif SC", Georgia, serif;
  --font-cn: "Noto Serif SC", "Fraunces", serif;
  --font-body: "Outfit", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.5;
  background: var(--bg);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 20% 0%, rgba(79, 140, 255, 0.22), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 15%, rgba(255, 77, 106, 0.18), transparent 50%),
    radial-gradient(ellipse 90% 60% at 50% 100%, rgba(79, 140, 255, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 40%, rgba(16, 20, 40, 0.9), transparent 70%),
    linear-gradient(180deg, #05060c 0%, #0a0c16 45%, #07080f 100%);
  animation: drift 18s ease-in-out infinite alternate;
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 30% 20%, rgba(79, 140, 255, 0.15), transparent 28%),
    radial-gradient(circle at 75% 30%, rgba(255, 77, 106, 0.12), transparent 26%);
  filter: blur(40px);
  animation: pulse-glow 10s ease-in-out infinite alternate;
  pointer-events: none;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  pointer-events: none;
  mix-blend-mode: soft-light;
}

@keyframes drift {
  from { transform: scale(1) translate(0, 0); }
  to { transform: scale(1.05) translate(-1.5%, 1%); }
}

@keyframes pulse-glow {
  from { opacity: 0.65; transform: scale(1); }
  to { opacity: 1; transform: scale(1.08); }
}

.page {
  width: min(100% - 2rem, 440px);
  margin: 0 auto;
  padding: clamp(2.5rem, 8vh, 4.5rem) 0 4rem;
}

@media (min-width: 900px) {
  .page {
    width: min(100% - 3rem, 1200px);
  }

  .visited-map {
    height: clamp(560px, 72vh, 780px);
  }
}

.section-map {
  width: 100%;
  text-align: center;
}

.section-map .section-title {
  text-align: center;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-height: min(72vh, 560px);
  justify-content: center;
  gap: 1rem;
}

.portrait-wrap {
  width: 148px;
  height: 148px;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(145deg, var(--sea), var(--glow-warm));
  box-shadow:
    0 0 24px var(--glow-teal),
    0 0 48px var(--glow-amber),
    0 0 80px rgba(79, 140, 255, 0.25);
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both, portrait-glow 4.5s ease-in-out infinite alternate;
}

@keyframes portrait-glow {
  from {
    box-shadow:
      0 0 18px var(--glow-teal),
      0 0 36px rgba(255, 77, 106, 0.25),
      0 0 60px rgba(79, 140, 255, 0.18);
  }
  to {
    box-shadow:
      0 0 28px var(--glow-teal),
      0 0 56px var(--glow-amber),
      0 0 90px rgba(79, 140, 255, 0.35);
  }
}

.portrait {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  background: var(--fog);
}

.name {
  margin: 0.35rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.name-latin {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 9vw, 3.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
  text-shadow:
    0 0 24px rgba(79, 140, 255, 0.45),
    0 0 48px rgba(255, 77, 106, 0.2);
}

.name-cn {
  font-family: var(--font-cn);
  font-size: clamp(1.35rem, 4.5vw, 1.65rem);
  font-weight: 500;
  color: var(--sea-deep);
  letter-spacing: 0.28em;
  padding-left: 0.28em;
  text-shadow: 0 0 18px rgba(255, 107, 129, 0.35);
}

.intro {
  margin: 0;
  max-width: 22ch;
  font-size: 1.05rem;
  color: var(--ink-soft);
  font-weight: 500;
  animation: rise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section {
  margin-top: 2.75rem;
  animation: rise 0.85s cubic-bezier(0.22, 1, 0.36, 1) 0.32s both;
}

.section-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sea);
  text-shadow: 0 0 16px rgba(79, 140, 255, 0.4);
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.btn-grid .btn:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .btn-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .btn-grid .btn:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: block;
}

.btn-label {
  line-height: 1;
}

.btn:hover,
.btn:focus-visible {
  background: var(--glass-strong);
  border-color: rgba(79, 140, 255, 0.55);
  box-shadow:
    0 0 16px rgba(79, 140, 255, 0.35),
    inset 0 0 20px rgba(79, 140, 255, 0.08);
  transform: translateY(-1px);
  outline: none;
  color: #fff;
}

.btn:active {
  transform: translateY(0);
}

.builds {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

@media (min-width: 900px) {
  .builds {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
  }

  .build {
    height: 100%;
    border: 1px solid var(--line);
    border-bottom-color: var(--line);
    background: var(--glass);
    padding: 1rem 0.95rem;
  }

  .build:hover,
  .build:focus-visible {
    transform: translateY(-2px);
  }
}

.build {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  text-decoration: none;
  color: inherit;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.build-logo {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--glass-strong);
  box-shadow: 0 0 12px rgba(79, 140, 255, 0.2);
}

.build-text {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.build:hover,
.build:focus-visible {
  background: var(--glass-strong);
  border-color: rgba(79, 140, 255, 0.35);
  box-shadow: 0 0 24px rgba(79, 140, 255, 0.15);
  transform: translateX(3px);
  outline: none;
}

.build-name {
  font-weight: 600;
  font-size: 1.02rem;
  color: #fff;
}

.build-desc {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.4;
}

.places-count {
  margin: -0.35rem 0 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-align: center;
}

.map-shell {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid rgba(79, 140, 255, 0.22);
  background: rgba(8, 10, 18, 0.72);
  backdrop-filter: blur(10px);
  overflow: hidden;
  padding: 0.5rem 0.35rem 0.75rem;
  box-shadow:
    0 0 32px rgba(79, 140, 255, 0.12),
    inset 0 0 40px rgba(79, 140, 255, 0.04);
  isolation: isolate;
}

.visited-map {
  width: 100%;
  height: clamp(220px, 52vw, 360px);
  overflow: hidden;
  touch-action: pan-x pan-y;
  isolation: isolate;
  contain: paint;
}

.visited-map .jvm-container {
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
}

.visited-map svg {
  width: 100%;
  height: 100%;
  overflow: hidden;
  /* Avoid CSS filters on SVG paths — they glitch badly on mobile zoom */
  will-change: auto;
}

.visited-map path.visited-glow,
.visited-map path.jvm-region[fill="#ff2d55"],
.visited-map path.jvm-region[fill="#ff4d6a"] {
  fill: #ff2d55 !important;
  stroke: #ff8fa3 !important;
  stroke-width: 0.85px;
  filter: none !important;
}

.visited-map path.visited-glow:hover,
.visited-map path.jvm-region[fill="#ff2d55"]:hover {
  fill: #ff4d6a !important;
  stroke: #ffb3c1 !important;
  filter: none !important;
}

.map-hint {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--sea);
  min-height: 1.2em;
  text-shadow: 0 0 12px rgba(79, 140, 255, 0.35);
}

.jvm-zoom-btn {
  border: 1px solid rgba(79, 140, 255, 0.35) !important;
  background: rgba(10, 12, 20, 0.9) !important;
  color: var(--ink) !important;
  border-radius: 8px !important;
  box-shadow: 0 0 12px rgba(79, 140, 255, 0.2) !important;
}

.jvm-tooltip {
  background: #0c1018 !important;
  color: #fff !important;
  border: 1px solid rgba(79, 140, 255, 0.4) !important;
  border-radius: 8px !important;
  font-family: var(--font-body) !important;
  font-size: 0.8rem !important;
  box-shadow: 0 0 16px rgba(79, 140, 255, 0.3) !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%) translateY(8px);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(12, 14, 22, 0.95);
  border: 1px solid rgba(79, 140, 255, 0.45);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 20;
  box-shadow: 0 0 24px rgba(79, 140, 255, 0.35);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 380px) {
  .btn-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Mobile / compact layout —— */
@media (max-width: 899px) {
  body {
    -webkit-tap-highlight-color: rgba(79, 140, 255, 0.2);
  }

  .atmosphere::before {
    filter: blur(28px);
    animation: none;
    opacity: 0.85;
  }

  .page {
    width: min(100% - 1.25rem, 440px);
    padding:
      max(1.25rem, env(safe-area-inset-top))
      0
      max(2.5rem, env(safe-area-inset-bottom));
  }

  .hero {
    min-height: auto;
    padding: 1.25rem 0 0.35rem;
    gap: 0.75rem;
  }

  .portrait-wrap {
    width: 112px;
    height: 112px;
    box-shadow:
      0 0 18px var(--glow-teal),
      0 0 36px rgba(255, 77, 106, 0.28);
    animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .name {
    margin-top: 0.15rem;
  }

  .name-latin {
    font-size: clamp(2rem, 8.5vw, 2.55rem);
  }

  .name-cn {
    font-size: 1.2rem;
    letter-spacing: 0.22em;
  }

  .intro {
    font-size: 0.98rem;
    max-width: 26ch;
    line-height: 1.4;
  }

  .section {
    margin-top: 1.75rem;
  }

  .section-title {
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    letter-spacing: 0.12em;
  }

  .btn-grid {
    gap: 0.5rem;
  }

  .btn {
    min-height: 2.85rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 12px;
  }

  .btn.revealed {
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    word-break: break-all;
  }

  .builds {
    gap: 0.45rem;
  }

  .build {
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    background: var(--glass);
    border-radius: 12px;
    min-height: 3.5rem;
  }

  .build:hover,
  .build:focus-visible,
  .build:active {
    transform: none;
    background: var(--glass-strong);
    border-color: rgba(79, 140, 255, 0.4);
  }

  .build-name {
    font-size: 0.95rem;
  }

  .build-desc {
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .section-map {
    width: 100%;
    margin-top: 1.75rem;
  }

  .places-count {
    margin: -0.2rem 0 0.65rem;
    font-size: 0.82rem;
  }

  .map-shell {
    border-radius: 12px;
    padding: 0.35rem 0.2rem 0.55rem;
  }

  .visited-map {
    height: min(52vw, 240px);
    min-height: 200px;
  }

  .map-hint {
    font-size: 0.75rem;
    padding: 0 0.5rem;
  }

  .jvm-zoom-btn {
    width: 32px !important;
    height: 32px !important;
    line-height: 30px !important;
  }

  .toast {
    bottom: max(1rem, env(safe-area-inset-bottom));
    max-width: calc(100% - 2rem);
  }
}

@media (max-width: 380px) {
  .btn-grid {
    grid-template-columns: 1fr 1fr;
  }

  .btn {
    font-size: 0.85rem;
    padding: 0.6rem 0.5rem;
  }
}

@media (min-width: 600px) and (max-width: 899px) {
  .page {
    width: min(100% - 2rem, 640px);
  }

  .builds {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }

  .visited-map {
    height: 300px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .atmosphere,
  .atmosphere::before,
  .portrait-wrap {
    animation: none;
  }
}
