:root {
  --bg-deep: #021225;
  --bg-mid: #03233d;
  --panel: rgba(5, 28, 48, 0.82);
  --panel-border: rgba(87, 172, 201, 0.22);
  --text-main: #d9ebf6;
  --text-muted: #8db2c5;
  --accent: #23d0c3;
  --accent-soft: rgba(35, 208, 195, 0.14);
  --good: #f0c040;
  --fair: #f08040;
  --poor: #e05060;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text-main);
  font-family: "Spectral", serif;
  background: radial-gradient(circle at 18% 18%, #0f3a5f 0%, #03233d 24%, #021225 65%, #01080f 100%);
  min-height: 100vh;
}

.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 80% 15%, rgba(35, 208, 195, 0.09), transparent 40%),
    radial-gradient(circle at 20% 85%, rgba(52, 124, 201, 0.12), transparent 35%);
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 30px;
  display: grid;
  gap: 12px;
}

.panel {
  background: linear-gradient(140deg, var(--panel), rgba(4, 24, 43, 0.88));
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 18px 38px rgba(0, 6, 12, 0.26);
  animation: rise-in 300ms ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  text-align: center;
  padding-top: 18px;
  padding-bottom: 18px;
}

.dev-support {
  border-color: rgba(108, 228, 184, 0.45);
  background: linear-gradient(130deg, rgba(15, 86, 63, 0.45), rgba(4, 36, 53, 0.92));
}

.support-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.support-copy {
  min-width: 0;
}

.support-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.66rem;
  color: #8af0c7;
}

.support-text {
  margin: 6px 0 0;
  color: #d1e9f4;
  font-size: 0.95rem;
}

.support-cta {
  flex-shrink: 0;
  text-decoration: none;
  border: 1px solid rgba(155, 255, 222, 0.6);
  background: linear-gradient(135deg, #22d0a8, #25b1d6);
  color: #032432;
  font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  transition: transform 160ms ease, filter 160ms ease;
}

.support-cta:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.28em;
  font-size: 0.65rem;
  text-transform: uppercase;
  color: #7cc6da;
}

.hero h1 {
  margin: 6px 0 4px;
  line-height: 1.1;
  font-family: "Fraunces", serif;
  font-size: clamp(1.45rem, 2.8vw, 2.4rem);
  font-weight: 700;
}

