/* فرّامة الألوان — candy-factory look: a dark tray with glossy cubes, toothed colour grinders spinning on the edges */
:root { --ink: #fff; --muted: #e6dcff; --card: rgba(30, 18, 64, .88); --line: rgba(255, 255, 255, .14); --gold: #ffd23f; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: #1d1240; }
body { min-height: 100vh; color: var(--ink); font-family: "Baloo Bhaijaan 2", system-ui, sans-serif; overflow-x: hidden;
  background: radial-gradient(circle at 15% 10%, #ff5d8f33, transparent 40%), radial-gradient(circle at 90% 85%, #4cc9f033, transparent 45%), linear-gradient(160deg, #2b1a55, #1d1240 60%, #13102f); }
.page { max-width: 560px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 14px calc(20px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.icon { width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); font-size: 20px; }
.card { margin-top: 12px; padding: 16px; border-radius: 26px; background: var(--card); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0, 0, 0, .4); }
.home { text-align: center; }
.home-art { width: min(240px, 66%); aspect-ratio: 1; border-radius: 26px; object-fit: cover; box-shadow: 0 10px 26px rgba(0, 0, 0, .5); }
.home h1 { margin: 8px 0 0; font-size: 40px; background: linear-gradient(90deg, #ff5d8f, #ffd23f, #4cc9f0, #7ae582); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home p { margin: 2px 0 8px; color: var(--muted); font-weight: 600; }
.stars-line b { color: var(--gold); }
.how { text-align: right; margin: 10px 0 0; padding: 10px 14px; list-style: none; border-radius: 16px; background: rgba(0, 0, 0, .25); line-height: 1.9; font-weight: 600; font-size: 14.5px; }
.btn { display: block; width: 100%; margin-top: 10px; border: 0; border-radius: 18px; padding: 13px; font-weight: 800; font-size: 19px; }
.btn-main { background: linear-gradient(135deg, #ff5d8f, #ff9a3c); color: #fff; box-shadow: 0 5px 0 #9c2f55; text-shadow: 0 1px 2px #0005; }
.btn-main:active { transform: translateY(3px); box-shadow: 0 2px 0 #9c2f55; }
.btn-ghost { background: rgba(255, 255, 255, .1); border: 1px solid var(--line); }
.map-head { display: flex; align-items: center; gap: 10px; }
.map-head h2 { flex: 1; margin: 0; font-size: 26px; color: var(--gold); }
.total { font-weight: 800; background: rgba(0, 0, 0, .3); padding: 4px 12px; border-radius: 999px; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.lv { aspect-ratio: 1; border: 0; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: inset 0 -4px 0 #0003, 0 3px 0 #0004; font-weight: 800; }
.lv b { font-size: 21px; line-height: 1; text-shadow: 0 2px 2px #0004; }
.lv small { font-size: 10px; letter-spacing: -1px; min-height: 13px; }
.lv.lock { background: rgba(255, 255, 255, .1); box-shadow: none; color: #fff9; }
body.playing .page { display: none; }
.play { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.hud { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.hbtn { flex: none; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); font-size: 22px; font-weight: 800; }
.hmid { flex: 1; text-align: center; line-height: 1.25; }
.hmid > b { display: block; font-size: 18px; color: var(--gold); }
.hmid small { font-size: 13px; color: var(--muted); font-weight: 700; }
.hmid small b { color: #fff; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 6px; touch-action: none; user-select: none; -webkit-user-select: none; }
.board { position: relative; border-radius: 22px; background: linear-gradient(160deg, #3a2a6e, #261a4f); box-shadow: inset 0 0 0 3px #ffffff1a, inset 0 8px 24px #0006, 0 18px 40px -12px #000a; }
.cell { position: absolute; border-radius: 9px; background: #ffffff0a; box-shadow: inset 0 0 0 1px #ffffff0d; }
/* grinders on the edges: a coloured frame with teeth that keep turning */
.grinder { position: absolute; z-index: 1; border-radius: 10px; overflow: hidden; background: var(--g);
  box-shadow: 0 0 0 2px #0006, 0 0 14px var(--g), inset 0 2px 0 #ffffff66, inset 0 -3px 0 #0004; }
.grinder::before { content: ""; position: absolute; inset: 3px; border-radius: 7px; opacity: .55;
  background: repeating-linear-gradient(90deg, #0000 0 6px, #0008 6px 8px, #fff6 8px 9px, #0000 9px 14px); animation: teeth .6s linear infinite; }
.grinder.v::before { background: repeating-linear-gradient(0deg, #0000 0 6px, #0008 6px 8px, #fff6 8px 9px, #0000 9px 14px); animation-name: teethV; }
@keyframes teeth { to { background-position: 14px 0; } }
@keyframes teethV { to { background-position: 0 14px; } }
.grinder.eat { animation: eat .45s ease; }
@keyframes eat { 25% { filter: brightness(1.6); transform: scale(1.06); } }
/* pieces: glossy candy cubes */
.piece { position: absolute; z-index: 3; transition: transform .09s ease-out; will-change: transform; }
.piece .bk { position: absolute; border-radius: 11px;
  background: radial-gradient(circle at 30% 25%, #ffffffb3 0 8%, #fff0 22%), linear-gradient(160deg, color-mix(in srgb, var(--c) 78%, #fff), var(--c) 55%, color-mix(in srgb, var(--c) 70%, #000));
  box-shadow: inset 0 -5px 0 #0003, inset 0 3px 0 #ffffff55, 0 4px 0 color-mix(in srgb, var(--c) 55%, #000), 0 8px 12px -6px #000a; }
.piece .ar { position: absolute; z-index: 2; display: grid; place-items: center; color: #fff; font-size: 22px; font-weight: 900; text-shadow: 0 2px 2px #0006; pointer-events: none; }
.piece.drag { z-index: 6; filter: brightness(1.08); }
.piece.out { transition: transform .38s cubic-bezier(.5, 0, .9, .5), opacity .38s; opacity: 0; }
.piece.nope { animation: nope .25s; }
@keyframes nope { 30% { translate: 4px 0; } 60% { translate: -4px 0; } }
.bit { position: absolute; z-index: 8; width: 9px; height: 9px; border-radius: 3px; pointer-events: none; animation: bit .7s ease-out forwards; }
@keyframes bit { to { transform: translate(var(--dx), var(--dy)) rotate(260deg) scale(.3); opacity: 0; } }
.hint { margin: 0; padding: 6px 14px 12px; text-align: center; font-weight: 700; color: var(--muted); font-size: 14px; }
.overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 6, 25, .78); }
.modal { width: min(380px, 100%); padding: 18px 16px; border-radius: 24px; background: #2b1d5a; border: 1px solid var(--line); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, .55); }
.modal h2 { margin: 0 0 6px; color: var(--gold); }
.modal p { margin: 4px 0; font-weight: 700; }
.res-stars { font-size: 44px; letter-spacing: 6px; }
.res-stars i { font-style: normal; display: inline-block; animation: starIn .5s cubic-bezier(.3, 1.8, .5, 1) backwards; }
.res-stars i:nth-child(2) { animation-delay: .25s; } .res-stars i:nth-child(3) { animation-delay: .5s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.sinan-credit { text-align: center; margin-top: 18px; color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.sinan-credit b { color: var(--gold); }
