/* ==========================================
   LANDING PAGE
   ========================================== */
html, body { margin: 0; padding: 0; font-family: sans-serif; background: #111; color: #fff; height: 100%; }

#landing {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 20px 40px;
}
#top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 13px;
}
#top-nav a {
    color: #888;
    text-decoration: none;
}
#top-nav a:hover { color: #fff; }
#intro-wrap {
    position: relative;
    width: 100%;
}
/* Obal okolo obrázka existuje preto, aby gradient sedel na spodku obrázka a nie na
   spodku celej sekcie – na mobile je sekcia vyššia o tlačidlo pod obrázkom. */
#intro-img {
    position: relative;
    width: 100%;
}
#intro-img picture { display: block; }
#intro-img img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0 0 8px 8px;
}
#intro-img::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to bottom, transparent, #111);
    pointer-events: none;
}
#intro-btn {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    z-index: 2;
    white-space: nowrap;
}
#intro-copy {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: #4caf50;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}
#intro-copy:hover { text-decoration: underline; }
#content {
    position: relative;
    z-index: 1;
    padding-top: 20px;
}
.btn-new {
    display: inline-block;
    padding: 13px 32px;
    background: #8B4513;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #ffeb3b;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    text-transform: uppercase;
    box-shadow: 0 8px 28px 6px rgba(0,0,0,0.95);
}
.btn-new:hover { background: #70360f; box-shadow: 0 4px 10px 2px rgba(0,0,0,0.7); }
h2 { font-size: 18px; color: #ccc; margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
    background: #222;
    color: #888;
    text-align: left;
    padding: 9px 12px;
    font-weight: normal;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.05em;
}
td { padding: 9px 12px; border-bottom: 1px solid #1e1e1e; vertical-align: middle; }
tr.active  td, tr.pending  td { background: rgba(0,100,0,0.18); }
tr.finished td { background: rgba(80,80,80,0.15); color: #777; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}
.badge-active   { background: #1a4a1a; color: #5f5; }
.badge-pending  { background: #1a3a1a; color: #afa; }
.badge-pending_coop { background: #1a3a1a; color: #afa; }
/* Spoločná hra čakajúca na spoluhráča — má pozývať, preto žltá ako akcent hry */
.badge-waiting  { background: #4a3a10; color: #ffeb3b; }
.badge-finished { background: #333;    color: #888; }
.btn-join {
    padding: 5px 16px;
    background: #1a4a8a;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    text-decoration: none;
}
.btn-join:hover { background: #1560b0; }
.btn-join-back { background: #2e7d32; font-weight: 700; }
.btn-join-back:hover { background: #3a9a40; }
tr.finished .btn-join { background: #333; color: #888; }
tr.finished .btn-join:hover { background: #444; }
.btn-join-full { background: #2a2a2a; color: #555; cursor: default; }
.btn-join-full:hover { background: #2a2a2a; }
/* Vstup do spoločnej hry: vstupom sa hra rozbehne a dvojica je v aliancii */
.btn-join-coop { background: #8B4513; font-weight: 700; }
.btn-join-coop:hover { background: #a35316; }
#refresh-note { font-size: 11px; color: #555; margin-top: 10px; }
#login-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.78);
    z-index: 9999;
}
#login-modal-box {
    background: #222;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 36px 40px;
    text-align: center;
    max-width: 380px;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
#login-modal-box p { font-size: 16px; color: #ccc; margin: 0 0 24px; line-height: 1.5; }
#login-modal-close {
    position: absolute;
    top: 10px; right: 14px;
    background: none;
    border: none;
    color: #888;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
#login-modal-close:hover { color: #fff; }
/* Uvítací modál: prihlásiť / registrovať / hrať ako hosť */
#login-modal-actions { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
#login-modal-actions .btn-new { box-shadow: none; padding: 11px 20px; font-size: 15px; }
.btn-new.wm-alt   { background: #2c2c2c; border-color: #8B4513; }
.btn-new.wm-alt:hover { background: #3a3a3a; }
.btn-new.wm-guest { background: #2c2c2c; border-color: #555; color: #ddd; font-family: inherit; }
.btn-new.wm-guest:hover { background: #3a3a3a; border-color: #888; }
#login-modal-note { font-size: 12px !important; color: #888 !important; margin: 20px 0 0 !important; }
#login-modal-err  { display: none; font-size: 13px !important; color: #ff8a80 !important; margin: 14px 0 0 !important; }

#help-btn {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 2;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #ffeb3b;
    color: #111;
    font-size: 18px;
    font-weight: bold;
    border: none;
    cursor: pointer;
    line-height: 32px;
    text-align: center;
    padding: 0;
}
#help-btn:hover { background: #ffe000; }
#tips-btn {
    position: absolute;
    top: 10px; right: 50px;
    z-index: 2;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    font-size: 17px;
    border: none;
    cursor: pointer;
    line-height: 32px;
    text-align: center;
    padding: 0;
}
#tips-btn:hover { background: #388e3c; }
#help-modal, #tips-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.78);
    z-index: 9999;
}
#help-box, #tips-box {
    background: #222;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 32px 36px;
    max-width: 480px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
#help-title, #tips-title { flex-shrink: 0; font-size: 20px; color: #ffeb3b; margin: 0 0 16px; }
#help-content, #tips-content { overflow-y: auto; min-height: 0; }
#help-content ul { margin: 0 0 16px; padding-left: 0; list-style: none; }
#help-content li { color: #ccc; font-size: 14px; margin-bottom: 8px; line-height: 1.5; }
#help-content p { color: #ffeb3b; font-size: 15px; font-weight: bold; margin: 0; text-align: center; }
#help-ok, #tips-ok { flex-shrink: 0; display: block; margin: 20px auto 0; padding: 10px 36px; background: #8B4513; color: #fff; border: none; border-radius: 6px; font-size: 15px; cursor: pointer; }
#help-ok:hover, #tips-ok:hover { background: #70360f; }

/* Popup novej hry — voľba veľkosti mapy a obtiažnosti */
#newgame-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.78);
    z-index: 9999;
}
/* Rozostupy sú zámerne utiahnuté: v popupe sú tri riadky kariet (veľkosť,
   obtiažnosť, mód hry) a s pôvodnými medzerami by na notebooku začal rolovať. */
#newgame-box {
    background: #222;
    border: 2px solid #555;
    border-radius: 12px;
    padding: 22px 26px 20px;
    max-width: 520px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}
#newgame-box h2 { font-size: 18px; color: #ffeb3b; margin: 0 0 14px; text-align: center; }
#newgame-close {
    position: absolute;
    top: 8px; right: 12px;
    background: none;
    border: none;
    color: #888;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
#newgame-close:hover { color: #fff; }

.opt-group { margin-bottom: 12px; }
.opt-label {
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}
.opt-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.opt-card {
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 8px;
    padding: 9px 6px 8px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.opt-card:hover { border-color: #666; }
.opt-card.active { border-color: #ffeb3b; background: #8B4513; }
.opt-ico  { font-size: 22px; line-height: 1.1; }
.opt-name { color: #eee; font-size: 13px; font-weight: bold; margin-top: 3px; }
.opt-sub  { color: #888; font-size: 11px; margin-top: 2px; }
.opt-card.active .opt-sub { color: #e6d3c0; }

/* Voľba "Súkromná hra" bola checkbox ako celá karta (.opt-check*). Od zavedenia
   módu hry je to tretia karta v riadku vedľa Verejnej a Spoločnej, takže tie
   pravidlá tu už nie sú — pozri .opt-card vyššie. */

.opt-bonus {
    text-align: center;
    color: #ccc;
    font-size: 14px;
    margin: 14px 0 12px;
}
#opt-bonus-val { color: #ffeb3b; font-weight: bold; font-size: 20px; }
/* Poznámka o delení bonusu v spoločnej hre — menšia, nech neprebije sumu */
#opt-bonus-note { color: #888; font-size: 11.5px; }
#newgame-start {
    display: block;
    width: 100%;
    padding: 11px;
    background: #8B4513;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    text-transform: uppercase;
    border: 2px solid #ffeb3b;
    border-radius: 6px;
    cursor: pointer;
}
#newgame-start:hover { background: #70360f; }

/* Preview button */
.btn-preview {
    padding: 5px 12px;
    background: #1a2e1a;
    color: #6f6;
    border: 1px solid #2a4a2a;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.btn-preview:hover { background: #1f3d1f; color: #8f8; }
tr.finished .btn-preview { background: #222; color: #666; border-color: #333; }

/* Preview modal */
#preview-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.82);
    z-index: 9999;
}
#preview-box {
    background: #1a1a28;
    border: 2px solid #444;
    border-radius: 12px;
    padding: 28px 28px 24px;
    max-width: 660px;
    width: 94%;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 40px rgba(0,0,0,0.9);
}
#preview-title {
    font-size: 15px;
    color: #aaa;
    margin: 0 0 16px;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
#preview-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    color: #777;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
#preview-close:hover { color: #fff; }
#preview-loading { color: #555; font-size: 14px; text-align: center; padding: 40px 0; }
#preview-content { }

/* MCRenderer layout */
.mcr-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}
.mcr-meta span {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 5px 11px;
    color: #ccc;
    font-size: 13px;
    white-space: nowrap;
}
.mcr-body {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.mcr-map-wrap { flex: 0 0 auto; }
.mcr-canvas {
    display: block;
    border-radius: 6px;
    border: 1px solid #333;
}
.mcr-stats {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}
.mcr-row {
    display: grid;
    grid-template-columns: 12px 1fr auto auto auto;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.mcr-neutral { opacity: 0.55; }
.mcr-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.mcr-name {
    color: #ddd;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mcr-bar-wrap {
    background: #222;
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    width: 90px;
}
.mcr-bar { height: 100%; border-radius: 4px; transition: width 0.3s; }
.mcr-pct { color: #aaa; font-size: 12px; width: 32px; text-align: right; }
.mcr-sol { color: #888; font-size: 12px; width: 52px; text-align: right; white-space: nowrap; }

/* Only-winner state */
.mcr-only-winner {
    text-align: center;
    padding: 36px 20px;
}
.mcr-winner-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #666;
    margin-bottom: 10px;
}
.mcr-winner-name {
    font-size: 26px;
    font-weight: bold;
    color: #4ade80;
}

@media (max-width: 560px) {
    .mcr-body { flex-direction: column; }
    .mcr-canvas { width: 100%; height: auto; }
}

/* ==========================================
   LANDING PAGE – MOBIL
   ==========================================
   Landing nemal doteraz žiaden breakpoint. Tabuľka so 7 stĺpcami pretekala mimo
   viewport (~580 px min-content), čím sa roztiahol celý dokument – intro obrázok
   potom vyzeral menší než zoznam a fixne pozicionované modály sa na iOS Safari
   vykreslili na šírku pretečeného obsahu, teda väčšie než obrazovka. */

/* --- Intro: obrázok od kraja po kraj, tlačidlo pod ním --- */
@media (max-width: 700px) {
    /* Bočný padding sa presúva z #landing dovnútra, aby bol obrázok od kraja po kraj */
    /* clip nevytvára scroll kontajner (na rozdiel od hidden), hidden je fallback */
    #landing { padding: 0 0 30px; overflow-x: hidden; overflow-x: clip; }
    #top-nav { padding: 10px 14px; }
    #content { padding: 20px 14px 0; }

    /* Výška podľa obsahu, žiadne 100svh: obrázok je na šírku (1024×750) a do portrétu
       telefónu sa nedá roztiahnuť bez orezania vpáleného nadpisu, takže vynútená
       celá výška by nechala veľké prázdne pásy nad obrázkom a pod tlačidlom. */
    #intro-wrap { text-align: center; }
    #intro-img img { border-radius: 0; }

    /* Tlačidlo zo stredu obrázka pod obrázok, aby neprekrývalo bojovníkov */
    #intro-btn {
        position: static;
        transform: none;
        margin-top: 22px;
    }
    .btn-new {
        padding: 18px 44px;
        font-size: 19px;
    }
    /* Copyright bol absolútne na spodku obrázka; teraz je pod tlačidlom v toku */
    #intro-copy {
        position: static;
        transform: none;
        display: inline-block;
        margin-top: 14px;
    }

    /* Väčší terč pre palec */
    #help-btn, #tips-btn {
        width: 40px; height: 40px;
        line-height: 40px;
        font-size: 20px;
    }
    #tips-btn { right: 58px; }

    /* Modály: bez border-boxu sa k percentuálnej šírke priráta padding a na úzkych
       displejoch modál pretečie mimo obrazovku. Zámerne len tu – na desktope by to
       modály zúžilo o šírku ich paddingu. */
    #login-modal-box, #help-box, #tips-box, #newgame-box, #preview-box {
        box-sizing: border-box;
    }
    #login-modal-box { width: 90%; }
}

/* --- Zoznam hier: z tabuľky na karty --- */
@media (max-width: 600px) {
    /* Zúžené na #content zámerne: game.css sa načítava aj na hernej obrazovke,
       holé table/tr/td selektory by tam rozbili prípadnú budúcu tabuľku. */
    #content thead { display: none; }
    #content table, #content tbody { display: block; }
    /* Poradie stĺpcov je dané pevne v JS šablóne (index.php), preto stačí :nth-child
       a template v JS sa nemusí meniť. */
    /* Auto-placement + order (nie grid-template-areas): prázdna bunka Víťaz sa dá
       vypnúť cez display:none a mriežka sa dotiahne bez zvyšnej medzery. Dva rovnaké
       stĺpce zaručia rovnako široké tlačidlá Vstúpiť/Náhľad. */
    #content tr {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 10px;
        align-items: center;
        background: #171717;
        border: 1px solid #262626;
        border-radius: 10px;
        padding: 12px 14px;
        margin-bottom: 10px;
    }
    /* Tint musí byť na karte, nie na bunkách */
    #content tr.active, #content tr.pending,
    #content tr.pending_coop                 { background: rgba(0,100,0,0.18); border-color: #24401f; }
    #content tr.waiting                      { background: rgba(139,69,19,0.22); border-color: #5a3c14; }
    #content tr.finished                     { background: rgba(80,80,80,0.15); color: #777; }
    #content td {
        display: block;
        border: 0;
        padding: 0;
        background: none;
    }
    /* Poradie na karte:  [stav | %]  /  [pred X | N 👤]  /  [🏆 víťaz]  /  [tlačidlá] */
    #content td:nth-child(2) { order: 1; }                                  /* stav   */
    #content td:nth-child(3) { order: 2; text-align: right; font-weight: bold; } /* %  */
    #content td:nth-child(1) { order: 3; color: #777; }                     /* aktivita */
    #content td:nth-child(4) { order: 4; text-align: right; }               /* hráči  */
    #content td:nth-child(5) { order: 5; grid-column: 1 / -1; }             /* víťaz  */
    #content td:nth-child(6) { order: 6; }                                  /* join   */
    #content td:nth-child(7) { order: 7; }                                  /* náhľad */
    #content td:nth-child(5):empty { display: none; }
    /* Popisky namiesto skrytej hlavičky. Emoji, aby nevznikali zlé tvary 1/2/5 hráčov. */
    #content td:nth-child(1)::before { content: 'pred '; }
    #content td:nth-child(4)::after  { content: ' \1F464'; }
    #content td:nth-child(5):not(:empty)::before { content: '\1F3C6\00A0'; }
    /* box-sizing je nutný: .btn-join je <a> (content-box), takže width:100% + padding
       by pretiekol stĺpec. .btn-preview je <button>, ten sa bez width:100% naopak
       zmrští – obe pravidlá spolu držia tlačidlá rovnako široké. */
    #content .btn-join, #content .btn-preview {
        display: block;
        box-sizing: border-box;
        width: 100%;
        text-align: center;
        padding: 11px;
        font-size: 14px;
    }
    /* Riadok "Načítavam…" / "Žiadne hry" má colspan=7, ktorý sa pri display:block
       ignoruje. Musí byť za :nth-child pravidlami, aby vyhral pri rovnakej špecificite. */
    #content tr > td:only-child {
        grid-column: 1 / -1;
        text-align: center;
        padding: 6px 0;
    }
    #content tr > td:only-child::before,
    #content tr > td:only-child::after { content: none; }
}

/* --- Popup novej hry --- */
@media (max-width: 480px) {
    #newgame-box { padding: 24px 18px 20px; width: 94%; }
    .opt-grid { grid-template-columns: 1fr; gap: 6px; }
    .opt-card {
        display: flex;
        align-items: center;
        gap: 12px;
        text-align: left;
        padding: 12px 14px;
    }
    .opt-ico  { font-size: 24px; flex: 0 0 auto; }
    .opt-name { margin-top: 0; }
    .opt-sub  { margin-top: 0; margin-left: auto; }
    .opt-bonus { margin: 18px 0 14px; }
}

/* ==========================================
   GAME
   ========================================== */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    background: #111;
    color: #fff;
    overflow: hidden;
    user-select: none;
    display: flex;
    flex-direction: column;
    font-family: sans-serif;
}
#top-ui {
    flex: 0 0 50px;
    z-index: 15;
    background: rgba(0,0,0,0.9);
    border-bottom: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
}
.ui-section { display: flex; align-items: center; gap: 15px; }
#timer { font-size: 22px; font-weight: bold; color: #ffeb3b; }
#player-info { font-size: 16px; }
/* Obsadenosť mapy — maličká, na konci pillu rýchlosti (vedľa nečinnosti) */
#occupancy-info { font-size: 10px; font-weight: bold; white-space: nowrap; cursor: help; color: #aaa; }
#occupancy-info.occ-open   { color: #00c851; }
#occupancy-info.occ-closed { color: #ff6b6b; }
#leaderboard { display: flex; gap: 8px; font-size: 13px; align-items: center; }
#leader-list { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 8px; }
.leader-item { background: rgba(255,255,255,0.05); padding: 2px 8px; border-radius: 4px; display: flex; gap: 6px; }
#combat-log-panel {
    flex-shrink: 0;
    height: 28px;
    background: rgba(10,10,10,0.9);
    border-bottom: 2px solid #333;
    box-sizing: border-box;
    padding: 6px 20px;
    overflow: hidden;
    font-family: monospace;
    font-size: 11px;
    color: #aaa;
    z-index: 20;
    transition: height 0.15s ease-in-out;
    display: flex;
    flex-direction: column;
}
#combat-log-panel.expanded { height: 120px; }
#log-container { flex: 1; overflow-y: auto; margin-top: 4px; }
.log-entry    { margin: 2px 0; border-left: 3px solid #555; padding-left: 8px; }
.log-attack     { border-left-color: #ff3333; color: #ff9999; }
.log-move       { border-left-color: #33b5e5; color: #99ccff; }
.log-takeover   { border-left-color: #00c851; color: #99ff99; font-weight: bold; }
.log-system     { border-left-color: #ffeb3b; color: #fff;    font-weight: bold; }
.log-diplomacy  { border-left-color: #ba8bff; color: #d9c2ff; font-weight: bold; }
#map-container { flex: 1 1 0; position: relative; overflow: hidden; }
canvas { display: block; cursor: pointer; width: 100%; height: 100%; touch-action: manipulation; }
#gauge-bar {
    flex: 0 0 28px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    box-sizing: border-box;
    z-index: 15;
}
.gauge-pill {
    background: rgba(0,0,0,0.92);
    border: 2px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    box-sizing: border-box;
    height: 100%;
}
#speed-pill { width: 20%; }
#troop-pill { width: 40%; }
.gauge-label { font-size: 10px; color: #aaa; white-space: nowrap; }
#troop-slider { flex: 1; cursor: pointer; height: 14px; accent-color: #8B4513; }
#gauge-pct  { font-size: 12px; font-weight: bold; color: #ffeb3b; min-width: 36px; text-align: right; }
#gauge-hint { font-size: 10px; color: #555; white-space: nowrap; min-width: 200px; text-align: right; transition: color 0.2s; }
#gauge-hint.selected { color: #33b5e5; }
#gauge-hint.ready    { color: #00c851; }
#sync-bar  { flex: 1; height: 8px; background: #333; border-radius: 4px; overflow: hidden; }
#sync-fill { height: 100%; width: 100%; background: #33b5e5; border-radius: 4px; transition: width 1s linear; }
#sync-val  { font-size: 12px; font-weight: bold; color: #33b5e5; min-width: 28px; text-align: right; }
@media (min-height: 700px) {
    #gauge-bar { flex: 0 0 44px; }
    .gauge-label { font-size: 12px; }
    #gauge-pct, #sync-val, #inactivity-val { font-size: 14px; }
    #troop-slider { height: 18px; }
}
@media (max-width: 900px) {
    #gauge-bar { flex: 0 0 auto; flex-direction: column; gap: 8px; padding: 10px 16px; background: rgba(10,10,10,0.95); border-top: 2px solid #333; }
    .gauge-pill { width: 100% !important; border: 2px solid #333 !important; border-radius: 8px !important; height: auto !important; padding: 14px 18px !important; flex-wrap: wrap; gap: 8px; }
    #speed-pill, #troop-pill { display: flex; align-items: center; }
    .gauge-label { font-size: 15px; }
    #gauge-pct, #sync-val, #inactivity-val, #inactivity-label { font-size: 16px; }
    #troop-slider { height: 28px; }
    #gauge-hint { display: none; }
    #top-ui { flex: 0 0 auto; flex-direction: column; align-items: stretch; justify-content: center; gap: 6px; padding: 8px 12px; }
    .ui-section { justify-content: space-between; }
    #occupancy-info { font-size: 13px; }
    #lbl-top-factions { display: none; }
    #leaderboard { width: 100%; gap: 4px; }
    #leader-list { display: grid !important; grid-template-columns: repeat(4, 1fr); gap: 4px !important; width: 100%; }
}
#game-over-screen {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
}
#game-over-box   { background: #222; border: 3px solid #8B4513; padding: 40px; border-radius: 12px; text-align: center; box-shadow: 0 0 30px rgba(139,69,19,0.3); max-width: 500px; }
#game-over-title { font-size: 36px; font-weight: bold; margin-bottom: 15px; text-transform: uppercase; }
#game-over-desc  { font-size: 18px; color: #ccc; margin-bottom: 25px; line-height: 1.5; }
.restart-btn { padding: 12px 30px; font-size: 16px; font-weight: bold; background: #8B4513; color: #fff; border: none; border-radius: 6px; cursor: pointer; text-transform: uppercase; }
.restart-btn:hover { background: #70360f; }
.troop-token { position: fixed; z-index: 200; pointer-events: none; display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -50%); }
.troop-token img { width: 24px; height: 24px; filter: drop-shadow(0 0 4px rgba(0,0,0,0.8)); }
.troop-token .troop-label { font-size: 10px; font-weight: bold; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; margin-top: 1px; white-space: nowrap; }
canvas.field-locked { cursor: not-allowed; }
#map-loading { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); color: #aaa; font-size: 18px; pointer-events: none; z-index: 5; }
#inactivity-pill {
    display: none;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.92);
    border: 2px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 0 12px;
    height: 100%;
    box-sizing: border-box;
    min-width: 160px;
}
#inactivity-pill.visible { display: flex; }
#inactivity-label { font-size: 10px; color: #aaa; white-space: nowrap; }
#inactivity-val   { font-size: 13px; font-weight: bold; color: #ffeb3b; min-width: 36px; text-align: right; }
#inactivity-pill.warn   #inactivity-val { color: #ffeb3b; }
#inactivity-pill.danger #inactivity-val { color: #ff4444; animation: pulse 0.6s infinite alternate; }
@keyframes pulse { from { opacity: 1; } to { opacity: 0.4; } }
#error-modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#error-box { background: #222; border: 3px solid #555; padding: 40px; border-radius: 12px; text-align: center; max-width: 420px; }
#error-box p { color: #ccc; font-size: 16px; line-height: 1.5; margin: 0 0 24px; }
#inactivity-screen {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#inactivity-box    { background: #222; border: 3px solid #555; padding: 40px; border-radius: 12px; text-align: center; max-width: 420px; }
#inactivity-box h2 { font-size: 26px; color: #ff4444; margin: 0 0 16px; }
#inactivity-box p  { color: #ccc; font-size: 15px; line-height: 1.5; margin: 0 0 24px; }

/* Spoločná hra — čakanie na spoluhráča. Rovnaká blokujúca vrstva ako
   #inactivity-screen; v čakajúcej hre sa naozaj nedá nič robiť. */
#coop-screen {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px;
    box-sizing: border-box;
}
#coop-box {
    background: #222;
    border: 3px solid #8B4513;
    padding: 32px 30px 26px;
    border-radius: 12px;
    text-align: center;
    max-width: 460px;
    width: 100%;
    box-sizing: border-box;
}
#coop-box h2 { font-size: 22px; color: #ffeb3b; margin: 0 0 14px; }
#coop-box p  { color: #ccc; font-size: 14px; line-height: 1.5; margin: 0 0 16px; }
#coop-box b  { color: #ffeb3b; }
/* Odkaz na hru: na klik sa označí celý, aby sa dal poslať spoluhráčovi */
#coop-link {
    width: 100%;
    box-sizing: border-box;
    background: #111;
    border: 1px solid #444;
    border-radius: 6px;
    color: #8fd0ff;
    font-size: 12px;
    padding: 9px 10px;
    text-align: center;
    cursor: pointer;
}
#coop-hint { color: #888 !important; font-size: 11.5px !important; margin: 8px 0 18px !important; }
#coop-solo { margin: 0 auto; }
#coop-back {
    display: block;
    margin-top: 14px;
    color: #888;
    font-size: 12px;
    text-decoration: none;
}
#coop-back:hover { color: #ccc; text-decoration: underline; }

/* Diplomacy modals */
#dipl-modal, #confirm-modal, #notice-modal {
    display: none;
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1500;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#dipl-box, #confirm-box, #notice-box {
    background: #222;
    border: 3px solid #8B4513;
    padding: 28px 32px;
    border-radius: 12px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 0 30px rgba(139,69,19,0.3);
}
#dipl-title, #confirm-title, #notice-title {
    font-size: 20px;
    font-weight: bold;
    color: #ffeb3b;
    margin-bottom: 16px;
}
#dipl-content { margin-bottom: 18px; }
.dipl-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px solid #333;
    font-size: 14px;
    color: #ccc;
    text-align: left;
}
.dipl-row span { color: #999; }
.dipl-row b { color: #fff; text-align: right; }
.dipl-row-wide b { max-width: 60%; }
.dipl-hint { margin-top: 12px; font-size: 12px; color: #33b5e5; line-height: 1.4; }
#dipl-truce-turns-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
#dipl-truce-turns-label { font-size: 13px; color: #ccc; white-space: nowrap; }
#dipl-truce-turns { flex: 1; cursor: pointer; accent-color: #33b5e5; }
#confirm-text, #notice-text { color: #ccc; font-size: 15px; line-height: 1.6; margin-bottom: 22px; }
#dipl-actions, #confirm-actions { display: flex; flex-direction: column; gap: 10px; }
.dipl-btn {
    padding: 11px 20px;
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: #fff;
}
.dipl-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.dipl-btn-truce  { background: #33b5e5; }
.dipl-btn-truce:hover:not(:disabled)  { background: #2596c4; }
.dipl-btn-ally   { background: #00c851; }
.dipl-btn-ally:hover:not(:disabled)   { background: #00a844; }
.dipl-btn-message { background: #9c27b0; }
.dipl-btn-message:hover:not(:disabled) { background: #7b1fa2; }
.dipl-btn-close  { background: #444; }
.dipl-btn-close:hover  { background: #555; }
.dipl-btn-yes    { background: #00c851; }
.dipl-btn-yes:hover    { background: #00a844; }
.dipl-btn-no     { background: #cc0000; }
.dipl-btn-no:hover     { background: #a80000; }
/* Aliancia sa ponúknuť nedá — tlačidlo ostáva viditeľné len ako vysvetlenie dôvodu,
   preto neutrálna šeď namiesto zelenej. Musí byť za .dipl-btn-ally (rovnaká špecificita). */
.dipl-btn-blocked { background: #333; color: #999; font-weight: normal; }
