:root {
  --bg: #0d1220; --bg2: #161d31; --gold: #d9a441; --gold2: #f3d27a; --ink: #f4ecd8; --mute: #a9a28f;
  --line: rgba(217, 164, 65, .35); --red: #e5533d; --green: #4caf50;
  --serif: 'Cinzel', Georgia, serif; --sans: 'Nunito', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); }
body { background: radial-gradient(ellipse at top, #1d2a4a 0%, var(--bg) 60%) fixed; overflow-x: hidden; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; font-size: 16px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: #0b0f1a; color: var(--ink); width: 100%; }
input:focus { outline: 2px solid var(--gold); }
h1, h2, h3 { font-family: var(--serif); color: var(--gold2); margin: .3em 0; }
h1 { font-size: clamp(28px, 5vw, 44px); text-shadow: 0 2px 12px rgba(0,0,0,.6); }
h2 { font-size: 24px; }
h3 { font-size: 17px; }

.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; align-items: center; justify-content: center; padding: 16px; }
#scr-game.active { display: block; padding: 0; }

.btn { border: 1px solid var(--line); background: linear-gradient(#26304d, #1a2238); color: var(--ink); padding: 12px 18px; border-radius: 10px; font-weight: 800; font-size: 15px; transition: transform .1s, filter .15s; }
.btn:hover { filter: brightness(1.2); }
.btn:active { transform: scale(.97); }
.btn.gold { background: linear-gradient(#f1c96b, #b9822a); color: #2a1a05; border-color: #f3d27a; box-shadow: 0 0 18px rgba(217,164,65,.35); }
.btn.ghost { background: transparent; }
.btn.red { background: linear-gradient(#e66a50, #a8331f); border-color: #f08a73; }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn.small { padding: 7px 12px; font-size: 13px; }

.menu-box { text-align: center; max-width: 440px; width: 100%; }
.selo { width: min(210px, 50vw); filter: drop-shadow(0 6px 24px rgba(0,0,0,.6)); }
.sub { color: var(--mute); margin-top: 0; }
.menu-btns { display: grid; gap: 10px; margin: 22px 0; }
.kh { width: 110px; opacity: .9; }

.panel { background: rgba(14,19,33,.92); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: 100%; max-width: 760px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.panel.narrow { max-width: 560px; }
.panel.rules { max-height: 92vh; overflow: auto; line-height: 1.5; }
.panel.rules li { margin-bottom: 6px; }
.hint { color: var(--mute); font-size: 14px; }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.lbl { display: block; font-size: 13px; color: var(--mute); margin: 8px 0 4px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; }
.split > div { display: grid; gap: 8px; align-content: start; }
.code-in { text-transform: uppercase; letter-spacing: 4px; text-align: center; font-weight: 800; }
.code { font-family: monospace; letter-spacing: 4px; background: #000; padding: 2px 10px; border-radius: 6px; color: var(--gold2); }
.err { color: var(--red); min-height: 1.2em; }

.prow { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06); }
.prow input { flex: 1; }
.swatch { display: inline-block; vertical-align: middle; width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; flex: none; box-shadow: 0 2px 6px rgba(0,0,0,.6); }
.prow .swatch { cursor: pointer; }
.kind { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: #0b0f1a; font-size: 20px; flex: none; }
.rm { background: none; border: none; color: var(--mute); font-size: 20px; width: 30px; }

/* ---------- jogo ---------- */
.game { display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: 1fr auto; height: 100vh; height: 100dvh; }
.board-wrap { grid-column: 1; grid-row: 1; display: flex; align-items: center; justify-content: center; padding: 8px; min-height: 0; overflow: hidden; }
.board { position: relative; aspect-ratio: 2481 / 1754; max-width: 100%; max-height: 100%; width: 100%; user-select: none; }
@supports (container-type: size) { .board-wrap { container-type: size; } .board { width: min(100cqw, 100cqh * 1.4145); } }
.board > img { width: 100%; height: 100%; display: block; border-radius: 10px; box-shadow: 0 6px 30px rgba(0,0,0,.6); }
.pile { position: absolute; width: 11.9%; height: 16.7%; display: flex; align-items: center; justify-content: center; }
.pile img { height: 100%; border-radius: 6px; box-shadow: 0 3px 10px rgba(0,0,0,.7), 3px 3px 0 #555, 5px 5px 0 #333; }
.pile span { position: absolute; bottom: -2px; left: 0; right: 0; text-align: center; font-family: var(--serif); font-size: clamp(8px, 1vw, 13px); background: rgba(0,0,0,.75); border-radius: 4px; padding: 1px 0; color: var(--gold2); line-height: 1.1; }
.pile-p { left: 85.7%; top: 30.8%; }
.pile-a { left: 85.7%; top: 54.7%; }
.pile.flash img { animation: flash .6s; }
@keyframes flash { 50% { filter: brightness(1.8); transform: scale(1.06); } }

.pawn { position: absolute; width: 3.1%; aspect-ratio: 1; margin: -1.55% 0 0 -1.55%; border-radius: 50% 50% 50% 50%; border: 2px solid #fff; box-shadow: 0 3px 6px rgba(0,0,0,.7), inset 0 -4px 6px rgba(0,0,0,.35), inset 0 3px 4px rgba(255,255,255,.5); transition: left .22s ease-out, top .22s ease-out; z-index: 5; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: clamp(7px, .9vw, 12px); color: #000; }
.pawn.dark { color: #fff; }
.pawn.cur { z-index: 6; animation: bob 1s ease-in-out infinite; outline: 3px solid var(--gold2); outline-offset: 1px; }
.pawn.slow { transition: left .65s ease-in-out, top .65s ease-in-out; }
@keyframes bob { 50% { transform: translateY(-18%); } }

.side { grid-column: 2; grid-row: 1 / span 2; background: rgba(10,14,25,.95); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-top { display: flex; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
#turn-label { font-family: var(--serif); color: var(--gold2); font-size: 15px; }
.icon-btn { background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; flex: none; }
#plist { padding: 6px 8px; border-bottom: 1px solid var(--line); overflow: auto; max-height: 48%; }
.pl { display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 8px; }
.pl.cur { background: rgba(217,164,65,.15); box-shadow: inset 3px 0 0 var(--gold); }
.pl .swatch { width: 22px; height: 22px; }
.pl .nm { font-weight: 800; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pl .meta { font-size: 12px; color: var(--mute); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.badge { background: #000; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 11px; color: var(--ink); white-space: nowrap; }
.badge.bad { border-color: #a33; color: #f99; }
.badge.good { border-color: #3a3; color: #9f9; }
#log { flex: 1; overflow: auto; padding: 8px 10px; font-size: 13px; line-height: 1.35; color: #cfc8b4; }
#log div { padding: 2px 0; border-bottom: 1px dashed rgba(255,255,255,.05); }
#log .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

.bottom { grid-column: 1; grid-row: 2; padding: 6px 10px 10px; display: flex; gap: 12px; align-items: flex-end; background: linear-gradient(transparent, rgba(0,0,0,.5)); min-height: 120px; }
#actionbar { display: flex; flex-direction: column; gap: 8px; min-width: 190px; }
#actionbar .msg { font-size: 13px; color: var(--mute); max-width: 220px; }
#actionbar .who { font-family: var(--serif); color: var(--gold2); }
#hand { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px; flex: 1; align-items: flex-end; min-height: 110px; }
.hcard { width: 104px; flex: none; border-radius: 7px; box-shadow: 0 3px 10px rgba(0,0,0,.7); transition: transform .15s; position: relative; }
.hcard img { width: 100%; display: block; border-radius: 7px; }
.hcard.play { cursor: pointer; outline: 3px solid var(--gold2); outline-offset: 1px; box-shadow: 0 0 16px rgba(243,210,122,.6); }
.hcard.play:hover { transform: translateY(-10px) scale(1.04); }
.hcard.dim { opacity: .55; }
.hcard .tag { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); font-size: 10px; background: #000; color: var(--gold2); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; white-space: nowrap; }
.hand-empty { color: var(--mute); font-size: 13px; align-self: center; }

/* ---------- camadas ---------- */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 40; background: rgba(0,0,0,.55); flex-direction: column; gap: 10px; text-align: center; padding: 16px; }
.overlay.on { display: flex; }
.overlay .big { width: min(300px, 70vw); border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.8); animation: pop .35s ease-out; }
.overlay .cap { font-family: var(--serif); font-size: 18px; color: var(--gold2); text-shadow: 0 2px 6px #000; max-width: 520px; }
.overlay .tap { color: var(--mute); font-size: 12px; }
@keyframes pop { from { transform: scale(.6) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }
.die { width: 110px; height: 110px; background: #fffaf0; border-radius: 20px; box-shadow: 0 8px 30px rgba(0,0,0,.7), inset 0 -6px 0 #d8cfbd; display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 14px; animation: roll 1s ease-out; }
.die i { width: 18px; height: 18px; border-radius: 50%; background: #1a1a1a; place-self: center; visibility: hidden; }
.die i.on { visibility: visible; }
@keyframes roll { 0% { transform: rotate(-200deg) scale(.4); } 70% { transform: rotate(20deg) scale(1.1); } 100% { transform: none; } }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 50; background: rgba(0,0,0,.6); padding: 14px; }
.modal.on { display: flex; }
.mbox { background: #121a2e; border: 1px solid var(--gold); border-radius: 14px; padding: 18px; max-width: 640px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: 0 10px 50px rgba(0,0,0,.8); animation: pop .25s ease-out; }
.mbox h3 { margin-top: 0; }
.mbox .cards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 12px 0; }
.mbox .cards .hcard { width: 120px; cursor: pointer; }
.mbox .cards .hcard:hover { transform: translateY(-6px); }
.mbox .big1 { display: block; width: min(240px, 60vw); margin: 10px auto; border-radius: 10px; }
.mbox .opts { display: grid; gap: 8px; margin-top: 10px; }
.pbtn { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #0b0f1a; color: var(--ink); font-weight: 800; font-size: 15px; text-align: left; }
.pbtn:hover { border-color: var(--gold2); }
.pbtn .swatch { width: 24px; height: 24px; }
.pbtn small { margin-left: auto; color: var(--mute); font-weight: 400; }
.timer { height: 4px; background: var(--gold); border-radius: 2px; margin-top: 12px; transform-origin: left; }
.curtain { text-align: center; }
.curtain > .swatch { display: block; width: 60px; height: 60px; margin: 10px auto; }
.mbox .whose { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }

.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%) translateY(-200%); opacity: 0; background: #000; border: 1px solid var(--gold); color: var(--ink); padding: 10px 16px; border-radius: 10px; z-index: 60; transition: transform .25s; max-width: 90vw; font-size: 14px; }
.toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }

.win h1 { font-size: 34px; }
.win .pbtn { padding: 7px 12px; }
.win .opts { gap: 6px; }
.confetti { position: fixed; top: -20px; width: 10px; height: 16px; z-index: 45; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- celular ---------- */
@media (max-width: 900px) {
  .game { grid-template-columns: 1fr; grid-template-rows: auto auto auto; height: auto; min-height: 100dvh; }
  .board-wrap { grid-row: 1; padding: 4px; container-type: normal !important; display: block; overflow-x: auto; position: relative; }
  .board { width: 100% !important; max-height: none; }
  .board-wrap.zoom .board { width: 210% !important; max-width: none; }
  .zoom-btn { display: block !important; }
  .bottom { grid-row: 2; flex-direction: column; align-items: stretch; min-height: 0; gap: 6px; }
  #hand { min-height: 0; }
  #actionbar { flex-direction: row; flex-wrap: wrap; align-items: center; min-width: 0; }
  #actionbar .msg { max-width: none; flex-basis: 100%; }
  .side { grid-column: 1; grid-row: 3; border-left: none; border-top: 1px solid var(--line); }
  #plist { max-height: none; }
  #log { max-height: 220px; }
  .hcard { width: 80px; }
  .split { grid-template-columns: 1fr; }
  .pawn { border-width: 1.5px; }
}

.zoom-btn { display: none; position: sticky; left: 6px; float: left; margin: 0 0 -42px 0; z-index: 8; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--gold); background: rgba(0,0,0,.7); color: #fff; font-size: 17px; }

/* ---------- animações extras ---------- */
.pawn.hop { animation: hop .26s ease-out !important; }
@keyframes hop { 0% { transform: translateY(0) scale(1); } 45% { transform: translateY(-75%) scale(1.08, .94); } 85% { transform: translateY(0) scale(1.12, .86); } 100% { transform: none; } }
.pawn.dizzy { animation: dizzy .9s ease-in-out !important; }
@keyframes dizzy { 0% { transform: rotate(0); } 30% { transform: rotate(260deg) scale(.85); } 60% { transform: rotate(520deg) translateX(10%); } 80% { transform: rotate(700deg) translateX(-10%); } 100% { transform: rotate(720deg); } }
.swirl { position: absolute; width: 6%; aspect-ratio: 1; margin: -3% 0 0 -3%; border-radius: 50%; z-index: 7; pointer-events: none;
  background: conic-gradient(from 0deg, transparent, rgba(155,227,255,.9), transparent, rgba(243,210,122,.9), transparent);
  -webkit-mask: radial-gradient(circle, transparent 30%, #000 32%, #000 60%, transparent 62%); mask: radial-gradient(circle, transparent 30%, #000 32%, #000 60%, transparent 62%);
  animation: swirl .9s ease-out forwards; }
@keyframes swirl { 0% { transform: scale(.2) rotate(0); opacity: 0; } 30% { opacity: 1; } 100% { transform: scale(1.6) rotate(540deg); opacity: 0; } }

.stamp { position: fixed; left: 50%; top: 42%; z-index: 55; pointer-events: none; font-family: var(--serif); font-weight: 800; font-size: clamp(34px, 7vw, 76px);
  padding: 6px 26px; border: 6px solid currentColor; border-radius: 14px; background: rgba(10,14,25,.82); text-shadow: 0 3px 0 rgba(0,0,0,.5); white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-8deg); animation: stamp 1.3s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes stamp { 0% { transform: translate(-50%, -50%) rotate(-8deg) scale(3); opacity: 0; } 18% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1.05); opacity: 0; } }
.shake { animation: shake .45s; }
@keyframes shake { 15% { transform: translate(-6px, 3px); } 30% { transform: translate(6px, -3px); } 45% { transform: translate(-5px, -2px); } 60% { transform: translate(4px, 3px); } 75% { transform: translate(-2px, 1px); } 100% { transform: none; } }

.flip { width: min(300px, 70vw); aspect-ratio: 408 / 470; perspective: 1200px; }
.flip-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; animation: flip .75s ease-in-out .15s forwards; }
.flip .face { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border-radius: 12px; backface-visibility: hidden; box-shadow: 0 10px 40px rgba(0,0,0,.8); }
.flip .front { transform: rotateY(180deg); }
@keyframes flip { 0% { transform: rotateY(0) scale(.7); } 50% { transform: rotateY(90deg) scale(1.08); } 100% { transform: rotateY(180deg) scale(1); } }

.banner { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 52; pointer-events: none; font-family: var(--serif); font-size: clamp(16px, 2.6vw, 26px); color: #2a1a05;
  background: linear-gradient(#f6d98a, #c9922f); padding: 10px 34px; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.6); white-space: nowrap; max-width: 94vw; overflow: hidden; text-overflow: ellipsis;
  animation: banner 2.4s ease-in-out forwards; }
.banner::before, .banner::after { content: ''; position: absolute; top: 8px; width: 22px; height: 100%; background: #9c6c1e; z-index: -1; }
.banner::before { left: -14px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 40% 50%); }
.banner::after { right: -14px; clip-path: polygon(0 0, 100% 0, 60% 50%, 100% 100%, 0 100%); }
@keyframes banner { 0% { transform: translateX(-50%) translateY(-40px) scale(.8); opacity: 0; } 12% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; } 85% { opacity: 1; } 100% { transform: translateX(-50%) translateY(-10px); opacity: 0; } }

/* emojis */
#emojibar { display: flex; gap: 4px; flex-wrap: wrap; }
#emojibar button { font-size: 22px; width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.45); line-height: 1; padding: 0; transition: transform .1s; }
#emojibar button:hover { transform: scale(1.18); }
#emojibar button:disabled { opacity: .35; }
.emo { position: absolute; z-index: 9; font-size: clamp(22px, 3vw, 40px); pointer-events: none; transform: translate(-50%, -100%); animation: emo 2.8s ease-out forwards; filter: drop-shadow(0 3px 4px rgba(0,0,0,.6)); }
.emo span { display: inline-block; background: #fff; border-radius: 50% 50% 50% 8px; padding: 4px 6px; line-height: 1; }
@keyframes emo { 0% { transform: translate(-50%, -60%) scale(.3); opacity: 0; } 12% { transform: translate(-50%, -120%) scale(1.15); opacity: 1; } 25% { transform: translate(-50%, -115%) scale(1); } 80% { opacity: 1; } 100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }
.pl .em { font-size: 18px; animation: pop .3s; }

/* prêmios */
.awards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.award { background: #0b0f1a; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: left; }
.award .ae { font-size: 26px; }
.award b { display: block; color: var(--gold2); font-family: var(--serif); font-size: 14px; margin: 2px 0; }
.award .an { font-weight: 800; display: flex; align-items: center; gap: 6px; }
.award .an .swatch { width: 16px; height: 16px; border-width: 1.5px; }
.award small { color: var(--mute); }
.share-img { width: 100%; max-width: 360px; display: block; margin: 8px auto; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.6); }
@media (max-width: 520px) { .awards { grid-template-columns: 1fr; } }

.act-col { display: flex; flex-direction: column; gap: 8px; min-width: 190px; }
@media (max-width: 900px) { .act-col { min-width: 0; } #emojibar { gap: 3px; } #emojibar button { width: 33px; height: 36px; font-size: 19px; } }
