/* Sapyor: telefon portret — yuqorida hisoblagichlar, o'rtada taxta, pastda bosh barmoq yetadigan asboblar; kompyuter — yon panel; telefon landscape — ikki yon relsda. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body { display: flex; flex-direction: column; min-height: 0; position: fixed; inset: 0; width: 100%; }
#app { flex: 1; min-height: 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "hud" "stage" "tools"; }
#side { display: none; }

/* hisoblagichlar */
#hud { grid-area: hud; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left)); }
.ctr { display: inline-flex; align-items: center; gap: 7px; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--sur); border: 1px solid var(--line); font-variant-numeric: tabular-nums; color: var(--fg); }
.ctr svg { width: 19px; height: 19px; color: var(--mut); flex: none; }
.ctr b { font-size: 19px; font-weight: 750; letter-spacing: -.01em; }
#ctrMines { justify-self: start; }
#ctrMines.hl { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.ctr.tm { justify-self: end; cursor: pointer; }
.ctr.tm:hover { background: var(--sur2); }
.ctr.tm:disabled { cursor: default; background: var(--sur); }
#timerIc { display: inline-flex; }
.lvl { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: center; min-height: 44px; min-width: 0; padding: 2px 20px 2px 6px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; line-height: 1.2; color: var(--fg); }
.lvl:hover { background: var(--sur); }
.lvl b, .lvl small { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvl b { font-size: 15px; font-weight: 750; }
.lvl small { font-size: 11.5px; color: var(--mut); }
@media (max-width: 379px) { .lvl b { font-size: 14px; } .lvl small { font-size: 11px; } .ctr { padding: 0 9px; gap: 5px; } .ctr b { font-size: 17px; } .sw button { font-size: 13px; padding: 0 4px; gap: 4px; } .tool { width: 46px; } }
.lvl small i { font-style: normal; color: var(--amber); }
.lvl .chev { position: absolute; right: 3px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--mut); }

/* taxta */
#stage { grid-area: stage; position: relative; min-height: 0; min-width: 0; overflow: hidden; }
#cv { position: absolute; left: 0; top: 0; display: block; touch-action: none; outline: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; cursor: default; }
#tip { position: absolute; left: 50%; top: 4px; transform: translateX(-50%); width: max-content; max-width: min(92%, 520px); padding: 5px 12px; border-radius: 10px; background: var(--head); color: var(--mut); font-size: 12.5px; line-height: 1.35; text-align: center; pointer-events: none; transition: opacity .25s; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#tip:empty { display: none; }
#tip.off { opacity: 0; }

/* to'xtatilgan */
#veil { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 55%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#veil > div { width: min(340px, 92%); padding: 18px; border-radius: 16px; background: var(--sur); border: 1px solid var(--line2); text-align: center; box-shadow: 0 16px 40px var(--shadow); }
#veil h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; }
#veil p { margin: 0 0 14px; color: var(--mut); font-size: 13.5px; }
#veil .gu-btn { width: 100%; }

