/* To‘rtlik: sokin «tosh kataklar» uslubi — tekis, iliq kulrang kataklar, tanlangani teskari rangda, topilgan guruh — darajasining yumshoq rangidagi chiziq.
   To‘rt daraja rangi (qum, shalfey, osmon, marjon) ikkala mavzuda ham o‘qiladi; daraja chiziqdagi kichik belgida ham ko‘rinadi (rang ajratish qiyin bo‘lsa).
   Sahifa aylanmaydi: taxta bo‘sh joyga moslashadi (JS: --tw --th --bw --bh), telefon portret, landshaft va kompyuter uchun alohida joylashuv. */
:root, :root[data-theme="dark"] {
  --tile: #1f232c; --tile-hi: #272c37; --tile-ink: #eceef3; --tile-edge: rgba(255,255,255,.045);
  --sel: #ece6d7; --sel-ink: #111216;
  --g1: #e6c562; --g2: #9ecb8f; --g3: #93b9e6; --g4: #ec9f87; --g-ink: #15130e;
  --pill-line: rgba(255,255,255,.22); --dot: #d9dce4; --soft: rgba(255,255,255,.06);
}
:root[data-theme="light"] {
  --bg: #f6f5f1; --head: rgba(246,245,241,.86);
  --tile: #e7e3d8; --tile-hi: #ddd8cb; --tile-ink: #16181d; --tile-edge: rgba(0,0,0,.04);
  --sel: #434956; --sel-ink: #fff;
  --g1: #f1cf66; --g2: #a9d79c; --g3: #a1c6ef; --g4: #f3a68e; --g-ink: #17150f;
  --pill-line: rgba(15,20,30,.28); --dot: #4a505e; --soft: rgba(15,20,30,.05);
}
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: flex; flex-direction: column; height: 100vh; height: var(--vvh, 100dvh); }
#app { flex: 1; min-height: 0; width: 100%; max-width: 660px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }

