* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #fdf8ec;
  font-family: 'Gaegu', 'Comic Sans MS', cursive;
  color: #2b2b40;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* Overlay: story box on top, buttons at the bottom, title cards in the middle */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
}

.story {
  max-width: min(680px, 94vw);
  background: rgba(255, 253, 246, 0.94);
  border: 3px solid #3a3a5a;
  border-radius: 18px 12px 20px 14px;
  padding: 8px 18px;
  font-size: clamp(18px, 2.7vw, 25px);
  line-height: 1.2;
  box-shadow: 4px 5px 0 rgba(58, 58, 90, 0.18);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.35s, transform 0.35s;
}
.story.show { opacity: 1; transform: none; }
.story p { margin: 0.25em 0; }
.story p.line { animation: pop-in 0.35s ease-out both; }
.story b { color: #d6336c; }
.story strong { color: #3561c4; }

.center {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  padding: 0 16px;
}

.titlecard h1 {
  margin: 0;
  font-size: clamp(40px, 8.5vw, 96px);
  line-height: 0.95;
  font-weight: 700;
  color: #3561c4;
  text-shadow: 3px 3px 0 #ffd84d, 6px 6px 0 rgba(58, 58, 90, 0.2);
  transform: rotate(-2deg);
  animation: pop-in 0.6s ease-out both;
}
.titlecard p {
  margin: 0.3em 0 0;
  font-size: clamp(22px, 4vw, 38px);
  font-weight: 700;
  color: #d6336c;
  animation: pop-in 0.6s 0.25s ease-out both;
}
.titlecard { margin-top: -18vh; }

.big {
  font-size: clamp(54px, 13vw, 140px);
  font-weight: 700;
  color: #2b2b40;
  text-shadow: 4px 4px 0 #ffd84d;
  animation: pop-in 0.45s ease-out both;
}
.big.small { font-size: clamp(34px, 7vw, 72px); }

.buttons {
  pointer-events: auto;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  font-family: inherit;
  font-size: clamp(21px, 3.2vw, 30px);
  font-weight: 700;
  padding: 8px 26px 10px;
  border: 3px solid #3a3a5a;
  border-radius: 14px 18px 12px 20px;
  background: #ffd84d;
  color: #2b2b40;
  box-shadow: 3px 4px 0 #3a3a5a;
  cursor: pointer;
  touch-action: manipulation;
  animation: pop-in 0.35s ease-out both;
}
.btn:hover { filter: brightness(1.05); }
.btn:active, .btn.held { transform: translate(2px, 3px); box-shadow: 1px 1px 0 #3a3a5a; }
.btn:focus-visible { outline: 3px dashed #3561c4; outline-offset: 4px; }
.btn.pink { background: #ff8fb3; }
.btn.blue { background: #8ec5ff; }
.btn.green { background: #8fe08a; }
.btn.red { background: #ff6b6b; color: #fff; }
.btn.big-btn { font-size: clamp(26px, 4vw, 38px); padding: 10px 34px 12px; }
.btn.runaway { position: fixed; z-index: 5; transition: left 0.22s ease-out, top 0.22s ease-out; animation: none; }

.toast {
  position: fixed;
  left: 50%;
  top: 34%;
  transform: translate(-50%, -50%) scale(0.8);
  background: #fffdf6;
  border: 3px solid #3a3a5a;
  border-radius: 16px 12px 18px 10px;
  padding: 6px 18px;
  font-size: clamp(20px, 3.2vw, 30px);
  font-weight: 700;
  box-shadow: 3px 4px 0 rgba(58, 58, 90, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.mute {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 10px;
  z-index: 10;
  width: 46px;
  height: 46px;
  border: 3px solid #3a3a5a;
  border-radius: 50%;
  background: #fffdf6;
  box-shadow: 2px 3px 0 #3a3a5a;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}
.mute:active { transform: translate(1px, 2px); box-shadow: 1px 1px 0 #3a3a5a; }
.mute:focus-visible { outline: 3px dashed #3561c4; outline-offset: 3px; }

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.85) translateY(6px); }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
