/* During an active quiz session, the app fills the full viewport */
#app.app--quiz-active {
  width: 100%;
  max-width: 100%;
  padding: 1rem;
  box-sizing: border-box;
  gap: 1rem;
  height: 100vh; /* fallback for browsers without svh support */
  height: 100svh;
  justify-content: flex-start;
}

/* During quiz, html/body should fit viewport — but never hide overflow.
   Content must actually fit; we don't suppress scrollbars. */
html:has(.app--quiz-active) {
  height: 100vh;
  height: 100svh;
}

/* Card zone: grows to fill remaining space, cards stacked for crossfade */
.card-container {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  width: 100%;
}

/* Stack all cards in the same cell for crossfade overlay */
.card-container .card {
  grid-area: 1 / 1;
  max-height: 100%;
  overflow: hidden;
}

@keyframes buttonFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.card {
  background: color-mix(in srgb, var(--bg-brown-dark) 88%, transparent);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  user-select: none;
}

.card-pips {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

/* Stack all pool names in the same grid cell so the widest name sets the width */
.card-name-stack {
  display: grid;
}

.card-name-stack .card-name {
  grid-area: 1 / 1;
  visibility: hidden;
}

.card-name-stack .card-name[data-active="true"] {
  visibility: visible;
}

.card-name {
  font-size: 1.75rem;
  font-weight: 700;
  font-family: 'GoudyMediaeval', Georgia, serif;
  color: #f0f0f0;
  text-align: center;
  letter-spacing: 0.02em;
  opacity: 1;
  transition: opacity 250ms ease;
}

.card-name-hidden {
  opacity: 0;
}

.progress-bar-track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  overflow: hidden;
  align-self: center;
  position: relative;
  opacity: 0.7;
}

.progress-bar-cover {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  background: var(--bg-brown-dark);
  border-radius: 0 2px 2px 0;
  width: 100%;
  /* transition set dynamically in JS based on card timing */
}

@media (prefers-reduced-motion: reduce) {
  .progress-bar-cover {
    transition: none;
  }
}

/* Footer below the card — two rows */
.done-zone {
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 0;
}

/* Row 1: Names reference */
.footer-names {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  padding: 0.25rem 0;
  gap: 0.5rem;
}

.footer-names-text {
  font-family: 'GoudyMediaeval', Georgia, serif;
  font-weight: bold;
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  color: rgba(224, 224, 224, 0.6);
  letter-spacing: 0.02em;
  line-height: 1.6;
}

.footer-names-minimize {
  font-size: 1rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.3);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color 200ms ease, background 200ms ease;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.footer-names-minimize svg {
  transform: translateY(3px);
}

.footer-names-minimize:hover {
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.08);
}

/* Row 2: Controls — everything right-aligned */
.footer-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
}

/* Circular pause button — styled like .gas-btn */
.footer-pause-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms ease, border-color 200ms ease;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.footer-pause-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.footer-pause-btn:active {
  transform: scale(0.93);
}

.footer-pause-btn--paused {
  border-color: rgba(100, 200, 200, 0.6);
}

@media (max-width: 600px) {
  .footer-pause-btn {
    width: 40px;
    height: 40px;
  }
}

.done-button {
  font-size: 1.1rem;
  font-weight: 600;
  color: #e0e0e0;
  background: color-mix(in srgb, var(--card-back-turquoise) 20%, transparent);
  border: 2px solid var(--card-back-turquoise);
  border-radius: 12px;
  padding: 0.9rem 1.5rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: background 200ms ease, border-color 200ms ease, transform 100ms ease;
  -webkit-tap-highlight-color: transparent;
}

.done-button.button-visible {
  animation: buttonFadeIn 600ms ease forwards;
  pointer-events: auto;
}

.done-button.button-steady {
  opacity: 1;
  animation: none;
  pointer-events: auto;
}

.done-button:hover {
  background: color-mix(in srgb, var(--card-back-turquoise) 35%, transparent);
  border-color: var(--card-back-oval-brighter);
}

.done-button:active {
  transform: scale(0.97);
}

/* Arc 11: Card image side-by-side layout */
.card--with-image {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: center;
}

