:root {
  color-scheme: dark;
  --bg: #080807;
  --panel: #151411;
  --panel-2: #1f1d18;
  --text: #f3efe3;
  --muted: #b8b1a1;
  --line: #3b382f;
  --gold: #f0b94c;
  --green: #6cc27a;
  --teal: #64c6bd;
  --red: #e2735f;
  --blue: #7bb5e8;
  --ink: #0d0c0a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Yu Gothic UI",
    "Hiragino Kaku Gothic ProN",
    Meiryo,
    system-ui,
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, rgba(240, 185, 76, 0.13), transparent 32rem),
    radial-gradient(circle at 80% 4%, rgba(100, 198, 189, 0.12), transparent 28rem),
    linear-gradient(135deg, #080807 0%, #12100c 56%, #081211 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px;
}

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

.kicker {
  margin: 0 0 7px;
  color: var(--gold);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(1.25rem, 2vw, 2rem);
  line-height: 1.15;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.04rem;
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span {
  border: 1px solid var(--line);
  background: rgba(21, 20, 17, 0.82);
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.mission-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.78fr);
  gap: 16px;
  align-items: stretch;
}

.planet-stage,
.briefing-panel,
.timeline-section,
.clock-panel,
.cause-panel {
  border: 1px solid var(--line);
  background: rgba(21, 20, 17, 0.88);
  box-shadow: var(--shadow);
}

.planet-stage {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border-radius: 8px;
}

.stage-copy {
  position: absolute;
  z-index: 3;
  left: 24px;
  top: 24px;
  width: min(520px, calc(100% - 48px));
  max-width: min(520px, calc(100% - 48px));
}

.stage-copy h2 {
  font-size: clamp(1.7rem, 4vw, 4.2rem);
  max-width: 780px;
}

.stage-copy p:last-child {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.8;
  overflow-wrap: anywhere;
}

#planet-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.history-art {
  position: absolute;
  right: 18px;
  bottom: 16px;
  z-index: 2;
  width: min(440px, 52%);
  opacity: 0.92;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.4));
  pointer-events: none;
}

.briefing-panel {
  border-radius: 8px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.metric-grid div,
.detail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px;
}

dt {
  color: var(--muted);
  font-size: 0.8rem;
}

dd {
  margin: 4px 0 0;
  font-weight: 800;
}

.detail-block p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.75;
}

.detail-block.compact {
  background: #151f1b;
}

.primary-action {
  margin-top: auto;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 14px 16px;
  color: #15110a;
  background: var(--gold);
  font-weight: 900;
}

.primary-action:focus-visible,
.filter:focus-visible,
.event-card:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.control-band {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 16px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 29, 24, 0.86);
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 13px;
  color: var(--text);
  background: #11100d;
  font-weight: 800;
}

.filter.is-active {
  color: var(--ink);
  background: var(--teal);
  border-color: var(--teal);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(330px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: #0f0e0c;
  color: var(--muted);
}

.search-box span {
  flex: 0 0 auto;
  font-weight: 800;
  font-size: 0.85rem;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  min-height: 42px;
  color: var(--text);
  background: transparent;
}

.timeline-section {
  border-radius: 8px;
  padding: 18px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head p:last-child,
#result-count,
#clock-readout {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.timeline-rail {
  position: relative;
  height: 86px;
  margin: 4px 0 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(240, 185, 76, 0.25), rgba(108, 194, 122, 0.18), rgba(123, 181, 232, 0.2), rgba(226, 115, 95, 0.2)),
    #10100d;
  overflow: hidden;
}

.timeline-rail::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 43px;
  height: 2px;
  background: rgba(243, 239, 227, 0.4);
}

.tick {
  position: absolute;
  top: 28px;
  width: 14px;
  height: 14px;
  transform: translateX(-50%);
  border: 2px solid var(--text);
  border-radius: 50%;
  background: var(--panel);
}

.tick.is-selected {
  width: 22px;
  height: 22px;
  top: 24px;
  background: var(--gold);
  border-color: var(--gold);
}

.tick-label {
  position: absolute;
  top: 52px;
  transform: translateX(-50%);
  max-width: 120px;
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
  display: none;
}

.tick-label.is-visible {
  display: block;
}

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

.event-card {
  display: grid;
  gap: 9px;
  min-height: 166px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  color: var(--text);
  text-align: left;
  background: #11100d;
}

.event-card.is-selected {
  border-color: var(--gold);
  background: #211b10;
}

.event-card strong {
  font-size: 1rem;
  line-height: 1.35;
}

.event-card small {
  color: var(--muted);
  font-weight: 800;
}

.event-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.88rem;
}

.category-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
}

.category-dot.life {
  background: var(--green);
}

.category-dot.climate {
  background: var(--blue);
}

.category-dot.civilization {
  background: var(--red);
}

.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.clock-panel,
.cause-panel {
  border-radius: 8px;
  padding: 18px;
}

.clock-face {
  position: relative;
  min-height: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    conic-gradient(from -90deg, rgba(240, 185, 76, 0.26), rgba(108, 194, 122, 0.18), rgba(123, 181, 232, 0.2), rgba(226, 115, 95, 0.2), rgba(240, 185, 76, 0.26)),
    #11100d;
  overflow: hidden;
}

.clock-face::before {
  content: "";
  position: absolute;
  inset: 16%;
  border: 1px solid rgba(243, 239, 227, 0.24);
  border-radius: 50%;
}

.clock-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: 0 0;
}

.clock-marker span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text);
  transform: translate(-5px, -5px);
}

.clock-marker b {
  position: absolute;
  left: 12px;
  top: -10px;
  width: 112px;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.3;
}

.chain-list {
  margin: 0;
  padding-left: 21px;
  color: var(--muted);
  line-height: 1.9;
}

.chain-list li + li {
  margin-top: 10px;
}

.chain-list span {
  color: var(--text);
  font-weight: 900;
}

@media (max-width: 1050px) {
  .mission-layout,
  .knowledge-layout {
    grid-template-columns: 1fr;
  }

  .briefing-panel {
    min-height: auto;
  }

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

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

  .topbar,
  .control-band,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .planet-stage {
    min-height: 560px;
  }

  .history-art {
    width: 76%;
    right: -10px;
    bottom: 14px;
  }

  .stage-copy {
    left: 16px;
    top: 18px;
    width: calc(100% - 32px);
    max-width: calc(100% - 32px);
  }

  .stage-copy p:last-child {
    max-width: 30ch;
    word-break: break-all;
  }

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

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

  .search-box {
    width: 100%;
  }

  .clock-marker b {
    display: none;
  }
}
