/* Khel ON Laddoo Line (four in a row) */
:root {
  --navy: #141721;
  --navy2: #1d2131;
  --navy3: #272c40;
  --ink: #f4f2fb;
  --muted: #a9aec4;
  --orange: #ff9a3c;
  --pink: #f04fa8;
  --purple: #8b5cf6;
  --teal: #2fd4c8;
  --gold: #ffd257;
  --grad: linear-gradient(100deg, #ff9a3c 0%, #f04fa8 52%, #8b5cf6 100%);
  --box: #5b3fb8;
  --box-edge: #4a2f9e;
  --hole: #11131c;
  --radius: 18px;
  --head: 'Outfit', 'Lilita One', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --laddoo: radial-gradient(circle at 30% 26%, rgba(255,255,255,.55) 0 8%, transparent 9%),
            radial-gradient(circle at 62% 38%, #ffd08a 0 5%, transparent 6%),
            radial-gradient(circle at 40% 64%, #ffd08a 0 5%, transparent 6%),
            radial-gradient(circle at 70% 70%, #e9741c 0 6%, transparent 7%),
            radial-gradient(circle at 24% 50%, #e9741c 0 5%, transparent 6%),
            radial-gradient(circle at 54% 18%, #e9741c 0 4%, transparent 5%),
            radial-gradient(circle at 36% 32%, #ffc06f, #ff9a3c 52%, #cf5d12);
  --peda: radial-gradient(ellipse 14% 8% at 50% 50%, #4f9a3a 0 60%, transparent 64%),
          radial-gradient(circle at 50% 50%, transparent 0 30%, rgba(0,0,0,.14) 31% 34%, transparent 35%),
          radial-gradient(circle at 32% 26%, rgba(255,255,255,.55) 0 8%, transparent 9%),
          radial-gradient(circle at 36% 32%, #b7fff4, #2fd4c8 52%, #128f87);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--navy); color: var(--ink); }
body { font-family: var(--body); font-size: 16px; line-height: 1.45; -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

#app { max-width: 620px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); }

/* Top bar */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 0 8px; }
.home-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-weight: 800; font-size: 15px; justify-self: start; padding: 8px 6px 8px 0; min-height: 44px; }
.home-link svg { width: 20px; height: 20px; }
.home-link:hover, .home-link:focus-visible { color: var(--ink); }
.title { margin: 0; font-family: var(--head); font-weight: 800; font-size: 24px; letter-spacing: .3px; white-space: nowrap; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.icon-btn { justify-self: end; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--navy2); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .snd-off { display: none; }
.icon-btn[aria-pressed="false"] .snd-on { display: none; }
.icon-btn[aria-pressed="false"] .snd-off { display: block; color: var(--muted); }

.screen { display: none; flex: 1; flex-direction: column; gap: 14px; }
.screen.active { display: flex; }

/* Menu */
.hero { text-align: center; padding: 6px 0 2px; }
.hero-box { width: 168px; margin: 6px auto 12px; padding: 10px; border-radius: 18px; background: var(--box); display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  box-shadow: inset 0 -5px 0 var(--box-edge), 0 12px 30px rgba(139, 92, 246, .35); transform: rotate(-4deg); }
.hb { aspect-ratio: 1; border-radius: 50%; background: var(--hole); }
.hb.l { background: var(--laddoo); }
.hb.p { background: var(--peda); }
.hb.e { animation: heroDrop 2.6s ease-in infinite; background: var(--laddoo); }
@keyframes heroDrop { 0%, 30% { transform: translateY(-120%); opacity: 0; } 45% { transform: translateY(0); opacity: 1; } 52% { transform: translateY(-14%); } 60%, 100% { transform: translateY(0); } }
.tagline { margin: 0 0 4px; font-family: var(--head); font-size: 20px; font-weight: 700; }
.stars-total { color: var(--muted); font-weight: 700; }
.stars-total b { color: var(--ink); }
.star-ico { color: var(--gold); }
.link-btn { background: none; border: 0; padding: 6px 2px; color: var(--teal); font-weight: 800; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn b { color: var(--teal); }
.resume { box-shadow: inset 0 0 0 2px var(--teal); }

.card { background: var(--navy2); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.slim { padding: 10px 16px; }
.card h2 { margin: 0; font-family: var(--head); font-size: 20px; }
.card h3 { margin: 0 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.mode-note { margin: -4px 0 0; color: var(--muted); font-size: 14px; min-height: 1.4em; }

.seg { display: flex; gap: 6px; background: var(--navy); border-radius: 14px; padding: 4px; }
.seg button { flex: 1; min-width: 0; min-height: 46px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 800; cursor: pointer; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; }
.seg button small { font-weight: 700; font-size: 11px; opacity: .85; }
.seg button[aria-checked="true"] { background: var(--navy3); color: var(--ink); box-shadow: inset 0 0 0 2px var(--teal); }
.lvstars { color: var(--gold); letter-spacing: 1px; min-height: 13px; }

.toggles { gap: 4px; display: flex; flex-direction: column; }
.tog { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 700; }
.tog input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tog .sw { width: 46px; height: 28px; border-radius: 14px; background: var(--navy3); position: relative; flex: none; transition: background .2s; }
.tog .sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tog input:checked + .sw { background: var(--teal); }
.tog input:checked + .sw::after { transform: translateX(18px); }
.tog input:focus-visible + .sw { outline: 3px solid var(--orange); outline-offset: 2px; }

.btn { border: 0; border-radius: 14px; min-height: 48px; padding: 10px 18px; font-weight: 800; font-size: 17px; cursor: pointer; width: 100%; }
.btn.big { min-height: 56px; font-size: 20px; font-family: var(--head); }
.btn.grad { background: var(--grad); color: #fff; box-shadow: 0 6px 20px rgba(240, 79, 168, .35); }
.btn.ghost { background: var(--navy3); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.fine { text-align: center; color: var(--muted); font-size: 13px; margin: 2px 0 8px; }

/* Game */
#game { gap: 10px; justify-content: center; }
.players { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.strip { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 4px 10px; border-radius: 12px; background: var(--navy2); transition: box-shadow .2s, opacity .2s; min-width: 0; opacity: .7; }
#stripB { justify-content: flex-end; }
.strip.turn { box-shadow: inset 0 0 0 2px var(--teal); opacity: 1; }
.strip b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; line-height: 1.1; }
.strip b small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; }
#stripB b { text-align: right; }
.strip .score { font-family: var(--head); font-weight: 800; color: var(--gold); margin-left: auto; }
#stripB .score { margin-left: 0; margin-right: auto; }
.sweet { width: 24px; height: 24px; border-radius: 50%; flex: none; }
.sweet.l { background: var(--laddoo); }
.sweet.p { background: var(--peda); }

.board-wrap { position: relative; width: 100%; max-width: min(100%, calc((100dvh - 330px) * 7 / 6), 560px); min-width: 288px; margin: 0 auto; align-self: center; }
@supports not (height: 100dvh) { .board-wrap { max-width: min(100%, calc((100vh - 330px) * 7 / 6), 560px); } }
.drop-row { position: relative; aspect-ratio: 7 / 1; width: 100%; }
.dropper { position: absolute; top: 8%; width: calc(100% / 7); height: 84%; border-radius: 50%; opacity: 0; transition: left .12s ease-out, opacity .15s; pointer-events: none; transform: scale(.82); }
.dropper.on { opacity: .85; }
.dropper.l { background: var(--laddoo); }
.dropper.p { background: var(--peda); }
.board { position: relative; width: 100%; aspect-ratio: 7 / 6; border-radius: 14px; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.cells, .discs, .frame, .cols { position: absolute; inset: 0; }
.cells { border-radius: 14px; background: var(--hole); overflow: hidden; }
.discs { overflow: hidden; border-radius: 14px; }
.frame { border-radius: 14px; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, transparent 0 37%, rgba(0,0,0,.35) 37.5% 40%, var(--box) 40.5%) 0 0 / calc(100% / 7) calc(100% / 6);
  box-shadow: 0 0 0 5px var(--box), inset 0 -4px 0 rgba(0,0,0,.18), 0 16px 40px rgba(0, 0, 0, .5); }
.cols { display: grid; grid-template-columns: repeat(7, 1fr); }
.col { border: 0; background: transparent; padding: 0; margin: 0; cursor: pointer; border-radius: 10px; }
.col:focus-visible { outline: 3px solid var(--orange); outline-offset: -3px; }
.col.hint { background: rgba(255, 210, 87, .22); box-shadow: inset 0 0 0 3px var(--gold); animation: hintPulse 1s ease-in-out infinite; }
.col.full, .col:disabled { cursor: default; }
@keyframes hintPulse { 50% { background: rgba(255, 210, 87, .08); } }
.disc { position: absolute; width: calc(100% / 7); height: calc(100% / 6); display: grid; place-items: center; pointer-events: none; will-change: transform; }
.disc i { display: block; width: 78%; height: 78%; border-radius: 50%; }
.disc.l i { background: var(--laddoo); }
.disc.p i { background: var(--peda); }
.disc.last i { box-shadow: 0 0 0 3px rgba(255, 255, 255, .55); }
.disc.win i { animation: winGlow .9s ease-in-out infinite; }
@keyframes winGlow { 50% { box-shadow: 0 0 0 5px var(--gold), 0 0 18px var(--gold); transform: scale(1.08); } }
.disc.danger i { box-shadow: 0 0 0 3px #ff4d6d; }
.mark { position: absolute; width: calc(100% / 7); height: calc(100% / 6); display: grid; place-items: center; pointer-events: none; }
.mark i { width: 40%; height: 40%; border-radius: 50%; border: 3px dashed #ff4d6d; animation: hintPulse 1s infinite; }
.mark.mine i { border-color: var(--gold); }

.thinking { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); background: rgba(20, 23, 33, .88); border-radius: 20px; padding: 8px 14px; display: flex; gap: 6px; z-index: 9; pointer-events: none; }
.thinking span { width: 9px; height: 9px; border-radius: 50%; background: var(--teal); animation: bob 1s infinite; }
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 50% { transform: translateY(-6px); opacity: .5; } }

.coach { display: flex; gap: 10px; align-items: flex-start; background: var(--navy2); border-radius: 14px; padding: 10px 12px; min-height: 62px; }
.coach p { margin: 0; font-weight: 700; font-size: 15px; }
.coach-face { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--laddoo); position: relative; }
.coach-face::before, .coach-face::after { content: ''; position: absolute; top: 12px; width: 5px; height: 7px; border-radius: 3px; background: #3a1d0a; }
.coach-face::before { left: 10px; }
.coach-face::after { right: 10px; }
.coach.flash { animation: flash .6s; }
.coach.warn { box-shadow: inset 0 0 0 2px #ff4d6d; }
@keyframes flash { 30% { box-shadow: 0 0 0 3px var(--gold); } }

.controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ctl { min-height: 56px; border: 0; border-radius: 14px; background: var(--navy2); color: var(--ink); font-weight: 800; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.ctl svg { width: 22px; height: 22px; }
.ctl:disabled { opacity: .4; cursor: default; }

/* How / badges */
.prose p, .prose li { margin: 0; }
.prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.prose .small { font-size: 14px; color: var(--muted); }
.badge-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.badge-list li { background: var(--navy); border-radius: 14px; padding: 12px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.badge-list li b { font-size: 14px; }
.badge-list li span { font-size: 12px; color: var(--muted); }
.badge-list li.locked { opacity: .45; }
.badge-list .bico, .res-badges .bico { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; background: var(--grad); color: #fff; }
.badge-list li.locked .bico { background: var(--navy3); }

/* Result */
.modal { position: fixed; inset: 0; background: rgba(8, 9, 14, .7); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--navy2); border-radius: 22px; padding: 22px 18px 16px; width: 100%; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 10px; animation: pop .35s ease-out; max-height: calc(100dvh - 32px); overflow-y: auto; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.modal-card h2 { margin: 0; font-family: var(--head); font-size: 28px; }
.modal-card p { margin: 0; color: var(--muted); font-weight: 700; }
.res-art { display: flex; justify-content: center; gap: 6px; }
.res-art i { width: 40px; height: 40px; border-radius: 50%; display: block; animation: hop .6s ease-in-out infinite alternate; }
.res-art i:nth-child(2) { animation-delay: .1s; } .res-art i:nth-child(3) { animation-delay: .2s; } .res-art i:nth-child(4) { animation-delay: .3s; }
.res-art i.l { background: var(--laddoo); }
.res-art i.p { background: var(--peda); }
@keyframes hop { to { transform: translateY(-8px); } }
.res-stars { font-size: 40px; letter-spacing: 6px; color: var(--navy3); }
.res-stars .on { color: var(--gold); display: inline-block; animation: starIn .4s backwards; }
.res-stars .on:nth-child(2) { animation-delay: .2s; }
.res-stars .on:nth-child(3) { animation-delay: .4s; }
@keyframes starIn { from { transform: scale(0) rotate(-90deg); } }
.res-badges { display: flex; flex-direction: column; gap: 6px; }
.res-badges div { display: flex; align-items: center; gap: 10px; background: var(--navy); border-radius: 12px; padding: 8px 10px; text-align: left; font-weight: 800; }
.res-badges .bico { width: 36px; height: 36px; font-size: 18px; flex: none; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy3); color: var(--ink); padding: 10px 16px; border-radius: 14px; font-weight: 800; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); z-index: 60; max-width: calc(100% - 32px); text-align: center; }

@media (max-width: 380px) {
  .title { font-size: 21px; }
  .home-link span { font-size: 14px; }
  .ctl { font-size: 12px; min-height: 52px; }
  .coach p { font-size: 14px; }
  .seg button { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
