.tetris-theme-explorer,
.tetris-theme-dialog {
  --theme-surface: #101a28;
  --theme-surface-raised: #172437;
  --theme-border: rgba(148, 163, 184, 0.22);
  --theme-text: #f8fafc;
  --theme-muted: #a8b5c7;
  --theme-focus: #67e8f9;
  --theme-ui-accent: #67e8f9;
  --theme-on-accent: #082f49;
  --theme-button-text: #cffafe;
  --theme-card-background: rgba(23, 36, 55, 0.82);
  --theme-card-border: rgba(148, 163, 184, 0.22);
  --theme-panel-background:
    radial-gradient(circle at 8% 0%, rgba(34, 211, 238, 0.1), transparent 28%),
    radial-gradient(circle at 94% 100%, rgba(56, 189, 248, 0.08), transparent 32%),
    linear-gradient(145deg, rgba(20, 32, 48, 0.98), rgba(10, 18, 30, 0.99));
  --theme-panel-shadow: 0 24px 72px rgba(2, 8, 23, 0.32);
  color: var(--theme-text);
  font-family: "Nunito", "Noto Sans SC", sans-serif;
  text-align: left;
}

.tetris-theme-explorer[data-page-category="sci-fi"],
.tetris-theme-dialog-backdrop[data-page-category="sci-fi"] .tetris-theme-dialog {
  --theme-border: rgba(65, 197, 243, 0.3);
  --theme-muted: #89a8bd;
  --theme-focus: #53dcff;
  --theme-ui-accent: #53dcff;
  --theme-on-accent: #052b3c;
  --theme-button-text: #c8f6ff;
  --theme-card-background: linear-gradient(150deg, rgba(7, 30, 50, 0.94), rgba(3, 15, 29, 0.97));
  --theme-card-border: rgba(66, 185, 232, 0.34);
  --theme-panel-background:
    radial-gradient(circle at 50% 0, rgba(26, 170, 222, 0.15), transparent 40%),
    linear-gradient(180deg, rgba(2, 16, 31, 0.98), rgba(2, 8, 18, 0.99));
  --theme-panel-shadow: inset 0 18px 50px rgba(0, 4, 13, 0.28), 0 24px 72px rgba(0, 5, 16, 0.42);
}

.tetris-theme-explorer[data-page-category="anime"],
.tetris-theme-dialog-backdrop[data-page-category="anime"] .tetris-theme-dialog {
  --theme-border: rgba(255, 187, 207, 0.3);
  --theme-text: #fff4f7;
  --theme-muted: #d5b2c0;
  --theme-focus: #ffc1d5;
  --theme-ui-accent: #f7a0be;
  --theme-on-accent: #4a142d;
  --theme-button-text: #ffe8f0;
  --theme-card-background: linear-gradient(150deg, rgba(67, 35, 59, 0.95), rgba(31, 20, 35, 0.98));
  --theme-card-border: rgba(255, 190, 214, 0.34);
  --theme-panel-background:
    radial-gradient(circle at 84% 8%, rgba(255, 187, 210, 0.17), transparent 29%),
    radial-gradient(circle at 13% 93%, rgba(164, 104, 183, 0.18), transparent 32%),
    linear-gradient(155deg, rgba(55, 28, 50, 0.99), rgba(22, 16, 29, 0.99));
  --theme-panel-shadow: inset 0 1px rgba(255, 241, 246, 0.16), 0 25px 75px rgba(18, 5, 15, 0.52);
}

.tetris-theme-explorer[data-page-category="retro"],
.tetris-theme-dialog-backdrop[data-page-category="retro"] .tetris-theme-dialog {
  --theme-border: rgba(234, 179, 8, 0.38);
  --theme-text: #fff9cc;
  --theme-muted: #d5cb8c;
  --theme-focus: #fde047;
  --theme-ui-accent: #eab308;
  --theme-on-accent: #292300;
  --theme-button-text: #fff7ae;
  --theme-card-background: linear-gradient(145deg, rgba(67, 64, 23, 0.95), rgba(31, 33, 17, 0.98));
  --theme-card-border: rgba(234, 179, 8, 0.34);
  --theme-panel-background:
    radial-gradient(circle at 50% 0, rgba(234, 179, 8, 0.14), transparent 38%),
    linear-gradient(160deg, rgba(52, 52, 20, 0.99), rgba(21, 25, 13, 0.99));
  --theme-panel-shadow: 0 24px 72px rgba(12, 15, 5, 0.5);
}

.tetris-theme-explorer,
.tetris-theme-explorer *,
.tetris-theme-dialog,
.tetris-theme-dialog * {
  box-sizing: border-box;
}

