/**
 * Poslední val - CSS styly (temný komiksový a grunge styl)
 */

:root {
    --bg-dark: #090a0f;
    --panel-bg: rgba(18, 20, 29, 0.94);
    --ink: #000000;
    --toxic-green: #10b981;
    --toxic-glow: #34d399;
    --blood-red: #ef4444;
    --hazard-yellow: #f59e0b;
    --border-comic: 3px solid #000;
    --shadow-comic: 4px 4px 0px #000;
    --font-heading: "Arial Black", Impact, sans-serif;
    --hud-h: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

input,
textarea {
    user-select: text;
    -webkit-user-select: text;
}

body.pv-body {
    background-color: var(--bg-dark);
    color: #f8fafc;
    font-family: system-ui, -apple-system, sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* Hlavní kontejner aplikace */
.pv-app {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Horní HUD lišta */
.pv-hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    min-height: var(--hud-h);
    background: var(--panel-bg);
    border-bottom: var(--border-comic);
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    z-index: 50;
    backdrop-filter: blur(8px);
}

.pv-hud-left, .pv-hud-center, .pv-hud-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pv-hud-left,
.pv-hud-right {
    flex-shrink: 0;
}

.pv-back-btn, .pv-icon-btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: #1e293b;
    color: #f8fafc;
    border: var(--border-comic);
    border-radius: 8px;
    box-shadow: 2px 2px 0 #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, background 0.2s;
}

.pv-back-btn:hover, .pv-icon-btn:hover {
    background: #334155;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #000;
}

.pv-brand {
    font-family: var(--font-heading);
    font-size: 18px;
    color: var(--toxic-green);
    letter-spacing: 0.5px;
    text-shadow: 2px 2px 0 #000;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* Středový časovač a ukazatel fází */
.pv-hud-phase {
    font-family: var(--font-heading);
    font-size: 14px;
    padding: 4px 12px;
    border-radius: 6px;
    border: 2px solid #000;
    text-transform: uppercase;
    white-space: nowrap;
}

.pv-hud-phase--build {
    background: #0284c7;
    color: #fff;
}

.pv-hud-phase--defense {
    background: var(--blood-red);
    color: #fff;
    animation: pulse-danger 1.5s infinite;
}

.pv-hud-phase--fast {
    background: #eab308;
    color: #000;
    border-color: #000;
    animation: pulse-fast 0.6s infinite;
}

@keyframes pulse-fast {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.92; transform: scale(1.05); }
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.03); }
}

.pv-hud-timer {
    font-family: monospace;
    font-size: 26px;
    font-weight: 900;
    color: #fef08a;
    text-shadow: 2px 2px 0 #000;
    min-width: 65px;
}

.pv-hud-round {
    font-size: 14px;
    color: #94a3b8;
    font-weight: bold;
    white-space: nowrap;
}

/* Tlačítko přeskočení dne přímo do boje */
.pv-skip-day-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background: #dc2626;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 2px solid #000;
    border-radius: 6px;
    box-shadow: 2px 2px 0 #000;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    user-select: none;
    margin-left: 4px;
    white-space: nowrap;
}
.pv-skip-day-btn:hover {
    background: #ef4444;
    transform: translateY(-1px);
}
.pv-skip-day-btn:active {
    transform: translateY(1px);
    box-shadow: 1px 1px 0 #000;
}
.pv-skip-day-btn[hidden] {
    display: none !important;
}

/* Suroviny v HUD */
.pv-resources {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(15, 23, 42, 0.8);
    padding: 6px 14px;
    border-radius: 8px;
    border: 2px solid #000;
}

.pv-res-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    font-size: 15px;
    white-space: nowrap;
}

