/* SamSam World! base styles: the page, the game stage and the classes games use (.abs, .quiz, .choice, .btn, .round, Sam, stickers, parties).
   The shell's screens are in components.css + screens.css; colours in tokens.css. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font); font-weight: 600;
  background: var(--ground);
  color: var(--ink); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; background: none; padding: 0; }
/* in a game: the land's soft colour behind the stage (body[data-land] sets --tint) */
body.playing { background: linear-gradient(160deg, var(--tint), var(--ground) 55%, #EAF8EE); }
/* the stage keeps clear of the notch and the home bar (--safe-*, see tokens.css) */
#stage { position: absolute; top: calc(var(--bar-h) + var(--safe-t)); left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); overflow: hidden; touch-action: none; display: none; }
.playing #stage { display: block; }
/* A game paints the stage (stage.style.background). #backdrop is the stage's box once more; its five tiles repeat that paint, mirrored,
   in the strips beside the notch and under the home bar, so a game's colours run to the edges of the screen (js/core/games.js hands
   the paint over as --paint). On a device with no notch and no home bar the tiles lie outside the screen. */
#backdrop { position: absolute; top: calc(var(--bar-h) + var(--safe-t)); left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); display: none; pointer-events: none; }
.playing #backdrop { display: block; animation: fadeIn .3s ease-out; }
#backdrop i { position: absolute; width: 100%; height: 100%; background: var(--paint, none); }
#backdrop i:nth-child(1) { right: 100%; top: 0; transform: scaleX(-1); }
#backdrop i:nth-child(2) { left: 100%; top: 0; transform: scaleX(-1); }
#backdrop i:nth-child(3) { left: 0; top: 100%; transform: scaleY(-1); }
#backdrop i:nth-child(4) { right: 100%; top: 100%; transform: scale(-1, -1); }
#backdrop i:nth-child(5) { left: 100%; top: 100%; transform: scale(-1, -1); }
/* a game that needs a taller screen waits and shows this: a phone turning upright (js/core/games.js, TALL) */
.turn-hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4%; }
.turn-hint svg { height: min(64%, 190px); width: auto; overflow: visible; }
.turn-phone { transform-box: fill-box; transform-origin: 50% 50%; animation: turnPhone 2.6s ease-in-out infinite; }
@keyframes turnPhone { 0%, 18% { transform: rotate(0); } 52%, 84% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

.fx { position: absolute; pointer-events: none; font-size: 40px; animation: burst 1.2s ease-out forwards; z-index: 50; }
/* a piece of coloured paper (confetti) in the cheer burst and the star party */
.fx.paper, .confetti.paper { width: 13px; height: 21px; border-radius: 3px; background: var(--c); font-size: 0; }
.fx.paper.dot, .confetti.paper.dot { width: 14px; height: 14px; border-radius: 50%; }
@keyframes burst {
  from { transform: translate(-50%, -50%) scale(.4); opacity: 1; }
  to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3) rotate(var(--r)); opacity: 0; }
}
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-14px) rotate(-4deg); } 40%, 80% { transform: translateX(14px) rotate(4deg); } }
.bounce { animation: bounce .6s; }
@keyframes bounce { 30% { transform: scale(1.25) translateY(-12px); } 60% { transform: scale(.92); } }
.popin { animation: popin .35s ease-out both; }
@keyframes drop { from { transform: translateY(-120vh); } }
@keyframes popin { from { transform: scale(0); } 70% { transform: scale(1.15); } }
.wiggle { animation: wiggle .5s; }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.1); } 75% { transform: rotate(12deg) scale(1.1); } }