.subhead {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.live-bar {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.live-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.live-label {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.65rem;
  color: #7cc6da;
}

.live-value strong {
  color: var(--accent);
  font-weight: 700;
}

.live-time {
  margin-left: auto;
  font-size: 0.75rem;
  color: #6f94a8;
}

.top-card {
  padding: 16px;
  border-color: rgba(0, 229, 160, 0.36);
  background: linear-gradient(135deg, rgba(0, 229, 160, 0.08), rgba(5, 42, 36, 0.22));
}

.top-grid {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.top-label {
  margin: 0 0 2px;
  letter-spacing: 0.21em;
  font-size: 0.64rem;
  text-transform: uppercase;
  color: #6ce4b8;
}

.top-name {
  margin: 0;
  font-size: clamp(1.02rem, 2.6vw, 1.4rem);
}

.top-meta {
  margin: 4px 0 0;
  color: #9ed0de;
  font-size: 0.84rem;
}

.top-score {
  text-align: right;
}

.top-percent {
  margin: 0;
  line-height: 1;
  font-size: clamp(1.8rem, 4.8vw, 2.8rem);
  color: #6ce4b8;
  font-family: "Fraunces", serif;
}

.top-caption {
  margin: 0;
  font-size: 0.74rem;
  color: #9ed0de;
}

.controls h2,
.section-title {
  margin: 0 0 8px;
  font-family: "Fraunces", serif;
  font-size: 1.12rem;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.button-row {
  display: flex;
  gap: 6px;
}

button.ghost {
  border: 1px solid rgba(87, 172, 201, 0.35);
  background: rgba(30, 62, 90, 0.2);
  color: #a4d0df;
  border-radius: 9px;
  padding: 7px 10px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

button.ghost:hover {
  background: rgba(35, 208, 195, 0.14);
  color: #d5eef7;
}

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

.control-block {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(4, 30, 50, 0.44);
  border: 1px solid rgba(87, 172, 201, 0.14);
}

.control-block span {
  font-size: 0.85rem;
  color: #a9cad8;
}

.control-block strong {
  color: #d6eef7;
  font-size: 0.95rem;
}

.control-block-full {
  grid-column: 1 / -1;
}

.control-inline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: #8ab2c5;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  border: 1px solid rgba(87, 172, 201, 0.28);
  border-radius: 8px;
  background: rgba(4, 24, 40, 0.95);
  color: #d9ebf6;
  padding: 7px;
  font: inherit;
}

input[type="range"] {
  accent-color: #4ab8d8;
}

.split-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}

#mapSvg {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  border: 1px solid rgba(74, 184, 216, 0.2);
  background: #011428;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#mapSvg.dragging {
  cursor: grabbing;
}

.muted {
  margin: 8px 0 0;
  color: #7b9eb0;
  font-size: 0.82rem;
}

.map-selection-info {
  margin-top: 8px;
  min-height: 86px;
  border-radius: 10px;
  border: 1px solid rgba(87, 172, 201, 0.22);
  background: rgba(4, 30, 50, 0.42);
  padding: 10px;
}

.map-selection-empty {
  margin: 0;
  color: #86a8ba;
  font-size: 0.86rem;
}

.map-selection-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.map-selection-name {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1rem;
  color: #d6edf7;
}

.map-selection-score {
  margin: 0;
  font-weight: 700;
  font-size: 0.95rem;
}

.map-selection-meta {
  margin: 0;
  color: #99bfd1;
  font-size: 0.82rem;
}

.map-selection-tip {
  margin: 6px 0 0;
  color: #b8d7e5;
  font-size: 0.85rem;
  line-height: 1.4;
}

.rankings {
  display: grid;
  gap: 7px;
}

.rank-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(87, 172, 201, 0.18);
  border-radius: 10px;
  background: rgba(4, 30, 50, 0.36);
  color: var(--text-main);
  padding: 10px;
  cursor: pointer;
  font: inherit;
}

.rank-item.active {
  border-color: rgba(35, 208, 195, 0.5);
  background: rgba(35, 208, 195, 0.09);
}

.rank-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.rank-index {
  display: inline-block;
  width: 24px;
  color: #7b9eb0;
}

.rank-name {
  flex: 1;
  font-weight: 600;
}

.rank-pct {
  font-weight: 700;
}

.rank-bar {
  margin-top: 5px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.rank-fill {
  height: 100%;
  border-radius: 999px;
}

.rank-meta {
  margin-top: 4px;
  font-size: 0.78rem;
  color: #86a8ba;
}

.detail-panel {
  min-height: 140px;
}

.detail-empty {
  margin: 0;
  font-size: 0.9rem;
  color: #86a8ba;
}

.detail-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.detail-top h3 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 1.2rem;
}

.detail-stars {
  margin: 4px 0 0;
  color: #9ac9db;
  font-size: 0.86rem;
}

.detail-pct {
  margin: 0;
  font-family: "Fraunces", serif;
  font-size: 2rem;
  line-height: 1;
}

.detail-badge {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.11em;
}

.detail-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  font-size: 0.85rem;
  color: #99c0d2;
}

.detail-grid span strong {
  color: #d8edf6;
}

.detail-guide {
  margin-top: 10px;
  border-left: 2px solid rgba(35, 208, 195, 0.5);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(35, 208, 195, 0.06);
  color: #9ac2d3;
  font-size: 0.86rem;
}

.detail-tips {
  margin: 9px 0 0;
  color: #abcfe0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.tip-text {
  margin: 0;
  color: #c0ddea;
  line-height: 1.5;
}

.status-bad {
  color: #ffb8b8;
}

@media (max-width: 960px) {
  .split-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .panel {
    padding: 12px;
  }

  .support-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .support-cta {
    width: 100%;
    text-align: center;
  }

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

  .panel-title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-grid {
    flex-direction: column;
    align-items: flex-start;
  }

  .top-score {
    text-align: left;
  }
}
