/* So‘zdon: ko‘rinish. Sahifa aylanmaydi: taxta bo‘sh joyga moslashadi (JS --t), klaviatura pastda. Telefon birinchi. */
:root { --hit: #3f9a5f; --near: #b5952b; --miss: #3b404c; --key: #2a2f3b; --key-fg: #eef0f5; --t-on: rgba(255,255,255,.34); --flip: 480ms; --kh: clamp(40px, 7.4dvh, 58px); --kg: 5px; }
:root[data-theme="light"] { --hit: #46a067; --near: #c2a02e; --miss: #7c8393; --key: #dcdfe7; --key-fg: #111419; --t-on: rgba(15,20,30,.5); }
:root[data-cb="1"] { --hit: #e0702f; --near: #3f95d4; }
:root[data-theme="light"][data-cb="1"] { --hit: #e0702f; --near: #3f95d4; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: flex; flex-direction: column; min-height: 0; height: 100vh; height: var(--vvh, 100dvh); }
.gu-bar { flex: none; position: relative; }
#app { flex: 1; min-height: 0; width: 100%; max-width: 500px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 6px; padding: 8px max(6px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }

/* yuqori qator: rejim va so‘z tili */
#top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
#modes { flex: 0 1 auto; }
#modes button { padding: 0 11px; }
#plangWrap { position: relative; flex: none; }
.soz-pick { display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 0 10px 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--sur2); color: var(--fg); font-weight: 650; font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.soz-pick:hover { border-color: var(--line2); }
.soz-pick svg { width: 12px; height: 12px; color: var(--mut); transform: rotate(-90deg); }
.soz-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 150px; padding: 4px; background: var(--sur); border: 1px solid var(--line2); border-radius: 12px; box-shadow: 0 14px 34px var(--shadow); }
.soz-menu button { display: block; width: 100%; min-height: 42px; padding: 0 12px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-weight: 600; font-size: 14.5px; cursor: pointer; }
.soz-menu button:hover { background: var(--sur2); }
.soz-menu button[aria-current] { color: var(--acc-text); }
#info { min-height: 18px; text-align: center; color: var(--mut); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* taxta */
#stage { position: relative; min-height: 0; min-width: 0; display: grid; place-items: center; }
#board { --t: 56px; --g: 5px; display: grid; gap: var(--g); perspective: 900px; }
.r { display: grid; grid-template-columns: repeat(5, var(--t)); gap: var(--g); }
.t { width: var(--t); height: var(--t); display: grid; place-items: center; border: 2px solid var(--line2); border-radius: 6px; font-weight: 750; font-size: calc(var(--t) * .5); line-height: 1; color: var(--fg); background: transparent; }
.t.two { font-size: calc(var(--t) * .4); letter-spacing: -.01em; }
.t.on { border-color: var(--t-on); }
.t.pop { animation: soz-pop .1s ease-out; }
.t.pend { color: var(--mut); border-style: dashed; }
.t.c0 { --c: var(--miss); } .t.c1 { --c: var(--near); } .t.c2 { --c: var(--hit); }
.t.c0, .t.c1, .t.c2 { background: var(--c); border-color: var(--c); color: #fff; }
.t.flip { animation: soz-flip var(--flip) ease-in-out both; animation-delay: calc(var(--i) * 240ms); }
.t.wave { animation: soz-wave .46s ease-out both; animation-delay: calc(var(--i) * 80ms); }
.r.shake { animation: soz-shake .42s ease-in-out; }
@keyframes soz-pop { 0% { transform: scale(.93); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes soz-flip {
  0% { transform: rotateX(0); background: transparent; border-color: var(--t-on); color: var(--fg); }
  49.9% { transform: rotateX(90deg); background: transparent; border-color: var(--t-on); color: var(--fg); }
  50% { transform: rotateX(90deg); background: var(--c); border-color: var(--c); color: #fff; }
  100% { transform: rotateX(0); background: var(--c); border-color: var(--c); color: #fff; }
}
@keyframes soz-wave { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-12%); } 72% { transform: translateY(2.5%); } }
@keyframes soz-shake { 12%, 88% { transform: translateX(-2px); } 28%, 72% { transform: translateX(4px); } 44% { transform: translateX(-5px); } 58% { transform: translateX(5px); } }

/* xabar: taxta ustida, sokin */
#msg { position: absolute; top: 2px; left: 50%; transform: translateX(-50%); z-index: 15; max-width: 96%; display: flex; align-items: center; gap: 10px; padding: 9px 14px; border-radius: 11px; background: var(--fg); color: var(--bg); font-size: 14px; font-weight: 650; line-height: 1.25; text-align: center; box-shadow: 0 8px 26px var(--shadow); opacity: 0; pointer-events: none; transition: opacity .14s; width: max-content; }
#msg.show { opacity: 1; pointer-events: auto; }
#msg button { flex: none; min-height: 34px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--bg); color: var(--fg); font-weight: 700; font-size: 13.5px; cursor: pointer; }

/* klaviatura */
#kb { display: grid; gap: var(--kg); touch-action: manipulation; }
.kr { display: flex; gap: var(--kg); }
.kr .sp { flex: .5 1 0; }
.k { flex: 1 1 0; min-width: 0; height: var(--kh); padding: 0; border: 0; border-radius: 7px; background: var(--key); color: var(--key-fg); font-weight: 700; font-size: 15.5px; display: grid; place-items: center; cursor: pointer; transition: background-color .12s, transform .06s; }
.k:active, .k.down { transform: scale(.96); filter: brightness(1.15); }
.k.wide { flex: 1.55 1 0; }
.k.enter { background: var(--acc); color: var(--acc-ink); }
.k svg { width: 21px; height: 21px; }
.k.c0 { background: var(--miss); color: rgba(255,255,255,.72); }
:root[data-theme="light"] .k.c0 { color: rgba(255,255,255,.9); }
.k.c1 { background: var(--near); color: #fff; }
.k.c2 { background: var(--hit); color: #fff; }
.kr.uzx .k { background: var(--sur3); font-size: 15px; letter-spacing: .01em; }
.kr.uzx .k.c0 { background: var(--miss); }
.kr.uzx .k.c1 { background: var(--near); }
.kr.uzx .k.c2 { background: var(--hit); }

/* natija: klaviatura o‘rnida */
#result { display: grid; gap: 7px; padding: 12px 14px; border-radius: 14px; background: var(--sur); border: 1px solid var(--line); animation: gu-rise .2s ease; }
.r-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.r-word { font-size: 21px; font-weight: 800; letter-spacing: .05em; }
.r-score { color: var(--mut); font-size: 13px; font-weight: 650; white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-gloss { margin: 0; font-size: 14px; line-height: 1.35; color: var(--fg); user-select: text; -webkit-user-select: text; }
.r-pub { margin: 0; font-size: 13px; color: var(--mut); }
.r-next { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--mut); }
.r-next b { color: var(--fg); font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.r-acts { display: flex; gap: 6px; margin-top: 2px; }
.r-acts .gu-btn { flex: 1 1 0; min-width: 0; padding: 0 6px; font-size: 14px; white-space: nowrap; }

/* arxiv */
#archive { position: absolute; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: grid; align-content: start; gap: 6px; padding-bottom: 8px; }
#archive[hidden] { display: none; }
.a-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--sur); text-align: left; cursor: pointer; }
.a-row:hover { border-color: var(--line2); background: var(--sur2); }
.a-row b { display: block; font-weight: 700; font-size: 14.5px; }
.a-row small { display: block; color: var(--mut); font-size: 12px; }
.a-res { font-weight: 750; font-size: 14px; font-variant-numeric: tabular-nums; color: var(--mut); }
.a-res.w { color: var(--hit); }
.a-res.l { color: var(--red); }
.a-res.p { color: var(--near); }

/* oynalar */
.ex { display: flex; gap: 4px; margin: 4px 0 2px; --t: 32px; }
.ex .t { font-size: 17px; }
.ex .t.two { font-size: 14px; }
.h-list { display: grid; gap: 7px; margin: 10px 0 0; }
.h-item { display: grid; grid-template-columns: 18px 1fr; align-items: center; gap: 9px; color: var(--fg); font-size: 14px; line-height: 1.3; }
.sq { width: 18px; height: 18px; border-radius: 4px; background: var(--c); }
.sq.c0 { --c: var(--miss); } .sq.c1 { --c: var(--near); } .sq.c2 { --c: var(--hit); }
.gu-modal .h-p { margin: 0 0 10px; color: var(--fg); font-size: 14px; line-height: 1.38; }
.gu-modal .h-note { margin: 12px 0 0; padding: 9px 11px; border-radius: 11px; background: var(--sur2); font-size: 13px; line-height: 1.36; color: var(--fg); }
.gu-modal .h-src { margin: 10px 0 0; font-size: 11px; line-height: 1.35; color: var(--mut); }
.h-src a { color: var(--mut); }
.opt { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.opt:first-of-type { border-top: 0; }
.opt b { display: block; font-weight: 700; font-size: 15px; }
.opt small { display: block; color: var(--mut); font-size: 12.5px; line-height: 1.35; margin-top: 2px; }
.sw { position: relative; width: 48px; height: 28px; padding: 0; border: 0; border-radius: 999px; background: var(--sur3); cursor: pointer; transition: background-color .15s; }
.sw::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s; }
.sw[aria-checked="true"] { background: var(--acc); }
.sw[aria-checked="true"]::after { transform: translateX(20px); }
.sw:disabled { opacity: .45; cursor: default; }
.gu-modal .gu-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gu-modal .gu-stats > div { display: flex; flex-direction: column; justify-content: space-between; gap: 2px; padding: 8px 9px; }
.gu-modal .gu-stats small { line-height: 1.2; }
.s-seg { margin-bottom: 12px; }
.dist { display: grid; gap: 5px; margin-top: 6px; }
.dist > div { display: grid; grid-template-columns: 14px 1fr; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.dist i { display: block; min-width: 22px; padding: 2px 7px; border-radius: 4px; background: var(--sur3); color: var(--fg); font-style: normal; text-align: right; font-size: 12.5px; font-weight: 700; }
.dist i.me { background: var(--hit); color: #fff; }
.s-h { margin: 14px 0 0; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--mut); }
.s-next { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13.5px; color: var(--mut); }
.s-next b { color: var(--fg); font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; }

@media (max-width: 400px) { .r-acts .gu-btn svg { display: none; } }

/* muqova rejimi (?shot=) */
body.shot .gu-bar, body.shot #top, body.shot #info, body.shot #bottom, body.shot #msg { display: none !important; }
body.shot #app { display: block; max-width: none; padding: 0; height: 100%; }
body.shot #stage { height: 100%; place-items: start center; padding-top: var(--shot-top, 18px); }
body.shot .t { box-shadow: 0 1px 0 rgba(0,0,0,.18); }

/* telefon landscape: taxta chapda, klaviatura o‘ngda */
@media (orientation: landscape) and (max-height: 560px) {
  :root { --kh: clamp(38px, 12.4dvh, 52px); --kg: 4px; }
  .gu-bar { height: calc(42px + env(safe-area-inset-top)); }
  #app { max-width: none; grid-template-columns: minmax(200px, 40%) minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); column-gap: 14px; row-gap: 4px; padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom)); }
  #stage { grid-column: 1; grid-row: 1 / span 3; }
  #top { grid-column: 2; grid-row: 1; }
  #info { grid-column: 2; grid-row: 2; }
  #bottom { grid-column: 2; grid-row: 3; align-self: end; }
  #modes button { min-height: 32px; }
  .soz-pick { min-height: 38px; }
  #result { gap: 4px; padding: 8px 12px; }
  .r-acts .gu-btn { min-height: 38px; }
  body.listing #app { grid-template-columns: minmax(0, 620px); justify-content: center; }
  body.listing #top, body.listing #info, body.listing #stage { grid-column: 1; }
  body.listing #stage { grid-row: 3; }
  body.listing #bottom { display: none; }
  .gu-modal { padding-top: 8px; padding-bottom: 8px; }
  .gu-modal > div { width: min(680px, 100%); padding: 14px 18px; }
  .gu-modal h2 { margin-bottom: 6px; }
  .gu-modal .gu-acts2 { margin-top: 10px; }
  .s-seg { margin-bottom: 8px; }
  .s-seg button { min-height: 32px; }
  .s-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .s-b .s-h { margin-top: 0; }
  .dist { gap: 3px; margin-top: 4px; }
  .dist i { padding: 1px 7px; }
}
/* past telefonlar: bo‘sh joyni taxtaga berish */
@media (max-height: 620px) and (orientation: portrait) {
  :root { --kh: clamp(36px, 7dvh, 46px); --kg: 4px; }
  .gu-bar { height: calc(44px + env(safe-area-inset-top)); }
  #app { gap: 4px; padding-top: 5px; padding-bottom: calc(5px + env(safe-area-inset-bottom)); }
  #modes button { min-height: 32px; }
  .soz-pick { min-height: 38px; }
  #info { min-height: 15px; font-size: 11.5px; }
}
@media (min-width: 720px) and (min-height: 700px) {
  :root { --kh: 56px; --kg: 6px; }
  .k { font-size: 17px; border-radius: 8px; }
  #app { padding-top: 14px; padding-bottom: 18px; gap: 10px; }
}
