@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&display=swap');

/* JetBrains Mono has no Han glyphs, so CJK falls through to whatever the
   system provides. Order runs Linux, Windows, macOS. */
:root {
  --bg: #0a0a0a;
  --fg: #33ff33;
  --dim: #777;
  --dimmer: #555;
  --line: #1a1a1a;
  --line-lit: #2a2a2a;
  --panel: #0e0e0e;
  --mono: 'JetBrains Mono', 'Noto Sans CJK SC', 'Noto Sans SC', 'Source Han Sans SC',
    'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', monospace;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--mono);
  background: var(--bg);
  color: var(--fg);
  padding: 2rem;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(51, 255, 51, 0.01) 2px,
    rgba(51, 255, 51, 0.01) 4px
  );
  pointer-events: none;
  z-index: 100;
}

.wrap {
  max-width: 1400px;
  margin: 0 auto;
}

/* ---- header ---- */

.topbar {
  margin-bottom: 2rem;
}

.prompt {
  color: #888;
  font-size: 0.8rem;
  margin-bottom: 0.3rem;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.tagline {
  color: var(--dim);
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 68ch;
}

.tagline a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--line-lit);
}

.tagline a:hover {
  border-bottom-color: var(--fg);
}

/* ---- layout ---- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.5rem;
  align-items: start;
}

.section-label {
  color: var(--dimmer);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 0.8rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #222;
}

/* ---- map ---- */

.mapwrap {
  min-width: 0;
}

#map {
  display: block;
  width: 100%;
  height: auto;
  background: #060606;
  border: 1px solid var(--line);
  border-radius: 2px;
  touch-action: manipulation;
}

.prov {
  stroke: #0a0a0a;
  stroke-width: 1.2;
  cursor: pointer;
  transition: fill 0.45s ease, filter 0.2s;
}

.prov:hover {
  filter: brightness(1.45);
}

.prov.sel {
  stroke: var(--fg);
  stroke-width: 2.2;
}

.prov:focus-visible {
  outline: none;
  stroke: var(--fg);
  stroke-width: 2.2;
}

.coast {
  fill: none;
  stroke: #3f4a55;
  stroke-width: 1.6;
  pointer-events: none;
}

.river {
  fill: none;
  stroke: #2f6f8f;
  stroke-width: 2.4;
  stroke-linecap: round;
  opacity: 0.85;
  pointer-events: none;
}

.plabel {
  pointer-events: none;
  text-anchor: middle;
  fill: #f0f0f0;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.85);
  stroke-width: 3.5;
}

.plabel .han {
  font-size: 17px;
  font-weight: 700;
}

.plabel .rom {
  font-size: 11px;
  fill: #b9b9b9;
}

.city {
  pointer-events: none;
}

.city circle {
  fill: #d8d8d8;
  opacity: 0.55;
}

.city text {
  font-size: 10.5px;
  fill: #9a9a9a;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.8);
  stroke-width: 3;
}

/* ---- battle pins ---- */

.battle {
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.battle.on {
  opacity: 1;
  pointer-events: auto;
}

.battle .ring {
  fill: rgba(10, 10, 10, 0.75);
  stroke: #ffd24d;
  stroke-width: 2;
}

.battle .x {
  stroke: #ffd24d;
  stroke-width: 2;
  stroke-linecap: round;
}

.battle text {
  font-size: 11px;
  fill: #ffd24d;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.85);
  stroke-width: 3.5;
}

.battle:hover .ring,
.battle.sel .ring {
  fill: #ffd24d;
}

.battle:hover .x,
.battle.sel .x {
  stroke: #0a0a0a;
}

.battle.fresh .ring {
  animation: pulse 1.4s ease-out 3;
}

@keyframes pulse {
  0% { r: 7; stroke-opacity: 1; }
  100% { r: 16; stroke-opacity: 0; }
}

/* ---- campaign routes ---- */

.route {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  pointer-events: none;
}

.route.on {
  opacity: 0.95;
}

.route-head {
  opacity: 0;
  pointer-events: none;
}

.route-head.on {
  opacity: 1;
}

/* ---- timeline ---- */

.timeline {
  margin-top: 1.2rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1rem 1.1rem 1.2rem;
  background: var(--panel);
}

.yearhead {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.yearhead .y {
  font-size: 1.5rem;
  font-weight: 700;
}

.yearhead .han {
  font-size: 1.05rem;
  color: #e6e6e6;
}

.yearhead .rom {
  font-size: 0.8rem;
  color: var(--dim);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 2px;
  background: #2a2a2a;
}

input[type='range']::-moz-range-track {
  height: 2px;
  background: #2a2a2a;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fg);
  border: none;
}

input[type='range']:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 4px;
}

.ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 0.2rem;
}