.tetris-theme-explorer {
  position: relative;
  width: min(1180px, calc(100% - 32px));
  margin: clamp(28px, 5vw, 64px) auto;
  padding: clamp(22px, 4vw, 38px);
  overflow: hidden;
  border: 1px solid var(--theme-border);
  border-radius: 22px;
  background: var(--theme-panel-background);
  box-shadow: var(--theme-panel-shadow);
}

.tetris-theme-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.tetris-theme-heading-copy {
  min-width: 0;
}

.tetris-theme-eyebrow,
.tetris-theme-card-category {
  display: block;
  color: var(--theme-ui-accent);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
}

.tetris-theme-title,
.tetris-theme-dialog-title {
  margin: 6px 0 0;
  color: var(--theme-text);
  font-size: clamp(1.6rem, 3vw, 2.35rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.tetris-theme-intro,
.tetris-theme-dialog-intro {
  max-width: 620px;
  margin: 9px 0 0;
  color: var(--theme-muted);
  font-size: 1rem;
  line-height: 1.65;
}

.tetris-theme-browse-button,
.tetris-theme-filter,
.tetris-theme-dialog-close {
  appearance: none;
  border: 0;
  font: inherit;
  cursor: pointer;
}

.tetris-theme-browse-button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--theme-ui-accent) 46%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--theme-ui-accent) 12%, transparent);
  color: var(--theme-button-text);
  font-size: 0.9rem;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tetris-theme-browse-button:hover {
  border-color: color-mix(in srgb, var(--theme-ui-accent) 76%, transparent);
  background: color-mix(in srgb, var(--theme-ui-accent) 20%, transparent);
  transform: translateY(-1px);
}

.tetris-theme-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tetris-theme-filters::-webkit-scrollbar {
  display: none;
}

.tetris-theme-filter {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--theme-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--theme-muted);
  font-size: 0.875rem;
  font-weight: 800;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.tetris-theme-filter:hover {
  color: var(--theme-text);
  border-color: rgba(148, 163, 184, 0.46);
}

.tetris-theme-filter.is-active {
  border-color: color-mix(in srgb, var(--theme-ui-accent) 70%, transparent);
  background: var(--theme-ui-accent);
  color: var(--theme-on-accent);
}

.tetris-theme-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.tetris-theme-dialog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.tetris-theme-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--theme-card-border);
  border-radius: 16px;
  background: var(--theme-card-background);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.tetris-theme-card:hover {
  border-color: color-mix(in srgb, var(--theme-accent) 62%, transparent);
  box-shadow: 0 16px 36px rgba(2, 8, 23, 0.3), 0 0 0 1px color-mix(in srgb, var(--theme-accent) 18%, transparent);
  transform: translateY(-4px);
}

.tetris-theme-card.is-current {
  border-color: color-mix(in srgb, var(--theme-accent) 72%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--theme-accent) 20%, transparent);
}

.tetris-theme-card-link {
  display: flex;
  height: 100%;
  color: inherit;
  text-decoration: none;
  flex-direction: column;
}

.tetris-theme-card-media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #070d16;
}

.tetris-theme-card-media::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 46%;
  background: linear-gradient(transparent, rgba(7, 13, 22, 0.72));
  pointer-events: none;
}

.tetris-theme-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 420ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tetris-theme-card:hover .tetris-theme-card-media img {
  transform: scale(1.045);
}

.tetris-theme-card-badges {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tetris-theme-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  background: rgba(5, 10, 18, 0.78);
  color: #f8fafc;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  backdrop-filter: blur(10px);
}

.tetris-theme-badge.is-current {
  color: #052e16;
  border-color: #86efac;
  background: #bbf7d0;
}

.tetris-theme-new-badge {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: inline-flex;
  min-height: 27px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(255, 246, 196, 0.94);
  border-radius: 7px;
  background: #ffd447;
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(44, 32, 0, 0.12);
  color: #211900;
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  line-height: 1;
}

.tetris-theme-new-badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #211900;
  box-shadow: 0 0 0 0 rgba(33, 25, 0, 0.34);
  animation: tetris-theme-new-dot-pulse 2.4s ease-out infinite;
}

.tetris-theme-new-badge-label {
  animation: tetris-theme-new-label-breathe 2.4s ease-in-out infinite;
}

@keyframes tetris-theme-new-dot-pulse {
  0%, 42%, 100% { box-shadow: 0 0 0 0 rgba(33, 25, 0, 0.34); }
  58% { box-shadow: 0 0 0 5px rgba(33, 25, 0, 0); }
}

@keyframes tetris-theme-new-label-breathe {
  0%, 42%, 100% { opacity: 1; transform: translateY(0); }
  58% { opacity: 0.72; transform: translateY(-1px); }
}

@media (prefers-reduced-motion: reduce) {
  .tetris-theme-new-badge::before,
  .tetris-theme-new-badge-label {
    animation: none;
  }
}