.pv-res-food { color: #86efac; }
.pv-res-scrap { color: #cbd5e1; }
.pv-res-ammo { color: #fde047; }
.pv-res-people { color: #7dd3fc; }

.pv-res-ammo.is-low {
    color: var(--blood-red);
    animation: pulse-danger 1s infinite;
}

.pv-gate-bar {
    width: 110px;
    height: 14px;
    background: #334155;
    border: 2px solid #000;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.pv-gate-hp {
    height: 100%;
    background: var(--toxic-green);
    width: 100%;
    transition: width 0.3s;
}

.pv-gate-hp.is-low {
    background: var(--blood-red);
}

.pv-hud-score {
    color: #fbbf24;
    font-family: monospace;
    font-size: 15px;
    white-space: nowrap;
}

.pv-save-badge {
    display: inline-block;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #64748b;
    border: 1px solid #000;
}

.pv-save-badge.saved {
    background: #22c55e;
    box-shadow: 0 0 8px #22c55e;
}

.pv-save-badge.failed {
    background: var(--blood-red);
    box-shadow: 0 0 8px var(--blood-red);
}

/* Hrací plátno */
.pv-stage {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    transition: filter 0.3s ease;
}

/* Rozostření mapy při pauze podle zadání uživatele */
.pv-stage.is-paused {
    filter: blur(12px) brightness(0.45);
    pointer-events: none;
}

#arena {
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

/* Spodní lišta zbraní a obranných prvků */
.pv-bottom-bar {
    position: fixed;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    z-index: 40;
}

.pv-action-group {
    display: flex;
    gap: 8px;
    background: var(--panel-bg);
    padding: 6px 10px;
    border: var(--border-comic);
    border-radius: 10px;
    box-shadow: var(--shadow-comic);
}

.pv-slot-btn {
    width: 58px;
    height: 58px;
    background: #1e293b;
    color: #f8fafc;
    border: 2px solid #334155;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    transition: transform 0.1s, border-color 0.2s, opacity 0.2s;
}

.pv-slot-btn i {
    font-size: 18px;
}

.pv-slot-btn .slot-key {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 9px;
    color: #94a3b8;
}

/* Náboje v zásobníku zbraně */
.pv-slot-btn .slot-ammo {
    font-size: 9px;
    font-family: monospace;
    color: #fde047;
    line-height: 1;
    min-height: 9px;
}

.pv-slot-btn.is-active {
    border-color: var(--toxic-green);
    background: #064e3b;
    box-shadow: 0 0 10px var(--toxic-green);
}

.pv-slot-btn.is-locked,
.pv-slot-btn.is-unaffordable {
    opacity: 0.4;
}

.pv-slot-btn.is-locked {
    cursor: not-allowed;
}

.pv-slot-btn:hover:not(.is-locked) {
    transform: translateY(-2px);
    border-color: #f8fafc;
}

.pv-slot-btn:focus-visible,
.pv-btn:focus-visible,
.pv-icon-btn:focus-visible,
.pv-back-btn:focus-visible,
.pv-rem-card:focus-visible,
.pv-interact:focus-visible,
.pv-place-cancel:focus-visible {
    outline: 3px solid #fde047;
    outline-offset: 2px;
}

/* Vlastní SVG ikony zbraní na blízko (stejná velikost jako ikony FontAwesome) */
.pv-svg-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
}

.pv-slot-btn .slot-icon {
    display: flex;
    font-size: 18px;
    line-height: 1;
}

/* Nástroje v liště staveb: úpravy obrany a rozkaz střelcům */
.pv-slot-btn--tool {
    border-color: #475569;
    background: #172033;
}

.pv-slot-btn--tool.is-active {
    border-color: #fde047;
    background: #3f3a12;
    box-shadow: 0 0 10px rgba(253, 224, 71, 0.6);
}

.pv-slot-btn.is-field {
    border-color: var(--hazard-yellow);
    background: #4a2a07;
}

.pv-slot-btn.is-active-mining {
    border-color: #38bdf8;
    background: #0c4a6e;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

/* Panel vybrané stavby: přesun a rozebrání na šrot (nad lištou stavby) */
.pv-defense-panel {
    position: fixed;
    left: 50%;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 150px);
    transform: translateX(-50%);
    z-index: 46;
    display: flex;
    align-items: center;
    gap: 10px;
    /* bez šířky by left: 50 % omezilo panel na půlku okna a zbytečně se zalamoval */
    width: max-content;
    max-width: calc(100vw - 32px);
    padding: 8px 10px 8px 14px;
    background: #0f172a;
    color: #e2e8f0;
    border: var(--border-comic);
    border-radius: 10px;
    box-shadow: var(--shadow-comic);
    animation: pop-in 0.18s ease-out;
}

.pv-defense-panel[hidden] {
    display: none;
}

.pv-dp-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pv-dp-info strong {
    font-size: 14px;
    white-space: nowrap;
}

.pv-dp-info small {
    font-size: 12px;
    color: #94a3b8;
}

.pv-dp-btn,
.pv-dp-close {
    min-height: 40px;
    padding: 6px 12px;
    border: 2px solid #000;
    border-radius: 6px;
    background: #334155;
    color: #fff;
    font-weight: bold;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}

.pv-dp-btn--scrap {
    background: #9a3412;
}

.pv-dp-close {
    min-width: 40px;
    padding: 6px 10px;
    background: transparent;
    border-color: #475569;
}

.pv-dp-btn:hover,
.pv-dp-close:hover {
    filter: brightness(1.2);
}

.pv-dp-btn:focus-visible,
.pv-dp-close:focus-visible {
    outline: 3px solid #fde047;
    outline-offset: 2px;
}

/* Tlačítko pro budovu, u které velitel stojí, a lišta stavby obrany (sdílejí místo nad spodní lištou) */
.pv-interact,
.pv-place-banner {
    position: fixed;
    left: 50%;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px);
    transform: translateX(-50%);
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 32px);
    padding: 8px 14px;
    border: var(--border-comic);
    border-radius: 10px;
    box-shadow: var(--shadow-comic);
    font-size: 14px;
    font-weight: bold;
}

.pv-interact {
    background: #fbbf24;
    color: #0d0d12;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    animation: pop-in 0.18s ease-out;
}

.pv-interact:hover {
    background: #fcd34d;
}

.pv-interact-key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 2px solid #0d0d12;
    border-radius: 5px;
    background: #fff;
    font-family: monospace;
}

