* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; user-select: none; }
:root { --gold: #ffd766; --gold2: #f5a623; --gold3: #b8740a; --red: #d81f26; --red2: #9c1015; --red3: #5c070a; --beige: #f0dcb4; }

/* fundo (aparece nas laterais no computador): pátio de templo desfocado */
body { background: #7a1a1c; }
body::before { content: ""; position: fixed; inset: -40px; filter: blur(14px); z-index: -1;
  background:
    repeating-linear-gradient(90deg, transparent 0 70px, #a5232680 70px 84px) 0 46% / 100% 22% no-repeat,
    linear-gradient(#6db8f2 0%, #bfe3fb 30%, #2d8a4e 30%, #2d8a4e 34%, #d5403f 34%, #b52a2c 66%, #8d8fa8 66%, #b9bdd2 100%); }

#stage { position: relative; margin: 0 auto; height: 100dvh; width: min(100vw, 480px); display: flex; flex-direction: column; overflow: hidden;
  background: linear-gradient(#c4161c, var(--red2) 55%, #7d0b10); box-shadow: 0 0 60px #000a; }

/* ---------- topo: céu, portal, telhado em arco, janela com a foto ---------- */
#top { position: relative; flex: 0 0 auto; height: clamp(175px, 30dvh, 250px); overflow: hidden;
  background: linear-gradient(#5fb2f0, #c9e9ff 46%, #c4161c 46%); transition: filter .6s; }
#top.bright { filter: brightness(1.18) saturate(1.15); }
#top::before { content: ""; position: absolute; left: 0; right: 0; top: 44%; bottom: 0; /* muro do portal */
  background:
    repeating-linear-gradient(90deg, transparent 0 22px, #ffd76633 22px 24px),
    repeating-linear-gradient(0deg, transparent 0 22px, #ffd76633 22px 24px),
    linear-gradient(#d3262b, #a81218); }
#top::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 9px; z-index: 5;
  background: linear-gradient(var(--gold), var(--gold2) 55%, var(--gold3)); box-shadow: 0 -2px 4px #0005; }
.post { position: absolute; bottom: 0; top: 50%; width: 16px; z-index: 2; background: linear-gradient(90deg, #8f0d12, #e6353b 50%, #8f0d12); border: 2px solid var(--gold); border-bottom: 0; border-radius: 4px 4px 0 0; }
.post.l { left: 10px; } .post.r { right: 10px; }

#rays { position: absolute; left: 50%; top: 62%; width: 150%; aspect-ratio: 1; transform: translate(-50%,-50%); z-index: 1; opacity: 0; transition: opacity .6s;
  background: repeating-conic-gradient(#fff6c8aa 0 9deg, transparent 9deg 18deg); border-radius: 50%; animation: rot 14s linear infinite;
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 62%); mask: radial-gradient(circle, #000 20%, transparent 62%); }
#top.bright #rays { opacity: 1; }

#hero { position: absolute; left: 50%; bottom: 7px; width: 62%; height: 70%; transform: translateX(-50%); transform-origin: 50% 100%; z-index: 3;
  border-radius: 50% 50% 10px 10px / 78% 78% 10px 10px; padding: 5px; animation: idle 3s ease-in-out infinite;
  background: linear-gradient(160deg, #fff1b8, var(--gold2) 45%, var(--gold3) 70%, var(--gold)); box-shadow: 0 0 0 2px #7a2c00, 0 6px 14px #0008; }
#hero.party { animation: party .5s ease-in-out infinite; }
#hero .win { width: 100%; height: 100%; border-radius: inherit; overflow: hidden; background: linear-gradient(#7cc4f5, #dff2ff); display: grid; place-items: center; font-size: 74px; }
#hero .win { background: repeating-conic-gradient(from 0deg at 50% 100%, #ffffff55 0 8deg, transparent 8deg 16deg), linear-gradient(#6dbdf5, #e6f6ff); }
#heroImg { position: absolute; left: 50%; bottom: 4px; height: 100%; max-width: 128%; transform: translateX(-50%); transform-origin: 50% 100%; object-fit: contain; object-position: 50% 100%;
  filter: drop-shadow(0 4px 6px #0007); pointer-events: none; display: none; }
#hero.has-img #heroImg { display: block; }
#hero.has-img .win { font-size: 0; }
#hero.throw #heroImg { animation: throw .7s cubic-bezier(.3,1.6,.5,1); }
@keyframes throw { 0% { transform: translateX(-50%) scale(1); } 35% { transform: translateX(-50%) scale(.86, 1.1) rotate(-4deg); } 60% { transform: translateX(-50%) scale(1.22) rotate(5deg); } 100% { transform: translateX(-50%) scale(1); } }
@keyframes idle { 0%,100% { transform: translateX(-50%) scale(1); } 50% { transform: translateX(-50%) scale(1.025); } }
@keyframes party { 0%,100% { transform: translateX(-50%) rotate(-3deg) scale(1.04); } 50% { transform: translateX(-50%) rotate(3deg) scale(1.1); } }

#roof { position: absolute; left: -7%; top: -2px; width: 114%; height: 60%; z-index: 4; filter: drop-shadow(0 6px 5px #0007); pointer-events: none; }
.lantern { position: absolute; top: 40%; z-index: 4; font-size: clamp(22px, 7vw, 32px); transform-origin: 50% 0; animation: swing 3s ease-in-out infinite; filter: drop-shadow(0 3px 4px #0006); }
.lantern.l { left: 7%; } .lantern.r { right: 7%; animation-delay: -1.5s; }
@keyframes swing { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

#mult { position: absolute; left: 50%; bottom: 10px; z-index: 6; font-weight: 900; font-style: italic; font-size: clamp(34px, 11vw, 50px); color: #fff3b0;
  -webkit-text-stroke: 2px #b3470a; text-shadow: 0 0 14px #ffdd55, 0 3px 0 #7a2c00; transform: translateX(-50%) scale(0) rotate(-20deg); transition: transform .45s cubic-bezier(.3,1.8,.5,1); }
#mult.show { transform: translateX(-50%) scale(1) rotate(-6deg); }

.petal { position: absolute; top: -20px; width: 11px; height: 9px; z-index: 7; border-radius: 80% 10% 80% 10%; background: linear-gradient(135deg, #ffd0dc, #ff8fab); opacity: .85; animation: fall linear infinite; pointer-events: none; }
@keyframes fall { to { transform: translate(-70px, 300px) rotate(540deg); } }

/* ---------- rolos ---------- */
#boardWrap { position: relative; flex: 1 1 auto; min-height: 0; margin: 0 22px; padding: 6px;
  background: linear-gradient(90deg, var(--gold3), var(--gold) 12%, var(--gold2) 50%, var(--gold) 88%, var(--gold3)); box-shadow: 0 8px 18px #0008; }
.pillar { position: absolute; top: 0; bottom: 0; width: 22px; display: flex; flex-direction: column; justify-content: space-around; align-items: center;
  background: linear-gradient(90deg, #7d0b10, #e6353b 45%, #a30f14); border: 2px solid var(--gold); color: var(--gold); font-size: 11px; font-weight: 900; text-shadow: 0 1px 0 #5c070a; }
.pillar.l { left: -22px; } .pillar.r { right: -22px; }
.pillar::before, .pillar::after { content: ""; position: absolute; left: -4px; right: -4px; height: 12px; border-radius: 3px; background: linear-gradient(var(--gold), var(--gold2), var(--gold3)); }
.pillar::before { top: -2px; } .pillar::after { bottom: -2px; }

#board { position: relative; display: flex; height: 100%; overflow: hidden; background: linear-gradient(#f6e6c4, var(--beige)); transition: box-shadow .5s; }
#board.merged { box-shadow: 0 0 30px 8px #ffe27a; }
.reel { position: relative; flex: 1; height: 100%; overflow: hidden; }
.reel + .reel { box-shadow: inset 3px 0 0 #d9a93f, inset 4px 0 0 #fff1b8; }
#board.merged .reel + .reel { box-shadow: none; }
#board.merged .reel { overflow: visible; } /* deixa os pedaços se sobreporem 1px: sem emenda na foto */
#board.feature { background: linear-gradient(#fbefd2, #f3e0b6); }
.strip { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: flex; flex-direction: column; will-change: transform; }
.strip.blur .cell { filter: blur(2.5px); }

.cell { position: relative; flex: 1 1 0; min-height: 0; }
.card { position: absolute; inset: 0; transform: scale(.9); transition: transform .7s cubic-bezier(.6,0,.2,1); }
#board.merged .piece .card { transform: scale(1.02); }
.face { position: absolute; inset: 0; border-radius: 10px; overflow: hidden; transition: border-radius .7s, box-shadow .7s; }
.front { display: grid; place-items: center; }
.photo { background: #2a0608; box-shadow: 0 0 0 2px var(--gold), 0 0 12px #ffdf6e; }
.photo.land { animation: land .55s cubic-bezier(.3,1.5,.5,1); }
.photo.land::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, #fff, #ffe27a); animation: fade .6s forwards; }
@keyframes land { from { transform: translateY(-130%) scale(1.15); } }
@keyframes fade { to { opacity: 0; } }
#board.merged .photo { border-radius: 0; box-shadow: none; }
.photo img { position: absolute; width: 300%; height: 300%; object-fit: cover; display: block; pointer-events: none; }
.emoji { font-size: clamp(38px, 15vw, 70px); line-height: 1; filter: drop-shadow(0 4px 3px #0004); }
.sym { position: absolute; left: 11%; top: 9%; width: 78%; height: 82%; object-fit: contain; filter: drop-shadow(0 4px 3px #0005); pointer-events: none; }
.cell.hit .front { animation: hit .45s ease-in-out infinite alternate; }
@keyframes hit { from { transform: scale(1); filter: drop-shadow(0 0 0 #ffe27a); } to { transform: scale(1.14); filter: drop-shadow(0 0 12px #ffb300); } }

/* efeitos da carta */
#dim { position: absolute; inset: 0; z-index: 11; pointer-events: none; opacity: 0; transition: opacity .4s; background: radial-gradient(circle at 50% 48%, transparent 0 22%, #1a0304d9 70%); }
#dim.on { opacity: 1; }
#stage.shake { animation: shake .45s; }
@keyframes shake { 0%,100% { transform: translate(0); } 15% { transform: translate(-7px, 5px); } 30% { transform: translate(6px, -6px); } 45% { transform: translate(-5px, -3px); } 60% { transform: translate(4px, 4px); } 80% { transform: translate(-2px, 1px); } }
.ring { position: absolute; z-index: 11; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; border: 5px solid #ffe27a; box-shadow: 0 0 18px #ffb300; pointer-events: none; animation: ring .7s ease-out forwards; }
@keyframes ring { to { transform: scale(11); opacity: 0; border-width: 1px; } }
.fly { position: absolute; z-index: 12; width: 14%; aspect-ratio: 3/4; margin: 0; border-radius: 5px; border: 2px solid var(--gold); background: linear-gradient(160deg, #f0373c, #b30f14); box-shadow: 0 0 12px #ffe27a; pointer-events: none; }

/* rolinho individual das novas rodadas */
.mini { position: absolute; inset: 0; overflow: hidden; }
.mini div { position: absolute; left: 0; top: 0; width: 100%; height: 400%; display: flex; flex-direction: column; filter: blur(3px); opacity: .55; animation: roll .28s linear infinite; }
.mini span { position: relative; flex: 1; }
.mini span img { position: absolute; left: 15%; top: 12%; width: 70%; height: 76%; object-fit: contain; }
@keyframes roll { from { transform: translateY(-50%); } to { transform: translateY(0); } }

#flash { position: absolute; inset: 0; z-index: 8; pointer-events: none; opacity: 0; background: radial-gradient(circle, #fff, #ffe27a 60%, #ffb300); }
#flash.go { animation: flash .9s ease-out; }
@keyframes flash { 0% { opacity: 0; } 35% { opacity: 1; } 100% { opacity: 0; } }

/* a carta "?" que o topo solta */
#qcard { position: absolute; left: 50%; z-index: 13; width: 38%; aspect-ratio: 3/4; transform: translate(-50%, -200%); pointer-events: none; perspective: 600px; visibility: hidden; }
#qcard.on { visibility: visible; }
#qcard .qin { width: 100%; height: 100%; border-radius: 10px; display: grid; place-items: center; border: 3px solid var(--gold);
  background: linear-gradient(160deg, #f0373c, #b30f14); box-shadow: 0 10px 22px #000a, inset 0 0 0 3px #b30f14, inset 0 0 0 5px #ffd76688; }
#qcard .qin b { display: grid; place-items: center; width: 62%; aspect-ratio: 1; border-radius: 50%; font-size: clamp(30px, 10vw, 46px); font-weight: 900; color: #a30f14;
  background: radial-gradient(circle at 35% 30%, #fff3b0, var(--gold2)); border: 3px solid #fff1b8; }
#qcard.glow .qin { animation: qglow .35s ease-in-out infinite alternate; }
@keyframes qglow { from { box-shadow: 0 10px 22px #000a, 0 0 0 0 #ffe27a; transform: rotate(-3deg); } to { box-shadow: 0 10px 22px #000a, 0 0 34px 12px #ffe27a; transform: rotate(3deg); } }

/* ---------- faixa, barras, controles ---------- */
#banner { position: relative; flex: 0 0 auto; margin: 9px 10px 0; min-height: 42px; padding: 6px 30px; display: grid; place-items: center; text-align: center; border-radius: 8px;
  border: 2px solid var(--gold); background: linear-gradient(#e6353b, #a30f14); box-shadow: inset 0 0 12px #0006, 0 3px 6px #0006;
  color: #fff; font-weight: 900; font-style: italic; font-size: clamp(15px, 4.5vw, 19px); text-shadow: 0 2px 0 #5c070a; }
#banner::before, #banner::after { content: "❖"; position: absolute; top: 50%; transform: translateY(-50%); color: var(--gold); font-style: normal; font-size: 18px; }
#banner::before { left: 8px; } #banner::after { right: 8px; }
#banner.pop span { display: inline-block; animation: pop .5s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { from { transform: scale(.6); } to { transform: scale(1); } }

#stats { flex: 0 0 auto; display: flex; gap: 6px; margin: 8px 10px 0; }
#stats div { flex: 1; padding: 6px 4px; border-radius: 6px; background: #5c070a; box-shadow: inset 0 2px 4px #0008; color: #fff; font-size: clamp(11px, 3.3vw, 14px); font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#controls { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-around; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: radial-gradient(circle at 50% 120%, #ffffff14 0 30%, transparent 31%) 0 0 / 34px 22px; }
.mini-btn { width: 44px; height: 44px; border-radius: 50%; border: 2px solid #c9912c; background: radial-gradient(circle at 35% 30%, #a30f14, #5c070a); color: #ffe9a8; font-size: 19px; font-weight: 900; cursor: pointer; }
.mini-btn:active { transform: scale(.9); } .mini-btn.on { background: radial-gradient(circle at 35% 30%, #ffd766, #d48806); color: #5c070a; }
#spinHold { position: relative; padding: 5px 5px 0; }
#spinHold::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: -9px; height: 16px; z-index: 0; border-radius: 4px 4px 12px 12px; background: linear-gradient(var(--gold), var(--gold2), var(--gold3)); box-shadow: 0 3px 5px #0008; }
#spin { position: relative; z-index: 1; display: grid; place-items: center; width: clamp(78px, 23vw, 96px); aspect-ratio: 1; border-radius: 50%; cursor: pointer; border: 5px solid var(--gold);
  background: radial-gradient(circle at 35% 28%, #8df5b3, #1fae5b 50%, #0b6b33); box-shadow: 0 0 0 3px var(--gold3), 0 6px 14px #000a, inset 0 -6px 10px #0005; transition: transform .1s; }
#spin svg { width: 62%; filter: drop-shadow(0 2px 2px #0007); }
#spin:active { transform: scale(.92); }
#spin.busy { filter: saturate(.5) brightness(.8); } #spin.busy svg { animation: rot .6s linear infinite; }
#spin.hint { animation: hint 1s ease-in-out infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
#rays { animation-name: rot2; } @keyframes rot2 { from { transform: translate(-50%,-50%) rotate(0); } to { transform: translate(-50%,-50%) rotate(360deg); } }
@keyframes hint { 0%,100% { box-shadow: 0 0 0 3px var(--gold3), 0 6px 14px #000a, 0 0 0 0 #7cf0a6cc; } 50% { box-shadow: 0 0 0 3px var(--gold3), 0 6px 14px #000a, 0 0 0 16px #7cf0a600; } }

/* ---------- overlays ---------- */
#fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
.overlay { position: absolute; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 26px; text-align: center;
  background: radial-gradient(circle at 50% 35%, #d81f26ee, #3a0406f5 75%); color: #fff3c4; transition: opacity .5s, visibility .5s; overflow-y: auto; }
.overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.overlay h1 { font-size: clamp(30px, 9vw, 44px); font-weight: 900; font-style: italic; color: var(--gold); -webkit-text-stroke: 1px #7a2c00; text-shadow: 0 3px 0 #7a2c00, 0 0 22px #ffb300; line-height: 1.05; }
.overlay h2 { font-size: clamp(20px, 6vw, 28px); color: #fff; text-shadow: 0 2px 0 #5c070a; }
.overlay p { font-size: clamp(15px, 4.4vw, 18px); line-height: 1.45; max-width: 360px; }
.overlay small { opacity: .75; font-size: 12px; }
.overlay .round { width: 150px; height: 150px; border-radius: 50%; border: 5px solid var(--gold); box-shadow: 0 0 30px #ffb300aa; overflow: hidden; display: grid; place-items: center; font-size: 84px; background: #7cc4f5; }
.overlay .round img { width: 100%; height: 100%; object-fit: cover; }
.btn { margin-top: 6px; padding: 14px 34px; border-radius: 40px; border: 3px solid #fff1b8; cursor: pointer; font-size: 19px; font-weight: 900; letter-spacing: 1px; color: #5c070a;
  background: linear-gradient(var(--gold), var(--gold2)); box-shadow: 0 5px 0 var(--gold3), 0 10px 18px #0008; animation: pulse 1.2s ease-in-out infinite; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--gold3); }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
#gallery { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; max-width: 360px; }
#gallery img { flex: 1 1 90px; max-width: 240px; min-width: 0; aspect-ratio: 4/3; object-fit: cover; border-radius: 10px; border: 3px solid var(--gold); box-shadow: 0 3px 10px #0008; }
