:root {
  --bg: #0f172a;
  --bg-soft: #111827;
  --card: rgba(15, 23, 42, 0.8);
  --primary: #38bdf8;
  --secondary: #22c55e;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --shadow: rgba(15, 23, 42, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, var(--bg), var(--bg-soft));
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 40px;
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  background: rgba(15, 23, 42, 0.55);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

.selectors {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.selector-label {
  color: var(--muted);
  font-size: 0.9rem;
}

.selector-options {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.7);
}

.selector-option {
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.selector-option:hover,
.selector-option:focus-visible {
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text);
  outline: none;
}

.selector-option.is-selected {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
}

.selector-option:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.45;
}

.brand {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  text-align: center;
  margin-bottom: 30px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.view-tab {
  padding: 12px 18px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.view-tab:hover,
.view-tab:focus-visible {
  color: var(--text);
}

.view-tab.is-active {
  border-bottom-color: var(--primary);
  color: var(--text);
}

.view-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

[hidden] {
  display: none !important;
}

.animation-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.play-button {
  padding: 9px 14px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.play-button:hover,
.play-button:focus-visible {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.2);
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.speed-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.speed-control input {
  width: min(180px, 35vw);
  accent-color: var(--primary);
}

.speed-control input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.speed-control output {
  min-width: 3em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.overlay-layout {
  display: grid;
  grid-template-columns: minmax(100px, 130px) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.forecast-select {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background: var(--card);
}

.forecast-select legend {
  padding: 0 6px;
  color: var(--text);
  font-weight: 700;
}

.forecast-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-flow: column;
  gap: 2px;
}

.forecast-option {
  width: 100%;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.forecast-option:hover,
.forecast-option:focus-visible {
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--text);
  outline: none;
}

.forecast-option.is-selected {
  border-color: rgba(56, 189, 248, 0.3);
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
}

.forecast-option.is-active {
  border-color: var(--primary);
  background: rgba(56, 189, 248, 0.26);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary), 0 0 12px rgba(56, 189, 248, 0.18);
}

.overlay-content {
  min-width: 0;
}

.overlay {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 3;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background: var(--bg-soft);
  box-shadow: 0 12px 28px var(--shadow);
}

@media (min-width: 641px) {
  .overlay {
    width: min(100%, max(240px, calc(100vh - 330px)));
    aspect-ratio: 850 / 768;
    margin-inline: auto;
  }
}

.overlay-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.overlay-caption {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.card {
  background: var(--card);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 12px 28px var(--shadow);
  transition: transform 0.25s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-6px);
  border-color: rgba(56, 189, 248, 0.6);
}

.card img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.image-placeholder {
  display: grid;
  min-height: 260px;
  margin: 0;
  padding: 24px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

.card-info {
  padding: 14px 16px 18px;
}

.card-info h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.card-info p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .topbar {
    padding: 16px 20px;
    flex-wrap: wrap;
  }

  .selector-label {
    display: none;
  }

  .selectors {
    width: 100%;
    justify-content: flex-start;
    gap: 12px;
  }

  .selector-group {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand {
    font-size: 1.1rem;
  }

  .overlay-layout {
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 8px;
  }

  .forecast-select {
    padding: 8px;
  }

  .forecast-options {
    grid-template-columns: repeat(2, max-content);
  }

  .forecast-option {
    width: auto;
  }

  .animation-controls {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .speed-control {
    flex: 1 1 0;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 6px;
  }

  .speed-control input {
    width: auto;
    min-width: 0;
    flex: 1 1 auto;
  }
}
