:root {
  --red: #e8291c;
  --bg: #0d0d0d;
  --surface: #161616;
  --surface2: #1f1f1f;
  --surface3: #272727;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f0f0f0;
  --text-muted: #888;
  --text-dim: #555;
  --font-display: 'Bebas Neue', sans-serif;
  --font-cond: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --sidebar: 260px;
}

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

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  overflow: hidden;
  user-select: none;
}

.app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo h1 {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: 3px;
  line-height: 1;
}

.logo h1 span {
  color: var(--red);
}

.logo p {
  font-family: var(--font-cond);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stages-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: thin;
}

.stage-item {
  padding: 10px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.stage-item.active {
  background: rgba(232, 41, 28, 0.1);
  border-left-color: var(--red);
}

.stage-num {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--text-muted);
}

.stage-item.active .stage-num {
  background: var(--red);
  color: #fff;
}

.stage-info {
  flex: 1;
  min-width: 0;
}

.stage-name {
  font-family: var(--font-cond);
  font-size: 14px;
  font-weight: 500;
}

.stage-progress-wrap {
  width: 100%;
  height: 2px;
  background: var(--surface3);
  margin-top: 6px;
}

.stage-progress-fill {
  height: 2px;
  background: var(--red);
  transition: width 0.3s;
}

/* MAIN */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.player-wrap {
  background: #000;
  position: relative;
  width: 100%;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* REPRODUCTOR FIJO A 62VH */
#videoContainer,
.player-empty {
  width: 100%;
  height: auto;
  max-height: 62vh;
  aspect-ratio: 16 / 9;
  background: #000;
  position: relative;
  overflow: hidden;
}

.player-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

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

.custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 10;
}

.fs-title {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 30px;
  background: linear-gradient(rgba(0,0,0,0.8), transparent);
  font-family: var(--font-cond);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 10;
  display: none;
}

#videoContainer.is-fullscreen .fs-title {
  display: block;
}

#videoContainer:hover .custom-controls,
#videoContainer:hover .fs-title {
  opacity: 1;
}

#videoContainer.idle {
  cursor: none;
}

#videoContainer.idle .custom-controls,
#videoContainer.idle .fs-title {
  opacity: 0 !important;
}

.progress-area {
  width: 100%;
  height: 24px;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
}

.progress-area::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.progress-fill {
  height: 5px;
  width: 0%;
  background: var(--red);
  border-radius: 3px;
  position: relative;
  z-index: 1;
}

.progress-fill::after {
  content: '';
  position: absolute;
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  background: var(--red);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.progress-area:hover .progress-fill::after,
.progress-area.dragging .progress-fill::after {
  opacity: 1;
}

.progress-fill::after:hover {
  transform: translateY(-50%) scale(1.2);
}

.controls-main {
  display: flex;
  align-items: center;
  gap: 15px;
}

.time-display {
  font-family: monospace;
  font-size: 13px;
  color: #888;
}

.now-playing-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 50px;
}

.np-return-btn {
  background: var(--surface3);
  color: var(--text);
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-family: var(--font-cond);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-left: auto;
}

.np-return-btn:hover {
  background: var(--red);
}

.np-badge {
  font-family: var(--font-cond);
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
}

.np-title {
  font-family: var(--font-cond);
  font-size: 15px;
  font-weight: 600;
}

.vol-control button {
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.vol-control input[type=range] {
  -webkit-appearance: none;
  margin: 0;
  padding: 0;
  background: var(--surface3);
  height: 4px;
  border-radius: 2px;
  outline: none;
}
.vol-control input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}
.vol-control input[type=range]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}
.vol-control input[type=range]::-moz-range-thumb {
  -moz-appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}
.vol-control input[type=range]::-moz-range-thumb:hover {
  transform: scale(1.2);
}

.episodes-area {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.episodes-header {
  padding: 12px 20px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.episodes-header h2 {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 2px;
}

.ep-row {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.12s;
  border-left: 3px solid transparent;
}

.ep-row:hover {
  background: var(--surface);
}

.ep-row.active {
  background: rgba(232, 41, 28, 0.08);
  border-left-color: var(--red);
}

.ep-row.watched {
  opacity: 0.5;
}

.ep-num-label {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text-dim);
  width: 35px;
  text-align: right;
}

.ep-thumb {
  width: 120px;
  height: 68px;
  background: var(--surface2);
  border-radius: 6px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ep-play-overlay {
  position: absolute;
  z-index: 2;
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform: scale(0.8);
}

.ep-row:hover .ep-play-overlay {
  opacity: 1;
  transform: scale(1);
}

.ep-row.active .ep-play-overlay {
  opacity: 1;
  transform: scale(1);
  background: var(--red);
}

.ep-title-text {
  font-family: var(--font-cond);
  font-size: 17px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unwatch-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  padding: 5px;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ep-row:hover .unwatch-btn {
  opacity: 1;
}

.unwatch-btn:hover {
  color: var(--red);
}

@media (max-width: 768px) {
  .app {
    flex-direction: column;
    overflow-y: auto;
  }

  .sidebar {
    width: 100%;
    height: auto;
  }

  .logo {
    text-align: center;
  }

  .stages-list {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }

  .stage-item {
    min-width: 140px;
  }

  #videoContainer,
  .player-empty {
    height: auto;
    aspect-ratio: 16 / 9;
  }
}
