*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --bg:      #1a1a2e;
    --bg2:     #16213e;
    --accent:  #e94560;
    --text:    #eaeaea;
    --muted:   #888;
    --common:    #78c850;
    --uncommon:  #4cc9f0;
    --rare:      #6890f0;
    --epic:      #9d4edd;
    --legend:    #ffd700;
}

html, body { height: 100%; overflow: hidden; font-family: 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); user-select: none; }

/* ---- OBRAZOVKY ---- */
.screen { position: absolute; inset: 0; display: none; flex-direction: column; }
.screen.active { display: flex; }

/* ---- LOADING ---- */
#screen-loading { justify-content: center; align-items: center; background: var(--bg); }
.load-box { text-align: center; }
.load-box h1 { font-size: 2.4rem; margin-bottom: .6rem; }
.load-box p  { color: var(--muted); margin-bottom: 1.2rem; }
.spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,.1); border-top-color: var(--accent); border-radius: 50%; margin: 0 auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- PROFIL ---- */
#screen-profile { justify-content: center; align-items: center; padding: 2rem; background: linear-gradient(135deg,#0f0c29,#302b63); }
.profile-box { text-align: center; width: 100%; max-width: 380px; }
.profile-box h1 { font-size: 2.4rem; margin-bottom: .4rem; }
.profile-box p  { color: var(--muted); margin-bottom: 1.6rem; }
input[type=text] { width: 100%; padding: .8rem 1rem; font-size: 1.1rem; border: 2px solid var(--accent); border-radius: 10px; background: rgba(255,255,255,.05); color: var(--text); margin-bottom: 1rem; outline: none; text-align: center; }

/* Profil — výběr */
#profile-list { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.profile-card { background: var(--bg2); border: 2px solid rgba(255,255,255,.08); border-radius: 12px; padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 1rem; cursor: pointer; transition: transform .1s, border-color .15s; }
.profile-card:active { transform: scale(.97); }
.profile-card.is-current { border-color: var(--accent); background: rgba(233,69,96,.12); }
.pc-name { font-weight: 700; }
.pc-stats { color: var(--muted); font-size: .9rem; }
.profile-loading, .profile-empty { color: var(--muted); text-align: center; padding: 1.5rem .5rem; line-height: 1.5; }
.profile-new-hint { color: var(--muted); margin-bottom: .8rem; }

