html:has(body.participant-app) {
  height: 100%;
  overflow: hidden;
}

body.participant-app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--viewport-height, 100dvh);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

body.participant-app #app,
body.participant-app #phone-preview {
  height: 100%;
  overflow: hidden;
}

.surprise-card {
  height: calc(100% - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
  margin: max(8px, env(safe-area-inset-top)) auto max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
}

.surprise-card h1 {
  color: var(--wine);
  font-weight: 400;
  font-size: clamp(1.8rem, 8vw, 3.8rem);
  line-height: 1.05;
  margin: clamp(.45rem, 2vh, 1rem) 0;
}

.surprise-card .intro { margin: .5rem 0; }
.gift-icon { font-size: clamp(2rem, 10vw, 4rem); }
.pin-form { width: min(100%, 390px); margin-top: clamp(.5rem, 2vh, 1.2rem); }
.pin-form label { display: block; margin-bottom: .55rem; font-weight: bold; }
.pin-input { text-align: center; letter-spacing: .7em; font-size: 1.5rem; font-weight: bold; }
.pin-form .button, .surprise-card > .button { width: min(100%, 390px); margin-top: .8rem; }
.phone-grid { width: min(100%, 430px); display: grid; grid-template-columns: repeat(3,1fr); gap: clamp(5px,2vw,10px); margin: clamp(.5rem,2vh,1.25rem) auto; }
.phone-cell { aspect-ratio: .54; min-width: 0; padding: 6px 2px; border: 3px solid #392027; border-radius: 10px; background: #250b14; color: #f7ebd3; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: inset 0 0 0 2px #c9a45c55; }
.phone-cell span { color: var(--gold); font-size: .75rem; }
.phone-cell strong { max-width: 100%; overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; font-size: clamp(.62rem,2.8vw,.95rem); }
.phone-cell.mine { outline: 5px solid var(--wine); animation: mine-pulse 1.2s ease-in-out infinite alternate; }
@keyframes mine-pulse { to { outline-color: var(--gold); transform: scale(1.04); } }
.place-arrow { color: var(--wine); font-size: clamp(2.2rem,12vw,4rem); line-height: 1; }
.arrow-0-0,.arrow-1-0 { transform: rotate(180deg); }
.arrow-0-1,.arrow-1-1 { transform: rotate(90deg); }
.ready-count { margin: .7rem 0 0; color: var(--muted); }
.play-button { min-height: 64px; font-size: 1.15rem; }
.play-pulse { width: 100px; height: 100px; display: grid; place-items: center; border-radius: 50%; color: #fff4d5; background: var(--wine); font-size: 2.8rem; box-shadow: 0 0 0 0 #651b2a66; animation: play-pulse 1.5s infinite; }
@keyframes play-pulse { 70% { box-shadow: 0 0 0 28px #651b2a00; } }
.movie-screen { position: absolute; inset: 0; overflow: hidden; background: #15070c; }
.movie-screen canvas, .movie-screen video { display: block; width: 100%; height: 100%; object-fit: fill; }
.download-progress { margin: .35rem 0; color: #27633a; font-weight: bold; font-size: .88rem; }
.sync-badge { position: absolute; left: 50%; bottom: max(8px,env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 4px 9px; border-radius: 20px; background: #13060bcc; color: #f7ebd3; font: 600 .65rem system-ui,sans-serif; opacity: .7; white-space: nowrap; }

.orientation-warning { display: none; }
@media (orientation: landscape) and (max-height: 600px) {
  body.participant-app::after { content: "Draai je telefoon rechtop\ADeze ervaring werkt alleen in portrait mode."; white-space: pre-line; position: fixed; z-index: 1000; inset: 0; display: grid; place-content: center; padding: 30px; text-align: center; font: 700 clamp(1.2rem,4vw,2rem)/1.45 system-ui,sans-serif; color: #fff4d5; background: #260c15; }
  body.participant-app > * { pointer-events: none; visibility: hidden; }
}

body.reading-screen .chapter {
  height: calc(100% - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
  margin-top: max(8px, env(safe-area-inset-top));
  margin-bottom: max(8px, env(safe-area-inset-bottom));
}

@media (max-width: 600px) {
  body.participant-app:not(.reading-screen) .card {
    width: calc(100% - 16px);
    height: calc(100% - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom)));
    max-height: none;
    margin: max(8px, env(safe-area-inset-top)) auto max(8px, env(safe-area-inset-bottom));
    padding: clamp(14px, 3vh, 24px) 20px;
    overflow: hidden;
  }

  body.participant-app .hero {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  body.participant-app .hero .illustration {
    width: 100%;
    max-height: min(31vh, 245px);
    object-fit: cover;
  }

  body.participant-app .hero h1 {
    font-size: clamp(2rem, 9vw, 3.25rem);
    margin: .35rem 0;
  }

  body.participant-app .hero .intro {
    margin: .35rem 0;
    font-size: 1rem;
  }

  body.participant-app .login {
    width: 100%;
    margin-top: .7rem;
  }

  body.participant-app .login label {
    margin-bottom: .25rem;
  }

  body.participant-app .login .field {
    padding: 10px 12px;
  }

  body.participant-app .login .button {
    min-height: 44px;
    margin-top: .65rem;
    padding: 8px 16px;
  }

  body.participant-app .waiting,
  body.participant-app .finished,
  body.participant-app .loading {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  body.participant-app .waiting h1,
  body.participant-app .finished h1 {
    margin: .4rem 0;
    font-size: clamp(1.75rem, 8vw, 3rem);
  }

  body.participant-app .waiting .roster {
    width: 100%;
    margin: clamp(8px, 2vh, 18px) auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 8px;
  }

  body.participant-app .waiting .person {
    min-width: 0;
    padding: 5px 4px;
    font-size: clamp(.72rem, 3vw, .9rem);
  }

  .surprise-card { width: calc(100% - 16px); padding: clamp(15px,4vw,24px); }
  .placement-screen h1, .controller-screen h1 { font-size: clamp(1.55rem,7vw,2.5rem); }
}

@media (max-height: 700px) and (max-width: 600px) {
  body.participant-app .hero .illustration { max-height: 24vh; }
  body.participant-app .hero .eyebrow { margin: .3rem 0; }
  body.participant-app .hero h1 { font-size: clamp(1.75rem, 8vw, 2.55rem); }
  body.participant-app .login { margin-top: .35rem; }
}