/* rejimlar: Bugun | Arxiv va boshqotirmalar tili */
#modes { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#seg button { position: relative; min-height: 38px; padding: 0 16px; font-size: 14px; }
#seg button::after { content: ""; position: absolute; inset: -4px 0; } /* teginish maydoni 46 px */
#modes .mr { display: flex; align-items: center; gap: 6px; }
.ib { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--sur2); color: var(--mut); cursor: pointer; }
.ib:hover { color: var(--fg); }
.ib svg { width: 19px; height: 19px; }
#plang { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--sur2); color: var(--mut); font: 700 13px var(--font); letter-spacing: .04em; cursor: pointer; }
#plang svg { width: 16px; height: 16px; }
#plang:hover { color: var(--fg); }
.lmenu { position: absolute; z-index: 30; min-width: 170px; padding: 4px; background: var(--sur); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 14px 34px var(--shadow); animation: gu-rise .16s ease; }
.lmenu small { display: block; padding: 8px 12px 4px; color: var(--mut); font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.lmenu button { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; font: 650 15px var(--font); text-align: left; cursor: pointer; }
.lmenu button:hover { background: var(--sur2); }
.lmenu button[aria-current="true"] { color: var(--acc-text); }
.lmenu button i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* o‘yin */
#play { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
#head { text-align: center; padding-top: 4px; }
#info { margin: 0; color: var(--mut); font-size: 13px; font-weight: 650; letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#info b { color: var(--fg); font-weight: 800; }
#info .dl { display: inline-flex; gap: 2px; margin-right: 5px; vertical-align: 1px; } /* umumiy qiyinlik: 1–3 nuqta */
#info .dl i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .28; }
#info .dl i.on { opacity: .85; }
#msg { position: relative; margin: 2px 0 0; min-height: 26px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; font-size: 15px; font-weight: 600; color: var(--fg); text-align: center; }
#msg span { max-width: 100%; }
#msg span { display: inline-block; animation: msg-in .22s ease-out; }
#msg.note span { padding: 3px 12px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 700; font-size: 14px; }
#msg.coach span { color: var(--fg); font-weight: 650; font-size: 14.5px; line-height: 1.3; }
@keyframes msg-in { from { opacity: 0; transform: translateY(4px); } }
#stage { flex: none; min-height: 0; min-width: 0; position: relative; display: grid; place-items: center; }
#board { --tw: 80px; --th: 76px; --bw: 344px; --bh: 328px; --gap: 8px; --tr: 12px; position: relative; width: var(--bw); height: var(--bh); }
.tile { position: absolute; left: 0; top: 0; width: var(--tw); height: var(--th); padding: 0; border: 0; background: none; color: inherit; cursor: pointer; touch-action: manipulation;
  transform: translate3d(var(--x, 0), var(--y, 0), 0); transition: transform .42s cubic-bezier(.3,.85,.25,1); -webkit-user-select: none; user-select: none; }
#board.instant .tile, #board.instant .bar { transition: none !important; }
.tile .face { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 4px; border-radius: var(--tr); background: var(--tile); color: var(--tile-ink);
  box-shadow: inset 0 1px 0 var(--tile-edge); transition: background-color .15s ease, color .15s ease, transform .12s ease, opacity .2s ease; }
.tile .tx { display: block; font-weight: 800; font-size: var(--fs, 16px); line-height: 1.1; letter-spacing: 0; text-align: center; white-space: pre; }
@media (hover: hover) { .tile:hover .face { background: var(--tile-hi); } .tile.sel:hover .face { background: var(--sel); } }
.tile:active .face { transform: scale(.955); }
.tile.sel .face { background: var(--sel); color: var(--sel-ink); }
.tile.pop .face { animation: t-pop .2s ease-out; }
@keyframes t-pop { 40% { transform: scale(.93); } 100% { transform: none; } }
.tile.g0 .face { background: var(--g1); color: var(--g-ink); } .tile.g1 .face { background: var(--g2); color: var(--g-ink); }
.tile.g2 .face { background: var(--g3); color: var(--g-ink); } .tile.g3 .face { background: var(--g4); color: var(--g-ink); }
.tile.fade .face { opacity: 0; }
.tile.sel, .tile.g0, .tile.g1, .tile.g2, .tile.g3 { z-index: 2; } /* yig‘ilayotgan guruh boshqalar ustidan uchadi */
.tile:focus-visible { outline: none; }
.tile:focus-visible .face { box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4.5px var(--acc); }
#board.locked .tile { cursor: default; }

/* topilgan guruh */
.bar { position: absolute; left: 0; top: 0; width: var(--bw); height: var(--th); transform: translate3d(0, var(--y, 0), 0); border-radius: var(--tr); color: var(--g-ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 30px; text-align: center; transition: transform .42s cubic-bezier(.3,.85,.25,1); }
.bar.l0 { background: var(--g1); } .bar.l1 { background: var(--g2); } .bar.l2 { background: var(--g3); } .bar.l3 { background: var(--g4); }
.bar b { display: block; max-width: 100%; font-weight: 800; font-size: var(--fc, 14.5px); line-height: 1.15; letter-spacing: .05em; white-space: pre; }
.bar .it { display: block; max-width: 100%; font-weight: 600; font-size: var(--fi, 14px); line-height: 1.2; white-space: pre; opacity: .9; }
/* daraja belgisi: «signal» ustunchalari (1–4) — rang ajratish qiyin bo‘lsa ham darajani ko‘rsatadi */
.bar .lv { position: absolute; right: 12px; top: 10px; display: flex; align-items: flex-end; gap: 2px; height: 10px; }
.bar .lv i { width: 3px; border-radius: 1px; background: currentColor; opacity: .18; }
.bar .lv i:nth-child(1) { height: 4px; } .bar .lv i:nth-child(2) { height: 6px; } .bar .lv i:nth-child(3) { height: 8px; } .bar .lv i:nth-child(4) { height: 10px; }
.bar .lv i.on { opacity: .62; }
.bar.in { animation: bar-in .34s cubic-bezier(.2,.9,.3,1.1) both; }
.bar.in b, .bar.in .it { animation: bar-tx .32s .08s ease-out both; }
@keyframes bar-in { from { opacity: 0; transform: translate3d(0, var(--y, 0), 0) scale(.97); } 60% { opacity: 1; transform: translate3d(0, var(--y, 0), 0) scale(1.015); } to { transform: translate3d(0, var(--y, 0), 0); } }
@keyframes bar-tx { from { opacity: 0; transform: translateY(5px); } }

/* xatolar va tugmalar */
#side { display: grid; gap: 10px; }
#status { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 28px; color: var(--mut); font-size: 14px; font-weight: 600; }
#bHint { flex: 0 0 auto; min-height: 40px; padding: 0 13px; margin-left: 4px; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; } /* yordam: ochilmagan eng oson guruh nomi */
#bHint svg { width: 16px; height: 16px; }
#msg.hintl span { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); }
#msg.hintl svg { width: 16px; height: 16px; flex: 0 0 auto; }
#dots { display: inline-flex; gap: 7px; }
#dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--dot); transition: transform .32s cubic-bezier(.5,0,.75,0), opacity .32s; }
#dots i.gone { transform: scale(0); opacity: 0; }
#controls { display: flex; justify-content: center; gap: 8px; }
#controls .pill { flex: 1 1 0; max-width: 156px; padding: 0 8px; font-size: clamp(13px, 3.6vw, 15px); overflow: hidden; text-overflow: ellipsis; } /* uch tugma har qanday tilda bir qatorga sig‘adi («Перемешать» 390 px da ham to‘liq) */
@media (max-width: 380px) { #controls .pill { font-size: 13.5px; padding: 0 6px; } #controls { gap: 6px; } } /* 360 px: «Перемешать», «Aralashtir» ham to‘liq ko‘rinsin */
.pill { flex: 0 1 auto; min-width: 0; min-height: 46px; padding: 0 18px; border: 1.5px solid var(--pill-line); border-radius: 999px; background: transparent; color: var(--fg);
  font: 700 15px var(--font); white-space: nowrap; cursor: pointer; transition: background-color .15s, color .15s, border-color .15s, opacity .15s, transform .08s; }
.pill:hover:not(:disabled) { background: var(--soft); }
.pill:active:not(:disabled) { transform: scale(.97); }
.pill:disabled { opacity: .38; cursor: default; }
.pill.go:not(:disabled) { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.pill.go:not(:disabled):hover { filter: brightness(1.08); }
.pill svg { width: 17px; height: 17px; margin-right: 6px; vertical-align: -3px; }
#after { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
#after .pill { padding: 0 20px; }
#play.done #controls { display: none; }
#play.done #status { visibility: hidden; } /* balandlik o‘zgarmasin: o‘yin tugaganda taxta sakramaydi */

/* arxiv */
#list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 2px 14px; -webkit-overflow-scrolling: touch; }
.l-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 2px 12px; }
.l-top p { margin: 0; color: var(--mut); font-size: 13.5px; }
.l-top .pill { flex: 0 0 auto; padding: 0 14px; } /* «Случайная» tugmasi siqilib, yozuvi chegaradan chiqmasin — matn o‘rniga qisqaradi */
.l-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 58px; padding: 9px 14px; margin-bottom: 7px; border: 1px solid var(--line); border-radius: 14px; background: var(--sur); text-align: left; cursor: pointer; transition: background-color .15s, border-color .15s; animation: row-in .3s ease-out both; animation-delay: calc(var(--i, 0) * 22ms); }
.l-row:hover { background: var(--sur2); border-color: var(--line2); }
.l-row b { display: block; font-size: 15.5px; font-weight: 750; }
.l-row small { display: flex; align-items: center; gap: 7px; color: var(--mut); font-size: 12.5px; margin-top: 1px; }
.l-row .dd { display: inline-flex; gap: 2px; }
.l-row .dd i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .25; }
.l-row .dd i.on { opacity: .9; }
.l-res { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--sur2); color: var(--mut); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.l-res.w { color: var(--fg); }
.l-res.w .sq { display: inline-flex; gap: 2px; }
.l-res .sq i { width: 7px; height: 7px; border-radius: 2px; }
.l-res.l { color: var(--red); }
.l-res.p { color: var(--acc-text); }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } }
body.listing #play { display: none; }

