.write-screen {
  min-height: 100vh;
  padding: var(--space-5) var(--space-3) var(--space-6);
}

.result-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  transition: opacity 400ms var(--ease-arc);
}

.result-section.is-revealed {
  opacity: 1;
}

.result-cards {
  --card-width: clamp(92px, 21vw, 140px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--card-width)), var(--card-width)));
  gap: clamp(18px, 4vw, var(--space-4));
  justify-content: center;
  width: 100%;
  max-width: 960px;
  margin-inline: auto;
}

.result-card-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  width: var(--card-width);
  min-width: 0;
}

.reveal-card {
  width: var(--card-width);
  aspect-ratio: 140 / 237;
  height: auto;
  perspective: 1000px;
}

.reveal-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 700ms var(--ease-arc);
}

.reveal-card-inner.is-flipped {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card-face--back {
  background-color: var(--mulberry);
  background-image: url('../img/card-back.svg');
  background-size: 72%;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid var(--hairline);
}

.card-face--front {
  transform: rotateY(180deg);
  border: 1px solid var(--hairline);
  background: var(--mulberry);
}

.card-face--front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.card-placeholder {
  width: 100%;
  height: 100%;
  background: var(--mulberry);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: var(--space-2);
  text-align: center;
}

.card-placeholder-en {
  color: var(--blush-veil);
  font-size: 1.3rem;
}

.card-placeholder-num {
  color: var(--ash-rose);
  font-size: 0.75rem;
  text-transform: lowercase;
  letter-spacing: 0.2em;
}

.reveal-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  opacity: 0;
  transition: opacity 400ms var(--ease-arc) 500ms;
}

.result-section.is-revealed .reveal-caption {
  opacity: 1;
}

.reveal-position-en {
  color: var(--ash-rose);
  letter-spacing: 0.3em;
}

.reveal-position-ko {
  color: var(--mauve-mute);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.reveal-name {
  font-size: 1.3rem;
  color: var(--blush-veil);
  margin-top: 8px;
}

.reveal-name-en {
  color: var(--mauve-mute);
  font-size: 0.78rem;
}

.card-lightbox {
  border: none;
  background: transparent;
  padding: 0;
  max-width: 90vw;
}

.card-lightbox::backdrop {
  background: rgba(26, 16, 19, 0.85);
}

.card-lightbox img {
  max-width: 90vw;
  max-height: 78vh;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius-card);
  border: 1px solid var(--hairline);
}

.lightbox-caption {
  text-align: center;
  color: var(--blush-veil);
  margin-top: var(--space-2);
}

