.tm-intro {
  padding: 56px 0 8px;
  text-align: center;
  background: radial-gradient(circle at 50% 0%, var(--lighter-background), var(--background) 70%);
}

.tm-intro h1 {
  color: var(--foreground);
  font-size: 2rem;
  margin-bottom: 8px;
}

.tm-intro .tagline {
  color: var(--light-foreground);
  font-size: 0.95rem;
}

.tm-panel {
  padding: 32px 0 80px;
}

.tm-wrap {
  max-width: 1200px;
}

.tm-map-box {
  background: var(--lighter-background);
  border: 1px solid var(--muted);
  border-radius: 12px;
  padding: 14px;
}

.tm-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--light-foreground);
}

.tm-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.tm-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  animation: tm-blink 1.4s ease-in-out infinite;
}

@keyframes tm-blink {
  50% { opacity: 0.25; }
}

.tm-map {
  position: relative;
  background: var(--dark-background);
  border-radius: 8px;
  overflow: hidden;
}

#tm-canvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
}

.tm-message {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  color: var(--light-foreground);
}

.tm-tooltip {
  position: absolute;
  pointer-events: none;
  max-width: 240px;
  background: var(--dark-background);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--foreground);
  transform: translate(-50%, calc(-100% - 12px));
  white-space: nowrap;
}

.tm-tooltip strong {
  color: var(--accent);
}

.tm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  list-style: none;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--light-foreground);
}

.tm-legend li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.tm-key {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.tm-key-source { background: var(--red); }
.tm-key-l3 { background: var(--accent); border-radius: 2px; height: 3px; width: 16px; }
.tm-key-l7 { background: #e86fd8; border-radius: 2px; height: 3px; width: 16px; }
.tm-key-origin { border: 1.5px solid rgba(246, 220, 172, 0.75); background: rgba(246, 220, 172, 0.1); }
.tm-key-c2 { background: var(--cyan); transform: rotate(45deg); border-radius: 1px; width: 9px; height: 9px; }

.tm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.tm-card {
  background: var(--lighter-background);
  border: 1px solid var(--muted);
  border-radius: 12px;
  padding: 16px 18px;
  min-width: 0;
}

.tm-card h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--light-foreground);
  margin-bottom: 12px;
}

.tm-card-feed {
  grid-column: 1 / -1;
}

.tm-feed {
  list-style: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  /* Exactly FEED_MAX (8) rows, so the box never shows a half-cut row. */
  height: calc(8 * (1.45em + 0.4em + 1px));
  overflow: hidden;
}

.tm-feed li {
  padding: 0.2em 0;
  border-bottom: 1px solid rgba(42, 107, 120, 0.35);
  color: var(--foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: tm-in 0.4s ease-out;
}

.tm-feed .tm-feed-time {
  color: var(--muted);
  margin-right: 6px;
}

.tm-feed .tm-tag {
  font-weight: 700;
  margin-right: 6px;
}

.tm-tag-src { color: var(--red); }
.tm-tag-l3 { color: var(--accent); }
.tm-tag-l7 { color: #e86fd8; }
.tm-tag-c2 { color: var(--cyan); }

@keyframes tm-in {
  from { opacity: 0; transform: translateY(-6px); }
}

.tm-bars {
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 0.85rem;
}

.tm-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
}

.tm-bar-label span:last-child {
  color: var(--light-foreground);
  font-variant-numeric: tabular-nums;
}

.tm-bar-track {
  height: 6px;
  background: var(--dark-background);
  border-radius: 999px;
  overflow: hidden;
}

.tm-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.tm-note {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--light-foreground);
  line-height: 1.6;
}

@media (max-width: 600px) {
  .tm-intro {
    padding-top: 36px;
  }

  .tm-map-box {
    padding: 10px;
  }

  #tm-canvas {
    aspect-ratio: 1.6 / 1;
  }

  .tm-status {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tm-live-dot,
  .tm-feed li {
    animation: none;
  }
}

