@font-face {
  font-family: 'Vazirmatn';
  src: url('Vazirmatn-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Vazirmatn';
  src: url('Vazirmatn-Bold.woff2') format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-color: #0b0c10;
  --card-bg: #161820;
  --card-hover: #212532;
  --primary: #e50914;
  --primary-hover: #f40612;
  --focus-ring: #00d2ff;
  --text-main: #ffffff;
  --text-muted: #9aa0a6;
  --badge-dub: #10b981;
  --badge-sub: #3b82f6;
  --badge-orig: #8b5cf6;
  --font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-family);
  overflow-x: hidden;
  padding: 16px;
}

button, input, textarea, select {
  font-family: inherit;
}

@media (min-width: 769px) {
  body {
    padding: 24px 36px;
  }
}

:focus-visible,
.card:focus, .card:hover,
.continue-card:focus, .continue-card:hover,
.btn:focus, .btn:hover,
.season-tab:focus, .season-tab:hover,
.ep-btn:focus, .ep-btn:hover,
.stream-item:focus, .stream-item:hover,
.osd-btn:focus, .osd-btn:hover,
.sub-opt-btn:focus, .sub-opt-btn:hover,
.sub-item-btn:focus, .sub-item-btn:hover,
.filter-btn:focus, .filter-btn:hover,
.player-back-btn:focus, .player-back-btn:hover,
.settings-btn:focus, .settings-btn:hover,
.search-input:focus {
  outline: 3px solid var(--focus-ring) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 18px rgba(0, 210, 255, 0.85) !important;
  transform: scale(1.05);
  z-index: 10;
}

header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

@media (min-width: 769px) {
  header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.logo {
  font-size: 24px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: 1px;
}

.settings-btn {
  background: #1e293b;
  color: #38bdf8;
  border: 1px solid #334155;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 2px solid transparent;
  border-radius: 25px;
  padding: 8px 16px;
  width: 100%;
  transition: all 0.2s;
}

@media (min-width: 769px) {
  .search-box {
    width: 320px;
  }
}

.search-box:focus-within {
  border-color: var(--focus-ring);
  box-shadow: 0 0 15px rgba(0, 210, 255, 0.4);
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 14px;
  width: 100%;
  direction: rtl;
}

.settings-input {
  background: #0b0c12;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 14px;
  font-family: monospace, sans-serif;
  letter-spacing: 0.5px;
}

.filters-container {
  margin-bottom: 14px;
}

.filters-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 10px 2px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.filters-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  background: var(--card-bg);
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  outline: none;
  transition: all 0.2s;
  flex-shrink: 0;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary-hover);
  color: #fff;
  box-shadow: 0 0 10px rgba(229, 9, 20, 0.6);
}

.row-title {
  font-size: 17px;
  font-weight: 700;
  margin: 18px 0 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.shelf {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 8px 4px 16px 4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.shelf::-webkit-scrollbar {
  display: none;
}

.card {
  flex: 0 0 135px;
  height: 205px;
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  outline: none;
  border: 2px solid transparent;
  transition: transform 0.2s, border-color 0.2s;
}

@media (min-width: 769px) {
  .card {
    flex: 0 0 165px;
    height: 250px;
  }
}

.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, rgba(11, 12, 16, 0.95) 20%, transparent 100%);
  padding: 8px 6px 4px 6px;
}

.card-title {
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
}

.continue-card {
  flex: 0 0 220px;
  height: 130px;
  border-radius: 10px;
  position: relative;
  background: var(--card-bg);
  overflow: hidden;
  cursor: pointer;
  outline: none;
  border: 2px solid transparent;
  transition: transform 0.2s;
}

.continue-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.55;
}

.delete-continue-btn {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  z-index: 15;
  outline: none;
  transition: transform 0.2s, background 0.2s;
}

.delete-continue-btn:hover,
.delete-continue-btn:focus {
  background: #ef4444 !important;
  transform: scale(1.2) !important;
}

.continue-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(0deg, rgba(0,0,0,0.9), transparent);
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 8, 0.94);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 10px;
}

.modal-box {
  width: 100%;
  max-width: 950px;
  max-height: 90vh;
  background: #14161e;
  border-radius: 14px;
  border: 1px solid #232838;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 769px) {
  .modal-box {
    flex-direction: row;
    width: 85vw;
    max-height: 85vh;
  }
}

.modal-poster {
  width: 100%;
  height: 160px;
  flex-shrink: 0;
  background: #0f1015;
}

@media (min-width: 769px) {
  .modal-poster {
    width: 270px;
    height: auto;
  }
}

.modal-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.modal-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  width: 100%;
  overflow-y: auto;
}

.modal-title {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 6px;
}

.modal-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.tag {
  background: #252a38;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  color: #38bdf8;
}

.modal-desc {
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 14px;
  max-height: 70px;
  overflow-y: auto;
}

