:root {
  color-scheme: light;
  --paper: #fff9e6;
  --screen: #f8fff4;
  --ink: #151515;
  --muted: #5b5b5b;
  --red: #e63946;
  --blue: #2676d9;
  --green: #2a9d5b;
  --yellow: #f4c542;
  --line: #151515;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  line-height: 1.45;
  background:
    linear-gradient(90deg, rgba(38, 118, 217, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(230, 57, 70, 0.07) 1px, transparent 1px),
    var(--paper);
  background-size: 18px 18px;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

.shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.collection-header,
.collection-actions,
.actions,
.creature-reveal,
.creature-info {
  display: grid;
  gap: 12px;
}

.topbar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding-bottom: 16px;
}

.brand {
  display: grid;
  gap: 4px;
}

.button,
.nes-btn {
  min-height: 44px;
  text-decoration: none;
}

.button.secondary {
  background: #fff;
}

.collection-shell {
  display: grid;
  align-content: start;
  gap: 18px;
  padding-top: 22px;
}

.collection-header {
  padding: 8px 0 4px;
}

.eyebrow {
  margin: 0;
  color: var(--red);
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.collection-header h1,
.hero h1,
.discovery-card h1 {
  margin-bottom: 0;
  line-height: 1;
  letter-spacing: 0;
}

.collection-header h1 {
  font-size: clamp(2rem, 12vw, 4.5rem);
}

.progress-label {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.progress {
  width: 100%;
  height: 20px;
  border: 4px solid var(--line);
  background: #fff;
}

.progress > span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--yellow));
  transition: width 180ms steps(5, end);
}

.collection-list,
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 12px;
}

.collection-row,
.collection-card {
  display: grid;
  align-content: start;
  justify-items: center;
  gap: 10px;
  min-height: 176px;
  padding: 10px;
  background: var(--screen);
  text-align: center;
  text-decoration: none;
}

.collection-row:hover {
  transform: translateY(-2px);
}

.collection-row h2,
.collection-card h2 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 1rem;
  line-height: 1.15;
}

.collection-portrait {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-height: 108px;
  border: 4px solid var(--line);
  background:
    linear-gradient(135deg, rgba(38, 118, 217, 0.16), transparent 45%),
    #ffffff;
  color: var(--muted);
  font-size: 2.4rem;
  font-weight: 900;
}

.collection-portrait img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.collection-row.unknown {
  background: #f2f2f2;
  color: var(--muted);
}

.collection-row.unknown .collection-portrait,
.missing-photo {
  background:
    repeating-linear-gradient(
      45deg,
      #ffffff,
      #ffffff 8px,
      #ececec 8px,
      #ececec 16px
    );
}

.collection-actions {
  padding-bottom: 28px;
}

.hero,
.discovery-card {
  display: grid;
  gap: 16px;
  border: 4px solid var(--line);
  background: var(--screen);
  padding: clamp(18px, 6vw, 34px);
  box-shadow: 8px 8px 0 var(--blue);
}

.hero {
  margin-bottom: 18px;
}

.hero h1 {
  font-size: clamp(2rem, 10vw, 4rem);
}

.hero p,
.discovery-card p,
.panel p {
  color: var(--muted);
}

.reward-code {
  width: fit-content;
  background: #fff;
  font-weight: 900;
}

.panel {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.discovery-shell {
  display: grid;
  align-items: center;
  padding-block: 22px;
}

.burst {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border: 4px solid var(--line);
  background: var(--yellow);
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
}

.creature-reveal strong {
  font-size: clamp(2rem, 12vw, 4.5rem);
  line-height: 1;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.creature-reveal span {
  color: var(--red);
  font-weight: 900;
}

.lore {
  border-left: 6px solid var(--yellow);
  padding-left: 12px;
  color: var(--ink);
  font-weight: 700;
}

.metadata-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.metadata-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 2px solid #d8d8d8;
  padding-bottom: 6px;
}

.metadata-row dt {
  color: var(--muted);
  font-weight: 800;
}

.metadata-row dd {
  margin: 0;
  text-align: right;
  font-weight: 900;
}

.complete-note {
  border: 4px solid var(--line);
  padding: 10px;
  background: #fff;
  font-weight: 900;
}

.actions.vertical {
  grid-template-columns: 1fr;
}

.viewer-body {
  overflow: hidden;
  background: #050505;
}

.viewer-screen {
  position: fixed;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    #101820;
  background-size: 24px 24px;
}

.viewer-screen #model-viewer {
  display: block;
  width: 100vw;
  height: 100svh;
  min-height: 100vh;
  background: transparent;
}

.viewer-back,
.viewer-caption,
.immersive-ar-button {
  position: fixed;
  z-index: 20;
}

.viewer-back {
  top: max(14px, env(safe-area-inset-top));
  left: 14px;
}

.viewer-caption {
  top: max(68px, calc(env(safe-area-inset-top) + 68px));
  left: 18px;
  right: 18px;
  color: #fff;
  pointer-events: none;
  text-shadow: 3px 3px 0 #000;
}

.viewer-caption h1 {
  margin: 0;
  font-size: clamp(1.6rem, 8vw, 3.2rem);
  line-height: 1;
}

.viewer-caption p {
  margin: 4px 0 0;
  color: #fff;
  font-weight: 900;
}

.immersive-ar-button {
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  width: auto;
  min-height: 54px;
}

#error {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 30;
  width: min(90vw, 360px);
  border: 4px solid var(--line);
  padding: 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 900;
  transform: translate3d(-50%, -50%, 0);
}

#error.hide {
  display: none;
}

.complete-link[hidden],
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 620px) {
  .collection-row,
  .collection-card {
    min-height: 210px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  body:not(.viewer-body) #model-viewer {
    height: 78vh;
    min-height: 280px;
  }
}