.ticks button {
  background: none;
  border: none;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--dimmer);
  cursor: pointer;
  padding: 0.2rem 0.1rem;
}

.ticks button:hover {
  color: var(--fg);
}

.ticks button[aria-current='true'] {
  color: var(--fg);
  font-weight: 700;
}

.blurb {
  margin-top: 0.9rem;
  color: #a8a8a8;
  font-size: 0.8rem;
  line-height: 1.7;
  max-width: 82ch;
}

/* ---- sidebar ---- */

.side {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  min-width: 0;
}

.card {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.9rem 1rem;
  background: var(--panel);
}

.legend-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.75rem;
}

.sw {
  width: 13px;
  height: 13px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.legend-row .han {
  color: #e6e6e6;
}

.legend-row .rom {
  color: var(--dim);
}

#detail h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f0f0f0;
  margin-bottom: 0.15rem;
}

#detail .sub {
  font-size: 0.72rem;
  color: var(--dim);
  margin-bottom: 0.6rem;
}

#detail p {
  font-size: 0.76rem;
  line-height: 1.7;
  color: #a8a8a8;
}

#detail .owner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  margin-bottom: 0.6rem;
}

#detail .hint {
  color: var(--dimmer);
  font-size: 0.75rem;
  line-height: 1.7;
}

.camp-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.camp {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  font-family: var(--mono);
  background: none;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 0.5rem 0.6rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.camp:hover {
  border-color: var(--fg);
  background: rgba(51, 255, 51, 0.03);
}

.camp[aria-pressed='true'] {
  border-color: var(--fg);
  background: rgba(51, 255, 51, 0.06);
}

.camp .han {
  font-size: 0.78rem;
  color: #e6e6e6;
}

.camp .span {
  font-size: 0.65rem;
  color: var(--dimmer);
}

.camp .glyph {
  font-size: 0.7rem;
  color: var(--dimmer);
}

.camp[aria-pressed='true'] .glyph {
  color: var(--fg);
}

#campText {
  margin-top: 0.7rem;
  font-size: 0.73rem;
  line-height: 1.7;
  color: #909090;
}

details.roster summary {
  cursor: pointer;
  color: var(--dimmer);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  list-style: none;
}

details.roster summary::-webkit-details-marker {
  display: none;
}

details.roster summary::before {
  content: '+ ';
}

details.roster[open] summary::before {
  content: '- ';
}

details.roster summary:hover {
  color: var(--fg);
}

.roster-list {
  margin-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 340px;
  overflow-y: auto;
}

.fig {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem;
  font-size: 0.72rem;
  line-height: 1.5;
}

.fig .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-top: 0.3rem;
}

.fig .han {
  color: #e6e6e6;
}

.fig .rom {
  color: var(--dim);
}

.fig .role {
  color: var(--dimmer);
  font-size: 0.68rem;
}

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: #444;
  font-size: 0.7rem;
  line-height: 1.8;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .roster-list {
    max-height: none;
  }
}

@media (max-width: 600px) {
  body {
    padding: 1.5rem 1rem;
  }
  h1 {
    font-size: 1.3rem;
  }
  .ticks button {
    font-size: 0.58rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }
  .battle.fresh .ring {
    animation: none;
  }
  .prov {
    transition: none;
  }
}
