:root {
  --felt: #0f5a3f;
  --felt-dark: #0b3d2e;
  --panel: rgba(0, 0, 0, 0.35);
  --text: #f3f6f4;
  --muted: #a9c4b8;
  --accent: #f5c542;
  --danger: #ff6b6b;
  --card-bg: #fffdf7;
  --card-red: #d12f2f;
  --card-black: #1b1b1b;
  --cw: clamp(40px, 10.5vw, 66px);
  --ch: calc(var(--cw) * 1.42);
  --hand-w: min(100vw, 960px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: radial-gradient(ellipse at center, var(--felt) 0%, var(--felt-dark) 80%);
  background-color: var(--felt-dark);
  overscroll-behavior: none;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9em; }
.error { color: var(--danger); min-height: 1.2em; margin: 4px 0; font-size: 0.9em; }
h1, h2 { margin: 0 0 12px; }
h2 { font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }

button, input {
  font: inherit; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18);
  padding: 10px 14px; color: var(--text); background: rgba(255,255,255,0.08);
}
input { width: 100%; background: rgba(0,0,0,0.25); }
input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
button { cursor: pointer; font-weight: 600; touch-action: manipulation; }
button:hover:not(:disabled) { background: rgba(255,255,255,0.16); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); color: #2a2100; border-color: transparent; }
button.primary:hover:not(:disabled) { background: #ffd65c; }
button.ghost { background: transparent; border-color: transparent; }
button.small { padding: 2px 8px; font-size: 0.9rem; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
.card-box { background: var(--panel); border-radius: 16px; padding: 18px; }

/* Login */
#screen-login { align-items: center; justify-content: center; padding: 16px; }
#login-form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
#login-form label { text-align: left; display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
#login-form .row button { flex: 1; }
.logo { font-size: 2rem; letter-spacing: 6px; color: var(--accent); }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(0,0,0,0.3);
}
.topbar .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Lobby */
.lobby { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; background: rgba(255,255,255,0.06); border-radius: 10px; }
.list li .info { min-width: 0; }
.list li .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .empty { justify-content: center; color: var(--muted); }
.tag { font-size: 0.75rem; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,0.12); white-space: nowrap; }
.tag.live { background: var(--danger); color: #fff; }
.tag.ok { background: #2ecc71; color: #06301a; }
table.lb { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
table.lb th, table.lb td { padding: 6px 4px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.08); }
table.lb th { color: var(--muted); font-weight: 500; }
table.lb td:nth-child(n+3), table.lb th:nth-child(n+3) { text-align: right; }
table.lb tr.me td { color: var(--accent); font-weight: 700; }

/* Room */
#screen-room { height: 100dvh; overflow: hidden; }
#table { position: relative; flex: 1; min-height: 0; }
.seat {
  position: absolute; display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--panel); border-radius: 12px; padding: 8px 10px; min-width: 96px;
  border: 2px solid transparent; transition: border-color .2s;
}
.seat:empty { display: none; }
#seat-top { top: 8px; left: 50%; transform: translateX(-50%); }
#seat-left { left: 8px; top: 40%; transform: translateY(-50%); }
#seat-right { right: 8px; top: 40%; transform: translateY(-50%); }
.seat.turn { border-color: var(--accent); box-shadow: 0 0 16px rgba(245,197,66,0.5); }
.seat .name { font-weight: 700; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat .count { display: flex; align-items: center; gap: 6px; font-size: 0.9rem; }
.mini-back {
  width: 18px; height: 26px; border-radius: 3px; border: 1px solid #fff;
  background: repeating-linear-gradient(45deg, #9b2226 0 4px, #ae2012 4px 8px);
}
.timer { width: 100%; height: 4px; background: rgba(255,255,255,0.15); border-radius: 2px; overflow: hidden; }
.timer > i { display: block; height: 100%; background: var(--accent); width: 100%; }

#center {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -40%);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  width: min(92%, 560px);
}
#center .pile { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; }
#center .pile .card { --cw: clamp(36px, 9vw, 58px); cursor: default; }
#center .pile.drop .card { animation: drop .25s ease-out; }
#center .who { font-size: 0.9rem; color: var(--muted); }
#center .chop { color: var(--danger); font-weight: 800; font-size: 1.1rem; }
@keyframes drop { from { transform: translateY(-20px) scale(1.1); opacity: 0; } to { transform: none; opacity: 1; } }

.panel {
  position: absolute; inset: 8px; margin: auto; max-width: 460px; height: fit-content; max-height: calc(100% - 16px);
  overflow: auto; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; z-index: 5;
}
.panel h3 { margin: 0; text-align: center; }
.panel .players { display: flex; flex-direction: column; gap: 6px; }
.panel .players > div { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; background: rgba(255,255,255,0.06); border-radius: 10px; }
.panel .row button { flex: 1; }
.panel .result-hand { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.panel .result-hand .card { --cw: 30px; cursor: default; }
.panel .winner { color: var(--accent); font-weight: 800; }

#me-bar { display: flex; justify-content: space-between; align-items: center; padding: 4px 12px; min-height: 28px; font-size: 0.9rem; }
#me-info.turn { color: var(--accent); font-weight: 700; }
#combo-hint { color: var(--muted); }
#combo-hint.bad { color: var(--danger); }
#combo-hint.good { color: #7dffb0; }

#hand {
  --n: 13;
  display: flex; justify-content: center; align-items: flex-end;
  padding: 18px 12px 6px; min-height: calc(var(--ch) + 24px);
  width: var(--hand-w); margin: 0 auto;
}
#hand .card + .card {
  margin-left: min(4px, calc((var(--hand-w) - 24px - var(--n) * var(--cw)) / (var(--n) - 1)));
}
#actions {
  display: flex; gap: 8px; justify-content: center; padding: 6px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
#actions button { flex: 1; max-width: 180px; padding: 12px 6px; min-width: 0; }

/* Lá bài */
.card {
  position: relative; flex: none; width: var(--cw); height: calc(var(--cw) * 1.42);
  background: var(--card-bg); color: var(--card-black); border-radius: calc(var(--cw) * 0.1);
  box-shadow: 0 2px 6px rgba(0,0,0,0.45); border: 1px solid #d9d4c5;
  cursor: pointer; user-select: none; transition: transform .12s;
  font-weight: 800; line-height: 1;
}
.card.red { color: var(--card-red); }
.card .r { position: absolute; top: 6%; left: 8%; font-size: calc(var(--cw) * 0.32); letter-spacing: -1px; }
.card .s { position: absolute; top: 34%; left: 8%; font-size: calc(var(--cw) * 0.26); }
.card .big { position: absolute; right: 8%; bottom: 6%; font-size: calc(var(--cw) * 0.5); }
#hand .card.sel { transform: translateY(-16px); box-shadow: 0 6px 14px rgba(0,0,0,0.5), 0 0 0 2px var(--accent); }
/* Chỉ hover trên máy có chuột; trên điện thoại :hover bị "dính" sau khi chạm làm lá bài lệch lên */
@media (hover: hover) and (pointer: fine) {
  #hand.myturn .card:not(.sel):hover { transform: translateY(-4px); }
}
.card.must { box-shadow: 0 0 0 2px var(--danger), 0 2px 6px rgba(0,0,0,0.45); }

/* Chat */
#chat {
  position: fixed; right: 12px; bottom: 90px; width: min(340px, calc(100vw - 24px)); height: 300px;
  background: rgba(0,0,0,0.85); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; z-index: 20;
}
#chat-log { flex: 1; overflow: auto; font-size: 0.92rem; display: flex; flex-direction: column; gap: 4px; }
#chat-log b { color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); margin-left: 2px; vertical-align: top; }

