:root {
  --bg: #28170c;
  --panel: rgba(255, 245, 221, 0.92);
  --panel-dark: rgba(72, 39, 19, 0.9);
  --ink: #2c1c12;
  --muted: #6d573f;
  --gold: #d69b45;
  --cream: #fff4d8;
  --line: rgba(90, 54, 25, 0.25);
  --shadow: 0 2vmin 4vmin rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #5a3318, var(--bg) 60%);
  color: var(--ink);
  font-family: Georgia, 'Times New Roman', serif;
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

button {
  font: inherit;
}

.stage {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.2vmin;
}

.screen {
  width: min(100vw, 177.7778vh);
  height: min(56.25vw, 100vh);
  max-width: 100vw;
  max-height: 100vh;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(rgba(255, 248, 232, 0.9), rgba(255, 239, 205, 0.93)),
    repeating-linear-gradient(45deg, rgba(117, 74, 37, 0.07) 0 0.7vmin, transparent 0.7vmin 1.4vmin);
  border: 0.45vmin solid #bd8840;
  border-radius: 2vmin;
  box-shadow: var(--shadow);
  overflow: hidden;
  padding: 2vmin;
}

.page[hidden] {
  display: none;
}

.main-header {
  height: 13%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #7a4b1b;
  font-size: clamp(0.5rem, 1.1vmin, 0.85rem);
  font-weight: 700;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

h1 {
  font-size: clamp(1.7rem, 4.6vmin, 4rem);
  line-height: 1;
  color: #3f230f;
  text-shadow: 0 0.2vmin 0 rgba(255, 255, 255, 0.7);
}

.home-layout {
  height: 87%;
  display: grid;
  grid-template-columns: 25% 75%;
  gap: 1.5vmin;
}

.category-panel {
  background: var(--panel-dark);
  border-radius: 1.5vmin;
  padding: 1.2vmin;
  overflow: hidden;
  display: grid;
  align-content: center;
}

.category-panel::before {
  content: 'Select a Category';
  display: block;
  color: var(--cream);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(0.48rem, 1.1vmin, 0.8rem);
  margin: 0 0 0.9vmin;
  text-align: center;
}

.category-card {
  width: 100%;
  border: 0.18vmin solid rgba(255, 232, 185, 0.3);
  border-radius: 1.1vmin;
  background: rgba(255, 245, 220, 0.88);
  color: var(--ink);
  display: grid;
  grid-template-columns: 3.4vmin 1fr;
  column-gap: 0.8vmin;
  align-items: center;
  padding: 0.8vmin;
  margin-bottom: 0.75vmin;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.category-card:last-child {
  margin-bottom: 0;
}

.category-card:hover,
.category-card:focus,
.category-card.active {
  transform: translateX(0.45vmin);
  background: #fff7df;
  border-color: var(--gold);
  outline: none;
}

.card-number {
  width: 3.4vmin;
  height: 3.4vmin;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #5c3418;
  color: var(--cream);
  font-size: clamp(0.72rem, 1.5vmin, 1rem);
  font-weight: 700;
}

.card-copy strong {
  display: block;
  font-size: clamp(0.78rem, 1.55vmin, 1.08rem);
  line-height: 1.05;
}

.card-copy small {
  display: block;
  margin-top: 0.25vmin;
  color: var(--muted);
  font-size: clamp(0.55rem, 0.95vmin, 0.72rem);
  line-height: 1.15;
}

.preview-panel {
  background: rgba(255, 255, 255, 0.38);
  border: 0.2vmin solid var(--line);
  border-radius: 1.5vmin;
  padding: 1.2vmin;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.frame-shell {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 0;
  position: relative;
  min-height: 0;
}

.preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  align-self: center;
  cursor: pointer;
  overflow: hidden;
  border: 0.6vmin solid #4a2a15;
  border-radius: 1.3vmin;
  background: #21130b;
  box-shadow: inset 0 0 0 0.45vmin #d39a4d, 0 1.6vmin 3vmin rgba(0, 0, 0, 0.25);
}

.preview-frame:focus {
  outline: 0.35vmin solid #ffe3a1;
  outline-offset: 0.3vmin;
}

.preview-frame img,
.detail-image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview-frame figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25vmin;
  padding: 1.2vmin 1.5vmin;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78) 18%);
  color: white;
}