.season-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.season-tab {
  background: #1e2230;
  border: 2px solid transparent;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #cbd5e1;
  white-space: nowrap;
  outline: none;
}

.season-tab.active {
  background: var(--primary);
  color: #fff;
}

.episodes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 7px;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 14px;
}

.ep-btn {
  background: #1d212d;
  border: 1px solid #334155;
  color: #fff;
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  outline: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  transition: all 0.2s;
}

.ep-btn.active {
  background: #0284c7;
  border-color: #38bdf8;
}

.ep-btn.unreleased {
  opacity: 0.45;
  border-style: dashed;
  border-color: #475569;
  background: #0f1118;
  color: #94a3b8;
}

.ep-btn.unreleased:hover,
.ep-btn.unreleased:focus {
  outline-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4) !important;
  transform: scale(1.02);
}

.ep-date {
  font-size: 8.5px;
  color: #94a3b8;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.ep-btn.unreleased .ep-date {
  color: #f59e0b;
  font-weight: 600;
}

.streams-section {
  background: #0d0e14;
  border-radius: 10px;
  padding: 12px;
  margin-top: 8px;
  border: 1px solid #1e2230;
}

.streams-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 1.5;
}

.stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #191c26;
  border: 1px solid #232838;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  outline: none;
}

.stream-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quality-tag {
  background: #dc2626;
  color: #fff;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: bold;
}

.lang-tag {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: bold;
}

.lang-dub { background: var(--badge-dub); color: #fff; }
.lang-sub { background: var(--badge-sub); color: #fff; }
.lang-orig { background: var(--badge-orig); color: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: bold;
  border-radius: 6px;
  cursor: pointer;
  outline: none;
}

#playerContainer {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 1000;
  display: none;
  transition: cursor 0.2s;
}

#playerContainer.hide-cursor {
  cursor: none;
}

#playerContainer:fullscreen,
#playerContainer:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
}

#mainVideo {
  width: 100%;
  height: 100%;
  outline: none;
}

.player-top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.88) 0%, rgba(0,0,0,0) 100%);
  z-index: 1010;
  gap: 10px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  opacity: 1;
  transform: translateY(0);
}

.player-top-bar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
}

.player-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.player-title {
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

@media (max-width: 768px) {
  .player-title {
    max-width: 160px;
    font-size: 12px;
  }
}

.player-actions-left {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  max-width: calc(100% - 150px);
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.player-actions-left::-webkit-scrollbar {
  display: none;
}

.osd-btn {
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  outline: none;
}

.player-back-btn {
  background: rgba(220, 38, 38, 0.85);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  outline: none;
}

.track-modal {
  position: absolute;
  top: 54px;
  background: #14161e;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  width: 340px;
  max-width: 92vw;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  z-index: 1025;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.95);
}

.track-modal-title {
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid #232838;
  padding-bottom: 4px;
  margin-bottom: 2px;
  font-weight: bold;
}

.sub-ctrl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0;
  font-size: 11px;
  color: #cbd5e1;
}

.sub-btn-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.sub-opt-btn {
  background: #252a38;
  color: #fff;
  border: 1px solid #3b82f6;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 10px;
  cursor: pointer;
  outline: none;
}

.sub-opt-btn.active {
  background: #3b82f6;
  font-weight: bold;
}

.color-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  outline: none;
}

.sub-item-btn {
  background: #1d212d;
  border: 1px solid #334155;
  color: #cbd5e1;
  padding: 7px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  width: 100%;
  text-align: right;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  transition: all 0.2s;
}

.sub-item-btn.active {
  background: #0284c7 !important;
  border-color: #38bdf8 !important;
  color: #ffffff !important;
  font-weight: bold;
}

#customSubtitleOverlay {
  position: absolute;
  bottom: 28px;
  left: 4%;
  right: 4%;
  text-align: center;
  pointer-events: none;
  z-index: 1005;
  display: flex;
  justify-content: center;
  transition: bottom 0.2s ease;
}

.subtitle-text {
  padding: 5px 16px;
  border-radius: 6px;
  line-height: 1.45;
  direction: rtl;
  max-width: 95%;
  transition: font-size 0.15s, color 0.15s;
}

.subtitle-text.box-bg {
  background-color: rgba(0, 0, 0, 0.85);
  text-shadow: 2px 2px 3px #000;
}

.subtitle-text.no-bg {
  background-color: transparent !important;
  text-shadow:
    -2px -2px 0 #000,
     2px -2px 0 #000,
    -2px  2px 0 #000,
     2px  2px 0 #000,
     0px  3px 6px rgba(0, 0, 0, 0.95);
}

.subtitle-text.font-vazir {
  font-family: 'Vazirmatn', sans-serif !important;
}

.subtitle-text.font-system {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { 
  to { transform: rotate(360deg); } 
}