.pv-place-banner {
    background: #0f172a;
    color: #e2e8f0;
}

.pv-place-banner > i {
    color: var(--toxic-glow);
    font-size: 18px;
}

.pv-place-cancel {
    padding: 6px 10px;
    border: 2px solid #000;
    border-radius: 6px;
    background: var(--blood-red);
    color: #fff;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.pv-interact[hidden],
.pv-place-banner[hidden] {
    display: none;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateX(-50%) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* Velký oznamovací pruh fází */
.pv-phase-notif {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%) scale(0.7);
    padding: 14px 32px;
    border-radius: 12px;
    border: 4px solid #000;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    font-family: var(--font-heading);
    font-size: 24px;
    letter-spacing: 1px;
    text-shadow: 2px 2px 0 #000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 80;
    white-space: nowrap;
}

.pv-phase-notif.is-active {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

.notif-danger { color: #fecaca; background: #991b1b; }
.notif-success { color: #bbf7d0; background: #166534; }

/* Modální okna (Start, Pauza, Budovy, Game Over) */
.pv-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.75);
    z-index: 100;
    backdrop-filter: blur(4px);
    padding: 16px;
}

.pv-modal[hidden] {
    display: none !important;
}

.pv-card {
    background: #181924;
    border: 4px solid #000;
    border-radius: 14px;
    box-shadow: 8px 8px 0px #000;
    max-width: 520px;
    width: 100%;
    padding: 26px;
    color: #f8fafc;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.pv-card--center {
    text-align: center;
}

.pv-card-title {
    font-family: var(--font-heading);
    font-size: 24px;
    color: var(--toxic-green);
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pv-card-title--danger {
    color: var(--blood-red);
    justify-content: center;
}

.pv-card-sub {
    font-size: 14px;
    color: #94a3b8;
    margin-bottom: 20px;
    line-height: 1.5;
}

.pv-btn {
    padding: 12px 20px;
    background: #334155;
    color: #fff;
    border: var(--border-comic);
    border-radius: 8px;
    box-shadow: var(--shadow-comic);
    font-family: var(--font-heading);
    font-size: 15px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    transition: transform 0.1s;
    width: 100%;
    margin-top: 10px;
}

.pv-btn:hover:not(:disabled) {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
}

.pv-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pv-btn--primary {
    background: var(--toxic-green);
    color: #000;
}

.pv-btn--danger {
    background: var(--blood-red);
    color: #fff;
}

.pv-btn--small {
    width: auto;
    margin-top: 0;
    padding: 7px 14px;
    font-size: 13px;
    white-space: nowrap;
}

.pv-form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.pv-form-group label,
.pv-group-label {
    font-weight: bold;
    font-size: 14px;
    color: #cbd5e1;
}

.pv-input {
    padding: 12px 14px;
    background: #0f172a;
    border: var(--border-comic);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    font-family: inherit;
}

.pv-input:focus {
    outline: none;
    border-color: var(--toxic-green);
    box-shadow: 0 0 8px var(--toxic-green);
}

/* Hláška ve startovním okně: chyba nebo informace o dohrané hře */
.pv-alert {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 2px solid #7f1d1d;
    border-radius: 8px;
    background: rgba(127, 29, 29, 0.35);
    color: #fecaca;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.45;
}

.pv-alert--info {
    border-color: #1e40af;
    background: rgba(30, 64, 175, 0.3);
    color: #bfdbfe;
}

.pv-alert[hidden],
.pv-continue[hidden] {
    display: none;
}

.pv-continue {
    background: #0f172a;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    border: 2px solid #334155;
}

.pv-continue p {
    font-size: 13px;
    color: #94a3b8;
    margin: 4px 0;
}

.pv-continue code {
    color: #fde047;
    font-weight: bold;
}

.pv-load-form {
    margin-top: 20px;
    border-top: 1px solid #334155;
    padding-top: 14px;
}

.pv-code-box {
    background: #0f172a;
    border: 2px dashed #475569;
    padding: 14px;
    border-radius: 8px;
    margin: 14px 0;
    text-align: center;
}

.pv-code-label {
    font-size: 12px;
    color: #94a3b8;
    text-transform: uppercase;
}

.pv-code-val {
    font-family: monospace;
    font-size: 22px;
    color: #fde047;
    font-weight: bold;
    display: block;
    margin: 4px 0;
    user-select: all;
    -webkit-user-select: all;
}

.pv-code-box .pv-btn {
    margin-top: 6px;
}

/* Volba zapamatování kódu (výběrové karty) */
.pv-remember-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 6px 0 0;
}

.pv-rem-card {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #f8fafc;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: border-color 0.2s, background 0.2s;
}

.pv-rem-card small {
    color: #94a3b8;
}

.pv-rem-card[aria-checked="true"] {
    border-color: var(--toxic-green);
    background: #064e3b;
}

.pv-rem-card[aria-checked="true"] strong i {
    color: var(--toxic-glow);
}

/* Ovládání v pauze */
.pv-controls {
    margin: 4px 0 6px;
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}

.pv-controls summary {
    cursor: pointer;
    font-weight: bold;
    color: #cbd5e1;
}

.pv-controls ul {
    margin-top: 8px;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #94a3b8;
    line-height: 1.4;
}

.pv-controls strong {
    color: #e2e8f0;
}

/* Modál budovy */
.pv-building-lvl {
    color: #38bdf8;
    display: block;
    margin-bottom: 10px;
}

.pv-building-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pv-building-actions .pv-btn {
    margin-top: 0;
    font-size: 14px;
}

.pv-modal-note {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.4;
}

.pv-modal-note--warn {
    color: #fbbf24;
}

#buildingModalClose {
    margin-top: 16px;
}

/* Výsledek po prohře */
.pv-result {
    background: #0f172a;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    border: 2px solid #334155;
}

.pv-result-score {
    font-size: 18px;
    margin-bottom: 6px;
}

.pv-result-score strong {
    color: #fde047;
    font-size: 24px;
}

.pv-result-stats {
    color: #94a3b8;
    font-size: 14px;
}

.pv-result-stats strong {
    color: #fff;
}

.pv-result-rank {
    margin-top: 8px;
    color: #34d399;
    font-weight: bold;
}

.pv-result-rank[hidden] {
    display: none;
}

/* Toast notifikace */
.pv-toasts {
    position: fixed;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 92px);
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 60;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 40px));
}

