:root {
  --page-width: 1600px;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --text: #111111;
  --muted: #555555;
  --line: #1f1f1f;
  --line-soft: #cfcfcf;
  --title-font: "Press Start 2P", "Courier New", monospace;
  --body-font: "Press Start 2P", "Courier New", monospace;
  --copy-font: "IBM Plex Mono", "SFMono-Regular", "Courier New", monospace;
  --ui-font: ui-monospace, "Cascadia Mono", Consolas, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: #e9e9e9;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--body-font);
}

body.modal-open {
  overflow: hidden;
}

.page-shell {
  width: min(100%, var(--page-width));
  margin: 0 auto;
  background: var(--panel);
  border-left: 1px solid var(--line-soft);
  border-right: 1px solid var(--line-soft);
}

.site-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 88px;
  padding: 1rem 1rem 1.3rem;
  border-bottom: 1px solid var(--line-soft);
}

.header-tools {
  position: absolute;
  right: 2rem;
  bottom: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.switch {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--line);
}

.switch-item {
  display: inline-flex;
  align-items: center;
  padding: 0.46rem 0.78rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 0.76rem;
  line-height: 1.3;
  letter-spacing: 0.08em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease, background-color 150ms ease;
}

.switch-item + .switch-item {
  border-left: 1px solid var(--line);
}

a.switch-item:hover,
a.switch-item:focus-visible {
  background: #f2f2f2;
  color: var(--text);
}

.switch-item.is-active {
  background: var(--text);
  color: #ffffff;
  cursor: default;
}

.ghost-link {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  color: var(--muted);
  font-family: var(--ui-font);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease;
}

.ghost-link:hover,
.ghost-link:focus-visible {
  color: var(--text);
}

.ghost-arrow {
  font-size: 0.64rem;
  line-height: 1;
}

.site-footer {
  display: flex;
  justify-content: center;
  padding: 1.15rem 1rem;
  border-top: 1px solid var(--line-soft);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.6rem 1.4rem;
}

.footer-credit a {
  color: inherit;
  text-decoration: none;
}

.footer-credit a:hover,
.footer-credit a:focus-visible {
  color: var(--text);
}

.site-logo {
  display: block;
  flex: none;
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
}

.site-header h1 {
  margin: 0;
  font-family: var(--title-font);
  font-size: clamp(1.02rem, 1.62vw, 1.5rem);
  line-height: 1.5;
  letter-spacing: 0.15em;
  text-indent: 0.15em;
  text-align: center;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  grid-auto-flow: row dense;
  gap: clamp(3.4rem, 6vw, 7rem) clamp(3rem, 5.6vw, 6rem);
  padding: 2.6rem 2rem 3.6rem;
}

.gallery-card {
  display: block;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.gallery-card.is-wide {
  grid-column: span 2;
  aspect-ratio: auto;
}

.gallery-card.is-tall {
  grid-row: span 2;
  aspect-ratio: auto;
}

.gallery-card:focus-visible {
  outline: 1px solid var(--text);
  outline-offset: 0.5rem;
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 2.5rem 1.5rem 3rem;
  text-align: center;
}

.gallery-empty p {
  margin: 0 0 0.8rem;
  font-family: var(--copy-font);
  font-size: 0.82rem;
  line-height: 1.8;
  text-transform: uppercase;
}

.gallery-empty p:last-child {
  margin-bottom: 0;
}

.art-frame {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
}

.art-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 180ms ease;
}

.gallery-card:hover .art-frame img,
.gallery-card:focus-visible .art-frame img {
  transform: scale(1.06);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: clamp(0.6rem, 3vw, 2rem);
}

.modal[hidden] {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 17, 17, 0.72);
}

.modal-panel {
  position: relative;
  width: min(100%, 880px);
  max-height: min(92vh, 900px);
  overflow: auto;
  padding: clamp(1rem, 2.4vw, 1.8rem);
  border: 1px solid var(--line-soft);
  background: var(--panel);
  box-shadow: 0 40px 120px -40px rgba(0, 0, 0, 0.45);
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.85rem;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-family: var(--copy-font);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, border-color 150ms ease;
}

.modal-close:hover,
.modal-close:focus-visible {
  border-color: var(--text);
  background: var(--text);
  color: var(--panel);
}

.modal-media {
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.2rem);
  background: #fafafa;
}

.modal-media img {
  display: block;
  width: min(100%, 480px);
  height: auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.modal-copy {
  margin-top: 1.1rem;
}

.modal-copy h2 {
  margin: 0;
  font-family: var(--title-font);
  font-size: 0.95rem;
  line-height: 1.9;
  letter-spacing: 0.12em;
}

@media (max-width: 1120px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: clamp(2.6rem, 6vw, 4rem) clamp(2.2rem, 5.4vw, 3.6rem);
    padding: 2rem 1.5rem 2.8rem;
  }
}

@media (max-width: 760px) {
  .site-header {
    gap: 0.55rem;
    min-height: 74px;
    padding-top: 1rem;
  }

  .site-logo {
    width: 72px;
    height: 72px;
  }

  .site-header h1 {
    font-size: 0.92rem;
    letter-spacing: 0.1em;
    text-indent: 0.1em;
  }

  .header-tools {
    position: static;
    justify-content: center;
    gap: 0.7rem;
    margin-top: 0.2rem;
  }

  .switch-item {
    padding: 0.4rem 0.66rem;
    font-size: 0.68rem;
  }

  .site-footer {
    padding: 1rem 0.8rem;
  }

  .footer-links {
    gap: 0.5rem 0.9rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
    gap: 2.4rem 2rem;
    padding: 1.6rem 1rem 2.4rem;
  }

  .modal-panel {
    width: 100%;
    max-height: calc(100vh - 1rem);
    padding: 0.9rem;
  }

  .modal-media {
    padding: 1rem;
  }
}

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