.tm-status-right {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.tm-fs-btn {
  background: var(--dark-background);
  border: 1px solid var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--foreground);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.tm-fs-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tm-fs-title {
  display: none;
}

/* ---- full screen (TV mode) ----
   Sizes are in vw/vh so the overlays scale with the display: readable from
   the couch on a TV, still sensible on a laptop. */

body.tm-fs-open {
  overflow: hidden;
}

.tm-map-box.is-fullscreen {
  position: fixed;
  inset: 0;
  /* Above the SomaFM player too, for the CSS-only fallback. */
  z-index: 2147483000;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  padding: 0;
  border: none;
  border-radius: 0;
  background: var(--dark-background);
}

.tm-map-box.is-fullscreen.is-idle,
.tm-map-box.is-fullscreen.is-idle * {
  cursor: none;
}

.is-fullscreen .tm-map {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.is-fullscreen #tm-canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
}

.is-fullscreen .tm-status {
  position: absolute;
  top: 2.5vh;
  left: 2vw;
  right: 2vw;
  z-index: 2;
  margin: 0;
  flex-direction: row;
  align-items: center;
  font-size: clamp(0.8rem, 1vw, 1.4rem);
}

.is-fullscreen .tm-live {
  font-size: clamp(0.75rem, 0.95vw, 1.3rem);
  gap: 0.7em;
}

.is-fullscreen .tm-live-dot {
  width: 0.7em;
  height: 0.7em;
}

.is-fullscreen .tm-fs-title {
  display: inline;
  margin-left: 0.9em;
  padding-left: 0.9em;
  border-left: 1px solid var(--muted);
  color: var(--foreground);
  letter-spacing: 0.12em;
}

.is-fullscreen .tm-fs-btn {
  font-size: inherit;
  padding: 0.3em 1em;
  opacity: 0.75;
}

.is-fullscreen.is-idle .tm-fs-btn {
  opacity: 0;
}

.is-fullscreen .tm-legend {
  position: absolute;
  right: 2vw;
  bottom: 2.5vh;
  z-index: 2;
  max-width: 34vw;
  margin: 0;
  flex-direction: column;
  gap: 0.5em;
  padding: 0.9em 1.2em;
  background: rgba(3, 18, 34, 0.78);
  border: 1px solid var(--muted);
  border-radius: 10px;
  font-size: clamp(0.75rem, 0.9vw, 1.25rem);
}

.is-fullscreen .tm-key {
  width: 0.8em;
  height: 0.8em;
}

.is-fullscreen .tm-key-l3,
.is-fullscreen .tm-key-l7 {
  width: 1.4em;
  height: 0.25em;
}

/* A narrow column over the Pacific, so it stays clear of South America. */
.is-fullscreen .tm-card-feed {
  position: absolute;
  left: 2vw;
  bottom: 2.5vh;
  z-index: 2;
  width: min(20.5vw, 460px);
  padding: 1em 1.3em;
  background: rgba(3, 18, 34, 0.78);
  border-radius: 10px;
  font-size: clamp(0.8rem, 1vw, 1.4rem);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.is-fullscreen .tm-card-feed h2 {
  font-size: 0.85em;
  margin-bottom: 0.6em;
}

.is-fullscreen .tm-feed {
  font-size: 0.85em;
  /* 4 entries of 3 lines each: time + tag, then up to 2 lines of detail. */
  height: calc(4 * (3 * 1.45em + 0.4em + 1px));
}

.is-fullscreen .tm-feed li {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: 1.45em 2.9em;
  white-space: normal;
}

.is-fullscreen .tm-feed li:nth-child(n + 5) {
  display: none;
}

.is-fullscreen .tm-feed-text {
  grid-column: 1 / -1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

@media (max-width: 600px) {
  .is-fullscreen .tm-card-feed {
    width: auto;
    right: 2vw;
    bottom: auto;
    top: 62vh;
  }

  .is-fullscreen .tm-legend {
    display: none;
  }
}