#toast {
  position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 50;
  background: rgba(0,0,0,0.85); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

@media (max-height: 520px) and (orientation: landscape) {
  :root { --cw: clamp(36px, 6vw, 56px); }
  #seat-left, #seat-right { top: 45%; }
  #hand { padding-top: 14px; }
}

/* Mã phòng trên thanh tiêu đề */
.room-head { display: flex; flex-direction: column; align-items: center; min-width: 0; line-height: 1.2; }
.room-head .title { max-width: 100%; }
.code-btn { background: rgba(255,255,255,0.12); border: 0; color: inherit; font-size: 0.75rem; padding: 2px 10px; border-radius: 99px; margin-top: 2px; letter-spacing: 1px; }
.panel .players .row { gap: 6px; }
.panel .players button.small { padding: 2px 8px; min-width: 0; flex: 0 0 auto; }

/* Bong bóng chat trên bàn */
.seat .bubble, #me-bubble {
  position: absolute; z-index: 8; max-width: 170px; width: max-content;
  background: #fff; color: #1d1d1d; font-size: 0.85rem; font-weight: 500; line-height: 1.3;
  padding: 6px 10px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  overflow-wrap: anywhere; animation: pop .18s ease-out;
}
.seat:has(.bubble) { z-index: 9; }
#seat-top .bubble { top: calc(100% + 6px); left: 50%; transform: translateX(-50%); }
#seat-left .bubble { left: 0; top: calc(100% + 6px); }
#seat-right .bubble { right: 0; top: calc(100% + 6px); }
#me-bubble { left: 50%; bottom: 6px; transform: translateX(-50%); }
#me-bubble.hidden { display: none; }
@keyframes pop { from { opacity: 0; scale: .85; } to { opacity: 1; scale: 1; } }