/* Žebříček */
#leaderboard-list { padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.lb-row { display: grid; grid-template-columns: 38px 1fr auto; grid-template-areas: "rank name total" "rank bar bar"; gap: .25rem .7rem; padding: .7rem .9rem; background: var(--bg2); border-radius: 12px; border: 1px solid rgba(255,255,255,.06); align-items: center; }
.lb-row.is-me { border-color: var(--accent); background: rgba(233,69,96,.12); }
.lb-rank  { grid-area: rank; font-size: 1.4rem; text-align: center; }
.lb-name  { grid-area: name; font-weight: 700; }
.lb-total { grid-area: total; font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.lb-wl { font-size: .72rem; color: #ff9500; font-weight: 600; }
.lb-bar   { grid-area: bar; display: flex; gap: 4px; flex-wrap: wrap; margin-top: .15rem; }
.br-pill { font-size: .7rem; padding: .1rem .45rem; border-radius: 8px; font-weight: 700; }
.br-common   { background: var(--common);   color: #000; }
.br-uncommon { background: var(--uncommon); color: #000; }
.br-rare     { background: var(--rare);     color: #fff; }
.br-epic     { background: var(--epic);     color: #fff; }
.br-legend   { background: var(--legend);   color: #000; }

/* ---- TLAČÍTKA ---- */
button { cursor: pointer; border: none; border-radius: 10px; font-weight: 700; transition: transform .1s, opacity .15s; color: #fff; }
button:active { transform: scale(.95); }
button:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); padding: .9rem; font-size: 1.1rem; width: 100%; }

/* ---- MAPA ---- */
#map { position: absolute; inset: 0; z-index: 1; }
#hud {
    position: absolute; top: 0; left: 0; right: 0; z-index: 1000;
    display: flex; align-items: center; gap: .5rem; padding: .5rem .7rem;
    background: rgba(22,33,62,.88); backdrop-filter: blur(6px);
}
.hud-chip { font-size: .85rem; padding: .3rem .6rem; background: rgba(255,255,255,.1); border-radius: 6px; white-space: nowrap; }
#btn-collection { margin-left: auto; padding: .35rem .8rem; background: var(--accent); font-size: .85rem; }
#btn-center { padding: .35rem .7rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); font-size: .85rem; }

/* Hráčská tečka */
.player-dot { width: 18px; height: 18px; background: var(--accent); border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 5px rgba(233,69,96,.25); animation: pdot 2s ease-in-out infinite; }
@keyframes pdot { 0%,100% { box-shadow: 0 0 0 5px rgba(233,69,96,.25); } 50% { box-shadow: 0 0 0 12px rgba(233,69,96,0); } }

/* === SOUBOJ === */
#screen-battle { background: linear-gradient(160deg, #1a0033, #3a0ca3, #1a1a2e); justify-content: center; align-items: center; padding: 1rem; }
.battle-box { width: 100%; max-width: 420px; text-align: center; }
#battle-phase { font-size: 2.4rem; font-weight: 900; margin-bottom: 1rem; min-height: 3rem; letter-spacing: 1px; }
.battle-countdown { color: #ffd60a; animation: bcd .9s ease-in-out infinite; }
.battle-go       { color: #ff4444; animation: bgo .25s ease-in-out infinite alternate; }
.battle-win      { color: #06d6a0; }
.battle-lose     { color: #e94560; }
.battle-draw     { color: #aaa; }
@keyframes bcd { 0%,100% { transform: scale(1); } 50% { transform: scale(1.2); } }
@keyframes bgo { from { transform: scale(1); } to { transform: scale(1.05); } }

.battle-arena { display: grid; grid-template-columns: 1fr auto 1fr; gap: .6rem; align-items: center; margin-bottom: 1.4rem; }
.battle-slot { background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.1); border-radius: 14px; padding: .8rem .5rem; }
.bs-name { font-size: .85rem; font-weight: 700; margin-bottom: .3rem; }
.bs-art { width: 70px; height: 70px; margin: 0 auto; }
.bs-art svg { width: 100%; height: 100%; }
.bs-mon { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.bs-empty { padding: 2rem .5rem; color: var(--muted); font-style: italic; }
.battle-vs { font-size: 1.6rem; font-weight: 900; color: #ff4444; }

#battle-tap-area { padding: 1rem; }
.battle-count { font-size: 4rem; font-weight: 900; color: #ffd60a; margin-bottom: .5rem; }
#battle-tap-btn { width: 100%; padding: 1.5rem; font-size: 1.6rem; font-weight: 900; background: var(--accent); color: white; border: none; border-radius: 18px; box-shadow: 0 6px 0 #8b1f37, 0 8px 20px rgba(0,0,0,.4); cursor: pointer; letter-spacing: 2px; transition: transform .05s, box-shadow .05s; }
#battle-tap-btn:active, #battle-tap-btn.pop { transform: translateY(3px); box-shadow: 0 3px 0 #8b1f37, 0 4px 10px rgba(0,0,0,.4); }

.battle-summary { background: rgba(0,0,0,.4); padding: 1.2rem; border-radius: 14px; font-size: 1.05rem; line-height: 1.8; }
.battle-summary strong { color: #ffd60a; font-size: 1.2rem; }
.battle-summary .btn-primary { margin-top: 1rem; }

/* === MODAL === */
#modal { position: fixed; inset: 0; z-index: 9000; display: none; align-items: center; justify-content: center; padding: 1rem; }
#modal.show { display: flex; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.modal-box { position: relative; background: linear-gradient(160deg, var(--bg2), var(--bg)); border: 2px solid var(--accent); border-radius: 18px; padding: 1.4rem 1.2rem; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.6); }
.modal-box h3 { font-size: 1.2rem; margin-bottom: .4rem; }
.modal-sub { color: var(--muted); font-size: .9rem; margin-bottom: .6rem; }
.modal-monster { display: flex; flex-direction: column; align-items: center; gap: .3rem; margin: .8rem 0; }
.modal-monster svg { width: 80px; height: 80px; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1rem; }
.modal-actions button { flex: 1; padding: .8rem; font-size: 1rem; font-weight: 700; border-radius: 10px; cursor: pointer; }
.btn-ghost { background: rgba(255,255,255,.1); color: white; border: 1px solid rgba(255,255,255,.2); }

/* Tlačítko boj na markeru hráče */
.op-fight { position: absolute; top: -8px; right: -8px; background: var(--accent); color: white; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: .85rem; box-shadow: 0 2px 6px rgba(0,0,0,.5); animation: opfight 1s ease-in-out infinite alternate; }
@keyframes opfight { from { transform: scale(1); } to { transform: scale(1.15); } }
.op-wrap.is-near .op-dot { background: #ff9500; box-shadow: 0 0 0 4px rgba(255,149,0,.4); }
.op-wrap { position: relative; }

/* Markery ostatních hráčů */
.op-icon { background: transparent; border: none; }
.op-wrap { display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.op-label { background: rgba(0,0,0,.78); color: #fff; font-size: .72rem; padding: 2px 8px; border-radius: 10px; margin-bottom: 3px; white-space: nowrap; font-weight: 600; box-shadow: 0 1px 4px rgba(0,0,0,.5); }
.op-dot { width: 16px; height: 16px; background: #06d6a0; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 4px rgba(6,214,160,.35); animation: oppulse 2.5s ease-in-out infinite; }
@keyframes oppulse { 0%,100% { box-shadow: 0 0 0 4px rgba(6,214,160,.35); } 50% { box-shadow: 0 0 0 9px rgba(6,214,160,0); } }

/* Multiplayer indikátor v HUD */
#hud-mp.mp-online  { background: rgba(6,214,160,.25); }
#hud-mp.mp-offline { background: rgba(255,80,80,.2); opacity: .6; }

/* Monster markery */
.m-marker { width: 44px; height: 44px; cursor: pointer; filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); transition: transform .15s; }
.m-marker svg { width: 100%; height: 100%; display: block; }
.m-marker.nearby { animation: mnear .9s ease-in-out infinite; }
@keyframes mnear { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

/* ---- SETKÁNÍ ---- */
#screen-encounter { justify-content: flex-start; align-items: center; padding: 1.2rem 1rem 1rem; background: linear-gradient(160deg,#0f0c29,#302b63,#1a1a2e); overflow-y: auto; }
.enc-box { text-align: center; width: 100%; max-width: 380px; }
#enc-emoji { display: inline-block; width: 130px; height: 130px; margin-bottom: .4rem; animation: bob .9s ease-in-out infinite alternate; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
#enc-emoji svg { width: 100%; height: 100%; }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-8px); } }
#enc-name { font-size: 1.9rem; margin-bottom: .3rem; }
.rarity-badge { display: inline-block; padding: .2rem .9rem; border-radius: 20px; font-size: .82rem; font-weight: 700; margin-bottom: .5rem; }
.rarity-common   { background: var(--common);    color: #000; }
.rarity-uncommon { background: var(--uncommon);  color: #000; }
.rarity-rare     { background: var(--rare);      color: #fff; }
.rarity-epic     { background: var(--epic);      color: #fff; }
.rarity-legendary{ background: var(--legend);    color: #000; }
#enc-desc { color: var(--muted); font-size: .88rem; margin-bottom: 1.2rem; }

#minigame-area  { margin-bottom: .8rem; }
.mg-hint { font-size: .82rem; color: var(--muted); margin-bottom: .7rem; }
#minigame-canvas { display: block; margin: 0 auto .9rem; touch-action: none; }
#btn-catch { width: 100%; padding: .95rem; background: var(--accent); font-size: 1.2rem; letter-spacing: 2px; border-radius: 12px; }

#catch-result .result-icon  { font-size: 2.8rem; margin-bottom: .3rem; }
#catch-result .result-text  { font-size: 1.2rem; margin-bottom: .4rem; }
#catch-result .result-emoji { width: 90px; height: 90px; margin: 0 auto 1rem; }
#catch-result .result-emoji svg { width: 100%; height: 100%; }
#catch-result button { padding: .75rem 2rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.25); font-size: 1rem; }

/* ---- SBÍRKA ---- */
#screen-collection { background: var(--bg); overflow-y: auto; }
.coll-header { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; background: var(--bg2); position: sticky; top: 0; z-index: 10; border-bottom: 1px solid rgba(255,255,255,.07); }
#btn-back-map { padding: .35rem .75rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.2); font-size: .85rem; }
.coll-header h2 { font-size: 1.1rem; }
#coll-stats { margin-left: auto; font-size: .8rem; color: var(--muted); }
#collection-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; padding: .9rem; }
.coll-card { background: var(--bg2); border-radius: 12px; padding: .8rem .5rem; text-align: center; border: 2px solid transparent; }
.coll-card.rarity-uncommon  { border-color: var(--uncommon); }
.coll-card.rarity-rare      { border-color: var(--rare); }
.coll-card.rarity-epic      { border-color: var(--epic);   box-shadow: 0 0 10px rgba(157,78,221,.3); }
.coll-card.rarity-legendary { border-color: var(--legend); box-shadow: 0 0 10px rgba(255,215,0,.35); }
.coll-badge { font-size: .6rem; padding: .12rem .45rem; border-radius: 8px; font-weight: 700; margin-bottom: .35rem; display: inline-block; }
.coll-emoji { width: 56px; height: 56px; margin: 0 auto; }
.coll-emoji svg { width: 100%; height: 100%; }
.coll-name  { font-size: .75rem; margin-top: .25rem; }
.coll-count { font-size: .72rem; color: var(--muted); background: rgba(255,255,255,.08); border-radius: 10px; padding: .05rem .4rem; display: inline-block; margin-top: .2rem; }
.coll-empty { grid-column: 1/-1; text-align: center; color: #555; padding: 3rem 1rem; line-height: 1.7; }

/* ---- NOTIFIKACE ---- */
#notification { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: .55rem 1.2rem; border-radius: 20px; font-size: .88rem; z-index: 9999; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; max-width: 90vw; text-align: center; }
#notification.show { opacity: 1; }

/* ==================================================================== */
/*  MOBIL / RESPONZIVITA — hra se hraje hlavně v terénu na telefonu.    */
/*  Nic nesmí přetékat vodorovně, tlačítka velká na prst, dotyk funguje.*/
/* ==================================================================== */

/* Nikdy vodorovné rolování; canvas a obrázky se vejdou do šířky. */
html, body { max-width: 100%; overflow-x: hidden; }
#minigame-canvas { max-width: 100%; height: auto; }
img, svg, canvas { max-width: 100%; }

/* Dotykové ovládání: markery a tlačítka reagují na prst, ne jen myš. */
.m-marker, .op-wrap, button, .profile-card { touch-action: manipulation; }
/* Marker příšery je terč pro prst — dej mu pořádnou plochu. */
.m-marker { -webkit-tap-highlight-color: transparent; }

/* Menší telefony (do 480 px) — zvětšit terče a upravit rozvržení. */
@media (max-width: 480px) {
    .load-box h1, .profile-box h1 { font-size: 2rem; }

    /* HUD: čipy se mohou zabalit, ať nic nepřeteče vpravo. */
    #hud { flex-wrap: wrap; gap: .4rem; padding: .45rem .55rem; }
    .hud-chip { font-size: .8rem; padding: .3rem .5rem; }
    /* Ovládací tlačítka na mapě větší a pohodlná na prst. */
    #btn-center, #btn-leaderboard, #btn-collection { min-width: 44px; min-height: 40px; padding: .45rem .7rem; font-size: 1rem; }
    #btn-collection { margin-left: auto; }

    /* Sbírka: na úzkém displeji 2 sloupce místo tří. */
    #collection-grid { grid-template-columns: repeat(2, 1fr); gap: .6rem; }

    /* Chytací tlačítko a boj — velké terče. */
    #btn-catch { padding: 1.05rem; font-size: 1.25rem; }
    #battle-tap-btn { padding: 1.35rem; font-size: 1.4rem; }

    /* Setkání se vejde i na malé výšky (vertikální rolování povoleno). */
    #enc-emoji { width: 110px; height: 110px; }
    #enc-name { font-size: 1.6rem; }
}

/* Nízké obrazovky na šířku (landscape) — ať jde vše dorolovat. */
@media (max-height: 480px) {
    #screen-encounter, #screen-battle { justify-content: flex-start; overflow-y: auto; }
    #enc-emoji { width: 90px; height: 90px; }
}