.preview-frame figcaption strong {
  font-size: clamp(1.2rem, 2.9vmin, 2.2rem);
}

.preview-frame figcaption span {
  font-family: Consolas, 'Courier New', monospace;
  font-size: clamp(0.55rem, 1.2vmin, 0.9rem);
  opacity: 0.92;
}

.arrow {
  width: 4.8vmin;
  height: 4.8vmin;
  border: 0;
  border-radius: 999px;
  background: #4a2a15;
  color: var(--cream);
  cursor: pointer;
  font-size: clamp(1rem, 3vmin, 2rem);
  box-shadow: 0 0.8vmin 1.5vmin rgba(0, 0, 0, 0.25);
  position: absolute;
  z-index: 3;
  top: 50%;
  transform: translateY(-50%);
}

.arrow-left {
  left: 1.2vmin;
}

.arrow-right {
  right: 1.2vmin;
}

.arrow:hover,
.arrow:focus,
.home-button:hover,
.home-button:focus {
  background: #7b4a20;
  outline: 0.25vmin solid #ffe3a1;
}

.preview-bottom {
  min-height: 5%;
  margin: 0.8vmin 0 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1vmin;
  align-items: center;
}

.preview-bottom p {
  font-size: clamp(0.62rem, 1.15vmin, 0.9rem);
  line-height: 1.25;
  color: #513217;
}

.counter {
  background: #4a2a15;
  color: var(--cream);
  border-radius: 999px;
  padding: 0.55vmin 1.2vmin;
  font-size: clamp(0.68rem, 1.35vmin, 0.95rem);
  white-space: nowrap;
}

.detail-page {
  display: grid;
  grid-template-rows: 13% 87%;
  gap: 1.4vmin;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2vmin;
}

.detail-header h2 {
  font-size: clamp(1.6rem, 4.2vmin, 3.6rem);
  line-height: 1;
  color: #3f230f;
}

.home-button {
  border: 0;
  border-radius: 999px;
  padding: 1vmin 2.4vmin;
  background: #4a2a15;
  color: var(--cream);
  cursor: pointer;
  font-size: clamp(0.82rem, 1.55vmin, 1.2rem);
  font-weight: 700;
}

.detail-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 68% 32%;
  gap: 1.4vmin;
}

.detail-image-frame {
  position: relative;
  min-height: 0;
  aspect-ratio: 16 / 9;
  align-self: center;
  overflow: hidden;
  border-radius: 1.4vmin;
  border: 0.55vmin solid #4a2a15;
  background: #21130b;
  box-shadow: inset 0 0 0 0.4vmin #d39a4d;
}

.detail-image-frame figcaption {
  position: absolute;
  left: 1.2vmin;
  bottom: 1.2vmin;
  padding: 0.7vmin 1vmin;
  border-radius: 0.7vmin;
  background: rgba(0, 0, 0, 0.72);
  color: #fff5dc;
  font-family: Consolas, 'Courier New', monospace;
  font-size: clamp(0.6rem, 1.25vmin, 0.92rem);
}

.detail-copy {
  background: var(--panel);
  border: 0.2vmin solid var(--line);
  border-radius: 1.4vmin;
  padding: 1.5vmin;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1vmin;
  overflow: hidden;
}

.detail-copy h3 {
  font-size: clamp(1rem, 2.1vmin, 1.6rem);
  color: #5a3417;
}

.detail-copy p {
  font-size: clamp(0.72rem, 1.45vmin, 1.05rem);
  line-height: 1.38;
  color: #3f2b18;
}

.edit-note {
  margin-top: 0.6vmin;
  padding: 0.9vmin;
  border-radius: 0.9vmin;
  background: rgba(214, 155, 69, 0.16);
  border: 0.15vmin solid rgba(90, 54, 25, 0.16);
}

code {
  font-family: Consolas, 'Courier New', monospace;
}

@media (max-aspect-ratio: 1/1) {
  body {
    overflow: auto;
  }

  .screen {
    width: 100vw;
    height: auto;
    min-height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .home-layout,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .category-panel {
    grid-template-columns: 1fr 1fr;
    gap: 0.75vmin;
  }

  .category-panel::before {
    grid-column: 1 / -1;
  }

  .category-card {
    margin-bottom: 0;
  }
}
