* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #0d0d14; }
body {
  height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #fff;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }

#ad-top { flex: 0 0 60px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #16161f; }
#ad-top span { width: 320px; height: 50px; border: 1px dashed #555; color: #777; display: grid; place-items: center; font-size: 12px; }

#wrap { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
/* game.js sets width, height (2:3) and font-size so everything scales together */
#game { position: relative; overflow: hidden; background: #333; touch-action: none; }
.fill { position: absolute; inset: 0; }
#scene { position: absolute; inset: 0; }
#background img { width: 100%; height: 100%; object-fit: cover; }
.actor { position: absolute; transform: translate(-50%, -100%); transition: left .45s ease-in, top .45s ease-in, width .45s ease-in; }
.actor img, .actor svg { display: block; width: 100%; height: auto; pointer-events: none; }
.actor > .frame { display: none; }
.actor > .frame.on { display: block; }
#doll { z-index: 1; }
#student { z-index: 2; }
#doll.attacking { z-index: 3; }

#smoke { z-index: 4; overflow: hidden; pointer-events: none; opacity: 0; }
#smoke.on { opacity: 1; }
#smoke.clearing { opacity: 0; transition: opacity .6s; }
#smoke .puff {
  position: absolute; width: 75%; aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(210,210,216,.95) 0%, rgba(175,175,184,.8) 38%, rgba(140,140,150,0) 70%);
  transform: translate(-50%, -50%) scale(0);
}
#smoke.on .puff { animation: puff 1.5s ease-out forwards; }
@keyframes puff { to { transform: translate(-50%, -50%) scale(1.35); } }
#smoke::after { content: ''; position: absolute; inset: 0; background: #a9a9b2; opacity: 0; }
#smoke.on::after { animation: haze 1.6s .5s forwards; }
@keyframes haze { to { opacity: .85; } }
#smoke img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#smoke.custom::after, #smoke.custom .puff { display: none; }
#smoke.custom.on img { animation: appear 1s ease-out; }
@keyframes appear { from { opacity: 0; transform: scale(.4); } }

#hud {
  position: absolute; z-index: 5; top: 2.5%; left: 3%; right: 3%;
  display: flex; align-items: center; justify-content: space-between;
  padding: .45em .9em; border-radius: 1em; background: rgba(0,0,0,.65);
}
.stat { display: flex; flex-direction: column; align-items: center; min-width: 4em; }
.stat small { font-size: .65em; opacity: .7; letter-spacing: .08em; }
.stat b { font-size: 1.35em; font-variant-numeric: tabular-nums; }
#hearts { font-size: 1.45em; letter-spacing: .05em; }
#hearts i { font-style: normal; color: #ff3b5c; }
#hearts i.lost { color: #555; }

#mute { position: absolute; z-index: 5; top: 13%; right: 3%; width: 2.4em; height: 2.4em; border: 0; border-radius: 50%; background: rgba(0,0,0,.5); font-size: 1em; }
#tap {
  position: absolute; z-index: 5; bottom: 3%; left: 8%; right: 8%; height: 11%;
  border: 0; border-radius: 1.2em; background: #ff2e74; color: #fff;
  font-family: inherit; font-weight: 800; font-size: 1.25em;
  box-shadow: 0 .3em 0 #9e1246; cursor: pointer; touch-action: none;
}
#tap.active { background: #2563eb; box-shadow: 0 .1em 0 #14378a; transform: translateY(.2em); }

.overlay { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1em; padding: 8%; text-align: center; background: rgba(8,8,16,.88); }
.overlay h1 { font-size: 2em; }
.overlay p { font-size: 1.1em; line-height: 1.45; white-space: pre-line; }
.overlay button { border: 0; border-radius: 2em; padding: .8em 1.8em; background: #ff2e74; color: #fff; font-family: inherit; font-weight: 700; font-size: 1.1em; cursor: pointer; }
.overlay button:disabled { background: #555; cursor: default; }
.overlay button.link { background: none; text-decoration: underline; font-size: .9em; }
#demo-ad { z-index: 20; background: #000; }