.pv-toast {
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid var(--toxic-green);
    color: #fff;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.6);
    animation: slide-toast 0.25s ease-out;
}

.pv-toast--warn {
    border-color: var(--hazard-yellow);
}

@keyframes slide-toast {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Cookie lišta (nad modály, aby šla odkliknout i u startovního okna) */
.pv-cookie-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: 920px;
    margin: 0 auto;
    background: #111827;
    border: var(--border-comic);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 120;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.7), var(--shadow-comic);
}

.pv-cookie-bar[hidden] {
    display: none;
}

.pv-cookie-bar > i {
    font-size: 26px;
    color: var(--hazard-yellow);
}

.pv-cookie-bar p {
    font-size: 13px;
    color: #cbd5e1;
    line-height: 1.4;
    flex: 1;
}

.pv-cookie-bar a {
    color: var(--toxic-green);
    text-decoration: underline;
}

.pv-cookie-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

/* Telefon na výšku během hry: výzva k otočení (hra mezitím stojí, hlídá main.js) */
.pv-rotate {
    display: none;
}

@media (pointer: coarse) and (orientation: portrait) {
    body[data-phase="game"] .pv-rotate {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 12px;
        padding: 24px;
        background: var(--bg-dark);
        text-align: center;
    }

    .pv-rotate i {
        font-size: 56px;
        color: var(--hazard-yellow);
        animation: rotate-phone 1.6s ease-in-out infinite;
    }

    .pv-rotate strong {
        font-family: var(--font-heading);
        font-size: 22px;
        color: var(--toxic-green);
    }

    .pv-rotate p {
        max-width: 280px;
        color: #94a3b8;
        line-height: 1.45;
    }
}