/* ================= Vũ trụ game (chọn game) ================= */
#screen-hub { background: radial-gradient(ellipse at 20% 0%, #3b2a7a 0%, transparent 55%), radial-gradient(ellipse at 90% 100%, #0f5a3f 0%, transparent 50%), #120f2b; }
.hub { width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.game-card {
  display: flex; align-items: center; gap: 16px; text-align: left; width: 100%;
  padding: 18px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.14); color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35); transition: transform .15s;
}
button.game-card:hover:not(:disabled) { transform: translateY(-2px); }
.game-card.tienlen { background: linear-gradient(135deg, #0f5a3f, #0b3d2e); }
.game-card.candy { background: linear-gradient(135deg, #c2185b, #6a1b9a); }
.game-card.soon { background: rgba(255,255,255,0.05); border-style: dashed; opacity: .7; }
.game-art { flex: none; width: 72px; height: 72px; border-radius: 18px; background: rgba(0,0,0,0.25); display: flex; align-items: center; justify-content: center; font-size: 2.6rem; gap: 2px; }
.game-art .cd.c0, .game-art .cd.c2, .game-art .cd.c4 { position: relative; width: 20px; height: 20px; translate: none; }
.game-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-weight: 400; }
.game-info b { font-size: 1.2rem; }
.game-info span { color: rgba(255,255,255,0.8); font-size: .92rem; }
.game-info .game-stat { color: var(--accent); font-weight: 600; }
.game-info .game-stat:empty { display: none; }

/* ================= Kẹo Ngọt ================= */
#screen-candy { height: 100dvh; background: radial-gradient(ellipse at 50% 0%, #f06292 0%, transparent 60%), linear-gradient(170deg, #8e24aa, #4a148c 70%); overflow: hidden; }
.candy-map { flex: 1; overflow: auto; width: 100%; max-width: 720px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(68px, 1fr)); gap: 12px; }
.level {
  aspect-ratio: 1; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 0;
  background: radial-gradient(circle at 35% 30%, #fff8 0 12%, transparent 13%), linear-gradient(160deg, #ff8ab8, #e91e63);
  border: 3px solid #fff6; color: #fff; box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.level .num { font-size: 1.3rem; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.level .stars { font-size: .75rem; color: #ffe066; letter-spacing: 1px; min-height: 1em; }
.level.done { background: radial-gradient(circle at 35% 30%, #fff8 0 12%, transparent 13%), linear-gradient(160deg, #ffd54f, #ff9800); }
.level.next { border-color: #fff; animation: pulse 1.4s ease-in-out infinite; }
.level.locked { background: rgba(255,255,255,.12); border-color: transparent; }
button.level:disabled { opacity: .55; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255,255,255,.25), 0 4px 10px rgba(0,0,0,.35); } }

#candy-play { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; }
.candy-hud { display: grid; grid-template-columns: 70px 1fr 1.1fr; gap: 8px; padding: 8px 12px 0; width: 100%; max-width: 560px; margin: 0 auto; }
.hud-box { background: rgba(0,0,0,.28); border-radius: 12px; padding: 6px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; }
.hud-box small { color: #f8bbd0; font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; }
.hud-box b { font-size: 1.25rem; }
#candy-goal { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.goal-item { display: flex; align-items: center; gap: 4px; }
.goal-item b { font-size: 1rem; }
.mini-jelly { display: inline-block; width: 18px; height: 18px; border-radius: 5px; background: #ff4fa3; box-shadow: inset 0 0 0 2px #fff6; }
.starbar { position: relative; width: 100%; height: 8px; background: rgba(255,255,255,.18); border-radius: 4px; margin-top: 4px; }
.starbar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffe066, #ffb300); border-radius: 4px; transition: width .3s; }
.starbar .tick { position: absolute; top: -5px; width: 0; height: 0; }
.starbar .tick::after { content: '★'; position: absolute; left: -7px; top: -3px; font-size: 13px; color: rgba(255,255,255,.4); }
.starbar .tick.got::after { color: #ffe066; text-shadow: 0 0 6px #ffb300; }

#candy-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 10px; position: relative; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
#candy-board {
  --rows: 8; --cols: 8;
  position: relative; aspect-ratio: var(--cols) / var(--rows);
  width: min(100%, 560px, calc((100dvh - 190px) * var(--cols) / var(--rows)));
  border-radius: 16px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 4px rgba(255,255,255,.18), 0 0 0 7px rgba(80,0,90,.45), 0 14px 30px rgba(0,0,0,.45);
}
#candy-board.shuffling .cd::before { animation: spin .5s ease-in-out; }
@keyframes spin { 50% { transform: scale(.4) rotate(180deg); } }

/* Ô nền + thạch. Vị trí đặt bằng `translate` để `scale`/`transform` dùng riêng cho hoạt ảnh (nảy, phồng, nổ). */
.tile, .cd, .fx {
  position: absolute; left: 0; top: 0;
  width: calc(100% / var(--cols)); height: calc(100% / var(--rows));
  translate: calc(var(--c) * 100%) calc(var(--r) * 100%);
}
.tile { background: rgba(40, 0, 70, .55); }
.tile.alt { background: rgba(70, 10, 100, .55); }
.tile.j1, .tile.j2 { box-shadow: inset 0 0 0 2px rgba(255,255,255,.3), inset 0 -6px 10px rgba(255,255,255,.12); border-radius: 18%; transition: background .3s; }
.tile.j1 { background: linear-gradient(160deg, rgba(255, 120, 190, .55), rgba(255, 50, 150, .45)); }
.tile.j2 { background: linear-gradient(160deg, rgba(255, 90, 170, .9), rgba(220, 20, 110, .85)); box-shadow: inset 0 0 0 3px rgba(255,255,255,.5), inset 0 -6px 10px rgba(255,255,255,.18); }

/* Kẹo: phần tử ngoài lo vị trí, ::before là thân kẹo (mỗi màu một hình), ::after là vệt bóng */
.cd {
  transition: translate var(--dur, .2s) var(--ease, cubic-bezier(.4,0,.2,1)) var(--delay, 0s), scale .15s;
  pointer-events: none; will-change: translate;
}
.cd::before, .cd::after { content: ''; position: absolute; inset: 9%; transition: transform .2s, opacity .2s; }
.cd::before {
  --base: #e53935; --hi: #ff8a80; --dk: #7f0000;
  background: radial-gradient(circle at 50% 38%, var(--hi) 0, var(--base) 55%, var(--dk) 100%);
}
.cd::after { background: radial-gradient(ellipse 34% 20% at 36% 27%, rgba(255,255,255,.9), rgba(255,255,255,0) 100%); }
.cd.c0::before { --base: #e8302a; --hi: #ff8a7a; --dk: #8e0b0b; border-radius: 50%; }
.cd.c1::before { --base: #fb7d10; --hi: #ffcc80; --dk: #a33f00; border-radius: 28%; inset: 12%; }
.cd.c2::before { --base: #fbc02d; --hi: #fff59d; --dk: #b57900; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); inset: 5%; }
.cd.c3::before { --base: #34a853; --hi: #a5e6a8; --dk: #0d5a22; clip-path: polygon(25% 6%, 75% 6%, 100% 50%, 75% 94%, 25% 94%, 0 50%); }
.cd.c4::before { --base: #1e88e5; --hi: #90caf9; --dk: #0b3c8c; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%; inset: 8% 16%; }
.cd.c5::before { --base: #9c27b0; --hi: #e1a6ef; --dk: #4a0a63; clip-path: polygon(50% 4%, 97% 88%, 3% 88%); inset: 6%; }
.cd.c0::before, .cd.c1::before, .cd.c4::before { box-shadow: 0 3px 3px rgba(0,0,0,.35), inset 0 -3px 5px rgba(0,0,0,.25), inset 0 2px 3px rgba(255,255,255,.35); }
.cd.s-h::before { background: repeating-linear-gradient(0deg, rgba(255,255,255,.85) 0 2px, transparent 2px 7px), radial-gradient(circle at 50% 38%, var(--hi), var(--base) 55%, var(--dk)); }
.cd.s-v::before { background: repeating-linear-gradient(90deg, rgba(255,255,255,.85) 0 2px, transparent 2px 7px), radial-gradient(circle at 50% 38%, var(--hi), var(--base) 55%, var(--dk)); }
.cd.s-wrap::after { inset: 3%; border: 3px solid #fff; border-radius: 30%; box-shadow: 0 0 10px #fff, inset 0 0 8px #fff; animation: glow 1s ease-in-out infinite alternate; }
.cd.bomb::before {
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, rgba(255,255,255,.8) 0 8%, transparent 20%), radial-gradient(circle, #3e2723 0 30%, transparent 32%),
    conic-gradient(#e53935, #ff9800, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935);
  animation: spinslow 3s linear infinite;
}
.cd.bomb::before { box-shadow: 0 0 8px rgba(255,255,255,.8); }
@keyframes spinslow { to { transform: rotate(360deg); } }
@keyframes glow { to { opacity: .55; } }
.cd.sel { scale: 1.12; z-index: 2; filter: drop-shadow(0 0 6px #fff); }
.cd.sel::before { animation: bob .6s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-6%) scale(1.04); } }
.cd.hint::before { animation: wiggle .5s ease-in-out infinite; }
@keyframes wiggle { 25% { transform: rotate(-12deg) scale(1.08); } 75% { transform: rotate(12deg) scale(1.08); } }
.cd.pop { z-index: 2; }
.cd.pop::before, .cd.pop::after { animation: none; }
.cd.mini { position: relative; display: inline-block; width: 22px; height: 22px; translate: none; filter: none; }

/* Hiệu ứng */
.fx { pointer-events: none; z-index: 3; }
.fx-h { width: 100%; background: linear-gradient(180deg, transparent, rgba(255,255,255,.95) 40% 60%, transparent); box-shadow: 0 0 18px #fff59d, 0 0 6px #fff; }
.fx-v { height: 100%; background: linear-gradient(90deg, transparent, rgba(255,255,255,.95) 40% 60%, transparent); box-shadow: 0 0 18px #fff59d, 0 0 6px #fff; }
.fx-ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 20px #ffeb3b, inset 0 0 14px #ffeb3b; animation: ring .8s ease-out forwards; }
.fx-ring.big::before { animation-name: ringbig; }
.fx-ring.rainbow::before { border-color: transparent; background: conic-gradient(#ff5a4f, #ffd93b, #4cd964, #3fa9ff, #c86bff, #ff5a4f) border-box;
  -webkit-mask: radial-gradient(circle, transparent 55%, #000 58%); mask: radial-gradient(circle, transparent 55%, #000 58%); animation-duration: 1.15s; }
.fx-glow.big::before { inset: -110%; }
.zap { position: absolute; height: 4px; margin-top: -2px; transform-origin: 0 50%; pointer-events: none; z-index: 4; border-radius: 2px;
  background: linear-gradient(90deg, #fff, #fff59d 60%, #fff); box-shadow: 0 0 8px #fff59d, 0 0 3px #fff; }
.fx-flash { width: 100%; height: 100%; translate: none; background: radial-gradient(circle, rgba(255,255,255,.95), rgba(255,235,59,.35)); animation: fxfade .9s ease-out forwards; }
.fx-glow::before { content: ''; position: absolute; inset: -30%; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.95), rgba(255,241,118,.5) 40%, transparent 70%); animation: glowburst .7s ease-out forwards; }
.fx-score {
  display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; font-size: clamp(14px, 4vw, 22px);
  text-shadow: 0 2px 0 var(--sc, #ad1457), 0 0 6px var(--sc, #ad1457); animation: floatup .8s ease-out forwards; overflow: visible; white-space: nowrap; z-index: 5;
}
.pt { position: absolute; border-radius: 50%; pointer-events: none; z-index: 4; box-shadow: 0 0 4px rgba(255,255,255,.6); }
.pt.star { border-radius: 0; clip-path: polygon(50% 0, 61% 38%, 100% 50%, 61% 62%, 50% 100%, 39% 62%, 0 50%, 39% 38%); box-shadow: none; }
.fx-word {
  position: absolute; left: 50%; top: 45%; z-index: 6; pointer-events: none; white-space: nowrap;
  font-size: clamp(28px, 9vw, 54px); font-weight: 900; color: #fff59d;
  -webkit-text-stroke: 1.5px #880e4f;
  text-shadow: 0 4px 0 #c2185b, 0 0 18px #ff4081, 0 8px 14px rgba(0,0,0,.45);
  animation: word 1.05s cubic-bezier(.2,.8,.3,1) forwards;
}
@keyframes fxfade { from { opacity: .9; } to { opacity: 0; } }
@keyframes ring { from { transform: scale(.6); opacity: 1; } to { transform: scale(3.2); opacity: 0; } }
@keyframes ringbig { from { transform: scale(.6); opacity: 1; } to { transform: scale(5.5); opacity: 0; } }
@keyframes glowburst { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.4); opacity: 0; } }
@keyframes floatup { 0% { transform: scale(.4); opacity: 0; } 20% { transform: scale(1.25); opacity: 1; } 40% { transform: scale(1); } 100% { transform: translateY(-80%); opacity: 0; } }
@keyframes word {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-8deg); opacity: 0; }
  22% { transform: translate(-50%, -50%) scale(1.2) rotate(3deg); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(.95) rotate(-1deg); }
  75% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -90%) scale(1.05); opacity: 0; }
}

#candy-modal { text-align: center; z-index: 10; animation: modalin .35s cubic-bezier(.2,.9,.3,1.3); }
@keyframes modalin { from { transform: scale(.7); opacity: 0; } }
#candy-modal .big-stars { font-size: 3rem; letter-spacing: 6px; display: flex; justify-content: center; gap: 4px; }
#candy-modal .big-stars span { color: rgba(255,255,255,.25); display: inline-block; }
#candy-modal .big-stars span.on { color: #ffe066; text-shadow: 0 0 12px #ffb300; animation: starin .5s cubic-bezier(.2,.9,.3,1.5) backwards; }
@keyframes starin { from { transform: scale(2.6) rotate(-90deg); opacity: 0; } }
.candy-tools { display: flex; align-items: center; gap: 2px; }
.candy-tools button.off { opacity: .45; text-decoration: line-through; }
#candy-modal .result-score { font-size: 1.2rem; font-weight: 700; }
.chapter-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 6px 2px -4px; }
.chapter-head b { font-size: 1.05rem; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.chapter-head span { color: #f8bbd0; font-size: .85rem; }
.chapter-head.locked { opacity: .55; }
#candy-levels { display: flex; flex-direction: column; gap: 14px; }
.level.done .stars { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
