@font-face {
  font-family: "Syne";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("./fonts/syne-latin-800-normal.woff2") format("woff2");
}

:root {
  --bg0: #0f1412;
  --ink: #e8f0ea;
  --muted: #8fa094;
  --accent: #6ecf9a;
  --accent-2: #c9f27a;
  --line: rgba(232, 240, 234, 0.12);
  --card: rgba(255, 255, 255, 0.04);
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --gap: 14px;
  --btn: 56px;
  --btn-play: 68px;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-body);
  background: var(--tg-theme-bg-color, var(--bg0));
  color: var(--tg-theme-text-color, var(--ink));
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100dvh;
  overflow: hidden;
}

button,
input,
.station,
.progress {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  outline: none;
}

button:focus,
button:focus-visible,
.station:focus,
.station:focus-visible {
  outline: none;
}

.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(110, 207, 154, 0.28), transparent 60%),
    radial-gradient(700px 420px at 110% 10%, rgba(201, 242, 122, 0.16), transparent 55%),
    radial-gradient(600px 500px at 50% 120%, rgba(60, 120, 100, 0.35), transparent 60%),
    linear-gradient(160deg, #101612, #0c1210 45%, #141c18);
  pointer-events: none;
}

@keyframes drift {
  from {
    filter: hue-rotate(0deg) saturate(1);
    transform: scale(1);
  }
  to {
    filter: hue-rotate(18deg) saturate(1.1);
    transform: scale(1.04);
  }
}

/* Brand + 50/50 stage | controls */
.shell {
  position: relative;
  z-index: 1;
  max-width: 440px;
  margin: 0 auto;
  height: 100dvh;
  max-height: 100dvh;
  padding:
    max(12px, env(safe-area-inset-top))
    16px
    max(14px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr 1fr;
  gap: var(--gap);
  overflow: hidden;
}

.top {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-btn {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.back-btn:active {
  opacity: 0.8;
  background: rgba(255, 255, 255, 0.2);
}
.back-btn svg {
  display: block;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
}

.stage {
  min-height: 0;
  display: flex;
}

.wave {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  border-radius: 22px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(110, 207, 154, 0.12), rgba(201, 242, 122, 0.04) 45%, transparent);
  box-shadow: inset 0 0 0 1px rgba(110, 207, 154, 0.14);
}

.wave canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.now {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 28px 14px 14px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(8, 12, 10, 0.35) 35%,
    rgba(8, 12, 10, 0.78) 100%
  );
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.66rem;
  color: var(--accent-2);
}

.track {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.15rem, 4.8vw, 1.55rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
  height: calc(1.15em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  text-wrap: balance;
  animation: fadeIn 0.45s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lower {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto 1fr auto;
  align-items: stretch;
}

.stations {
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: var(--gap);
}

.station {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 16px;
  min-height: 44px;
  padding: 10px 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: -0.02em;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.station:active {
  transform: scale(0.98);
}

.station.is-active {
  border-color: transparent;
  background: linear-gradient(145deg, rgba(110, 207, 154, 0.28), rgba(201, 242, 122, 0.16));
  box-shadow: inset 0 0 0 1px rgba(110, 207, 154, 0.45);
}

.progress-wrap {
  grid-row: 3;
  display: grid;
  gap: 6px;
  align-self: center;
}

.progress {
  padding: 10px 0;
  pointer-events: none;
  cursor: default;
  touch-action: none;
  user-select: none;
}

.progress__track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(232, 240, 234, 0.1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    transparent 0%,
    #3fa876 18%,
    var(--accent) 50%,
    var(--accent-2) 82%,
    transparent 100%
  );
  box-shadow: 0 0 16px rgba(110, 207, 154, 0.35);
  animation: progressLive 2.4s linear infinite;
  transition: none;
  will-change: transform;
}

.progress.is-playing .progress__bar {
  animation-play-state: running;
}

.progress:not(.is-playing) .progress__bar {
  animation: none;
  width: 18%;
  opacity: 0.45;
  transform: none;
  background: linear-gradient(90deg, #3fa876 0%, var(--accent) 100%);
}

@keyframes progressLive {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(240%);
  }
}

.progress__knob {
  display: none;
}

.times {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  grid-row: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  justify-items: center;
  gap: var(--gap);
  min-height: 0;
}

.btn {
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.btn svg {
  width: 24px;
  height: 24px;
  display: block;
  grid-area: 1 / 1;
}

.btn:active {
  transform: scale(0.95);
}

.btn.icon {
  width: var(--btn);
  height: var(--btn);
  border-radius: 18px;
  color: var(--muted);
}

.btn.icon.play {
  width: var(--btn-play);
  height: var(--btn-play);
  border-radius: 22px;
  color: var(--ink);
}

.btn.icon.play svg {
  width: 28px;
  height: 28px;
}

.btn.icon.is-active {
  color: var(--accent-2);
  border-color: transparent;
  background: linear-gradient(145deg, rgba(110, 207, 154, 0.28), rgba(201, 242, 122, 0.16));
  box-shadow: inset 0 0 0 1px rgba(110, 207, 154, 0.45);
}

#btnPlay .icon-play {
  margin-left: 2px;
  opacity: 1;
  visibility: visible;
}

#btnPlay .icon-pause {
  opacity: 0;
  visibility: hidden;
}

#btnPlay.is-playing .icon-play {
  opacity: 0;
  visibility: hidden;
}

#btnPlay.is-playing .icon-pause {
  opacity: 1;
  visibility: visible;
  margin-left: 0;
}

.vol-wrap {
  position: relative;
  display: grid;
  place-items: center;
}

.vol-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  transform: translateX(-50%);
  width: 36px;
  height: 192px;
  padding: 0;
  border-radius: 18px;
  background: rgba(232, 240, 234, 0.12);
  border: 1px solid rgba(110, 207, 154, 0.22);
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.35),
    0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  touch-action: none;
  cursor: ns-resize;
  z-index: 20;
}

.vol-popover[hidden] {
  display: none;
}

.vol-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 30%;
  border-radius: inherit;
  background: linear-gradient(180deg, var(--accent-2) 0%, var(--accent) 55%, #3fa876 100%);
  box-shadow: 0 0 18px rgba(110, 207, 154, 0.35);
  pointer-events: none;
}

@media (max-height: 700px) {
  :root {
    --gap: 12px;
    --btn: 50px;
    --btn-play: 60px;
  }

  .vol-popover {
    height: 166px;
  }
}

@media (max-width: 360px) {
  :root {
    --btn: 48px;
    --btn-play: 56px;
    --gap: 10px;
  }

  .station {
    font-size: 0.74rem;
    padding-inline: 4px;
  }
}