@keyframes rotate-phone {
    0%, 30% { transform: rotate(0deg); }
    60%, 100% { transform: rotate(-90deg); }
}

/* Responzivita: pod 1100 px se horní i spodní lišta zhustí. Plná velikost potřebuje skoro 1050 px
   (horní lišta) a 1000 px (14 tlačítek dole), na iPadu naležato a v okně na půl monitoru by přetekly */
@media (max-width: 1100px) {
    :root {
        --hud-h: 56px;
    }
    .pv-hud {
        padding: 0 10px;
        gap: 8px;
    }
    .pv-hud-left, .pv-hud-center, .pv-hud-right {
        gap: 8px;
    }
    .pv-brand {
        display: none;
    }
    .pv-hud-phase {
        font-size: 12px;
        padding: 3px 8px;
    }
    .pv-hud-timer {
        font-size: 20px;
        min-width: 50px;
    }
    .pv-resources {
        gap: 8px;
        padding: 4px 8px;
    }
    .pv-res-item {
        font-size: 13px;
        gap: 4px;
    }
    .pv-gate-bar {
        width: 60px;
    }
    .pv-hud-score {
        font-size: 13px;
    }
    .pv-back-btn, .pv-icon-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    .pv-bottom-bar {
        gap: 6px;
    }
    .pv-action-group {
        gap: 5px;
        padding: 5px 6px;
    }
    .pv-slot-btn {
        width: 50px;
        height: 50px;
        font-size: 9px;
    }
    .pv-slot-btn i {
        font-size: 15px;
    }
    .pv-phase-notif {
        font-size: 18px;
        padding: 10px 18px;
    }
    .pv-interact,
    .pv-place-banner,
    .pv-toasts {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 76px);
    }
    .pv-defense-panel {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 130px);
        flex-wrap: wrap;
        justify-content: center;
    }
    .pv-cookie-bar {
        flex-wrap: wrap;
        padding: 12px 14px;
    }
    .pv-cookie-bar > i {
        display: none;
    }
    .pv-cookie-bar p {
        flex-basis: 100%;
        font-size: 12px;
    }
}

/* Telefon naležato a užší okno: zhuštěná horní lišta potřebuje asi 800 px, zmizí číslo kola (je i v oznámení úsvitu)
   a z tlačítka Do boje zůstane ikona, jinak by tlačítko pauzy zajelo za okraj */
@media (max-width: 860px) {
    .pv-hud {
        gap: 6px;
        padding-left: 8px;
        padding-right: 8px;
    }
    .pv-hud-left, .pv-hud-center, .pv-hud-right {
        gap: 6px;
    }
    .pv-hud-timer {
        min-width: 44px;
    }
    .pv-hud-round {
        display: none;
    }
    .pv-skip-day-btn > span {
        display: none;
    }
    .pv-resources {
        gap: 6px;
        padding: 4px 6px;
    }
    .pv-gate-bar {
        width: 44px;
    }
}

