* { box-sizing: border-box; }

:root {
  --desktop: #0a6f72;
  --desktop-dark: #07595c;
  --win: #c7c3bb;
  --win-soft: #d8d4cc;
  --win-light: #ffffff;
  --win-dark: #3b3b3b;
  --blue: #02027c;
  --blue2: #137fc0;
  --text: #111;
  --muted: #333;
  --yellow: #fff8c7;
  --gold: #f7c948;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.08), transparent 25%),
    linear-gradient(135deg, var(--desktop), var(--desktop-dark));
  color: var(--text);
  font-family: Tahoma, Verdana, Arial, sans-serif;
  font-size: 14px;
}

.desktop {
  width: min(1180px, calc(100% - 24px));
  margin: 16px auto 30px;
}

.win-window {
  background: var(--win);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  box-shadow: 3px 3px 0 rgba(0,0,0,.85);
  margin-bottom: 16px;
}

.top-window {
  margin-top: 8px;
}

.title-bar {
  background: linear-gradient(90deg, var(--blue), var(--blue2));
  color: white;
  min-height: 29px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 4px 9px;
  font-weight: bold;
  letter-spacing: .1px;
}

.title-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 0 #000;
}

.window-buttons {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.window-buttons span {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: var(--win);
  border: 2px solid;
  border-color: var(--win-light) var(--win-dark) var(--win-dark) var(--win-light);
  position: relative;
}

.window-buttons span:nth-child(1)::after {
  content: "_";
  position: absolute;
  left: 4px;
  top: -4px;
  color: #000;
  font-size: 13px;
}

.window-buttons span:nth-child(2)::after {
  content: "□";
  position: absolute;
  left: 2px;
  top: -2px;
  color: #000;
  font-size: 12px;
}

.window-buttons span:nth-child(3)::after {
  content: "×";
  position: absolute;
  left: 3px;
  top: -2px;
  color: #000;
  font-size: 14px;
}

.window-body {
  padding: 15px;
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.7px;
  line-height: 1.1;
}

.tagline {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.search-panel {
  background: var(--win-soft);
  border: 2px solid;
  border-color: #777 #fff #fff #777;
  padding: 12px;
}

.search-panel label {
  display: block;
  margin-bottom: 7px;
  font-weight: bold;
}

.search-row {
  display: flex;
  gap: 8px;
}

input {
  width: 100%;
  height: 36px;
  padding: 7px 9px;
  border: 2px solid;
  border-color: #444 #fff #fff #444;
  background: white;
  color: #111;
  font-family: inherit;
  outline: none;
}

input:focus {
  background: #fffef2;
}

button,
.button,
.side-link,
.card a,
.back-link {
  display: inline-block;
  background: var(--win);
  color: #000;
  text-decoration: none;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  padding: 7px 12px;
  font-family: inherit;
  cursor: pointer;
  min-height: 34px;
}

button:hover,
.button:hover,
.side-link:hover,
.card a:hover,
.back-link:hover {
  background: #d6d2ca;
}

button:active,
.button:active,
.side-link:active,
.card a:active,
.back-link:active {
  border-color: #404040 #fff #fff #404040;
  transform: translate(1px, 1px);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 16px;
  align-items: start;
}

.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}

.movie-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.card {
  background: var(--win-soft);
  border: 2px solid;
  border-color: #fff #777 #777 #fff;
  padding: 8px;
  transition: transform .08s ease, box-shadow .08s ease;
}

.card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 #333;
}

.poster {
  height: 222px;
  background:
    linear-gradient(135deg, #00111f, #022b45 58%, #000);
  border: 2px solid;
  border-color: #404040 #fff #fff #404040;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  text-align: center;
  padding: 12px;
  font-weight: bold;
  margin-bottom: 8px;
  line-height: 1.3;
  text-shadow: 1px 1px 0 #000;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.25;
}

.meta {
  color: #303030;
  min-height: 38px;
  margin: 0 0 8px;
  line-height: 1.35;
}

.side-box {
  position: sticky;
  top: 12px;
}

.side-link {
  display: block;
  margin-bottom: 8px;
}

.ad-slot {
  margin-top: 14px;
  background: var(--yellow);
  border: 2px dashed #8d7b00;
  padding: 12px;
  text-align: center;
  color: #333;
  font-size: 13px;
}

.ad-slot.small {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-wrap {
  background: #000;
  border: 2px solid;
  border-color: #404040 #fff #fff #404040;
  aspect-ratio: 16 / 9;
}

.player-wrap iframe {
  width: 100%;
  height: 100%;
  display: block;
}

.footer {
  text-align: center;
  background: var(--win);
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  box-shadow: 3px 3px 0 rgba(0,0,0,.85);
  padding: 11px;
}

.footer a {
  color: #000080;
  margin: 0 8px;
  font-weight: bold;
}

.footer a:hover {
  color: #b00000;
}

.legal {
  line-height: 1.7;
  max-width: 850px;
}

@media (max-width: 780px) {
  .desktop {
    width: min(100% - 14px, 1180px);
    margin-top: 8px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .side-box {
    position: static;
  }

  .search-row {
    flex-direction: column;
  }

  .movie-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
  }

  .poster {
    height: 175px;
  }

  h1 {
    font-size: 24px;
  }

  .window-body {
    padding: 11px;
  }

  .footer a {
    display: inline-block;
    margin: 5px 7px;
  }
}

.brand-row {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
}

.site-logo {
  width: 100%;
  max-width: 230px;
  height: auto;
  display: block;
  image-rendering: auto;
}

@media (max-width: 680px) {
  .brand-row {
    grid-template-columns: 1fr;
  }

  .site-logo {
    max-width: 250px;
  }
}


.ad-placeholder {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(255,255,255,.38),
      rgba(255,255,255,.38) 8px,
      rgba(0,0,0,.04) 8px,
      rgba(0,0,0,.04) 16px
    );
  color: #514700;
  font-weight: bold;
}

.ad-slot.small .ad-placeholder {
  min-height: 92px;
}

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

.poster:has(.poster-img) {
  padding: 0;
}

.poster-fallback {
  padding: 12px;
}

.loading-box,
.empty-state {
  grid-column: 1 / -1;
  background: #d8d4cc;
  border: 2px solid;
  border-color: #fff #777 #777 #fff;
  padding: 14px;
  font-weight: bold;
}

.category-btn {
  width: 100%;
  text-align: left;
  font-weight: bold;
}

.category-btn.active {
  background: #000080;
  color: #fff;
  border-color: #404040 #fff #fff #404040;
}

.category-btn.active::before {
  content: "▶ ";
  color: #ffcc33;
}

.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #d8d4cc;
  border: 2px solid;
  border-color: #777 #fff #fff #777;
  padding: 10px;
  margin-bottom: 12px;
  font-weight: bold;
}

#loadMoreBtn:disabled {
  opacity: .65;
  cursor: wait;
}

@media (max-width: 680px) {
  .catalog-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  #loadMoreBtn {
    width: 100%;
  }
}

.episode-controls {
  grid-template-columns: repeat(5, minmax(120px, auto));
  gap: 8px;
  align-items: end;
  margin: 12px 0 4px;
  background: #d8d4cc;
  border: 2px solid;
  border-color: #777 #fff #fff #777;
  padding: 10px;
}

.episode-controls label {
  font-weight: bold;
}

.episode-controls input {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 780px) {
  .episode-controls {
    grid-template-columns: 1fr;
  }
}