.quiz { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; padding: 10px; }
.show { font-size: clamp(40px, 11vmin, 100px); text-align: center; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; max-width: 96vw; }
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: clamp(10px, 3vmin, 24px); }
.choice {
  min-width: clamp(90px, 22vmin, 170px); min-height: clamp(90px, 22vmin, 170px); padding: 10px; border-radius: 30px;
  background: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.15); font-size: clamp(44px, 11vmin, 90px); font-weight: bold;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px;
}
.choice.right { background: #c9ffcf; animation: bounce .6s; }
/* quiz(): --s is the side of an answer button; js/core/quiz.js sets it so the round fills the screen (pictures are half of it) */
.quiz.fit .show { font-size: calc(var(--s) * .5); }
.quiz.fit .choices { gap: calc(var(--s) * .12); }
.quiz.fit .choice { min-width: var(--s); min-height: var(--s); font-size: calc(var(--s) * .5); border-radius: calc(var(--s) * .18); }
/* a round whose answers stand beside the picture: a phone held on its side (quiz() with beside: true) */
.quiz.beside { flex-direction: row; }
.blob { width: 1em; height: 1em; border-radius: 50%; box-shadow: inset -.08em -.1em 0 rgba(0,0,0,.18), inset .1em .1em 0 rgba(255,255,255,.45); }
.btn { padding: 14px 22px; border-radius: 24px; background: #fff; box-shadow: 0 5px 0 rgba(0,0,0,.15); font-size: 28px; font-weight: bold; }
.btn:active, .choice:active { transform: translateY(3px); }
.round { width: 60px; height: 60px; border-radius: 50%; background: #fff; font-size: 30px; box-shadow: 0 4px 0 rgba(0,0,0,.12); position: relative; flex: none; }
.abs { position: absolute; }
.mid { transform: translate(-50%, -50%); }
.big-word { font-weight: bold; -webkit-text-stroke: 2px rgba(0,0,0,.25); }
.dragging { z-index: 40; filter: drop-shadow(0 10px 8px rgba(0,0,0,.3)); }

/* ---------- app feel ---------- */
/* no double-tap zoom; the page itself never bounces or slides (only screens and windows scroll); text keeps its size when an iPhone is turned */
html { touch-action: manipulation; overscroll-behavior: none; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@keyframes screenIn { from { opacity: 0; transform: translateY(26px) scale(.98); } }
@keyframes fadeOut { to { opacity: 0; transform: scale(1.04); } }
.playing #stage { animation: screenIn .32s cubic-bezier(.2,.9,.3,1.2); }
@keyframes spin { to { transform: rotate(1turn); } }

/* ---------- Sam ---------- */
.sam { flex: none; cursor: pointer; }
.sam svg { overflow: visible; }
.sam-all, .sam-arm-l, .sam-arm-r, .sam-eyes, .sam-ear-l, .sam-ear-r { transform-box: fill-box; }
.sam-all { transform-origin: 50% 100%; animation: samBob 2.6s ease-in-out infinite; }
.sam-eyes { transform-origin: center; animation: samBlink 4s infinite; }
.sam-arm-l { transform-origin: 80% 20%; } .sam-arm-r { transform-origin: 20% 20%; }
.sam-ear-l { transform-origin: 50% 100%; animation: samEar 3s ease-in-out infinite; }
.sam-ear-r { transform-origin: 50% 100%; animation: samEar 3s ease-in-out infinite reverse; }
@keyframes samBob { 50% { transform: translateY(-3px) scale(1.02, .98); } }
@keyframes samBlink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes samEar { 50% { transform: rotate(-8deg); } }
.sam.wave .sam-arm-r { animation: samWave .5s ease-in-out infinite alternate; }
@keyframes samWave { from { transform: rotate(-20deg) translate(4px, -10px); } to { transform: rotate(-70deg) translate(10px, -16px); } }
.sam.jump .sam-all, .sam.cheer .sam-all { animation: samJump .6s ease-out 2; }
.sam.cheer .sam-arm-l { animation: samArmL .3s ease-in-out infinite alternate; }
.sam.cheer .sam-arm-r { animation: samArmR .3s ease-in-out infinite alternate; }
@keyframes samJump { 0% { transform: scale(1.1, .85); } 40% { transform: translateY(-26%) scale(.95, 1.08); } 75% { transform: translateY(0) scale(1.08, .9); } 100% { transform: none; } }
@keyframes samArmL { from { transform: rotate(10deg); } to { transform: rotate(70deg) translate(-4px, -14px); } }
@keyframes samArmR { from { transform: rotate(-10deg); } to { transform: rotate(-70deg) translate(4px, -14px); } }
.sam.dance .sam-all { animation: samDance .5s ease-in-out infinite alternate; }
.sam.dance .sam-arm-l { animation: samArmL .25s ease-in-out infinite alternate; }
.sam.dance .sam-arm-r { animation: samArmR .25s ease-in-out infinite alternate-reverse; }
@keyframes samDance { from { transform: rotate(-10deg) translateY(0); } to { transform: rotate(10deg) translateY(-12%); } }
.cheer-pop { position: fixed; left: max(8px, var(--safe-l)); bottom: 0; z-index: 250; pointer-events: none; animation: cheerIn 1.5s ease-in-out forwards; }
@keyframes cheerIn { 0% { transform: translateY(110%); } 20%, 80% { transform: translateY(6%); } 100% { transform: translateY(110%); } }
.cheer-pop.right { left: auto; right: max(8px, var(--safe-r)); }

/* ---------- stickers ---------- */
.sticker { font-size: 64px; line-height: 1;
  filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 5px 5px rgba(0,0,0,.25)); }
/* a new sticker: the card glides in slowly from the right, rests at the side (the game stays in view), then slides up */
.sticker.big { font-size: clamp(64px, 13vmin, 104px); animation: stickSway 2.6s ease-in-out infinite; }
@keyframes stickSway { 0%, 100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
.pop-wrap { position: fixed; inset: 0; z-index: 260; display: flex; align-items: center; justify-content: flex-end; pointer-events: none; overflow: hidden;
  padding: calc(var(--bar-h) + var(--safe-t) + 10px) max(12px, var(--safe-r)) max(10px, var(--safe-b)) 12px; }
.pop-card { background: rgba(255,255,255,.96); border-radius: 28px; padding: 12px 18px 14px; text-align: center; box-shadow: var(--sh-pop); max-width: 44vw;
  animation: stickerIn 1.1s cubic-bezier(.22,.8,.3,1) both; transition: transform 1.1s ease-in-out, opacity 1.1s ease-in; }
@keyframes stickerIn { from { transform: translateX(calc(100% + 60px)) rotate(6deg); } }
.pop-card.away { transform: translateY(-55vh) scale(.25); opacity: 0; }
.pop-title { font-size: clamp(16px, 3vmin, 22px); font-weight: bold; color: var(--ink); margin-bottom: 6px; }
.pop-name { font-size: clamp(16px, 3vmin, 22px); font-weight: bold; color: var(--ink); margin-top: 8px; }
.party { position: fixed; inset: 0; z-index: 270; pointer-events: none; overflow: hidden; }
.party.out { animation: fadeOut .5s forwards; }
.confetti { position: absolute; top: -60px; font-size: 34px; animation: fall linear both; }
@keyframes fall { to { transform: translateY(calc(100vh + 120px)) rotate(var(--r)); } }
.party-mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.party-text { font-size: clamp(34px, 8vw, 64px); font-weight: bold; color: #E8600C; text-shadow: 3px 3px 0 #fff, -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff;
  animation: popin .5s ease-out both, pulse 1s .5s infinite; }

@keyframes pulse { 50% { transform: scale(1.08); } }

@keyframes fadeIn { from { opacity: 0; } }