.card-image-column {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mtg-card-img {
  aspect-ratio: 5 / 7;
  width: 180px;
  border-radius: 20px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  display: block;
}

.card-quiz-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

@media (max-width: 500px) {
  .card--with-image {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .mtg-card-img {
    width: 140px;
  }
}

#app.app--quiz-active .card {
  border-radius: 0;
  padding: 1.5rem;
  justify-content: center;
}

/* Full-screen side-by-side layout: image grows, quiz column scales up */
#app.app--quiz-active .card--with-image {
  grid-template-columns: auto 1fr;
  gap: 2rem;
  max-height: 100%;
  align-items: center;
  border-radius: 4px;
}

#app.app--quiz-active .card-image-column {
  max-height: 100%;
  justify-content: center;
}

#app.app--quiz-active .mtg-card-img {
  width: auto;
  max-width: min(45vw, 360px);
  max-height: 100%;
  object-fit: contain;
}

#app.app--quiz-active .card-quiz-column {
  gap: 2rem;
}

#app.app--quiz-active .card-name {
  font-size: var(--combo-name-size);
}

#app.app--quiz-active .card-pips .mana-pip {
  width: clamp(48px, 7vw, 96px);
  height: clamp(48px, 7vw, 96px);
}

/* No-image full-screen: center the pips and name */
#app.app--quiz-active .card:not(.card--with-image) {
  gap: 2rem;
}

#app.app--quiz-active .card:not(.card--with-image) .card-name {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

#app.app--quiz-active .card:not(.card--with-image) .card-pips .mana-pip {
  width: clamp(64px, 10vw, 120px);
  height: clamp(64px, 10vw, 120px);
}

/* === Level Intro Slide === */

@keyframes levelIntroHintPulse {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.85; }
}

@keyframes levelIntroDismiss {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.level-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100svh; /* safe area override when supported */
  width: 100%;
  animation: cardEnter 250ms ease-out;
}

.level-intro--dismissing {
  animation: levelIntroDismiss 150ms ease-in forwards;
}

.level-intro-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.level-intro-number {
  font-family: 'Jost', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 5.5rem);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: #f0f0f0;
  margin: 0;
  line-height: 1;
}

.level-intro-rule {
  border: none;
  border-top: 1px solid #c8b88a;
  width: clamp(60px, 12vw, 100px);
  margin: 0.5rem 0;
}

.level-intro-subtitle {
  font-family: 'Jost', system-ui, sans-serif;
  font-weight: 400;
  font-size: 1.5rem;
  letter-spacing: 0.08em;
  color: #c8b88a;
  margin: 0;
}

.level-intro-names {
  font-family: 'GoudyMediaeval', Georgia, serif;
  font-weight: bold;
  font-size: var(--combo-name-size);
  letter-spacing: 0.03em;
  color: #e0e0e0;
  margin: 0.5rem 0 0;
  max-width: 90vw;
  text-align: center;
  line-height: 1.7;
}

.level-intro-cta {
  font-family: 'Jost', system-ui, sans-serif;
  font-weight: 400;
  font-size: 1.7rem;
  color: var(--card-back-turquoise);
  margin-top: clamp(2rem, 5vh, 3.5rem);
  animation: levelIntroHintPulse 2.5s ease-in-out infinite 800ms;
}

/* Mobile: scale down level intro */
@media (max-width: 600px) {
  .level-intro-number {
    font-size: clamp(2.5rem, 12vw, 3.5rem);
  }

  .level-intro-subtitle {
    font-size: 1.3rem;
  }

}

/* === End Level Intro Slide === */

/* Mobile: stack image above pips/name when screen is narrow */
@media (max-width: 600px) {
  :root {
    --combo-name-size: clamp(1.5rem, 5vw, 2rem);
  }

  #app.app--quiz-active .card--with-image {
    grid-template-columns: 1fr;
    justify-items: center;
    align-items: start;
    gap: 1rem;
  }

  #app.app--quiz-active .card-image-column {
    height: auto;
  }

  #app.app--quiz-active .mtg-card-img {
    max-width: min(70vw, 240px);
    max-height: 40vh;
  }

  #app.app--quiz-active .card-pips .mana-pip {
    width: clamp(40px, 8vw, 64px);
    height: clamp(40px, 8vw, 64px);
  }
}

/* Sound toggle on slides — larger and higher-contrast, matching pause button */
.sound-toggle-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #ccc;
  padding: 0;
}

.sound-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ccc;
}

@media (max-width: 600px) {
  .sound-toggle-btn {
    width: 40px;
    height: 40px;
  }
}
