:root {
  --ink: #4a2158;
  --muted: #7a5b86;
  --gold: #ffb703;
  --gold-2: #fb8500;
  --pink: #ff4d8d;
  --pink-2: #e2186a;
  --card: rgba(255, 255, 255, 0.88);
  --sky: #8fd4ff;
  font-family: Fredoka, "Trebuchet MS", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--sky);
  overflow-x: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 18% 12%, #fff 0 46px, transparent 48px),
    radial-gradient(circle at 78% 8%, #fff 0 64px, transparent 66px),
    radial-gradient(circle at 60% 28%, rgba(255,255,255,.7) 0 28px, transparent 30px),
    linear-gradient(180deg, #b9e6ff 0%, #8fd4ff 42%, #ffe7f4 100%);
}
body[data-stage="2"] .sky { background: linear-gradient(180deg, #ffd0ea, #f7b6d8 50%, #fff0c9); }
body[data-stage="3"] .sky { background: linear-gradient(180deg, #c8fff4, #7ad7c8 55%, #fff6c8); }
body[data-stage="4"] .sky { background: linear-gradient(180deg, #f6d7b0, #e7b48a 50%, #d98a5a); }
body[data-stage="5"] .sky { background: linear-gradient(180deg, #efe7ff, #c7b6ff 50%, #ffd6ef); }

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,.82);
  border-bottom: 4px solid #ff8ac4;
  position: sticky;
  top: 0;
  z-index: 5;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.brand strong { display: block; font-size: 22px; line-height: 1; }
.brand small { color: var(--muted); font-size: 12px; }
.brand-candy {
  width: 34px; height: 34px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe0ea, #ff4d6d 55%, #c9184a);
  box-shadow: inset 0 -4px 0 rgba(0,0,0,.08), 0 4px 0 #ffd0e0;
}
.top-actions, .wallet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.text-link {
  background: none; border: 0; color: #9a3d78; font-weight: 600; text-decoration: none;
}
.text-link.center { display: block; width: 100%; margin-top: 8px; }
.saldo {
  background: #fff; border: 2px solid #ffd0ea; border-radius: 999px;
  padding: 6px 10px; font-weight: 700;
}

.btn {
  border: 0; border-radius: 999px; padding: 14px 18px; font-weight: 700;
  color: #fff; letter-spacing: .01em;
}
.btn.sm { padding: 8px 14px; font-size: 14px; }
.btn.gold {
  background: linear-gradient(180deg, #ffd15a, var(--gold-2));
  box-shadow: 0 5px 0 #c45e00;
}
.btn.pink {
  background: linear-gradient(180deg, #ff7eb3, var(--pink-2));
  box-shadow: 0 5px 0 #9d0d4a;
}
.btn.ghost {
  background: #fff; color: var(--ink);
  box-shadow: 0 5px 0 #e7c3d8;
}
.btn:disabled { filter: grayscale(.3); opacity: .65; cursor: default; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }

main, #game { width: min(520px, 100%); margin: 0 auto; padding: 18px 16px 40px; }
h1 {
  margin: 8px 0 14px; text-align: center; font-size: clamp(34px, 9vw, 52px); line-height: .95;
  color: #fff; -webkit-text-stroke: 6px #ff4f9a; paint-order: stroke fill;
  text-shadow: 0 6px 0 #c81e68;
}
.pill {
  margin: 8px auto 0; width: fit-content; background: #fff; color: #e2186a;
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600;
  box-shadow: 0 4px 0 #ffd0e4;
}
.cta-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.cta-row .btn { min-width: 160px; }

.hero-board, .board {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px;
  background: linear-gradient(180deg, #fff7df, #ffe08a);
  border: 6px solid #fff; border-radius: 22px;
  padding: 8px; box-shadow: 0 14px 0 rgba(90, 40, 90, .12), 0 18px 30px rgba(80, 30, 80, .12);
}
.hero-board { grid-template-columns: repeat(6, 1fr); width: min(280px, 70vw); margin: 0 auto; pointer-events: none; }
.cell {
  aspect-ratio: 1; border: 0; background: rgba(255,255,255,.35); border-radius: 12px;
  display: grid; place-items: center; padding: 0; position: relative;
}
.cell.sel { outline: 3px solid #fff; outline-offset: -2px; background: rgba(255,255,255,.7); }
.cell.pop .candy { animation: pop .16s ease forwards; }
@keyframes pop { to { transform: scale(.15); opacity: 0; } }

.candy {
  width: 94%; height: 94%; position: relative;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  filter: drop-shadow(0 2px 0 rgba(40, 20, 60, .18));
}
.candy.c1 { background-image: url("/doces/candies/red.svg?v=4"); }
.candy.c2 { background-image: url("/doces/candies/orange.svg?v=4"); }
.candy.c3 { background-image: url("/doces/candies/yellow.svg?v=4"); }
.candy.c4 { background-image: url("/doces/candies/green.svg?v=4"); }
.candy.c5 { background-image: url("/doces/candies/blue.svg?v=4"); }
.candy.c6 { background-image: url("/doces/candies/purple.svg?v=4"); }
.candy.k-h::after, .candy.k-v::after {
  content: ""; position: absolute; background: rgba(255,255,255,.82);
}
.candy.k-h::after { left: 8%; right: 8%; top: 38%; height: 22%; border-radius: 99px; }
.candy.k-v::after { top: 8%; bottom: 8%; left: 38%; width: 22%; border-radius: 99px; }
.candy.k-w { box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(255, 70, 130, .55), inset 0 -5px 0 rgba(0,0,0,.12); }
.candy.k-b {
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 38% 32%, #fff6c2, #ffd23f 28%, #2b2b2b 70%);
}

.panel {
  background: var(--card); border-radius: 22px; padding: 16px; margin-top: 18px;
  box-shadow: 0 8px 0 rgba(255,255,255,.4);
}
.panel h2 { margin: 0 0 6px; }
.panel p { margin: 0; color: var(--muted); }
.stages { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.stage {
  border: 2px solid transparent; background: #fff; border-radius: 14px;
  padding: 8px 10px; font-weight: 700; font-size: 13px;
}
.stage.on { border-color: #e2186a; }
.stage i { display: block; width: 28px; height: 10px; border-radius: 99px; margin-bottom: 4px; }
.steps { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 12px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; }
.steps span {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center; background: #ff4d8d; color: #fff; font-weight: 700;
}
.steps h3 { margin: 0; }
.steps p { margin: 2px 0 0; }
.end-cta { text-align: center; }
.legal { text-align: center; color: #6d4a78; font-size: 12px; }
.affiliate-cta { text-align: center; }
.affiliate-cta .btn { width: 100%; margin-top: 12px; }

#modal-affiliate {
  width: min(460px, calc(100% - 24px));
  max-height: min(88vh, 820px);
  overflow: auto;
}
#modal-affiliate h3 { margin: 16px 0 6px; font-size: 16px; }
.aff-balance {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px;
}
.aff-balance > div {
  background: #fff7fb; border-radius: 16px; padding: 10px 12px;
}
.aff-balance span, .aff-balance small { display: block; color: var(--muted); font-size: 12px; }
.aff-balance strong { display: block; font-size: 20px; line-height: 1.2; }
.aff-link {
  margin: 0; padding: 10px 12px; background: #fff; border-radius: 12px;
  border: 2px dashed #ffb3d4; word-break: break-all; font-size: 13px; font-weight: 600;
}
.rate-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.rate-pill {
  background: #fff; border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 700;
  box-shadow: 0 3px 0 #ffd0e4;
}
.aff-levels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.aff-level {
  background: #fff; border: 2px solid #ffd0e4; border-radius: 16px; padding: 10px;
}
.aff-level b { display: block; font-size: 18px; }
.aff-level span, .aff-level small { display: block; color: var(--muted); font-size: 12px; }
.aff-tabs { display: flex; gap: 6px; margin: 8px 0; }
.aff-tabs button {
  flex: 1; border: 2px solid transparent; background: #fff; border-radius: 12px;
  padding: 8px 0; font-weight: 700;
}
.aff-tabs button.on { border-color: #e2186a; background: #ff4d8d; color: #fff; }
.aff-list { display: grid; }
.aff-row {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 8px 0; border-top: 1px solid #f3d5e6; font-size: 13px;
}
.aff-row strong { color: #0b9b4a; }
.aff-empty { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
#form-aff-withdraw { margin-top: 8px; }
#modal-affiliate .btn { width: 100%; margin-top: 8px; }
#modal-affiliate .cta-row .btn { width: auto; flex: 1; }

.hud { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 0; background: #fff; font-size: 20px;
  box-shadow: 0 4px 0 #ffd0e4;
}
.hud-mid { flex: 1; }
.progress { height: 14px; background: #fff; border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 2px #ffd0e4; }
#progress-bar { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd15a, #ff4d8d); }
.hud-meta { display: flex; justify-content: space-between; margin-top: 4px; font-size: 13px; font-weight: 700; }
.moves {
  width: 64px; height: 64px; border-radius: 50%; background: #7b3ff0; color: #fff;
  display: grid; place-items: center; align-content: center; box-shadow: 0 4px 0 #5424b0;
}
.moves b { font-size: 22px; line-height: 1; }
.moves small { font-size: 9px; }
.stage-name { text-align: center; font-weight: 700; margin: 8px 0; }
.board-wrap { position: relative; }
.board { touch-action: none; }
.hint { text-align: center; color: #6d4a78; font-size: 14px; }
.game-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.game-actions .btn { flex: 1; min-width: 120px; }
.gain {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%);
  background: #fff; color: #0b9b4a; font-weight: 700; border-radius: 999px;
  padding: 6px 12px; box-shadow: 0 6px 0 rgba(0,0,0,.06);
}

dialog {
  border: 0; border-radius: 22px; padding: 18px; width: min(420px, calc(100% - 24px));
  box-shadow: 0 20px 60px rgba(40, 10, 40, .3);
}
dialog::backdrop { background: rgba(40, 10, 50, .45); }
dialog h2 { margin: 0 0 8px; }
label { display: grid; gap: 4px; font-size: 14px; font-weight: 600; margin: 10px 0; }
input, textarea {
  border: 2px solid #ffd0e4; border-radius: 12px; padding: 10px 12px; background: #fff;
}
textarea { min-height: 72px; width: 100%; }
.form-error { color: #c01848; min-height: 1.2em; font-size: 14px; margin: 0; }
.muted { color: var(--muted); font-size: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { margin-top: 3px; }
.deposit-list { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; }
.deposit-list li { padding: 6px 0; border-top: 1px solid #f3d5e6; }
.bets { display: flex; flex-wrap: wrap; gap: 8px; }
.bets button, .stage { cursor: pointer; }
.bets button.on { background: #ff4d8d; color: #fff; border-color: #ff4d8d; }
#pix-qr { width: 180px; height: 180px; display: block; margin: 8px auto; background: #fff; }
.result-prize { font-size: 28px; text-align: center; margin: 8px 0 14px; }
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #3a1848; color: #fff; padding: 10px 14px; border-radius: 12px; z-index: 20;
  max-width: min(420px, calc(100% - 24px)); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .cell.pop .candy { animation: none; opacity: .3; }
}
