:root {
  --bg: #F7F3EA;
  --surface: #FFFFFF;
  --ink: #1F2933;
  --muted: #566170;
  --line: #E3DBCB;
  --navy: #1F3A5F;
  --accent: #C43B12;
  --accent-soft: #FFF1EB;
  --ok: #167A4A;
  --ok-soft: #E4F4EA;
  --bad: #C23B3B;
  --land: #E5DDC9;
  --shadow: 0 1px 2px rgba(31, 41, 51, .06), 0 8px 24px rgba(31, 41, 51, .08);
  --r: 18px;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); background-color: var(--bg);
  background-image:
    radial-gradient(900px 500px at 85% -10%, rgba(196, 59, 18, .09), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(31, 58, 95, .09), transparent 60%),
    radial-gradient(rgba(31, 58, 95, .07) 1px, transparent 1.4px);
  background-size: auto, auto, 22px 22px;
  background-attachment: fixed;
  font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.ico { display: inline-grid; place-items: center; width: 1.25em; height: 1.25em; }
.ico svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-star svg { fill: currentColor; }

/* ---------- úvod ---------- */
.home { max-width: 760px; margin: 0 auto; padding: calc(12px + env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom)); }
.home-head { position: relative; padding-top: 4px; }
.hero-map { position: relative; width: min(100%, 520px); margin: 0 auto; animation: rise .7s both; }
.hero-svg { display: block; width: 100%; height: auto; touch-action: auto; filter: drop-shadow(0 10px 18px rgba(31, 58, 95, .16)); }
.hero-svg .region { fill: #F2ECDC; stroke: #fff; }
.hero-svg .region:nth-child(3n) { fill: #ECE4CF; }
.hero-svg .region:nth-child(4n+1) { fill: #F6F0E2; }
.hero-svg .pt-box, .hero-svg .pt-q, .hero-svg .pt-ck, .hero-svg .pt-sel { display: none; }
.hero-svg .pt-pulse { fill: var(--accent); opacity: .22; transform-origin: 0 0; animation: heroPulse 3.2s var(--d, 0s) infinite ease-out; r: 9px; }
.hero-svg .pt::after { content: none; }
.hero-svg .pt { animation: none; }
.hero-svg .pt.is-hero::before { content: none; }
.eyebrow { margin: 18px 0 2px; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 800; animation: rise .6s .1s both; }
.home h1 { margin: 0; font-size: clamp(34px, 9vw, 52px); line-height: 1.02; letter-spacing: -.02em; color: var(--navy); animation: rise .6s .15s both; }
.lead { margin: 8px 0 0; color: var(--muted); font-size: 17px; animation: rise .6s .2s both; }
.levels { display: grid; gap: 12px; margin-top: 22px; }
.level {
  display: grid; grid-template-columns: 52px 1fr 24px; align-items: center; gap: 14px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 14px 14px 12px;
  box-shadow: var(--shadow); min-height: 88px; animation: rise .55s calc(.25s + var(--i) * .07s) both;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.level:hover { transform: translateY(-2px); border-color: var(--navy); }
.level:active { transform: scale(.985); }
.level-ico { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 15px; background: var(--navy); color: #fff; }
.level-ico .ico { width: 28px; height: 28px; }
.level-body { display: grid; gap: 1px; min-width: 0; }
.level-num { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.level-title { font-size: 19px; font-weight: 800; line-height: 1.15; }
.level-sub { font-size: 14px; color: var(--muted); }
.level-best { font-size: 13px; color: var(--muted); margin-top: 3px; }
.level-best.has { color: var(--ok); font-weight: 700; }
.level-go { color: var(--navy); transform: rotate(180deg); }
.foot { margin: 22px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------- hra: společné ---------- */
.screen { min-height: 100dvh; }
.play { max-width: 1040px; margin: 0 auto; padding: 0 12px calc(24px + env(safe-area-inset-bottom)); user-select: none; -webkit-user-select: none; }
.bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  margin: 0 -12px 10px; padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: rgba(247, 243, 234, .82); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid rgba(227, 219, 203, .8);
}
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; flex: none; transition: transform .15s; }
.icon-btn:active { transform: scale(.94); }
.bar-title { margin: 0; font-size: 18px; line-height: 1.15; flex: 1; min-width: 0; font-weight: 800; color: var(--navy); }
.stats { display: flex; gap: 6px; flex: none; }
.stat { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 10px 0 7px; border-radius: 12px; background: var(--surface); border: 1.5px solid var(--line); font-weight: 800; font-variant-numeric: tabular-nums; font-size: 15px; }
.stat .ico { width: 18px; height: 18px; color: var(--muted); }
.stat-err .ico { color: var(--bad); }
.stat.bump { animation: bump .35s; }
.status { margin: 0; min-height: 24px; font-size: 15px; font-weight: 650; color: var(--navy); transition: color .2s; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

/* ---------- mapa ---------- */
.map-card { position: relative; background: linear-gradient(180deg, #FFFFFF, #FBF8F1); border: 1.5px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 8px; overflow: hidden; }
.map-host { position: relative; width: 100%; }
.map { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden; border-radius: 10px; }
.map-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px 0; font-weight: 800; font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.region { fill: var(--land); stroke: #fff; stroke-width: 1.3px; vector-effect: non-scaling-stroke; transition: fill .45s ease, filter .2s; cursor: pointer; }
.region.is-done { fill: var(--c); cursor: default; }
.region.is-selected { fill: #F6C9B8; }
.region.is-done.is-pop { animation: pop .5s; transform-box: fill-box; transform-origin: center; }
@media (hover: hover) { .region:not(.is-done):hover { fill: #D9CFB6; } }
.region.is-wrong { animation: wrongFill .65s; }
.points { pointer-events: none; }
.pt-box { fill: #fff; stroke: var(--accent); stroke-width: 2px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.25)); transition: fill .25s, stroke .25s; }
.pt-q { font: 800 11px/1 ui-rounded, system-ui, sans-serif; fill: var(--accent); }
.pt-ck { fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.pt-sel { fill: none; stroke: var(--accent); stroke-width: 2.5; opacity: 0; }
.pt-pulse { fill: none; }
.pt.is-selected .pt-sel { opacity: 1; animation: ringPulse 1s infinite; transform-origin: 0 0; }
.pt.is-selected .pt-box { fill: #FFE3D8; }
.pt.is-done .pt-box { fill: var(--ok); stroke: #fff; }
.pt.is-done .pt-q { opacity: 0; }
.pt.is-done .pt-ck { opacity: 1; stroke-dasharray: 14; animation: draw .4s both; }
.pt.is-done { animation: dotPop .5s; }
.pt.is-wrong .pt-box { animation: shake .5s; stroke: var(--bad); fill: #FBD5D5; }
.pt-label, .region-label { opacity: 0; transition: opacity .35s; }
.pt-label.is-on, .region-label.is-on { opacity: 1; }
.pt-label text, .region-label text, .inset-caption {
  font: 800 11.5px/1 ui-rounded, system-ui, sans-serif; fill: var(--ink);
  paint-order: stroke; stroke: rgba(255, 255, 255, .92); stroke-width: 3.4px; stroke-linejoin: round;
}
.region-label text { font-size: 10.5px; }
.inset-caption { font-size: 9.5px; fill: var(--muted); font-weight: 700; }
.inset-frame { fill: #fff; stroke: var(--line); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.praha-ring { fill: none; stroke: var(--navy); stroke-width: 1.5px; stroke-dasharray: 3 3; opacity: .7; }
.pt.is-hl .pt-box { fill: var(--navy); stroke: #fff; }
.mini .pt-box { }
.map-ctl { position: absolute; left: 6px; bottom: 6px; display: flex; gap: 6px; z-index: 3; }
.map-ctl button { width: 40px; height: 40px; border-radius: 12px; border: 1.5px solid var(--line); background: rgba(255,255,255,.92); font-size: 22px; font-weight: 800; line-height: 1; color: var(--navy); box-shadow: 0 2px 6px rgba(0,0,0,.1); }
.map-ctl button:active { transform: scale(.92); }

/* ---------- hra: přiřazování ---------- */
.play-main { display: grid; gap: 12px; }
.play-side { display: grid; gap: 10px; align-content: start; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min, 120px), 1fr)); gap: 8px; }
.card {
  position: relative; min-height: 48px; padding: 8px 10px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 750; font-size: 14.5px; line-height: 1.15; text-align: center; display: grid; place-items: center;
  transition: transform .15s, border-color .15s, background .15s, box-shadow .15s, opacity .3s;
  box-shadow: 0 1px 2px rgba(31,41,51,.06);
}
.card:active { transform: scale(.97); }
.card.is-sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(196, 59, 18,.18); transform: translateY(-1px); }
.card.is-bad { animation: cardBad .9s; }
.card.is-done { background: var(--ok-soft); border-color: #9BD3B2; color: var(--ok); cursor: default; box-shadow: none; }
.card-ok { display: none; position: absolute; right: 5px; top: 5px; width: 16px; height: 16px; }
.card-ok .ico { width: 16px; height: 16px; }
.card.is-done .card-ok { display: block; }
.card.is-done .card-txt { text-decoration: line-through; text-decoration-thickness: 1.5px; }

/* ---------- pexeso ---------- */
.pex-top { display: grid; gap: 10px; margin-bottom: 12px; }
.mini-card { padding: 6px; }
.mini .map { max-height: 150px; width: auto; margin: 0 auto; }
.pex-meta { display: grid; gap: 6px; align-content: start; }
.seg { display: inline-flex; padding: 3px; border-radius: 14px; background: #ECE5D4; width: max-content; }
.seg-btn { border: 0; background: transparent; border-radius: 11px; min-height: 40px; padding: 0 16px; font-weight: 800; font-size: 14.5px; color: var(--muted); }
.seg-btn.on { background: var(--surface); color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.best { font-size: 13px; color: var(--muted); font-weight: 650; }
.pex-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pcard { position: relative; aspect-ratio: 1 / .84; padding: 0; border: 0; background: none; perspective: 900px; animation: deal .5s calc(var(--i) * 28ms) both; }
.pface { position: absolute; inset: 0; border-radius: 14px; display: grid; place-items: center; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .5s cubic-bezier(.3, .7, .2, 1), box-shadow .3s, background .3s; overflow: hidden; }
.pback {
  background:
    radial-gradient(circle at 25% 20%, rgba(255,255,255,.18), transparent 45%),
    repeating-linear-gradient(135deg, rgba(255,255,255,.06) 0 2px, transparent 2px 9px),
    var(--navy);
  box-shadow: 0 3px 0 #14263F, 0 6px 14px rgba(20, 38, 63, .22);
  border: 2px solid rgba(255,255,255,.14);
}
.pmark { font-weight: 800; font-size: 30px; color: rgba(255,255,255,.85); }
.pfront { transform: rotateY(180deg); background: var(--surface); border: 2px solid var(--line); padding: 4px; }
.pcard.is-open .pback { transform: rotateY(180deg); }
.pcard.is-open .pfront { transform: rotateY(0); }
.pcard:not(.is-open):active .pback { transform: scale(.97); }
.pcard.is-match .pfront { background: var(--c); border-color: rgba(31,41,51,.25); box-shadow: 0 0 0 3px rgba(255,255,255,.6) inset; }
.pcard.is-match { animation: matchPop .5s; }
.ptxt { font-weight: 800; font-size: 13.5px; line-height: 1.15; text-align: center; color: var(--ink); padding: 0 2px; max-width: 100%; overflow-wrap: break-word; }
.shape { width: 88%; height: 88%; }
.shape path { fill: var(--navy); }
.pcard.is-match .shape path { fill: rgba(31,41,51,.78); }
.pcard:disabled { cursor: default; }

/* ---------- výsledek ---------- */
.result { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(31, 41, 51, .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .3s both; }
.result-card { position: relative; z-index: 1; width: min(100%, 360px); background: var(--surface); border-radius: 26px; padding: 26px 22px 20px; text-align: center; box-shadow: 0 24px 60px rgba(0,0,0,.25); animation: sheet .5s cubic-bezier(.2, .9, .3, 1.2) both; }
.result h2 { margin: 6px 0 4px; font-size: 26px; color: var(--navy); line-height: 1.1; }
.result-stars { display: flex; justify-content: center; gap: 6px; }
.rs { color: #DDD5C2; display: inline-grid; transform: scale(.4); opacity: 0; animation: starIn .5s calc(.2s + var(--i) * .14s) both cubic-bezier(.2, .9, .3, 1.5); }
.rs .ico { width: 42px; height: 42px; }
.rs.on { color: #F2B134; }
.badge { display: inline-block; margin: 2px 0 0; padding: 3px 12px; border-radius: 99px; background: var(--ok-soft); color: var(--ok); font-weight: 800; font-size: 13px; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.result-stats > div { background: var(--bg); border-radius: 16px; padding: 10px 8px; }
.result-stats dt { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.result-stats dd { margin: 2px 0 0; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
.result-actions { display: grid; gap: 8px; }
.btn { min-height: 50px; border-radius: 15px; border: 0; font-weight: 800; font-size: 16.5px; padding: 0 18px; transition: transform .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px rgba(196, 59, 18, .3); }
.btn-ghost { background: var(--bg); color: var(--navy); }
.confetti { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.confetti i { position: absolute; top: -14px; left: var(--x); width: 9px; height: 14px; border-radius: 2px; animation: fall var(--d) var(--w) cubic-bezier(.3, .5, .6, 1) forwards; }

/* ---------- animace ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheet { from { opacity: 0; transform: translateY(30px) scale(.94); } to { opacity: 1; transform: none; } }
@keyframes starIn { from { opacity: 0; transform: scale(.2) rotate(-40deg); } to { opacity: 1; transform: none; } }
@keyframes deal { from { opacity: 0; transform: translateY(18px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
@keyframes cardBad { 0%, 55% { border-color: var(--bad); background: #FDE8E8; } 12% { transform: translateX(-5px); } 24% { transform: translateX(5px); } 36% { transform: translateX(-3px); } 48% { transform: translateX(3px); } 100% { transform: none; } }
@keyframes bump { 40% { transform: scale(1.18); background: #FBD5D5; } }
@keyframes pop { 50% { transform: scale(1.04); } }
@keyframes matchPop { 40% { transform: scale(1.06); } }
@keyframes dotPop { 0% { transform-box: fill-box; } }
@keyframes wrongFill { 0%, 100% { fill: var(--land); } 30% { fill: #F2A3A3; } }
@keyframes ringPulse { 0% { stroke-width: 2.5; } 50% { stroke-width: 4; } 100% { stroke-width: 2.5; } }
@keyframes heroPulse { 0% { transform: scale(.4); opacity: .55; } 70% { transform: scale(2.4); opacity: 0; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes draw { from { stroke-dashoffset: 14; } to { stroke-dashoffset: 0; } }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .rs { opacity: 1; transform: none; }
}

/* ---------- větší displeje ---------- */
@media (min-width: 640px) {
  .play { padding: 0 20px 32px; }
  .bar { margin: 0 -20px 14px; padding-left: 20px; padding-right: 20px; }
  .bar-title { font-size: 21px; }
  .pex-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .ptxt { font-size: 17px; }
  .levels { grid-template-columns: 1fr 1fr; }
  .pex-top { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: center; }
  .mini .map { max-height: 190px; }
}
@media (min-width: 920px) {
  .play-locate .play-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
  .play-locate .map-card { position: sticky; top: 76px; padding: 12px; }
  .pex-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .region-label text { font-size: 9.5px; }
  .pt-label text { font-size: 11px; }
}
@media (max-width: 359px) {
  .stat { padding: 0 7px 0 5px; font-size: 14px; }
  .bar-title { font-size: 16px; }
}
