[hidden] {
  display: none !important;
}

.num-font {
  font-family: ui-rounded, "Arial Rounded MT Bold", system-ui, sans-serif;
  font-weight: 800;
}

.stage {
  --cards-h: calc(clamp(96px, 36vw, 150px) + env(safe-area-inset-bottom));
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: calc(56px + env(safe-area-inset-top)) minmax(0, 1fr) var(--cards-h);
  overflow: hidden;
  background: #2a1810;
  color: #fff1d6;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

@media (max-height: 699.98px) {
  .stage {
    grid-template-rows: calc(56px + env(safe-area-inset-top)) minmax(0, 1fr) 0px;
    transition: grid-template-rows 250ms ease-out;
  }

  .stage.cards-open {
    grid-template-rows: calc(56px + env(safe-area-inset-top)) minmax(0, 1fr) var(--cards-h);
  }
}

.stage-top {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  pointer-events: none;
}

.ctl-gap {
  flex: 1;
}

.scene {
  position: relative;
  min-height: 0;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.3;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .25 0 0 0 0 .15 0 0 0 0 .08 0 0 0 1.1 -.3'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 72% at 50% 46%, transparent 55%, var(--vignette, transparent) 100%);
}

.scene svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.ctl {
  position: relative;
  box-sizing: border-box;
  flex: none;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 2px solid #3a2314;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #b57b46, #6b4226 72%);
  box-shadow: 0 2px 0 #2a170c, 0 4px 8px rgba(0, 0, 0, 0.35);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.ctl::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
}

.ctl svg {
  width: 26px;
  height: 26px;
}

.ctl:focus-visible,
.card:focus-visible,
.retry:focus-visible,
.start-button:focus-visible,
.unlock:focus-visible {
  outline: 3px solid #fff1d6;
  outline-offset: 3px;
}

.ctl:active {
  transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
  .ctl:hover {
    filter: brightness(1.12);
  }
}

.ctl:focus-visible {
  filter: brightness(1.12);
}

.ctl-floating {
  position: absolute;
  left: max(10px, env(safe-area-inset-left));
  top: calc(6px + env(safe-area-inset-top));
}

.ctl-speaker.glow {
  animation: glow 1.6s ease-in-out 1;
}

.ctl.pulse {
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes glow {
  0%, 100% { box-shadow: 0 2px 0 #2a170c, 0 0 0 0 rgba(255, 233, 168, 0); }
  50% { box-shadow: 0 2px 0 #2a170c, 0 0 0 8px rgba(255, 233, 168, 0.85); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 2px 0 #2a170c, 0 0 0 0 rgba(255, 233, 168, 0); }
  50% { transform: scale(1.08); box-shadow: 0 2px 0 #2a170c, 0 0 0 6px rgba(255, 233, 168, 0.7); }
}

.cards-row {
  position: relative;
  z-index: 3;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 10px;
  padding: 6px max(10px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  pointer-events: none;
}

.card {
  flex: 0 1 auto;
  min-width: 0;
  height: 100%;
  aspect-ratio: 100 / 112;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}

.card svg {
  display: block;
  width: 100%;
  height: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    transform: translateY(-2px);
  }
}

.card:focus-visible {
  transform: translateY(-2px);
}

.card.wrong {
  opacity: 0.55;
  animation: shake 360ms ease-in-out 1;
}

.card.right {
  transform: scale(1.07);
  filter: drop-shadow(0 0 10px var(--world)) drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
}

@keyframes shake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.tap {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.tap:focus-visible {
  outline: 3px solid #fff1d6;
  outline-offset: 2px;
}

.unlock {
  position: absolute;
  inset: 0;
  z-index: 6;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  background: rgba(20, 10, 5, 0.55);
  color: #fff1d6;
  font: inherit;
  font-size: 1.125rem;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.unlock-disc {
  display: grid;
  place-items: center;
  width: min(46vw, 200px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 4px solid #3a2314;
  background: radial-gradient(circle at 35% 28%, #b57b46, #6b4226 72%);
  box-shadow: 0 0 0 6px rgba(255, 233, 168, 0.35), 0 8px 18px rgba(0, 0, 0, 0.5);
}

.unlock-disc svg {
  width: 52%;
  height: 52%;
}

.turn-hint {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgb(20, 10, 5);
}

.turn-phone {
  display: block;
  width: min(36vh, 150px);
  height: min(36vh, 150px);
  animation: turn-phone 3.2s ease-in-out infinite;
}

@keyframes turn-phone {
  0%, 15% { transform: rotate(-90deg); }
  55%, 100% { transform: rotate(0deg); }
}

@media (orientation: landscape) and (max-height: 499.98px) {
  .stage-top {
    z-index: 9;
  }

  .stage-top .ctl:not(.ctl-home) {
    visibility: hidden;
  }
}

.fx-layer {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  overflow: hidden;
}

.pointer-hand,
.pointer-ring {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
}

.pointer-hand svg {
  display: block;
  filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.45));
}

.pointer-ring {
  box-sizing: border-box;
  width: 48px;
  height: 48px;
  border: 4px solid #fff1d6;
  border-radius: 50%;
}

.burst-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}

.burst-ring,
.burst-flash {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}

.burst-ring {
  box-sizing: border-box;
  width: 64px;
  height: 64px;
  border: 4px solid #fff;
}

.burst-flash {
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.85), rgba(255, 244, 220, 0) 70%);
}

.fx {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  overflow: hidden;
}

.fx-start {
  background: rgba(20, 10, 5, 0.7);
}

.fx-backdrop {
  position: absolute;
  inset: 0;
}

.fx-door {
  position: absolute;
  will-change: transform;
}

.fx-door > * {
  position: absolute;
}

.fx-frame {
  inset: 0;
  background-size: 300% 300%;
  background-repeat: no-repeat;
}

.fx-doorway {
  overflow: hidden;
}

.fx-bright {
  inset: 0;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255, 255, 255, 0.95), rgba(255, 244, 220, 0) 72%);
}

.fx-leaf {
  transform-origin: 0 50%;
  transform-style: preserve-3d;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background-repeat: no-repeat;
}

.fx-back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
  opacity: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  background: linear-gradient(90deg, #2d1a0e, #4a2d1a 55%, #3a2314);
}

.fx-knob {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c4, #d9a441 45%, #8a5a12 100%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  opacity: 0;
}

.fx-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pt {
  position: absolute;
  left: 0;
  top: 0;
  background: var(--tint);
  pointer-events: none;
  will-change: transform, opacity;
}

.pt-star { clip-path: polygon(50% 0, 61% 35%, 98% 38%, 68% 59%, 79% 95%, 50% 73%, 21% 95%, 32% 59%, 2% 38%, 39% 35%); }
.pt-drop { border-radius: 50% 0 50% 50%; }
.pt-leaf { border-radius: 0 100% 0 100%; }
.pt-spark { border-radius: 50%; box-shadow: 0 0 6px 2px var(--tint); }
.pt-confetti { border-radius: 2px; }
.pt-dot { border-radius: 22%; background: radial-gradient(circle at 50% 50%, #fff 0 24%, var(--tint) 26%); }
.pt-petal { border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%; }
.pt-bubble { box-sizing: border-box; border-radius: 50%; border: 2px solid var(--tint); background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.1) 40%, transparent 60%); }
.pt-lantern { border-radius: 50%; background: radial-gradient(circle, #fff6d8, var(--tint) 60%, transparent 72%); box-shadow: 0 0 8px 3px var(--tint); }

.retry {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border: 3px solid #3a2314;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 28%, #b57b46, #6b4226 72%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  pointer-events: auto;
}

.retry svg {
  width: 36px;
  height: 36px;
}

.start-button {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-sizing: border-box;
  width: min(60vw, 60vh, 260px);
  aspect-ratio: 1;
  margin: 0;
  padding: 0;
  border: 5px solid #8a5a33;
  border-radius: 22%;
  background: #3b2417;
  box-shadow: 0 0 0 6px rgba(255, 233, 168, 0.25), 0 0 40px var(--world);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  pointer-events: auto;
  animation: start-pulse 1.6s ease-in-out infinite;
}

.start-button svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes start-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}

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

  .turn-phone {
    animation: none;
  }

  .ctl-speaker.glow {
    animation: none;
    box-shadow: 0 2px 0 #2a170c, 0 0 0 6px rgba(255, 233, 168, 0.85);
  }

  .ctl.pulse {
    animation: none;
    box-shadow: 0 2px 0 #2a170c, 0 0 0 5px rgba(255, 233, 168, 0.7);
  }

  .card.wrong {
    animation: none;
  }

  .start-button {
    animation: none;
  }
}
