/* Round 3 (v1.3): one button system on the 8 px grid, IBM Plex type scale, home layout 360-1440,
   next goal + chapter pips, streak multiplier, near-miss ring, aim strip, settings, daily gift, spring popups. */
:root { --t-xs: 12px; --t-s: 14px; --t-m: 16px; --t-l: 20px; --t-xl: 24px; --t-2xl: 32px;
  --spring: cubic-bezier(.3,1.45,.5,1); --ease: cubic-bezier(.2,.8,.2,1); --edge: #E2D3BC; }
body { font-weight: 600; letter-spacing: -.005em; }
[dir=rtl] body { letter-spacing: 0; }
h2, .win-title, .logo .word, .level-pill, .btn { font-weight: 700; }

/* ---------- buttons: md 56, lg 64, xl 72, sm 48; icon + 1-2 words; pressed and disabled states ---------- */
.btn { min-height: 56px; padding: 0 24px; gap: 8px; border-radius: 16px; font-size: var(--t-l); line-height: 1; letter-spacing: 0;
  transition: transform .09s var(--ease), box-shadow .09s, filter .15s, background-color .15s; }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn.sm { min-height: 48px; padding: 0 16px; font-size: var(--t-m); border-radius: 14px; }
.btn.sm svg { width: 20px; height: 20px; }
.btn.lg { min-height: 64px; font-size: 22px; border-radius: 20px; }
.btn.xl { min-height: 72px; font-size: var(--t-xl); border-radius: 24px; }
.btn.primary { box-shadow: 0 4px 0 var(--accent-d), 0 10px 20px rgba(232,102,61,.28); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-d), 0 4px 10px rgba(232,102,61,.2); }
.btn.soft { background: var(--paper); box-shadow: 0 4px 0 var(--edge), 0 8px 18px rgba(70,44,18,.07); }
.btn.soft:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.btn.ghost { box-shadow: inset 0 0 0 2px var(--edge); color: #6E6259; }
.btn.ghost:active { transform: scale(.98); background: rgba(226,211,188,.35); }
.btn.danger { background: var(--hard); color: #fff; box-shadow: 0 4px 0 #9E2A23; }
.btn.danger:active { transform: translateY(3px); box-shadow: 0 1px 0 #9E2A23; }
.btn[disabled], .btn.primary[disabled], .btn.soft[disabled] { background: #EDE3D3; color: #A99C8E; box-shadow: none; filter: none; transform: none; cursor: default; }
.btn[disabled]::after { display: none; }
.btn small { font-size: var(--t-s); font-weight: 700; opacity: .85; }
.btn small.price { display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border-radius: 16px; background: rgba(0,0,0,.14); opacity: 1; }
.btn small.price svg { width: 20px; height: 20px; }
.btn .badge { top: -8px; }
.btn small s { text-decoration-thickness: 2px; }
.icon-btn { width: 48px; height: 48px; border-radius: 16px; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { transform: translateY(2px) scale(.96); }
.chip { min-height: 48px; height: 48px; padding: 0 16px 0 8px; border-radius: 24px; font-size: 18px; font-weight: 700; }
button.chip:active { transform: translateY(2px); }
.actions { gap: 8px; margin-top: 24px; } .actions.col { gap: 12px; } .actions.duo { margin-top: 0; }
.actions.duo .btn { flex: 1; }

/* ---------- home ---------- */
#home { gap: 8px; }
.home-main { justify-content: safe center; gap: 12px; padding: 4px 0; }
.home-left, .home-right { gap: 12px; }
.topbar { gap: 8px; } .topbar .chips { gap: 8px; }
.logo .word { font-size: 28px; letter-spacing: -.02em; }
.logo .emblem { width: 40px; height: 40px; }
.mosaic-card { width: min(100%, 320px, 33vh); }
.mosaic-card .ch-row { font-size: var(--t-l); margin: 12px 4px 8px; }
#playBtn { width: min(100%, 360px); justify-content: center; gap: 12px; padding: 0 16px; }
#playBtn .pb-ico { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; background: rgba(255,255,255,.22); }
#playBtn .pb-ico svg { width: 22px; height: 22px; }
#playBtn .pb-txt { white-space: nowrap; }
#playBtn .pb-txt b { font-weight: 700; }
#playBtn .tier-tag, #playBtn .streak-chip { margin: 0; height: 28px; padding: 0 10px; border-radius: 14px; font-size: var(--t-s); display: inline-flex; align-items: center; gap: 4px; }
.goal-row { display: flex; align-items: center; gap: 12px; width: min(100%, 360px); min-height: 48px; margin: 0 auto; padding: 0 16px 0 8px; border-radius: 24px;
  background: rgba(255,250,242,.75); box-shadow: inset 0 0 0 1px var(--edge); font-size: var(--t-m); text-align: start; transition: transform .1s; }
.goal-row:active { transform: scale(.98); }
.goal-row .g-ico { width: 36px; height: 36px; border-radius: 18px; display: grid; place-items: center; background: #FFF1D6; color: #C98A16; flex: none; }
.goal-row[data-kind=player] .g-ico { background: #EFE6FB; color: var(--super); }
.goal-row .g-ico svg { width: 22px; height: 22px; }
.goal-row .g-lbl { white-space: nowrap; }
.goal-row .bar { flex: 1; height: 10px; border-radius: 5px; }
.goal-row .g-num { font-size: var(--t-s); color: var(--muted); min-width: 40px; text-align: end; }
.goal-row .g-num svg { width: 20px; height: 20px; color: var(--teal); margin-inline-start: auto; }
.goal-row.ready { background: #FFF1D6; box-shadow: inset 0 0 0 2px var(--gold); animation: beat 1.4s infinite; }
.modes { gap: 8px; width: min(100%, 440px); }
.mode-tile { min-height: 88px; padding: 12px 0 8px; gap: 4px; border-radius: 16px; font-size: var(--t-s); font-weight: 700; }
.mode-tile .ico { width: 40px; height: 40px; }
.mode-tile .sub { font-size: var(--t-xs); }
.meta-row { width: min(100%, 440px); gap: 4px; }
.meta-btn { min-height: 68px; font-size: var(--t-xs); gap: 4px; }
.meta-btn .ico { width: 48px; height: 48px; border-radius: 16px; transition: transform .1s; }

/* chapter pips: 10 levels, Hard (1) and Super Hard (2) marked ahead */
.pips { display: flex; gap: 4px; align-items: center; justify-content: space-between; margin: 0 4px; }
.pip { position: relative; flex: 1; height: 10px; border-radius: 5px; background: #EADCC6; box-shadow: inset 0 1px 2px rgba(80,50,20,.15); }
.pip.done { background: linear-gradient(90deg, var(--gold), var(--accent)); box-shadow: none; }
.pip.cur { background: #fff; box-shadow: inset 0 0 0 2px var(--accent); }
.pip.t1:not(.done) { background: rgba(217,68,59,.2); } .pip.t2:not(.done) { background: rgba(122,63,209,.22); }
.pip.t1.cur { box-shadow: inset 0 0 0 2px var(--hard); } .pip.t2.cur { box-shadow: inset 0 0 0 2px var(--super); }
.pip b { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 9px; display: grid; place-items: center;
  font-size: 11px; font-style: normal; color: #fff; background: var(--hard); }
.pip.t2 b { background: var(--super); }
.pips.sm { margin: 4px 0 0; gap: 3px; width: 120px; } .pips.sm .pip { height: 6px; border-radius: 3px; }
.pips.sm .pip b { display: none; } .pips.sm .pip.t1, .pips.sm .pip.t2 { height: 8px; }

/* ---------- HUD ---------- */
.level-pill { height: 48px; flex-direction: column; justify-content: center; gap: 0; padding: 0 16px; border-radius: 24px; font-size: 18px; }
.level-pill .lp-top { display: flex; align-items: center; gap: 8px; line-height: 1.1; }
.level-pill .pips[hidden] { display: none; }
.hud-chip { height: 40px; font-size: var(--t-m); font-weight: 700; }
.hud-chip.sk { color: var(--accent); background: #FFF1E8; box-shadow: 0 2px 0 #F2C9B4; }
.hud-chip.sk svg { color: var(--accent); }
.hud-chip.sk.bump { animation: hit .45s var(--spring); }
.tier { font-weight: 700; font-size: var(--t-xs); }

/* ---------- power dock: the aim hint takes the bar's place (never over the board) ---------- */
.power-dock { position: relative; }
.aim-strip { position: absolute; inset: 0; display: flex; align-items: center; gap: 12px; padding: 0 8px 0 16px; border-radius: 20px; background: var(--teal); color: #fff;
  font-size: var(--t-l); opacity: 0; transform: translateY(8px) scale(.98); pointer-events: none; transition: opacity .18s, transform .25s var(--spring);
  box-shadow: 0 4px 0 var(--teal-d), 0 10px 22px rgba(20,96,90,.25); }
.power-dock.aiming .aim-strip { opacity: 1; transform: none; pointer-events: auto; }
.power-dock.aiming .boosters { visibility: hidden; }
.aim-strip .ico svg { width: 28px; height: 28px; } .aim-strip .lbl { flex: 1; }
.aim-strip .icon-btn { background: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.boost { min-height: 72px; border-radius: 16px; font-size: var(--t-xs); font-weight: 700; transition: transform .09s var(--ease), box-shadow .09s; }
.boost:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--edge); }
.boost[disabled] { opacity: 1; background: #EFE6D7; box-shadow: none; color: #A99C8E; } .boost[disabled] svg { color: #B9AE9F; }
.boost.locked { opacity: 1; background: #EFE6D7; color: #A99C8E; box-shadow: none; }
.boost.locked svg { color: #B9AE9F; }

/* ---------- sheets: spring in, content staggers ---------- */
.sheet { padding: 24px 24px calc(var(--safe-b) + 24px); border-radius: 32px 32px 0 0; transition: transform .42s cubic-bezier(.22,1.18,.36,1); }
.sheet.out { transition: transform .22s ease-in; }
.sheet h2 { font-size: 26px; margin: 0 0 8px; line-height: 1.2; }
.sheet .sub { margin: 0 0 8px; font-size: var(--t-m); }
.sheet-layer.on .sheet > * { animation: rise .42s var(--spring) both; }
.sheet-layer.on .sheet > *:nth-child(2) { animation-delay: .04s; } .sheet-layer.on .sheet > *:nth-child(3) { animation-delay: .08s; }
.sheet-layer.on .sheet > *:nth-child(4) { animation-delay: .12s; } .sheet-layer.on .sheet > *:nth-child(n+5) { animation-delay: .16s; }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.sheet-icon { animation: popin .5s var(--spring) both !important; }
@keyframes popin { from { transform: scale(.3); opacity: 0; } }
#toast { top: calc(var(--safe-t) + 80px); min-height: 48px; display: flex; align-items: center; font-size: var(--t-m); border-radius: 24px; }
#toast.on { animation: toastin .35s var(--spring); } @keyframes toastin { from { transform: translate(-50%, -16px) scale(.9); } }

/* settings: two grouped cards, 56 px rows */
.sheet.settings .set-group { background: var(--bg); border-radius: 20px; padding: 0 16px; margin-bottom: 16px; }
.sheet.settings .row-set { min-height: 56px; gap: 12px; font-size: 18px; width: 100%; }
.sheet.settings .set-group .row-set:last-child { border-bottom: 0; }
.row-set .ico { background: var(--paper); width: 40px; height: 40px; } .row-set .ico svg { width: 22px; height: 22px; }
.row-set.danger { color: var(--hard); } .row-set.danger .ico { color: var(--hard); }
.row-set .chev { width: 20px; height: 20px; transform: scaleX(-1); color: var(--muted); } [dir=rtl] .row-set .chev { transform: none; }
.sw { width: 56px; height: 32px; } input:checked + .sw::after { inset-inline-start: 28px; }
.seg { padding: 4px; border-radius: 16px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--edge); }
.seg button { min-height: 40px; min-width: 56px; padding: 0 12px; border-radius: 12px; font-size: var(--t-m); }
.seg button.on { background: var(--teal); color: #fff; box-shadow: 0 2px 0 var(--teal-d); }
.sheet.confirm .actions .btn { flex: 1; }

/* near miss */
.near-ring { position: relative; width: 120px; height: 120px; margin: 0 auto 8px; animation: popin .55s var(--spring) both; }
.near-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.near-ring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.near-ring .trk { stroke: #EFE3D1; }
.near-ring .val { stroke: var(--accent); stroke-dasharray: calc(var(--p) * 100) 100; animation: ringfill .9s .15s var(--ease) both; }
[dir=rtl] .near-ring svg { transform: rotate(-90deg) scaleY(-1); }
@keyframes ringfill { from { stroke-dasharray: 0 100; } }
.near-ring b { position: absolute; inset: 0; display: flex; align-items: baseline; justify-content: center; padding-top: 38px; font-size: 36px; font-weight: 700; direction: ltr; }
.near-ring b small { font-size: var(--t-l); color: var(--muted); }
.sheet.nearmiss h2 { color: var(--accent); font-size: 30px; }
.streak-risk { display: inline-flex; align-items: center; gap: 8px; margin: 8px 0 0; padding: 0 16px; height: 40px; border-radius: 20px; background: #FFF1E8;
  color: var(--accent); font-size: var(--t-m); }
.streak-risk svg { width: 20px; height: 20px; }
.btn small.lose { display: inline-flex; align-items: center; gap: 2px; color: var(--hard); }
.btn small.lose svg { width: 16px; height: 16px; }

/* result: streak multiplier chip lands on the coins */
.reward { gap: 8px; align-items: center; }
.reward .chip { height: 48px; font-size: var(--t-xl); }
.streak-c .mult { font-style: normal; font-size: var(--t-m); padding: 0 8px; height: 28px; border-radius: 14px; display: inline-grid; place-items: center;
  background: var(--accent); color: #fff; margin-inline-start: 4px; }
.streak-c.hit { animation: hit .45s var(--spring); } @keyframes hit { 40% { transform: scale(1.22) rotate(-4deg); } }
.next-reward { min-height: 48px; }

/* daily gift */
.sheet.gift { text-align: center; }
.gift-box { position: relative; display: block; width: 200px; height: 200px; margin: 0 auto; }
.gift-svg { position: absolute; left: 20px; top: 40px; width: 160px; height: 150px; overflow: visible; }
.gift-box .g-lid { transform-origin: 80px 56px; transform-box: view-box; }
.sheet.gift:not(.opened) .gift-svg { animation: wobble 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
.sheet.gift.opened .g-lid { animation: lidoff .6s cubic-bezier(.3,.7,.4,1) forwards; }
@keyframes lidoff { 40% { transform: translate(0, -46px) rotate(-8deg); } to { transform: translate(-30px, -30px) rotate(-28deg); opacity: 0; } }
.gift-rays { position: absolute; inset: -20px; border-radius: 50%; opacity: 0; pointer-events: none;
  background: repeating-conic-gradient(rgba(242,194,48,.38) 0 10deg, rgba(242,194,48,0) 10deg 30deg);
  -webkit-mask: radial-gradient(circle, #000 20%, transparent 68%); mask: radial-gradient(circle, #000 20%, transparent 68%); }
.sheet.gift.opened .gift-rays { opacity: 1; transition: opacity .4s .2s; animation: rays 12s linear infinite; }
.gift-items { position: absolute; left: 0; right: 0; top: 4px; display: flex; justify-content: center; gap: 12px; pointer-events: none; }
.gi { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border-radius: 20px; background: var(--paper);
  box-shadow: 0 4px 0 var(--edge), 0 12px 24px rgba(70,44,18,.18); font-size: var(--t-xl); font-weight: 700; opacity: 0; transform: translateY(60px) scale(.3); }
.gi svg { width: 40px; height: 40px; }
.sheet.gift.opened .gi { animation: giftout .6s var(--spring) forwards; }
.sheet.gift.opened .gi:nth-child(2) { animation-delay: .14s; }
@keyframes giftout { from { opacity: 0; transform: translateY(60px) scale(.3); } 30% { opacity: 1; } to { opacity: 1; transform: none; } }
.gift-hint { margin: 0; color: var(--muted); font-size: var(--t-m); min-height: 24px; }
.sheet.gift.opened .gift-hint { visibility: hidden; }
.gift-strip { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }
.gd { width: 32px; height: 32px; border-radius: 16px; display: grid; place-items: center; background: var(--bg); font-style: normal; font-size: var(--t-s); color: var(--muted); }
.gd.now { box-shadow: inset 0 0 0 2px var(--gold); color: var(--ink); } .gd.got { background: var(--teal); color: #fff; box-shadow: none; transition: background .3s .5s; }
.gift .actions .btn[hidden] { display: none; } .gift .actions .btn.in { animation: rise .4s var(--spring) both; }
.fly-coin { position: fixed; left: 0; top: 0; width: 28px; height: 28px; margin: -14px 0 0 -14px; z-index: 50; pointer-events: none; }
.fly-coin svg { width: 28px; height: 28px; filter: drop-shadow(0 3px 4px rgba(80,50,10,.3)); }

/* calm motion: no wobble, rays, slides or springs */
html.calm *, html.calm *::before, html.calm *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .08s !important; }
html.calm .screen { transform: none !important; }

/* ---------- small phones (360 x 740) ---------- */
@media (max-width: 380px) {
  .screen { padding-inline: 12px; }
  .logo .word { font-size: 26px; } .logo .emblem { width: 36px; height: 36px; }
  .chip { padding: 0 12px 0 6px; font-size: var(--t-m); }
  .mode-tile { font-size: var(--t-xs); min-height: 80px; } .mode-tile .ico { width: 36px; height: 36px; }
  .btn.xl { font-size: 22px; }
}
@media (max-height: 760px) { .mosaic-card { width: min(100%, 240px, 30vh); } .home-main, .home-left, .home-right { gap: 8px; } .mode-tile { min-height: 76px; padding-top: 8px; } .meta-btn { min-height: 62px; } .brand { margin: -4px 0; } }

@media (max-height: 680px) {
  .mosaic-card { width: min(100%, 180px, 23vh); } .home-main { padding: 0; } .mosaic-card .ch-row { margin-top: 4px; }
  .logo .word { font-size: 24px; } .logo .emblem { width: 32px; height: 32px; }
  .btn.xl { min-height: 64px; } .goal-row { min-height: 44px; }
  .mode-tile { min-height: 56px; padding: 6px 0; gap: 2px; } .mode-tile .ico { width: 32px; height: 32px; } .mode-tile .sub:empty { display: none; }
  .meta-btn { min-height: 56px; gap: 2px; } .meta-btn .ico { width: 40px; height: 40px; }
  .sheet .mosaic-frame { width: min(62vw, 34vh); } .sheet .win-title { font-size: 32px; } .sheet .stars { margin: 0; }
}

/* ---------- desktop ---------- */
@media (min-width: 900px) {
  #home .topbar { width: 100%; max-width: 1100px; align-self: center; }
  .home-main { gap: 80px; }
  .home-left { width: 460px; } .home-right { width: 440px; gap: 24px; }
  .mosaic-card { width: 100%; }
  .logo .word { font-size: 40px; } .logo .emblem { width: 56px; height: 56px; }
  #playBtn, .goal-row, .modes, .meta-row { width: 100%; }
  .btn.xl { min-height: 80px; font-size: 28px; }
  .mode-tile { min-height: 104px; font-size: var(--t-m); } .mode-tile .ico { width: 48px; height: 48px; } .mode-tile .ico svg { width: 28px; height: 28px; }
  .meta-btn { font-size: var(--t-s); } .meta-btn .ico { width: 56px; height: 56px; }
  .goal-row { min-height: 56px; font-size: 18px; }
  .sheet { border-radius: 32px; bottom: 50%; transform: translate(-50%, 60%) scale(.96); opacity: 0; transition: transform .4s cubic-bezier(.22,1.18,.36,1), opacity .2s; }
  .sheet-layer.on .sheet { transform: translate(-50%, 50%); opacity: 1; }
  .sheet.out { transform: translate(-50%, 56%) scale(.97) !important; opacity: 0; }
  .boosters .boost { min-height: 80px; font-size: var(--t-s); }
}