.tetris-theme-card-body {
  display: flex;
  flex: 1;
  padding: 17px 18px 18px;
  flex-direction: column;
}

.tetris-theme-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tetris-theme-card-category {
  color: var(--theme-accent);
  font-size: 0.66rem;
  letter-spacing: 0.13em;
}

.tetris-theme-card-date {
  color: var(--theme-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
  white-space: nowrap;
}

.tetris-theme-card-title {
  margin: 6px 0 0;
  color: var(--theme-text);
  font-size: 1.16rem;
  font-weight: 900;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.tetris-theme-card-description {
  display: -webkit-box;
  min-height: 3.1em;
  margin: 8px 0 14px;
  overflow: hidden;
  color: var(--theme-muted);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.tetris-theme-card-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.tetris-theme-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tetris-theme-card-tag {
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.055);
  color: #cbd5e1;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.tetris-theme-card-action {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--theme-accent) 46%, transparent);
  border-radius: 50%;
  background: color-mix(in srgb, var(--theme-accent) 14%, transparent);
  color: var(--theme-accent);
  font-size: 1.05rem;
  font-weight: 900;
  transition: transform 160ms ease, background 160ms ease;
}

.tetris-theme-card:hover .tetris-theme-card-action {
  background: color-mix(in srgb, var(--theme-accent) 24%, transparent);
  transform: translateX(2px);
}

.tetris-theme-entry {
  position: relative;
}

.tetris-theme-entry .tetris-theme-entry-label {
  white-space: nowrap;
}

body.tetris-theme-dialog-open {
  overflow: hidden;
}

.tetris-theme-dialog-backdrop[hidden] {
  display: none;
}

.tetris-theme-dialog-backdrop {
  position: fixed;
  z-index: 100000;
  inset: 0;
  display: grid;
  padding: 24px;
  overflow-y: auto;
  place-items: center;
  background: rgba(2, 6, 14, 0.82);
  backdrop-filter: blur(12px);
}

.tetris-theme-dialog {
  width: min(1080px, 100%);
  max-height: min(850px, calc(100vh - 48px));
  padding: clamp(20px, 4vw, 36px);
  overflow-y: auto;
  border: 1px solid color-mix(in srgb, var(--theme-ui-accent) 30%, transparent);
  border-radius: 22px;
  background: var(--theme-panel-background);
  box-shadow: var(--theme-panel-shadow), 0 32px 100px rgba(0, 0, 0, 0.48);
}

.tetris-theme-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.tetris-theme-dialog-copy {
  min-width: 0;
}

.tetris-theme-dialog-close {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 1px solid var(--theme-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: #f8fafc;
  font-size: 1.8rem;
  font-weight: 300;
  line-height: 1;
}

.tetris-theme-dialog-close:hover {
  border-color: rgba(248, 250, 252, 0.5);
  background: rgba(255, 255, 255, 0.1);
}

.tetris-theme-dialog-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tetris-theme-card.is-compact .tetris-theme-card-body {
  padding: 15px;
}

.tetris-theme-card.is-compact .tetris-theme-card-description {
  font-size: 0.9rem;
}

.tetris-theme-browse-button:focus-visible,
.tetris-theme-filter:focus-visible,
.tetris-theme-card-link:focus-visible,
.tetris-theme-dialog-close:focus-visible,
.tetris-theme-entry:focus-visible {
  outline: 3px solid var(--theme-focus);
  outline-offset: 3px;
}

@media (max-width: 900px) {
  .tetris-theme-grid,
  .tetris-theme-dialog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .tetris-theme-explorer {
    width: calc(100% - 20px);
    margin: 26px auto;
    padding: 20px 16px;
    border-radius: 18px;
  }

  .tetris-theme-heading {
    align-items: flex-start;
    margin-bottom: 18px;
    flex-direction: column;
  }

  .tetris-theme-browse-button {
    width: 100%;
  }

  .tetris-theme-grid {
    display: flex;
    margin-right: -16px;
    padding-right: 16px;
    padding-bottom: 10px;
    overflow-x: auto;
    scroll-padding-left: 0;
    scroll-snap-type: x mandatory;
  }

  .tetris-theme-grid .tetris-theme-card {
    width: min(84vw, 330px);
    flex: 0 0 min(84vw, 330px);
    scroll-snap-align: start;
  }

  .tetris-theme-dialog-backdrop {
    align-items: end;
    padding: 0;
  }

  .tetris-theme-dialog {
    width: 100%;
    max-height: 88vh;
    padding: 22px 16px calc(22px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 22px 22px 0 0;
  }

  .tetris-theme-dialog-title {
    font-size: 1.55rem;
  }

  .tetris-theme-dialog-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tetris-theme-explorer *,
  .tetris-theme-dialog * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
