@font-face {
  font-family: "Keyart Title";
  src: url("assets/fonts/mc-ten-lowercase-alt.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Keyart Rating";
  src: url("assets/fonts/Minecraft.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #000;
  --text: #fff;
  --muted: #b2b2b2;
  --gold: #ffdc16;
  --caption: #494949;
  --caption-stroke: #707070;
  font-family: "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 0; background: #000; }
body { margin: 0; padding: 0; min-height: 100vh; color: var(--text); background: #000; }
button { font: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #ddd; outline-offset: -3px; }
.site-shell { width: 100%; margin: 0; padding: 0; }

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

.keyart-card {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
  aspect-ratio: 16 / 9;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #000;
  box-shadow: none;
  cursor: pointer;
  isolation: isolate;
  line-height: 0;
}

.keyart-card[data-popular="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 3px solid var(--gold);
  pointer-events: none;
}

.keyart-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  color: var(--muted);
  font-size: 12px;
  background: #000;
}

.empty-state { margin: 0; padding: 64px 20px; color: var(--muted); font-size: 14px; line-height: 1.8; text-align: center; }
body:has(.viewer[open]), body.viewer-open { overflow: hidden; }

.viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  color: var(--text);
  background: #000;
}

.viewer[open] { display: block; }
.viewer:not([open]) { display: none; }
.viewer::backdrop { background: #000; }

.viewer-shell {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  padding: max(64px, env(safe-area-inset-top)) max(32px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(32px, env(safe-area-inset-left));
  overflow: auto;
}

.viewer-close {
  position: fixed;
  z-index: 3;
  top: max(12px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #737373;
  border-radius: 0;
  color: #fff;
  background: #292929;
  cursor: pointer;
}

.viewer-close span { display: block; font-size: 30px; font-weight: 300; line-height: 1; }
@media (hover: hover) { .viewer-close:hover { background: #494949; } }

.viewer-figure {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: min(1600px, 100%);
  max-width: 100%;
  min-width: 0;
  margin: 0;
  overflow: visible;
  container-type: inline-size;
}

.viewer-image-wrap {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 100%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: var(--art-aspect, 16 / 9);
  overflow: visible;
  isolation: isolate;
  background: transparent;
}

.viewer-glow {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(45px) saturate(1.4);
  opacity: .55;
  transform: scale(1.04);
  pointer-events: none;
  user-select: none;
}

.viewer-image { position: relative; z-index: 1; display: block; width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: contain; }
.viewer-error { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px; color: var(--muted); font-size: 14px; line-height: 1.7; text-align: center; }

.viewer-caption {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  flex: none;
  gap: 12px 28px;
  width: 100%;
  min-width: 0;
  min-height: 84px;
  margin: 0;
  padding: 17px 24px;
  border: 2px solid var(--caption-stroke);
  color: #fff;
  background: var(--caption);
}

.viewer-caption h1 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-family: "Keyart Title", "Segoe UI", sans-serif; font-size: clamp(19px, 2.2cqw, 30px); font-weight: 400; line-height: 1.25; text-align: left; }

.viewer-rating {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 9px;
  min-width: 0;
  color: #fff;
  font-size: clamp(17px, 1.7cqw, 24px);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.rating-stars { display: block; flex: 0 0 auto; width: 140px; height: 28px; overflow: visible; color: var(--gold); }
.rating-stars svg { display: block; width: 100%; height: 100%; }
.rating-stars-empty { fill: #8a8a8a; }
.rating-stars-filled { fill: var(--gold); }
.rating-value, .rating-count { color: #fff; white-space: nowrap; font-family: "Keyart Rating", "Segoe UI", sans-serif; font-weight: 400; }

@container (max-width: 660px) {
  .viewer-caption { grid-template-columns: minmax(0, 1fr); min-height: 0; gap: 10px; padding: 14px 16px; }
  .viewer-caption h1 { font-size: 21px; }
  .viewer-rating { justify-content: flex-start; font-size: 19px; }
  .rating-stars { width: 125px; height: 25px; }
}

@container (max-width: 360px) {
  .viewer-caption { gap: 8px; padding: 11px 12px; }
  .viewer-caption h1 { font-size: 18px; }
  .viewer-rating { gap: 5px 7px; font-size: 17px; }
  .rating-stars { width: 110px; height: 22px; }
}

@container (max-width: 240px) {
  .viewer-caption { padding: 8px; }
  .viewer-caption h1 { font-size: 16px; }
  .viewer-rating { font-size: 14px; }
  .rating-stars { width: 80px; height: 16px; }
}

@media (max-width: 760px) {
  .viewer-shell { padding: 64px max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}

@media (max-width: 480px) {
  .viewer-shell { padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
}

@media (max-height: 480px) and (orientation: landscape) {
  .viewer-shell { padding: 10px max(64px, env(safe-area-inset-right)) 10px max(64px, env(safe-area-inset-left)); }
  .viewer-caption { min-height: 0; gap: 5px 14px; padding: 8px 12px; }
  .viewer-caption h1 { font-size: 16px; }
  .viewer-rating { font-size: 16px; }
  .rating-stars { width: 100px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; transition: none !important; }
}
