:root {
  color-scheme: light;
  --paper: #f2f0e9;
  --ink: #262923;
  --muted: #76796e;
  --line: #d5d6cc;
  --accent: #536443;
  --stage: #e3e5dd;
  --tile: #e0e3d8;
  --hover: #e4e5dc;
  --selected: #faf9f5;
  --rim: #ffffff80;
  --backdrop: #20271d65;
  --ambient-opacity: .32;
  --glow-core: #39602f;
  --glow: #80be55a6;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #121212;
  --ink: #e8e8e8;
  --muted: #a0a0a0;
  --line: #333333;
  --accent: #d0d0d0;
  --stage: #0b0b0b;
  --tile: #1b1b1b;
  --hover: #252525;
  --selected: #363636;
  --rim: #3a3a3a;
  --backdrop: #000000a6;
  --ambient-opacity: .23;
  --glow-core: #ffffff;
  --glow: #ffffff99;
}
* { box-sizing: border-box; }
/* The background fades independently of the native scrolling surface. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { margin: 0; background: var(--paper); }
.page-scroll { height: 100dvh; overflow: auto; overscroll-behavior: contain; scrollbar-width: none; }
.page-scroll::-webkit-scrollbar { display: none; }
button, input, a { -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; }
button, a { color: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button svg, a svg, .search svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.bar { max-width: 1800px; margin: auto; padding: 32px 48px 26px; display: flex; align-items: center; justify-content: space-between; gap: 24px; animation: page-in 650ms cubic-bezier(.16, 1, .3, 1) both; }
.brand { display: flex; align-items: center; flex-shrink: 0; }
.brand .icon-button { width: 24px; height: 24px; flex-basis: 24px; padding: 0; margin-left: -3px; align-self: flex-end; color: var(--muted); }
.brand .icon-button svg { width: 12px; height: 12px; }
.wordmark { text-decoration: none; font: 38px/1 Georgia, serif; letter-spacing: -1.6px; }
.brand #count { font: 12px/1.4 "Segoe UI", sans-serif; color: var(--muted); align-self: flex-start; margin: 2px 0 0 -16px; }
.bar-actions { display: flex; flex: 1; align-items: center; justify-content: flex-end; gap: 18px; min-width: 0; }
.search { display: flex; flex: 0 1 238px; align-items: center; gap: 10px; border-bottom: 2px solid var(--line); border-radius: 6px 6px 0 0; padding: 10px; color: var(--muted); min-width: 0; }
.search:focus-within { border-color: var(--accent); background: var(--hover); color: var(--ink); }
.search svg { width: 17px; height: 17px; }
.search input { background: transparent; border: 0; color: var(--ink); width: 100%; min-width: 0; font-size: 14px; padding: 0; outline: none; }
.search input::placeholder { color: var(--muted); }
.theme-toggle { position: relative; }
.theme-toggle svg { position: absolute; }
.theme-toggle .sun { opacity: 0; transform: rotate(-60deg) scale(.6); }
[data-theme="dark"] .theme-toggle .sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .moon { opacity: 0; transform: rotate(60deg) scale(.6); }
main { max-width: 1800px; margin: auto; padding: 0 48px 64px; }
.gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 24px; animation: page-in 750ms 80ms cubic-bezier(.16, 1, .3, 1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.card { display: flex; flex-direction: column; border: 0; padding: 0; background: transparent; text-align: left; min-width: 0; }
.picture { position: relative; aspect-ratio: 1; width: 100%; overflow: hidden; background: var(--tile); }
.picture-image { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(0 4px 12px #00000050); transition: transform .35s ease; }
.picture-backdrop { position: absolute; inset: -24px; width: calc(100% + 48px); height: calc(100% + 48px); object-fit: cover; filter: blur(22px); opacity: var(--ambient-opacity); pointer-events: none; }
.card:hover .picture-image { transform: scale(1.035); }
.card:hover .caption { color: var(--accent); }
.caption { display: flex; gap: 12px; align-items: baseline; width: 100%; padding-top: 13px; line-height: 1.35; }
.number { color: var(--muted); font: 11px/1.4 Consolas, monospace; flex: 0 0 25px; }
.name { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }
.featured { grid-column: span 2; grid-row: span 2; }
.featured .picture { flex: 1; aspect-ratio: auto; min-height: 300px; background: #d2d3d5; }
.featured .picture-backdrop { display: none; }
.featured .picture-image { position: absolute; inset: 0; object-fit: contain; image-rendering: auto; filter: none; }
#empty { padding: 80px 0; color: var(--muted); text-align: center; }
dialog { position: fixed; inset: 0; width: min(1280px, calc(100% - 80px)); height: min(1000px, calc(100dvh - 80px)); max-width: none; max-height: none; border: 1px solid var(--rim); border-radius: 14px; overflow: hidden; padding: 0; margin: auto; color: var(--ink); background: var(--paper); box-shadow: 0 32px 100px #10181045, 0 4px 18px #10181020; }
dialog[open] { display: flex; flex-direction: column; animation: viewer-in 380ms cubic-bezier(.16, 1, .3, 1) both; }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(7px); animation: backdrop-in 300ms ease both; }
dialog.closing { animation: viewer-out 200ms ease-in both; pointer-events: none; }
dialog.closing::backdrop { animation: backdrop-out 200ms ease-in both; }
@keyframes viewer-in { from { opacity: 0; transform: translateY(20px) scale(.955); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes viewer-out { from { opacity: 1; transform: translateY(0) scale(1); } to { opacity: 0; transform: translateY(12px) scale(.975); } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes backdrop-out { from { opacity: 1; } to { opacity: 0; } }
body:has(dialog[open]) .page-scroll { overflow: hidden; }
.about-dialog { width: min(520px, calc(100% - 32px)); height: fit-content; max-height: calc(100dvh - 48px); padding: 28px 32px 32px; overflow-y: auto; scrollbar-width: none; }
.about-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.about-heading h1 { margin: 0; font: 27px/1.2 Georgia, serif; letter-spacing: -.5px; }
.about-dialog p { margin: 12px 0 0; font-size: 14px; line-height: 1.75; }
.about-downloads { margin-top: 24px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); }
.about-downloads strong { font-weight: 500; color: var(--ink); }
.about-downloads code { font-size: 12px; }
.viewer-bar { min-height: 76px; padding: 16px 28px; display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.viewer-title { display: flex; flex-direction: column; justify-content: center; gap: 3px; align-items: center; min-width: 0; text-align: center; }
#world-id { color: var(--muted); font: 10px/1.2 Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
#world-name { font-size: 18px; font-weight: 500; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 40px; border: 0; background: transparent; text-decoration: none; }
.icon-button svg { transition: filter 180ms ease; }
.icon-button:is(:hover, :focus-visible):not(:disabled) { color: var(--glow-core); }
.icon-button:is(:hover, :focus-visible):not(:disabled) svg { filter: drop-shadow(0 0 2px var(--glow)) drop-shadow(0 0 6px var(--glow)) drop-shadow(0 0 12px var(--glow)); }
.icon-button:focus-visible { outline: none; }
#fit:is(:hover, :focus-visible) { color: var(--glow-core); text-shadow: 0 0 5px var(--glow), 0 0 12px var(--glow); }
.icon-button:disabled { opacity: .35; cursor: default; }
.stage { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; background: var(--stage); }
.stage::before { content: ""; position: absolute; inset: -40px; background: var(--preview-image) center / cover; filter: blur(32px); opacity: var(--ambient-opacity); pointer-events: none; }
.stage.zoomed { cursor: grab; }
.stage.dragging { cursor: grabbing; }
#full-image { position: absolute; left: 50%; top: 50%; width: 0; height: 0; max-width: none; transform-origin: center; user-select: none; image-rendering: pixelated; filter: drop-shadow(0 8px 20px #00000050); }
#full-image.render { image-rendering: auto; }
.step { position: absolute; top: 50%; transform: translateY(-50%); z-index: 1; width: 44px; height: 44px; }
.previous { left: 20px; }
.next { right: 20px; }
.viewer-footer { min-height: 76px; padding: 12px 28px; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px; border-top: 1px solid var(--line); }
.view-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 7px; background: var(--hover); justify-self: start; }
.view-tabs button { padding: 8px 12px; background: none; border: 0; border-radius: 4px; color: var(--muted); font-size: 13px; }
.view-tabs button[aria-pressed="true"] { color: var(--ink); background: var(--selected); box-shadow: 0 1px 3px #00000012; }
.view-tabs[hidden] { display: none; }
.image-controls { display: flex; grid-column: 2; align-items: center; gap: 4px; }
.download-world { display: inline-flex; grid-column: 3; align-items: center; justify-content: center; justify-self: end; gap: 10px; height: 42px; padding: 0 16px; border-radius: 5px; background: var(--ink); color: var(--paper); font-size: 13px; line-height: 1; text-decoration: none; white-space: nowrap; }
.download-world svg { width: 18px; height: 18px; flex: 0 0 18px; }
.download-world:hover { background: var(--accent); }
#fit { background: none; border: 0; padding: 11px; font-size: 12px; }

/* Transition the surfaces and text together; images keep their original colors. */
:root, body, dialog, dialog::backdrop, .viewer-bar, .viewer-footer, .stage,
.picture, .search, .search input, .search input::placeholder, .brand #count,
.number, .caption, #world-id, #empty, .view-tabs, .view-tabs button, .about-downloads, .about-downloads strong,
.download-world, .icon-button, #fit {
  transition: background-color 520ms ease, color 520ms ease, border-color 520ms ease;
}
.picture-backdrop, .stage::before { transition: opacity 520ms ease; }
.theme-toggle svg { transition: opacity 320ms ease, transform 400ms ease, filter 180ms ease; }
@media (min-width: 1500px) { .bar { padding-top: 40px; padding-bottom: 34px; } .gallery { gap: 36px 30px; } }
@media (max-width: 1000px) {
  .bar { padding: 28px 28px 24px; }
  main { padding: 0 28px 40px; }
  .gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px 20px; }
}
@media (max-width: 760px) {
  .viewer-footer { grid-template-columns: 1fr 1fr; gap: 12px; }
  .view-tabs { grid-column: 1 / -1; justify-self: center; }
  .image-controls { grid-column: 1; justify-self: start; }
  .download-world { grid-column: 2; }
}
@media (max-width: 650px) {
  .bar { padding: 25px 18px 22px; gap: 16px; }
  .wordmark { font-size: 31px; }
  .bar-actions { gap: 8px; }
  .search { padding: 9px 5px; gap: 6px; }
  .search input { font-size: 13px; }
  main { padding: 0 18px 32px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 14px; }
  .featured { grid-row: auto; }
  .featured .picture { aspect-ratio: 1.25; min-height: 0; }
  .caption { gap: 6px; padding-top: 10px; }
  .name { font-size: 12px; }
  .number { font-size: 10px; flex-basis: 23px; }
  dialog { width: calc(100% - 20px); height: calc(100dvh - 32px); border-radius: 12px; }
  .about-dialog { width: calc(100% - 32px); height: fit-content; padding: 20px 24px 24px; }
  .about-heading h1 { font-size: 24px; }
  .viewer-bar { min-height: 67px; padding: 12px 14px; }
  #world-name { font-size: 15px; }
  .viewer-footer { padding: 12px 14px; }
  .image-controls { gap: 0; }
  .previous { left: 8px; }
  .next { right: 8px; }
  .step { width: 36px; height: 40px; }
}
@media (max-width: 360px) {
  .bar { gap: 10px; }
  .viewer-bar { gap: 8px; }
  .viewer-footer { padding: 10px; gap: 10px; }
  .download-world { padding: 0 10px; gap: 6px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, dialog::backdrop { transition: none !important; }
  .bar, .gallery, dialog[open], dialog.closing, dialog::backdrop, dialog.closing::backdrop { animation: none; }
}
@media (forced-colors: active) {
  .icon-button:focus-visible { outline: 2px solid Highlight; outline-offset: 3px; }
}