/* natija varag‘i */
#result { position: fixed; inset: 0; z-index: 40; display: grid; align-items: end; justify-items: center; background: rgba(5,7,11,.5); animation: gu-fade .2s ease; }
:root[data-theme="light"] #result { background: rgba(20,24,32,.32); }
#result.closing { animation: gu-fade .2s ease reverse both; }
.sh { position: relative; width: min(480px, 100%); max-height: calc(100% - 28px); overflow-y: auto; overscroll-behavior: contain; padding: 22px 20px calc(18px + env(safe-area-inset-bottom));
  background: var(--sur); border: 1px solid var(--line2); border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: 0 -18px 50px var(--shadow); animation: sh-up .36s cubic-bezier(.2,.9,.25,1); }
#result.closing .sh { animation: sh-up .2s ease-in reverse both; }
@keyframes sh-up { from { transform: translateY(100%); } }
.sh.noanim, #result.noanim { animation: none; }
.sh-x { position: absolute; right: 10px; top: 10px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--mut); cursor: pointer; }
.sh-x:hover { background: var(--sur2); color: var(--fg); }
.sh-x svg { width: 20px; height: 20px; }
.sh-k { margin: 0; color: var(--mut); font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.sh-t { margin: 6px 0 2px; font-size: 27px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.sh-s { margin: 0 0 14px; color: var(--mut); font-size: 14.5px; }
.sh-grid { display: inline-grid; gap: 5px; margin: 0 0 16px; padding: 12px 14px; border-radius: 16px; background: var(--sur2); }
.sh-grid div { display: flex; gap: 5px; }
.sh-grid i { width: 26px; height: 26px; border-radius: 7px; animation: sq-in .3s cubic-bezier(.2,1.2,.4,1) both; animation-delay: calc(var(--r) * 70ms + var(--c) * 18ms + 120ms); }
@keyframes sq-in { from { opacity: 0; transform: scale(.6); } }
.q0 { background: var(--g1); } .q1 { background: var(--g2); } .q2 { background: var(--g3); } .q3 { background: var(--g4); }
.sh-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 14px; }
.sh-stats div { padding: 9px 4px 8px; border-radius: 12px; background: var(--sur2); text-align: center; }
.sh-stats b { display: block; font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.sh-stats small { display: block; margin-top: 2px; color: var(--mut); font-size: 11.5px; line-height: 1.2; }
.sh-dist { display: grid; gap: 5px; margin: 0 0 14px; }
.sh-dist .dl { margin: 0 0 2px; color: var(--mut); font-size: 12px; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.sh-dist div { display: grid; grid-template-columns: 74px 1fr; align-items: center; gap: 8px; font-size: 13px; color: var(--mut); }
.sh-dist div span { text-align: right; white-space: nowrap; }
.sh-dist div i { display: block; width: var(--p); min-width: 26px; padding: 2px 8px; border-radius: 6px; background: var(--sur3); color: var(--fg); font-style: normal; font-weight: 750; text-align: right; font-variant-numeric: tabular-nums; transition: width .5s; }
.sh-dist div i.me { background: var(--fg); color: var(--bg); }
.sh-next { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 0 0 14px; padding: 11px 14px; border-radius: 12px; background: var(--sur2); color: var(--mut); font-size: 14px; }
.sh-next b { color: var(--fg); font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.sh-line { margin: 0 0 14px; color: var(--mut); font-size: 13.5px; }
.sh-acts { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.sh .c1 { text-align: center; }
.sh .c1 .sh-k { padding: 0 40px; }
.sh-acts .pill { flex: 1 1 140px; }
.sh-ad { margin-top: 14px; }
.sh .col { min-width: 0; }

/* yordam oynasi */
.hw p { margin: 0 0 10px; color: var(--fg); font-size: 15px; }
.hw ul { margin: 0 0 12px; padding-left: 18px; color: var(--fg); font-size: 14.5px; }
.hw li { margin: 0 0 6px; }
.hw .ex { margin: 6px 0 12px; display: grid; gap: 6px; }
.hw .exb { display: grid; place-items: center; min-height: 54px; padding: 6px 10px; border-radius: 11px; color: var(--g-ink); text-align: center; }
.hw .exb b { font-size: 13px; font-weight: 800; letter-spacing: .05em; }
.hw .exb span { font-size: 13px; font-weight: 600; }
.hw .exn { margin: -2px 0 12px; color: var(--mut); font-size: 13.5px; }
.hw .lvls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 12px; }
.hw .lvls div { padding: 9px 4px; border-radius: 10px; color: var(--g-ink); font-size: 12px; font-weight: 750; text-align: center; line-height: 1.2; }
.hw .keys { color: var(--mut); font-size: 13px; }
.hw .keys kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 2px; border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 6px; font: 700 12px var(--font); text-align: center; color: var(--fg); }
.hw a { color: var(--acc-text); font-weight: 650; }
.st-arch { margin: 2px 0 0; color: var(--mut); font-size: 13.5px; }

/* telefon landshaft: taxta chapda, qolgani o‘ngda */
@media (orientation: landscape) and (max-height: 560px) {
  #app { max-width: none; display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 34%); grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 22px; row-gap: 6px;
    grid-template-areas: "stage modes" "stage head" "stage gap" "stage side"; padding-top: 8px; }
  #play { display: contents; }
  #modes { grid-area: modes; }
  #head { grid-area: head; text-align: left; padding-top: 6px; }
  #msg { justify-content: flex-start; min-height: 44px; }
  #stage { grid-area: stage; height: auto; }
  #stage #board { position: absolute; left: 50%; top: 50%; translate: -50% -50%; }
  #side { grid-area: side; align-self: end; }
  #controls { flex-wrap: wrap; }
  #controls .pill { flex: 1 1 40%; }
  #controls .go { flex-basis: 100%; }
  #status { justify-content: flex-start; }
  #after { justify-content: flex-start; }
  #list { grid-column: 1 / -1; grid-row: 2 / -1; }
  body.listing #modes { grid-column: 1 / -1; }
  #result { align-items: center; }
  .sh { width: min(760px, calc(100% - 24px)); max-height: calc(100% - 16px); display: grid; grid-template-columns: 1fr 1fr; column-gap: 22px; border-radius: 22px; border-bottom: 1px solid var(--line2); padding: 18px 20px; }
  .sh-t { font-size: 23px; }
  .sh-grid i { width: 21px; height: 21px; }
  .sh .c2 { padding-top: 30px; }
  .sh .c1 .sh-k { padding: 0; }
  .sh-acts { margin-bottom: 4px; }
  .sh-dist { gap: 3px; }
  .sh-dist div i { padding: 1px 8px; }
}
/* kompyuter va planshet */
@media (min-width: 700px) and (min-height: 600px) {
  #app { padding-top: 18px; gap: 10px; }
  #msg { font-size: 16px; }
  .pill { min-height: 48px; padding: 0 24px; font-size: 15.5px; }
  #result { align-items: center; }
  .sh { border-radius: 24px; border-bottom: 1px solid var(--line2); padding: 26px 26px 22px; }
}
@media (prefers-reduced-motion: reduce) { .tile, .bar { transition: none; } }

/* muqova rejimi (?shot=): faqat taxta, panel va reklamasiz */
body.shot .gu-bar, body.shot #modes, body.shot #after { display: none !important; }
body.shot:not(.ui) #app { display: block; max-width: none; height: 100%; padding: var(--shot-top, 14px) 14px 0; }
body.shot:not(.ui) #play { display: flex; height: 100%; justify-content: flex-start; }
body.shot:not(.ui) #head, body.shot:not(.ui) #side { display: none; }
body.shot:not(.ui) #stage #board { position: relative; left: auto; top: auto; translate: none; }
body.shot.ui #app { padding-top: 22px; padding-bottom: 22px; }
body.shot { background: var(--shot-bg, var(--bg)); }
body.shot #board { transform: rotate(var(--shot-tilt, 0deg)) scale(var(--shot-zoom, 1)); filter: drop-shadow(0 18px 30px rgba(0,0,0,.28)); }
