:root {
  --bg: #0b0b0f;
  --panel: #14141c;
  --text: #f4f4f8;
  --muted: #b8b8c6;
  --pink: #ff4d9a;
  --pink-2: #ff7ab3;
  --pink-dark: #d61d73;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 18px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 50% -10%, #1c1220 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100dvh;
}

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
}

.player-wrap {
  width: min(100%, 920px);
  display: flex;
  justify-content: center;
}

.player-wrap.is-vertical {
  width: min(100%, 380px);
}

.screen {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  aspect-ratio: 16 / 9;
  max-height: min(72dvh, 820px);
}

.screen.is-vertical {
  aspect-ratio: 9 / 16;
  width: min(100%, 920px);
  margin-inline: auto;
  max-height: min(72dvh, 820px);
}

video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.overlay,
.missing {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.missing {
  background: linear-gradient(180deg, #15151d, #0d0d12);
  color: var(--muted);
  text-align: center;
  gap: 8px;
  pointer-events: none;
  z-index: 2;
}

.missing[hidden] { display: none !important; }
.missing code {
  color: var(--pink-2);
  font-size: 0.95rem;
}

.big-play {
  width: 78px;
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 77, 154, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.big-play:hover {
  background: var(--pink-2);
  transform: scale(1.05);
}

.big-play svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
  margin-left: 4px;
}

.screen.is-playing .overlay {
  opacity: 0;
  pointer-events: none;
}

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  opacity: 1;
  transition: opacity 0.25s ease;
  z-index: 3;
}

.screen.is-playing:not(.show-controls) .controls {
  opacity: 0;
}

.ctrl-btn {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 0;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 10px;
}

.ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ctrl-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-pause,
.icon-mute,
.is-playing .icon-play,
.is-muted .icon-vol {
  display: none;
}

.is-playing .icon-pause,
.is-muted .icon-mute {
  display: block;
}

.time {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: #fff;
  min-width: 36px;
}

.bar {
  position: relative;
  height: 28px;
  display: grid;
  align-items: center;
}

.bar-bg {
  height: 5px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.bar-buffered,
.bar-played {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: inherit;
}

.bar-buffered {
  background: rgba(255, 255, 255, 0.32);
}

.bar-played {
  background: var(--pink);
}

.seek {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.actions {
  width: min(100%, 920px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.player-wrap.is-vertical + .actions {
  width: min(100%, 380px);
}

.player-wrap:has(.is-vertical) + .actions {
  width: min(100%, 920px);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  box-shadow: 0 8px 20px rgba(255, 77, 154, 0.28);
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn .emoji {
  font-size: 1.15em;
  line-height: 1;
}

.btn:hover {
  background: var(--pink-2);
  transform: translateY(-1px);
}

.btn:active {
  background: var(--pink-dark);
  transform: translateY(0);
}

@media (max-width: 640px) {
  .app {
    justify-content: center;
    padding-top: calc(12px + env(safe-area-inset-top));
  }

  .screen {
    max-height: min(68dvh, 720px);
    border-radius: 14px;
  }

  .screen.is-vertical {
    width: min(100%, 92vw);
    max-height: min(70dvh, 760px);
  }

  .actions {
    width: 100%;
    gap: 10px;
  }

  .btn {
    min-height: 50px;
    font-size: 15px;
  }

  .time:last-of-type {
    display: none;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .app {
    flex-direction: row;
    align-items: stretch;
    gap: 14px;
  }

  .player-wrap {
    flex: 1;
    width: auto;
  }

  .screen,
  .screen.is-vertical {
    width: 100%;
    height: calc(100dvh - 24px);
    max-height: none;
    aspect-ratio: auto;
  }

  .actions {
    width: min(220px, 34vw);
    grid-template-columns: 1fr;
    align-content: center;
  }
}