/* Úzké okno: lišta se zalomí do dvou řádků */
@media (max-width: 640px) {
    .pv-skip-day-btn > span {
        display: inline;
    }
    .pv-hud {
        flex-wrap: wrap;
        justify-content: center;
        padding: 6px 8px;
        row-gap: 6px;
    }
    .pv-hud-right {
        order: 3;
        width: 100%;
        justify-content: center;
    }
    .pv-hud-round {
        display: none;
    }
    .pv-skip-day-btn {
        height: 28px;
        padding: 0 8px;
        font-size: 11px;
    }
    .pv-resources {
        gap: 6px;
        padding: 4px 6px;
    }
    .pv-res-item {
        font-size: 12px;
        gap: 3px;
    }
    .pv-gate-bar {
        width: 44px;
    }
    .pv-slot-btn {
        width: 44px;
        height: 46px;
    }
}

/* Úzké okno: zbraně a stavby se vedle sebe nevejdou, jdou pod sebe a hlášky nad ně */
@media (max-width: 810px) and (min-height: 501px) {
    .pv-bottom-bar {
        left: 8px;
        right: 8px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }
    .pv-interact,
    .pv-place-banner,
    .pv-toasts {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 150px);
    }
    .pv-defense-panel {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 204px);
    }
}

/* Nízký displej na šířku (mobil): tlačítka po stranách, svět dostane celou výšku */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --hud-h: 46px;
    }
    .pv-hud {
        padding: 0 8px;
    }
    .pv-back-btn, .pv-icon-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
        box-shadow: 1px 1px 0 #000;
    }
    .pv-hud-timer {
        font-size: 18px;
    }
    .pv-bottom-bar {
        top: calc(var(--hud-h) + 8px);
        bottom: max(8px, env(safe-area-inset-bottom));
        left: max(6px, env(safe-area-inset-left));
        right: max(6px, env(safe-area-inset-right));
        transform: none;
        justify-content: space-between;
        align-items: center;
        pointer-events: none;
    }
    .pv-action-group {
        flex-direction: column;
        pointer-events: auto;
        padding: 4px;
        gap: 4px;
    }
    .pv-slot-btn {
        width: 46px;
        height: 44px;
    }
    .pv-slot-btn > span:not(.slot-key):not(.slot-ammo):not(.slot-icon) {
        display: none;
    }
    .pv-interact,
    .pv-place-banner {
        bottom: max(8px, env(safe-area-inset-bottom));
        max-width: calc(100vw - 140px);
        font-size: 12px;
        padding: 6px 10px;
    }
    .pv-defense-panel {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 58px);
        max-width: calc(100vw - 140px);
        padding: 6px 8px;
        gap: 6px;
    }
    .pv-toasts {
        top: calc(var(--hud-h) + 10px);
        bottom: auto;
        left: 70px;
    }
    /* Oznámení fáze dole uprostřed, nahoře by se překrylo s hláškami, které chodí současně */
    .pv-phase-notif {
        top: auto;
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 56px);
        font-size: 15px;
    }
    .pv-card {
        max-height: calc(100vh - 24px);
        padding: 16px;
    }
}

/* Telefon naležato: 8 tlačítek staveb se do jednoho sloupce nevejde (krajní by zajela pod horní lištu a pod okraj), jdou do dvou */
@media (max-height: 460px) and (orientation: landscape) {
    .pv-action-group--build {
        display: grid;
        grid-template-columns: repeat(2, auto);
    }
}

/* Velmi nízký displej naležato: ani 6 zbraní se do sloupce nevejde */
@media (max-height: 370px) and (orientation: landscape) {
    .pv-action-group--weapons {
        display: grid;
        grid-template-columns: repeat(2, auto);
    }
}

/* Dotykové ovládání: tlačítka aspoň 44 × 44 px */
@media (pointer: coarse) {
    .pv-back-btn,
    .pv-icon-btn {
        width: 44px;
        height: 44px;
    }
    .pv-interact,
    .pv-place-cancel {
        min-height: 44px;
    }
}
