:root {
  --board: max(300px, min(calc(100vw - 28px), 72vh));
  --bg1: #e9f5ff; --bg2: #fff1fb; --ink: #3b3556;
  --light: #fff1d6; --dark: #b5dbc9;
  --pink: #ff8fab; --blue: #7cc6fe; --green: #8fd6a0; --yellow: #ffd66b;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: linear-gradient(160deg, var(--bg1), var(--bg2)); color: var(--ink); overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

.screen { position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; overflow-y: auto; overflow-x: hidden;
  padding: calc(12px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left)); }
.screen.active { display: flex; }

.btn { min-height: 64px; padding: 0 32px; border-radius: 32px; background: var(--pink); color: #fff; font-size: 1.6rem; font-weight: 800; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.15); }
.btn.big { min-height: 88px; padding: 0 56px; font-size: 2.4rem; background: var(--green); }
.btn.blue { background: var(--blue); } .btn.gray { background: #b9b4cf; } .btn.small { font-size: 1.2rem; min-height: 52px; }
.round { width: 56px; height: 56px; border-radius: 50%; background: #fff; font-size: 1.7rem; box-shadow: 0 4px 0 rgba(0,0,0,.12); flex: none; }
.round:active { transform: translateY(2px); }

.owl { font-size: 4rem; animation: bob 2.4s ease-in-out infinite; line-height: 1; }
.owl.big { font-size: 9rem; }
.bubble { background: #fff; border-radius: 24px; padding: 12px 18px; font-size: 1.2rem; font-weight: 700; box-shadow: 0 4px 0 rgba(0,0,0,.08); max-width: 560px; min-height: 52px; display: flex; align-items: center; }
@keyframes bob { 50% { transform: translateY(-6px); } }

/* Bosh ekran */
.home { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.home h1 { margin: 0; font-size: 2.4rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; align-items: center; }

/* Yuqori panel */
.topbar { width: 100%; max-width: 900px; display: flex; align-items: center; gap: 10px; padding: 4px 0 8px; }
.topbar .title { flex: 1; text-align: center; font-size: 1.5rem; font-weight: 800; }
.topbar .task { font-size: 2rem; background: #fff; width: 56px; height: 56px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
#lv-progress { flex: 1; text-align: center; font-size: 1.3rem; letter-spacing: 2px; }

/* Xarita */
.path { position: relative; width: 100%; max-width: 560px; margin: 0 auto; flex: none; }
.path svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.node { position: absolute; transform: translateX(-50%); width: 104px; height: 104px; border-radius: 50%; background: #fff; border: 6px solid var(--blue); box-shadow: 0 6px 0 rgba(0,0,0,.15); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 2.6rem; line-height: 1; }
.node .ico { font-family: "Segoe UI Symbol","Apple Symbols","DejaVu Sans",system-ui,sans-serif; }
.node .st { font-size: .8rem; font-weight: 800; margin-top: 2px; }
.node .lab { position: absolute; top: 100%; margin-top: 4px; font-size: .75rem; font-weight: 800; white-space: nowrap; }
.node.done { border-color: var(--green); }
.node.locked { border-color: #cfcbe0; background: #eeedf5; filter: grayscale(.7); }
.node .lock { position: absolute; right: -4px; top: -4px; font-size: 1.5rem; }

/* Bo‘lim */
.steps { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin: auto; }
.step { width: 108px; height: 108px; border-radius: 50%; background: #fff; border: 6px solid var(--blue); font-size: 2.4rem; font-weight: 800; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 6px 0 rgba(0,0,0,.15); }
.step.done { border-color: var(--green); }
.step .st { font-size: .9rem; }

/* Tanishuv kartasi */
.intro { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.bigpiece { font-size: clamp(3.5rem, 11vh, 7rem); line-height: 1; color: #fff; font-family: "Segoe UI Symbol","Apple Symbols","DejaVu Sans",system-ui,sans-serif;
  text-shadow: 3px 0 #3b3556, -3px 0 #3b3556, 0 3px #3b3556, 0 -3px #3b3556, 2px 2px #3b3556, -2px 2px #3b3556, 2px -2px #3b3556, -2px -2px #3b3556; }
.pname { font-size: 2.2rem; font-weight: 800; }

/* Bosqich */
.stage { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.coach { display: flex; align-items: center; gap: 10px; width: 100%; max-width: var(--board); }
.coach .owl { font-size: 3rem; }
@media (min-aspect-ratio: 13/10) {
  :root { --board: min(58vw, 78vh); }
  .stage { flex-direction: row-reverse; justify-content: center; align-items: center; }
  .coach { flex-direction: column; max-width: 260px; }
}

/* Taxta */
.board { position: relative; width: var(--board); height: var(--board); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 6px #8fc3b2, 0 10px 0 6px rgba(0,0,0,.12);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; flex: none; }
.board.small { --board: min(64vw, 40vh); }
.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; display: flex; align-items: center; justify-content: center; }
.sq.light { background: var(--light); } .sq.dark { background: var(--dark); }
.sq::before { content: ''; position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.sq::after { content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); border-radius: 50%; opacity: 0; pointer-events: none; z-index: 1; }
.sq.lit::before { opacity: 1; background: rgba(255,214,102,.8); }
.sq.sel::before { opacity: 1; background: rgba(255,230,100,.7); }
.sq.danger::before { opacity: 1; background: rgba(255,70,90,.45); }
.sq.attacker::before { opacity: 1; background: rgba(255,150,0,.65); animation: pulse 1s infinite; }
.sq.hint::before { opacity: 1; background: rgba(110,220,140,.8); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.sq.dot::after { opacity: 1; width: 34%; height: 34%; background: rgba(80,70,140,.55); }
.sq.ring::after { opacity: 1; width: 90%; height: 90%; border: calc(var(--board) / 8 * .08) solid rgba(255,90,110,.85); }
.sq.itemring::after { opacity: 1; width: 90%; height: 90%; border: calc(var(--board) / 8 * .08) solid rgba(70,190,110,.85); }
.item { font-size: calc(var(--board) / 8 * .6); line-height: 1; z-index: 2; pointer-events: none; animation: bob 1.8s ease-in-out infinite; }
.item.rock { animation: none; }
.item.collected { animation: collect .45s ease-out forwards; }
@keyframes collect { to { transform: scale(2) translateY(-30%); opacity: 0; } }
.coord { position: absolute; font-size: calc(var(--board) / 8 * .22); font-weight: 800; opacity: .6; pointer-events: none; }
.coord.cf { right: 3px; bottom: 1px; } .coord.cr { left: 3px; top: 1px; }
.board:not(.coords) .coord { display: none; }

.pieces { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.piece { position: absolute; width: 12.5%; height: 12.5%; display: flex; align-items: center; justify-content: center; line-height: 1;
  font-size: calc(var(--board) / 8 * .84); font-family: "Segoe UI Symbol","Apple Symbols","DejaVu Sans",system-ui,sans-serif; will-change: transform; }
.piece.w { color: #fff; text-shadow: 1.5px 0 #3b3556, -1.5px 0 #3b3556, 0 1.5px #3b3556, 0 -1.5px #3b3556, 1px 1px #3b3556, -1px 1px #3b3556, 1px -1px #3b3556, -1px -1px #3b3556, 0 3px 3px rgba(0,0,0,.25); }
.piece.b { color: #2f2748; text-shadow: 0 0 2px rgba(255,255,255,.7), 0 3px 3px rgba(0,0,0,.25); }
.piece.moving { z-index: 7; }
.piece.dragging { z-index: 9; transition: none !important; }
.piece.captured { transform: scale(0); opacity: 0; transition: transform .25s, opacity .25s; }
.piece.pop { animation: pop .4s ease-out; }
.piece.promo { filter: drop-shadow(0 0 8px gold); }
@keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }

/* Qatlamlar */
.overlay { position: fixed; inset: 0; background: rgba(40,30,80,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.card { position: relative; background: #fff; border-radius: 32px; padding: 24px; max-width: 460px; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; overflow: hidden; box-shadow: 0 10px 0 rgba(0,0,0,.15); }
.card h2 { margin: 0; font-size: 2rem; }
.bigstars { font-size: 3.4rem; display: flex; gap: 6px; }
.bigstars span { animation: pop .6s ease-out backwards; }
.bigstars span:nth-child(2) { animation-delay: .25s; } .bigstars span:nth-child(3) { animation-delay: .5s; }
.bigstars .off { filter: grayscale(1); opacity: .35; }
.sticker { font-size: 4rem; animation: pop .8s ease-out; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; animation: fall 2.6s linear infinite; }
@keyframes fall { to { transform: translateY(520px) rotate(720deg); } }

/* Albom, ota-ona */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px; width: 100%; max-width: 640px; margin: 12px auto; }
.slot { background: #fff; border-radius: 24px; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 3.4rem; box-shadow: 0 5px 0 rgba(0,0,0,.1); }
.slot.empty { opacity: .45; filter: grayscale(1); }
.panel { width: 100%; max-width: 560px; background: #fff; border-radius: 24px; padding: 16px; margin: 8px 0; font-size: 1.05rem; line-height: 1.5; }
.sw { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 1.2rem; font-weight: 700; }
.sw input { width: 28px; height: 28px; }
.gate .opts { display: flex; gap: 12px; }
.gate .opts .btn { min-width: 84px; padding: 0 20px; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #3b3556; color: #fff; padding: 12px 20px; border-radius: 20px; z-index: 80; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Bosh ekran ostidagi tushuntirish (qidiruv va ota‑onalar uchun) */
#screen-home .home { flex: none; min-height: calc(100% - 8px); justify-content: center; margin: 0; }
.about { width: 100%; max-width: 760px; margin-top: 24px; background: rgba(255,255,255,.85); border-radius: 24px; padding: 8px 22px 18px; line-height: 1.6; user-select: text; -webkit-user-select: text; }
.about h2 { font-size: 1.4rem; line-height: 1.3; } .about h3 { font-size: 1.1rem; margin-bottom: 0; } .about h3 + p { margin-top: 4px; }
.about a { color: #1f6f54; font-weight: 700; }
.about .cards { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.about .cards a { display: inline-block; background: #fff; border-radius: 16px; padding: 8px 14px; text-decoration: none; box-shadow: 0 3px 0 rgba(0,0,0,.08); }
#screen-home .btn { color: #2b2540; }
/* o‘yin ekranlarida ikki barmoq bilan kattalashtirish o‘chiq */
.screen:not(#screen-home) { touch-action: pan-x pan-y; }
