html, body, #game {
  width: 100%;
  height: 100%;
  height: 100dvh;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

#game {
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

#game canvas {
  display: block !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  touch-action: none;
  image-rendering: pixelated;
}

#mobile-launcher {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(150deg, #050b18f5, #102853f5);
  text-align: center;
}

#mobile-launcher.hidden { display: none; }

.victory-stage {
  position: relative;
  width: min(430px, 88vw);
  height: min(250px, 38vh);
  margin: 6px auto 2px;
  overflow: hidden;
}

.victory-directors {
  position: absolute;
  z-index: 3;
  left: 52%;
  bottom: 6px;
  width: auto;
  height: 100%;
  max-width: 42%;
  object-fit: contain;
  transform: translateX(-50%);
  animation: victory-cheer 2.4s ease-in-out infinite;
}

.victory-professor {
  position: absolute;
  z-index: 3;
  left: 6%;
  bottom: 12px;
  width: min(102px, 23vw);
  animation: professor-arrives 1.1s ease-out both, professor-bob 1.6s 1.1s ease-in-out infinite;
}

.victory-aileen {
  position: absolute;
  z-index: 4;
  right: 1%;
  bottom: 0;
  width: min(155px, 36vw);
  opacity: .96;
  animation: aileen-short 1.3s ease-in-out infinite;
}

.spark {
  position: absolute;
  z-index: 4;
  color: #ff49c5;
  font: 700 26px/1 monospace;
  text-shadow: 0 0 12px #ff49c5, 0 0 18px #58eaff;
  animation: spark-pop .72s steps(2, end) infinite;
}
.spark-one { right: 23%; bottom: 30%; }
.spark-two { right: 10%; bottom: 49%; animation-delay: .27s; }
.spark-three { right: 34%; bottom: 14%; animation-delay: .48s; }

@keyframes victory-cheer { 0%,100% { transform: translateX(-20%) translateY(0); } 50% { transform: translateX(-20%) translateY(-7px); } }
@keyframes professor-arrives { from { transform: translateX(-110px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes professor-bob { 0%,100% { translate: 0 0; } 50% { translate: 0 -7px; } }
@keyframes aileen-short { 0%,100% { filter: brightness(.82); } 50% { filter: brightness(1.35) drop-shadow(0 0 8px #ff49c5); } }
@keyframes spark-pop { 0%,100% { opacity: 0; transform: scale(.4) rotate(0deg); } 50% { opacity: 1; transform: scale(1.25) rotate(20deg); } }

/* Lage landscape-schermen: de complete overwinningsscène blijft zichtbaar. */
@media (pointer: coarse) and (orientation: landscape) {
  .victory-stage { height: 174px; margin: 2px auto 0; }
  .victory-directors { width: auto; height: 100%; max-width: 38vw; object-fit: contain; bottom: 1px; }
  .victory-professor { width: 75px; bottom: 5px; }
  .victory-aileen { width: 132px; right: 1px; }
  .victory-card h2 { margin: 2px 0; font-size: clamp(22px, 4vw, 32px); }
  .victory-card p { margin: 3px 0 6px; font-size: 13px; line-height: 1.25; }
  .victory-card .continue { min-height: 42px; }
}

/* Laat een touchgame pas zien na de fullscreen-start. Dit dekt ook directe
   ontwikkelaar-links en voorkomt een half zichtbare 960px-canvas in portret. */
@media (pointer: coarse) and (orientation: portrait) {
  #game { visibility: hidden; }
  #mobile-launcher:not(.hidden) { visibility: visible; }
}

.mobile-launcher-card {
  width: min(430px, 100%);
  padding: 28px 22px;
  border: 3px solid #38e8ff;
  border-radius: 20px;
  background: #09142df5;
  box-shadow: 0 20px 80px #000c, 0 0 38px #38e8ff38;
}

.mobile-launcher-card .phone-icon {
  color: #58f2bd;
  font: 700 48px/1 monospace;
  transform: rotate(-35deg);
}

.mobile-launcher-card strong {
  display: block;
  margin: 12px 0 8px;
  font: 700 24px/1.2 monospace;
}

.mobile-launcher-card span {
  display: block;
  max-width: 330px;
  margin: 0 auto 22px;
  color: #d8eaff;
  font: 16px/1.4 system-ui;
}

#fullscreen-button {
  width: 100%;
  min-height: 56px;
  border: 2px solid #ff79ac;
  border-radius: 12px;
  color: #fff;
  background: #e63f83;
  box-shadow: 0 8px 28px #0007;
  font: 700 19px monospace;
}

#fullscreen-toggle {
  position: fixed;
  z-index: 11000;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  width: 46px;
  height: 46px;
  border: 2px solid #ffffff99;
  border-radius: 11px;
  color: #fff;
  background: #09142dcc;
  font: 700 25px/1 monospace;
  cursor: pointer;
}

@media (pointer: fine) {
  #fullscreen-toggle { display: none; }
}

@media (orientation: portrait) and (pointer: coarse) {
  .mobile-launcher-card .phone-icon {
    animation: turn-phone 1.8s ease-in-out infinite alternate;
  }
}

@keyframes turn-phone {
  from { transform: rotate(0deg); }
  to { transform: rotate(-90deg); }
}

/* Mobile game controls: prevent browser gestures stealing touches. */
#game, #game canvas {
  touch-action: none !important;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) and (orientation: landscape) {
  #game canvas { width: 100vw !important; height: 100dvh !important; object-fit: fill !important; }
  #fullscreen-toggle { opacity: .72; width: 40px; height: 40px; }
}

/* v4: use every available pixel on mobile. Phaser EXPAND keeps the game ratio
   while enlarging the game viewport, so wider phones reveal more of the school. */
@media (pointer: coarse) and (orientation: landscape) {
  html, body, #game { width: 100vw !important; height: 100dvh !important; }
  #game { position: fixed !important; inset: 0 !important; display: block !important; }
  #game canvas { position: absolute !important; inset: 0 !important; width: 100vw !important; height: 100dvh !important; max-width: none !important; max-height: none !important; object-fit: fill !important; }
}