.lightbox-close {
  display: block;
  margin: var(--space-2) auto 0;
  color: var(--mauve-mute);
  font-family: var(--font-label);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.lightbox-close:hover {
  color: var(--ash-rose);
}

/* Four-card spread: three cards on top, with the fourth centred below. */
.result-cards--four {
  grid-template-columns: repeat(3, var(--card-width));
  grid-template-areas:
    "one two three"
    ". four .";
  max-width: calc(var(--card-width) * 3 + var(--space-4) * 2);
}

.result-cards--four .result-card-col:nth-child(1) { grid-area: one; }
.result-cards--four .result-card-col:nth-child(2) { grid-area: two; }
.result-cards--four .result-card-col:nth-child(3) { grid-area: three; }
.result-cards--four .result-card-col:nth-child(4) { grid-area: four; }

/* Seven-card spread: the same 3-column diamond shown in the reference. */
.result-cards--seven {
  --card-width: clamp(82px, 27vw, 150px);
  grid-template-columns: repeat(3, var(--card-width));
  grid-template-areas:
    ". one ."
    "five seven six"
    "three seven two"
    ". four .";
  align-items: center;
  column-gap: clamp(5px, 2vw, 20px);
  row-gap: clamp(12px, 3vw, 28px);
  max-width: calc(var(--card-width) * 3 + 40px);
}

.result-cards--seven .result-card-col:nth-child(1) { grid-area: one; }
.result-cards--seven .result-card-col:nth-child(2) { grid-area: two; }
.result-cards--seven .result-card-col:nth-child(3) { grid-area: three; }
.result-cards--seven .result-card-col:nth-child(4) { grid-area: four; }
.result-cards--seven .result-card-col:nth-child(5) { grid-area: five; }
.result-cards--seven .result-card-col:nth-child(6) { grid-area: six; }
.result-cards--seven .result-card-col:nth-child(7) { grid-area: seven; }

.result-cards--seven .reveal-caption,
.result-cards--celtic_cross .reveal-caption {
  display: none;
}

.result-cards--seven .result-card-col::after,
.result-cards--celtic_cross .result-card-col::after {
  content: attr(data-card-number);
  color: var(--mauve-mute);
  font-family: var(--font-label);
  font-size: clamp(0.62rem, 2.4vw, 0.78rem);
  line-height: 1;
  text-align: center;
}

/* Celtic cross: six-card cross on the left, four-card staff on the right. */
.result-cards--celtic_cross {
  --card-width: clamp(68px, 20vw, 132px);
  display: block;
  position: relative;
  width: min(100%, calc(var(--card-width) * 4.75));
  height: calc(var(--card-width) * 7.05);
  max-width: none;
}

.result-cards--celtic_cross .result-card-col {
  position: absolute;
  gap: 3px;
}

.result-cards--celtic_cross .result-card-col:nth-child(1) { left: 27%; top: 35%; z-index: 2; }
.result-cards--celtic_cross .result-card-col:nth-child(2) { left: 27%; top: 39%; z-index: 4; transform: rotate(90deg); }
.result-cards--celtic_cross .result-card-col:nth-child(2)::after { transform: rotate(-90deg); }
.result-cards--celtic_cross .result-card-col:nth-child(3) { left: 27%; top: 70%; }
.result-cards--celtic_cross .result-card-col:nth-child(4) { left: 1%; top: 35%; }
.result-cards--celtic_cross .result-card-col:nth-child(5) { left: 27%; top: 0; }
.result-cards--celtic_cross .result-card-col:nth-child(6) { left: 53%; top: 35%; }
.result-cards--celtic_cross .result-card-col:nth-child(7) { right: 0; top: 75%; }
.result-cards--celtic_cross .result-card-col:nth-child(8) { right: 0; top: 50%; }
.result-cards--celtic_cross .result-card-col:nth-child(9) { right: 0; top: 25%; }
.result-cards--celtic_cross .result-card-col:nth-child(10) { right: 0; top: 0; }

@media (max-width: 639px) {
  .write-screen {
    padding-inline: 8px;
  }

  /* Keep every spread inside the initial mobile viewport, including short
     landscape screens. Width is the normal limiter; svh is the safety net. */
  .result-cards:not(.result-cards--four):not(.result-cards--seven):not(.result-cards--celtic_cross) {
    --card-width: min(27vw, calc((100svh - 160px) / 2.35), 118px);
    grid-template-columns: repeat(auto-fit, var(--card-width));
    gap: 18px 8px;
  }

  .result-cards--one {
    --card-width: min(38vw, calc((100svh - 160px) / 2.35), 140px);
  }

  .result-cards--three {
    grid-template-columns: repeat(3, var(--card-width));
  }

  .result-cards--four {
    --card-width: min(26.5vw, calc((100svh - 190px) / 3.4), 110px);
    column-gap: min(2.5vw, 10px);
    row-gap: 12px;
    max-width: calc(var(--card-width) * 3 + min(5vw, 20px));
  }

  .result-cards--seven {
    --card-width: min(18.5vw, calc((100svh - 140px) / 6.8), 96px);
    column-gap: min(2vw, 8px);
    row-gap: clamp(10px, 3vw, 16px);
    max-width: calc(var(--card-width) * 3 + min(4vw, 16px));
  }

  .result-cards--seven .result-card-col {
    gap: 2px;
  }

  .result-cards--seven .result-card-col:nth-child(1) {
    transform: translateY(calc(clamp(10px, 3vw, 16px) * 0.45));
  }

  .result-cards--seven .result-card-col:nth-child(4) {
    transform: translateY(calc(clamp(10px, 3vw, 16px) * -0.45));
  }

  .result-cards--seven .result-card-col::after {
    font-size: clamp(0.55rem, 2.2vw, 0.66rem);
  }

  .result-cards--celtic_cross {
    --card-width: min(20vw, calc((100svh - 88px) / 7.05), 92px);
  }

  .reveal-caption {
    gap: 1px;
    line-height: 1.3;
  }

  .reveal-position-en {
    font-size: 0.58rem;
    letter-spacing: 0.12em;
  }

  .reveal-position-ko {
    font-size: 0.65rem;
    margin-bottom: 1px;
  }

  .reveal-name {
    font-size: 0.82rem;
    margin-top: 2px;
  }

  .reveal-name-en {
    font-size: 0.58rem;
  }

}
