:root {
  --bg: #07111f;
  --bg-soft: #0f1d32;
  --panel: rgba(9, 20, 36, 0.76);
  --panel-strong: rgba(14, 30, 52, 0.92);
  --panel-border: rgba(148, 180, 255, 0.15);
  --text: #f4f7fb;
  --muted: #9fb0ca;
  --accent: #58c4dd;
  --accent-strong: #7e8bff;
  --accent-warm: #f9966b;
  --success: #6fdfb2;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Instrument Serif",
    "Iowan Old Style",
    "Palatino Linotype",
    "Book Antiqua",
    serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(126, 139, 255, 0.2), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(88, 196, 221, 0.18), transparent 24%),
    radial-gradient(circle at bottom center, rgba(249, 150, 107, 0.14), transparent 30%),
    linear-gradient(180deg, #08111e 0%, #0b1628 50%, #07111f 100%);
}

button,
input {
  font: inherit;
}

a {
  color: #8ecfff;
}

.page-shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  justify-content: flex-start;
  gap: 24px;
  align-items: end;
  margin-bottom: 14px;
  padding: 8px 6px 0;
}

.eyebrow,
.panel__eyebrow,
.meta-label {
  margin: 0 0 10px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  font-size: 0.76rem;
  font-weight: 700;
}

h1,
h2,
h3,
strong,
.track-title {
  font-weight: 600;
}

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

h1 {
  margin-bottom: 0;
  max-width: none;
  font-size: clamp(1.8rem, 2.8vw, 3.1rem);
  line-height: 0.98;
  white-space: nowrap;
}

h2 {
  font-size: 1.7rem;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(380px, 0.85fr);
  gap: 18px;
}

.panel {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(16, 31, 54, 0.96), rgba(8, 18, 32, 0.9)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(135deg, rgba(126, 139, 255, 0.08), transparent 30%),
    radial-gradient(circle at top right, rgba(88, 196, 221, 0.12), transparent 28%);
}

.panel > * {
  position: relative;
  z-index: 1;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.map-panel {
  min-height: 820px;
  --map-flag-url: none;
}

.map-panel::after {
  content: "";
  position: absolute;
  inset: 84px 22px 22px;
  border-radius: 22px;
  background-image: var(--map-flag-url);
  background-repeat: no-repeat;
  background-position: center;
  background-size: min(68%, 720px);
  opacity: 0.055;
  filter: grayscale(1) contrast(1.05);
  pointer-events: none;
  z-index: 0;
}

.map-panel .panel__header {
  min-height: 132px;
  align-items: stretch;
}

#map {
  min-height: 730px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(159, 176, 202, 0.14);
}

.sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}

.listening-panel {
  margin-top: 18px;
}

.listening-stats {
  max-height: 260px;
  overflow: auto;
  padding-right: 6px;
}

.listening-stats__empty {
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(159, 176, 202, 0.18);
  background: rgba(255, 255, 255, 0.025);
  color: var(--muted);
  line-height: 1.6;
}

.listening-stats__row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(159, 176, 202, 0.1);
}

.listening-stats__row:last-child {
  border-bottom: none;
}

.listening-stats__rank {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(88, 196, 221, 0.12);
  border: 1px solid rgba(88, 196, 221, 0.18);
  color: #c2f6ff;
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
}

.listening-stats__copy {
  min-width: 0;
}

.listening-stats__copy strong,
.listening-stats__copy span {
  display: block;
}

.listening-stats__copy span {
  margin-top: 3px;
  color: var(--muted);
}

.attribution-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 18px;
  padding: 10px 6px 0;
  color: var(--muted);
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  font-size: 0.84rem;
  line-height: 1.5;
}

.attribution-footer span::after {
  content: "•";
  margin-left: 18px;
  color: rgba(159, 176, 202, 0.4);
}

.attribution-footer span:last-child::after {
  display: none;
}

.map-note,
.country-description,
.status-message,
.wander-note,
.player__meta,
.track-meta {
  color: var(--muted);
}

.country-info-card {
  min-width: 260px;
  max-width: 320px;
  height: 132px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(159, 176, 202, 0.14);
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
}

.country-info-card__label {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
}

.country-info-card__value {
  color: var(--text);
  line-height: 1.45;
  font-size: 1rem;
  min-height: 0;
  flex: 1;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.country-info-card__value img {
  display: block;
  width: 100%;
  height: 76px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid rgba(159, 176, 202, 0.18);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform 160ms ease,
    opacity 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  color: #06111e;
  background: linear-gradient(135deg, var(--accent), #89ebff);
}

.button--secondary {
  color: var(--text);
  background: linear-gradient(135deg, rgba(126, 139, 255, 0.32), rgba(88, 196, 221, 0.24));
  border: 1px solid rgba(159, 176, 202, 0.18);
}

.button--ghost {
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(159, 176, 202, 0.2);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(88, 196, 221, 0.12);
  border: 1px solid rgba(88, 196, 221, 0.18);
  color: #c2f6ff;
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-message {
  padding: 14px 15px;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(159, 176, 202, 0.2);
  background: rgba(255, 255, 255, 0.03);
  line-height: 1.6;
}

.player {
  margin-top: 18px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(159, 176, 202, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(126, 139, 255, 0.08)),
    rgba(0, 0, 0, 0.14);
}

.player--empty {
  min-height: 180px;
  display: grid;
  place-items: center;
}

.player iframe,
.player audio,
#youtube-player-host,
#youtube-player-host iframe {
  width: 100%;
}

.player iframe,
#youtube-player-host,
#youtube-player-host iframe {
  aspect-ratio: 16 / 9;
  border: none;
  border-radius: 18px;
}

.player audio {
  display: block;
}

.player__placeholder {
  color: var(--muted);
  text-align: center;
  font-size: 1.1rem;
}

.player__meta {
  margin-top: 12px;
  line-height: 1.5;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

.meta-card {
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(159, 176, 202, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.meta-card strong {
  display: block;
  font-size: 1rem;
}

.range-control {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
  color: var(--text);
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
}

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

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.wander-note {
  margin-bottom: 0;
  margin-top: 16px;
  line-height: 1.6;
}

.leaflet-container {
  background: #112844;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: rgba(14, 30, 52, 0.96);
  color: var(--text);
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  color: var(--text);
  font-family:
    "Avenir Next",
    "Segoe UI",
    sans-serif;
}

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

  .map-panel {
    min-height: 620px;
  }

  #map {
    min-height: 560px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 1440px);
    padding-top: 16px;
  }

  .topbar,
  .panel__header,
  .range-control,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .panel {
    padding: 18px;
  }

  .listening-stats {
    max-height: 220px;
  }

  .meta-grid {
    display: grid;
  }

  h1 {
    font-size: 2rem;
    white-space: normal;
  }

  .attribution-footer {
    gap: 8px 12px;
  }

  .attribution-footer span::after {
    margin-left: 12px;
  }
}