/* yordam va natija paneli: taxta ustida, pastda */
.panel { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 5; max-width: 500px; margin: 0 auto; max-height: calc(100% - 16px); overflow: auto; padding: 14px; border-radius: 16px; background: var(--sur); border: 1px solid var(--line2); box-shadow: 0 14px 40px var(--shadow); animation: gu-rise .18s cubic-bezier(.2,.8,.3,1); user-select: text; -webkit-user-select: text; }
.panel h3 { margin: 0 0 4px; padding-right: 34px; font-size: 16.5px; font-weight: 800; letter-spacing: -.01em; }
.panel p { margin: 0; font-size: 14px; line-height: 1.45; color: var(--fg); }
.panel p + p { margin-top: 6px; }
.panel .mut { color: var(--mut); font-size: 13px; }
.panel .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.panel .row > * { flex: 1 1 120px; }
.panel .x { position: absolute; right: 7px; top: 7px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: var(--mut); cursor: pointer; }
.panel .x:hover { background: var(--sur2); color: var(--fg); }
.panel .x svg { width: 18px; height: 18px; }
.panel .gu-stats { margin-top: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.panel .gu-stats > div { padding: 7px 9px; }
.panel .gu-stats b { font-size: 17px; white-space: nowrap; }
.panel .gu-stats small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel .line { margin-top: 9px; font-size: 13.5px; color: var(--mut); }
.panel .line b { color: var(--fg); font-weight: 700; }
.panel .line.good b { color: var(--acc-text); }
.panel .link { padding: 0; border: 0; background: none; color: var(--acc-text); font-weight: 650; font-size: 13.5px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
#sideDock:empty { display: none; }
#sideDock .panel { position: relative; left: auto; right: auto; bottom: auto; margin: 0 0 12px; max-width: none; max-height: none; box-shadow: none; background: var(--sur2); border-color: var(--line2); }
#sideDock .panel .gu-stats > div { background: var(--sur3); }
#sideDock .panel .row { flex-direction: column; }
#sideDock .panel .row > * { flex: none; width: 100%; }

/* asboblar */
#tools { grid-area: tools; display: flex; align-items: center; gap: 8px; padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
.sw { display: flex; flex: 1 1 auto; min-width: 0; padding: 3px; gap: 2px; border-radius: 14px; background: var(--sur2); border: 1px solid var(--line); }
.sw button { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 46px; padding: 0 8px; border: 0; border-radius: 11px; background: transparent; color: var(--mut); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.sw button svg { width: 18px; height: 18px; flex: none; }
.sw button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
@media (hover: hover) and (pointer: fine) { .sw { visibility: hidden; } } /* sichqonchada Ochish / Bayroq almashtirgichi kerak emas: tugmalar bor */
.tool { flex: none; display: grid; place-items: center; width: 52px; height: 52px; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--sur); color: var(--fg); cursor: pointer; }
.tool:hover { background: var(--sur2); }
.tool:active { transform: scale(.97); }
.tool:disabled { opacity: .4; cursor: default; }
.tool svg { width: 22px; height: 22px; }

/* boshqaruv: daraja, rejim, kunlik (yon panel va telefon oynasi uchun bir xil) */
.ctl { display: grid; gap: 14px; }
.ctl .tag { margin: 0; font-size: 13.5px; color: var(--mut); line-height: 1.45; }
.ctl .tag b { color: var(--fg); font-weight: 700; }
.ctl .sec { display: grid; gap: 6px; }
.ctl .mini:empty { display: none; }
.rows { display: grid; gap: 6px; }
.rows button { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 10px; width: 100%; min-height: 48px; padding: 5px 12px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--sur); color: var(--fg); cursor: pointer; }
.rows button:hover { background: var(--sur2); }
.rows button[aria-current="true"] { border-color: var(--acc); background: var(--glow); }
.rows b { font-weight: 700; font-size: 14.5px; }
.rows small { grid-column: 1; color: var(--mut); font-size: 12px; }
.rows .end { grid-column: 2; grid-row: 1 / span 2; color: var(--mut); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; }
.ctl .gu-seg { display: flex; width: 100%; }
.ctl .gu-seg button { flex: 1 1 auto; min-height: 40px; padding: 0 7px; }
.ctl .gu-seg button svg { width: 13px; height: 13px; margin-right: 3px; vertical-align: -1.5px; color: var(--green); }
.ctl .desc { margin: 0; color: var(--mut); font-size: 12.5px; line-height: 1.4; }
.ctl .desc a, #side a { color: var(--acc-text); }
.cust { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cust input { width: 100%; min-width: 0; text-align: center; font-variant-numeric: tabular-nums; }
.err { color: var(--red); font-size: 13px; margin: 8px 0 0; }
.tabs { display: grid; gap: 8px; margin-bottom: 8px; }
.tabs .gu-seg { display: flex; }
.tabs .gu-seg button { flex: 1 1 auto; padding: 0 8px; }
.myStats { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.myStats .gu-empty { padding: 8px; }
#boardBox { min-height: 120px; max-height: min(44vh, 380px); overflow: auto; }
.gu-table .sub { color: var(--mut); font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.help { font-size: 14px; color: var(--fg); }
.help h3 { margin: 14px 0 4px; font-size: 14.5px; font-weight: 750; }
.help p { margin: 4px 0; color: var(--fg); }
.help ul { margin: 4px 0; padding-left: 18px; }
.help li { margin: 3px 0; }
.help a { color: var(--acc-text); }
.help .keys kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--line2); background: var(--sur2); font: 600 12px var(--font); text-align: center; }

/* sensorda barcha tugmalar kamida 44 px */
@media (pointer: coarse) {
  .ctl .gu-seg button, .tabs .gu-seg button, #cmode button { min-height: 44px; }
  .ctl .gu-btn.sm { min-height: 44px; }
  .panel .x { width: 44px; height: 44px; right: 3px; top: 3px; }
  .panel .link { min-height: 32px; }
}

/* ?shot= — faqat taxta (muqova va SEO rasmlari) */
body.shot .gu-bar, body.shot #hud, body.shot #tools, body.shot #side, body.shot #tip { display: none !important; }
body.shot #app { grid-template-columns: minmax(0, 1fr) !important; grid-template-rows: minmax(0, 1fr) !important; grid-template-areas: "stage" !important; }

/* kompyuter: yon panel */
@media (min-width: 980px) and (min-height: 520px) {
  #app { grid-template-columns: minmax(0, 1fr) 296px; grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "hud side" "stage side"; }
  #hud { padding: 8px 12px 4px; }
  #tools { display: none; }
  #side { grid-area: side; display: block; overflow-y: auto; padding: 12px 14px 16px; border-left: 1px solid var(--line); background: var(--sur); }
  .lvl { cursor: default; }
  .lvl:hover { background: transparent; }
  .lvl .chev { display: none; }
  .lvl { padding: 2px 10px; }
  .ctl { gap: 11px; }
  .ctl .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .ctl .btns .gu-btn { padding: 0 8px; gap: 6px; font-size: 14px; white-space: nowrap; }
  .rows { gap: 5px; }
  .rows button { min-height: 40px; padding: 4px 11px; grid-template-columns: auto minmax(0, 1fr) auto; }
  .rows small { grid-column: 2; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rows .end { grid-column: 3; grid-row: 1; }
  .rows b { font-size: 14px; }
  .panel { bottom: 10px; }
  #cv { cursor: pointer; }
}
.ctl .btns { display: none; }
@media (min-width: 980px) and (min-height: 520px) { .ctl .btns { display: grid; } }
/* kompyuter, lekin sensor (planshet): Ochish / Bayroq almashtirgichi kerak */
@media (min-width: 980px) and (min-height: 520px) and (any-pointer: coarse) {
  #app { grid-template-rows: auto minmax(0, 1fr) auto; grid-template-areas: "hud side" "stage side" "tools side"; }
  #tools { display: flex; }
}

/* telefon landscape: chapda sayt paneli, o'ngda hisoblagich va asboblar — ikkala bosh barmoq yetadi */
@media (max-height: 519px) and (orientation: landscape) {
  body { flex-direction: row; }
  .gu-bar { position: relative; flex: none; flex-direction: column; justify-content: flex-start; gap: 2px; width: calc(50px + env(safe-area-inset-left)); height: 100%; padding: 4px 4px 4px calc(4px + env(safe-area-inset-left)); border-bottom: 0; border-right: 1px solid var(--line); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .gu-bar h1, .gu-bar .gu-sp { display: none; }
  .gu-bar .gu-acts { flex-direction: column; gap: 2px; }
  .gu-menu2 { left: calc(100% + 4px); right: auto; top: auto; bottom: 8px; }
  #app { grid-template-columns: minmax(0, 1fr) calc(158px + env(safe-area-inset-right)); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "stage hud" "stage tools"; }
  #hud { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 6px; padding: 6px calc(6px + env(safe-area-inset-right)) 2px 6px; }
  #hud .ctr { justify-self: stretch; height: 40px; padding: 0 8px; justify-content: center; gap: 5px; }
  #hud .ctr b { font-size: 16px; }
  #hud .ctr svg { width: 15px; height: 15px; }
  #levelBtn { grid-column: 1 / span 2; grid-row: 2; }
  .lvl small { white-space: normal; text-align: center; }
  .lvl small span { display: block; }
  .lvl small .sep { display: none; }
  #ctrMines { grid-column: 1; grid-row: 1; }
  #timerBtn { grid-column: 2; grid-row: 1; }
  #tools { flex-wrap: wrap; align-content: flex-end; gap: 6px; padding: 4px calc(6px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) 6px; }
  .sw { flex: 1 1 100%; flex-direction: column; }
  .sw button { flex: none; height: 42px; }
  .tool { flex: 1 1 calc(50% - 3px); width: auto; height: 44px; }
  #fitBtn { flex: 1 1 calc(33% - 4px); }
  .panel { max-width: 480px; padding: 10px 12px; }
  .panel .row { margin-top: 8px; }
  .panel .gu-stats { margin-top: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel .line { margin-top: 5px; }
}
