/* Rangoli Match — festival nights on the Khel ON look. */
:root {
  --desk: #141721; --panel: #20253a; --panel-2: #2a3049; --line: #363d5c; --ink: #f5f3ff; --muted: #a9abc6;
  --orange: #ff9a3c; --pink: #f04fa8; --violet: #8b5cf6; --teal: #2fd4c8; --gold: #ffc23d;
  --acc: #ffb13c; --fbg: #2a1840; --frame: #7a4a1a;
  --grad: linear-gradient(100deg, var(--orange), var(--pink) 50%, var(--violet));
  --display: "Outfit", "Trebuchet MS", system-ui, sans-serif; --body: "Nunito", "Segoe UI", system-ui, sans-serif;
  --cs: 44px;
  color-scheme: dark;
}
[hidden] { display: none !important; }
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: hidden; }
body { background: var(--desk); color: var(--ink); font-family: var(--body); font-size: 16px; -webkit-tap-highlight-color: transparent; min-height: 100vh; -webkit-user-select: none; user-select: none; overflow-x: hidden; }
body.playing { background: radial-gradient(90% 60% at 50% 0%, color-mix(in srgb, var(--fbg) 90%, transparent), transparent 75%), var(--desk); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, .board:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 10px; }
h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
p { margin: 0; }
svg { display: block; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 20px; border-radius: 999px; font-family: var(--display); font-weight: 800; font-size: 17px; color: var(--ink); white-space: nowrap; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 18px rgba(240, 79, 168, .28); }
.btn.teal { background: var(--teal); color: #08221f; }
.btn.ghost { border: 2px solid var(--line); }

/* ---------- the festival map ---------- */
.map { max-width: 960px; margin: 0 auto; padding: 14px 16px 60px; display: flex; flex-direction: column; gap: 18px; }
.ptop { display: flex; gap: 14px; align-items: flex-start; }
.ptop h1 { font-size: clamp(26px, 4.4vw, 38px); font-weight: 800; }
.ptop .sub { color: var(--muted); font-weight: 700; margin-top: 4px; }
.back { min-height: 44px; padding: 8px 14px; border-radius: 12px; border: 2px solid var(--line); font-weight: 800; white-space: nowrap; }
.festsec { border-radius: 22px; overflow: hidden; background: var(--fb, #2a1840); border: 1px solid rgba(255, 255, 255, .08); margin-bottom: 16px; }
.festsec.locked { opacity: .55; }
.fhead { position: relative; padding: 12px 16px 10px; }
.fhead svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .38; }
.fhead h2, .fhead p { text-shadow: 0 1px 3px rgba(0,0,0,.9), 0 0 10px rgba(0,0,0,.6); }
.fhead h2 { position: relative; font-size: 24px; color: var(--fa, #ffb13c); }
.fhead p { position: relative; color: #e2e1f3; font-weight: 700; font-size: 14px; }
.fhead .fst { position: relative; color: var(--gold); font-weight: 900; font-size: 13px; margin-top: 2px; }
.lgrid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; padding: 12px; background: rgba(0, 0, 0, .22); }
@media (min-width: 700px) { .lgrid { grid-template-columns: repeat(10, minmax(0, 1fr)); } }
.lv { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 74px; border-radius: 50%; aspect-ratio: 1; background: #20253a; border: 2px solid rgba(255, 255, 255, .12); max-width: 76px; width: 100%; margin: 0 auto; }
.lv b { font-family: var(--display); font-size: 20px; line-height: 1; }
.lv .st { font-size: 11px; letter-spacing: 1px; color: #4a5070; line-height: 1; }
.lv .st .on { color: var(--gold); }
.lv .gi { width: 20px; height: 20px; }
.lv .gi svg { width: 100%; height: 100%; }
.lv.next { border-color: var(--fa, #ffb13c); box-shadow: 0 0 0 4px color-mix(in srgb, var(--fa, #ffb13c) 30%, transparent); }
.lv.next::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--fa, #ffb13c); animation: nextp 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes nextp { 0% { transform: scale(.92); opacity: .9; } 100% { transform: scale(1.12); opacity: 0; } }
.lv.done { background: #2a3049; }
.lv.locked { opacity: .45; cursor: default; }
.lv.locked svg { width: 18px; height: 18px; }

/* ---------- playing ---------- */
.play { max-width: 600px; margin: 0 auto; padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: calc(100vh - var(--kd-h, 68px)); min-height: calc(100dvh - var(--kd-h, 68px)); }
.hud { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }
.hud-l { display: flex; flex-direction: column; min-width: 0; }
.hud-l b { font-family: var(--display); font-size: 21px; font-weight: 800; color: var(--acc); line-height: 1.1; }
.hud-l span { color: var(--muted); font-weight: 800; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-r { display: flex; gap: 6px; flex: none; }
.pill { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-weight: 900; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: center; }
.pill.moves::after { content: " moves"; font-size: 12px; color: var(--muted); }
.pill.moves.low { background: #5a1f2c; border-color: #ff6b7a; }
.pill.score::after { content: " pts"; font-size: 12px; color: var(--muted); }
.goalrow { display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px 10px; }
.goal { display: flex; gap: 10px; align-items: center; }
.gic { width: 38px; height: 38px; flex: none; }
.gic svg { width: 100%; height: 100%; }
.gtx { display: flex; flex-direction: column; min-width: 0; }
.gtx b { font-family: var(--display); font-size: 16px; line-height: 1.15; }
.gtx small { color: var(--muted); font-weight: 800; font-size: 13px; }
.goal.met small { color: var(--teal); }
.goal.bump .gic { animation: bump .35s; }
@keyframes bump { 50% { transform: scale(1.25); } }
.sbar { position: relative; height: 8px; border-radius: 99px; background: #2a3049; margin: 4px 8px 2px; }
.sbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--grad); width: 0; transition: width .3s; }
.sbar .ss { position: absolute; top: 50%; transform: translate(-50%, -50%); font-size: 15px; color: #4a5070; line-height: 1; text-shadow: 0 0 3px #141721; }
.sbar .ss.on { color: var(--gold); }
.fest { height: 34px; margin: -2px 0 -6px; }
.fest svg { width: 100%; height: 100%; }
.boardwrap { display: flex; justify-content: center; align-items: center; flex: 1 1 auto; padding-bottom: 4vh; }
.board { position: relative; width: min(calc(100vw - 16px), 584px, calc(100vh - var(--kd-h, 68px) - 196px)); width: min(calc(100vw - 16px), 584px, calc(100dvh - var(--kd-h, 68px) - 196px)); min-width: min(calc(100vw - 16px), 288px); aspect-ratio: 1; border-radius: 18px; background: #1a1430; border: 4px solid var(--frame); box-shadow: 0 16px 40px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(255, 255, 255, .06); overflow: hidden; touch-action: none; box-sizing: content-box; }
.cells, .chalks, .tiles, .fx { position: absolute; inset: 0; }
.cells { display: grid; grid-template-columns: repeat(8, 1fr); }
.cells i { border: 1px solid rgba(255, 255, 255, .035); }
.cells i:nth-child(16n+1), .cells i:nth-child(16n+3), .cells i:nth-child(16n+5), .cells i:nth-child(16n+7), .cells i:nth-child(16n+10), .cells i:nth-child(16n+12), .cells i:nth-child(16n+14), .cells i:nth-child(16n+16) { background: rgba(255, 255, 255, .035); }
.chalk, .tile { position: absolute; left: 0; top: 0; width: var(--cs); height: var(--cs); transform: translate(calc(var(--x) * var(--cs)), calc(var(--y) * var(--cs))); }
.chalk svg { width: 100%; height: 100%; }
.chalk.hit { animation: chalkhit .35s; }
@keyframes chalkhit { 40% { transform: translate(calc(var(--x) * var(--cs)), calc(var(--y) * var(--cs))) scale(.82); filter: brightness(1.6); } }
.chalk.gone { opacity: 0; transition: opacity .3s; }
.tile { transition-property: transform; transition-timing-function: cubic-bezier(.35, 0, .6, 1.15); will-change: transform; }
.tile .in { width: 100%; height: 100%; padding: 6%; transition: transform .15s, opacity .2s; }
.tile svg { width: 100%; height: 100%; overflow: visible; }
.tile.sel .in { transform: scale(1.12); filter: drop-shadow(0 0 6px #fff); }
.tile.sel::before { content: ""; position: absolute; inset: 3%; border-radius: 22%; border: 3px solid #fff; box-shadow: 0 0 12px rgba(255, 255, 255, .6); }
.tile.hint .in { animation: hint 1s ease-in-out infinite; }
@keyframes hint { 25% { transform: rotate(-9deg) scale(1.08); } 75% { transform: rotate(9deg) scale(1.08); } }
.tile.pop .in { transform: scale(1.35); opacity: 0; transition: transform .24s ease-out, opacity .24s ease-in; }
.tile.made .in { animation: made .4s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes made { from { transform: scale(.3); } }
.tile.collect .in { transform: translateY(40%) scale(.4); opacity: 0; transition: transform .45s ease-in, opacity .45s; }
.tile .spin { transform-origin: 50px 50px; animation: spin 2.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tile .fz { animation: fz .7s ease-in-out infinite alternate; }
@keyframes fz { to { opacity: .55; } }
.cursor { position: absolute; left: 0; top: 0; width: var(--cs); height: var(--cs); border: 3px dashed var(--teal); border-radius: 22%; transform: translate(calc(var(--x) * var(--cs)), calc(var(--y) * var(--cs))); pointer-events: none; }
.fx { pointer-events: none; }
.spark { position: absolute; width: 8px; height: 8px; margin: -4px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 8px var(--c, #fff); animation: spark .55s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }
.beam { position: absolute; background: linear-gradient(90deg, transparent, #fff8c8 20%, #fff 50%, #fff8c8 80%, transparent); box-shadow: 0 0 18px #ffd23c; border-radius: 99px; animation: beam .38s ease-out forwards; }
.beam.v { background: linear-gradient(180deg, transparent, #fff8c8 20%, #fff 50%, #fff8c8 80%, transparent); }
@keyframes beam { from { opacity: 1; } to { opacity: 0; } }
.ring { position: absolute; border-radius: 50%; border: 6px solid #ffd23c; box-shadow: 0 0 22px #ff9a3c, inset 0 0 22px #ff9a3c; animation: ring .45s ease-out forwards; }
@keyframes ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.swirl { position: absolute; inset: 0; background: conic-gradient(from 0deg, rgba(255, 138, 31, .35), rgba(255, 95, 174, .35), rgba(255, 194, 26, .35), rgba(63, 184, 255, .35), rgba(60, 207, 110, .35), rgba(169, 121, 255, .35), rgba(255, 138, 31, .35)); animation: swirl .6s ease-out forwards; }
@keyframes swirl { from { opacity: 0; transform: rotate(-90deg) scale(.4); } 40% { opacity: 1; } to { opacity: 0; transform: rotate(90deg) scale(1.4); } }
.chain { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-family: var(--display); font-weight: 800; font-size: 34px; color: #fff; text-shadow: 0 3px 0 #b03a7a, 0 0 18px rgba(240, 79, 168, .8); white-space: nowrap; animation: chain .8s ease-out forwards; z-index: 3; }
@keyframes chain { 0% { transform: translate(-50%, -50%) scale(.4); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; } 70% { opacity: 1; } to { transform: translate(-50%, -90%); opacity: 0; } }
.board.shake { animation: bshake .3s; }
@keyframes bshake { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
.msg { text-align: center; color: var(--muted); font-weight: 800; font-size: 14px; min-height: 20px; }
body.paused .play *, body.paused .play *::before { animation-play-state: paused !important; }

@media (max-height: 700px) { .goalrow { padding: 5px 8px; gap: 3px; } .gic { width: 30px; height: 30px; } .fest { height: 22px; } .play { gap: 6px; padding-top: 6px; } .board { width: min(calc(100vw - 16px), 584px, calc(100dvh - var(--kd-h, 68px) - 172px)); } }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 2147483000; background: rgba(8, 10, 18, .72); display: grid; place-items: center; padding: 14px; }
.box { width: min(480px, 100%); max-height: calc(100vh - 28px); overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.box h2 { font-size: 25px; font-weight: 800; }
.box p { color: #d2d1e8; line-height: 1.5; }
.box .small, .small { font-size: 13px; color: var(--muted); }
.box .kick { color: var(--acc); font-weight: 800; font-size: 14px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.btns.col { flex-direction: column; align-items: stretch; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; line-height: 1.45; color: #d2d1e8; }
.fw { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fw div { background: #2a3049; border-radius: 14px; padding: 8px 6px; text-align: center; }
.fw svg { width: 44px; height: 44px; margin: 0 auto 4px; }
.fw b { display: block; font-family: var(--display); font-size: 15px; }
.fw small { display: block; color: var(--muted); font-weight: 700; font-size: 12px; line-height: 1.3; }
.goalcard { display: flex; gap: 12px; align-items: center; background: #2a3049; border-radius: 16px; padding: 12px; }
.goalcard svg { width: 54px; height: 54px; flex: none; }
.goalcard b { font-family: var(--display); font-size: 19px; display: block; }
.goalcard small { color: var(--muted); font-weight: 800; }
.box.win { text-align: center; }
.win-stars { display: flex; justify-content: center; gap: 8px; font-size: 52px; line-height: 1; }
.win-stars span { color: #3a4060; }
.win-stars span.on { color: var(--gold); animation: starin .5s cubic-bezier(.2, 1.6, .4, 1) both; text-shadow: 0 0 20px rgba(255, 194, 61, .5); }
@keyframes starin { from { transform: scale(0) rotate(-40deg); } }
.toast { position: fixed; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 92px); transform: translateX(-50%); z-index: 2147483100; background: #f5f3ff; color: #141721; font-weight: 800; padding: 10px 18px; border-radius: 999px; box-shadow: 0 10px 30px rgba(0, 0, 0, .4); max-width: calc(100vw - 32px); text-align: center; pointer-events: none; }
@media (max-width: 640px) { .scrim { align-items: end; padding: 0; } .box { width: 100%; border-radius: 24px 24px 0 0; max-height: 92vh; padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .spark, .chain { display: none; }
}
