html,
body {
    margin: 0;
    height: 100%;
}

body {
    overflow: hidden;
    background: #2b2a22;
    font-family: Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    overscroll-behavior: none;
}

/* rozmery a zmenseni nastavuje JS */
#arena {
    position: fixed;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    overflow: hidden;
    background-color: #4a4535;
    background-image:
        radial-gradient(circle at 30% 40%, rgba(110, 120, 70, .35), transparent 35%),
        radial-gradient(circle at 75% 70%, rgba(30, 25, 15, .35), transparent 30%),
        radial-gradient(circle at 60% 20%, rgba(130, 115, 80, .3), transparent 25%),
        radial-gradient(rgba(0, 0, 0, .14) 1px, transparent 1.5px);
    background-size: 420px 420px, 360px 360px, 280px 280px, 8px 8px;
}

#arena::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: inset 0 0 140px rgba(0, 0, 0, .6);
    pointer-events: none;
}

/* barvy hracu */
#tank_1 {
    --barva: #6b9a3a;
    --tmava: #3f5e1f;
    --svetla: #9cc96a;
}

#tank_2 {
    --barva: #c49a5a;
    --tmava: #85622f;
    --svetla: #ecca92;
}

.hrac-1 {
    color: #a5d16b;
}

.hrac-2 {
    color: #e9c58f;
}

/* tank - .tank je bod ve stredu, .telo se otaci kolem nej */
.tank {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 2;
}

.telo {
    position: absolute;
    left: -20px;
    top: -28px;
    width: 40px;
    height: 56px;
}

.pas {
    position: absolute;
    top: 0;
    width: 10px;
    height: 56px;
    border-radius: 3px;
    background-color: #1e1e1e;
    background-image: linear-gradient(to bottom, #4a4a4a 0, #4a4a4a 2px, #1e1e1e 2px);
    background-size: 100% 6px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(0, 0, 0, .6);
}

.pas-l {
    left: 0;
}

.pas-p {
    right: 0;
}

.korba {
    position: absolute;
    left: 7px;
    right: 7px;
    top: 2px;
    bottom: 2px;
    border-radius: 4px 4px 3px 3px;
    background: linear-gradient(to right, var(--tmava), var(--barva) 25%, var(--barva) 75%, var(--tmava));
    box-shadow: 0 3px 8px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(0, 0, 0, .35);
}

.korba::before {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    top: 3px;
    height: 7px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .12);
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .3);
}

.korba::after {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    bottom: 3px;
    height: 9px;
    background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, .4) 0, rgba(0, 0, 0, .4) 1px, transparent 1px, transparent 3px);
}

.vez {
    position: absolute;
    left: 20px;
    top: 28px;
    width: 0;
    height: 0;
}

.hlaven {
    position: absolute;
    left: -3px;
    top: -34px;
    width: 6px;
    height: 26px;
    border-radius: 1px;
    background: linear-gradient(to right, #2a2a2a, #6a6a6a 45%, #2a2a2a);
    box-shadow: 0 2px 3px rgba(0, 0, 0, .5);
}

.hlaven::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 0;
    width: 8px;
    height: 5px;
    border-radius: 1px;
    background: #1a1a1a;
}

.kopule {
    position: absolute;
    left: -12px;
    top: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: radial-gradient(circle at 38% 35%, var(--svetla), var(--barva) 55%, var(--tmava));
    box-shadow: 0 3px 6px rgba(0, 0, 0, .55), inset 0 0 0 1px rgba(0, 0, 0, .35);
}

.kopule::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 9px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tmava);
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .25);
}

/* zivoty a nabijeni nad tankem */
.hud {
    position: absolute;
    left: -22px;
    top: -50px;
    width: 44px;
    z-index: 1;
}

.hud.dole {
    top: 40px;
}

.zivoty,
.nabiti {
    overflow: hidden;
    border-radius: 3px;
    background: rgba(0, 0, 0, .55);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}

.zivoty {
    height: 5px;
}

.nabiti {
    height: 3px;
    margin-top: 2px;
}

.zivoty .bar,
.nabiti .bar {
    height: 100%;
}

.zivoty .bar {
    transition: width .2s, background-color .2s;
}

.nabiti .bar {
    background: #a07c2c;
}

.hud.nabito .nabiti .bar {
    background: #ffd23f;
}

/* stavy tanku */
.tank.zasazen .telo {
    filter: brightness(2.2) saturate(.5);
}

.tank.zniceny .telo {
    filter: grayscale(1) brightness(.35);
}

.tank.zniceny .hud {
    display: none;
}

.tank.zniceny .telo::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 3px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(60, 60, 60, .9), rgba(60, 60, 60, 0) 70%);
    animation: kour 1s ease-out infinite;
}

.tank.objeveni .telo {
    animation: objeveni .6s ease-out;
}

/* strela */
.strela {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 3;
}

.strela::before {
    content: '';
    position: absolute;
    left: -2px;
    top: -6px;
    width: 4px;
    height: 10px;
    border-radius: 2px 2px 1px 1px;
    background: linear-gradient(to bottom, #fff7c2, #ffbf2e 45%, #b8620a);
    box-shadow: 0 0 6px 2px rgba(255, 170, 0, .55);
}

.strela::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 4px;
    width: 2px;
    height: 22px;
    background: linear-gradient(to bottom, rgba(255, 200, 80, .7), rgba(255, 200, 80, 0));
}

/* prekazky */
.prekazka {
    position: absolute;
    z-index: 1;
    border-radius: 3px;
    background-color: #77756a;
    background-image:
        linear-gradient(90deg, rgba(0, 0, 0, .28) 1px, transparent 1px),
        linear-gradient(rgba(0, 0, 0, .28) 1px, transparent 1px),
        linear-gradient(135deg, rgba(255, 255, 255, .12), rgba(0, 0, 0, .15));
    background-size: 30px 30px, 30px 30px, 100% 100%;
    box-shadow: 0 6px 12px rgba(0, 0, 0, .5), inset 0 0 0 2px rgba(0, 0, 0, .3), inset 0 2px 0 rgba(255, 255, 255, .15);
}

/* efekty - .efekt je bod, kresli se pseudo-elementy */
.efekt {
    position: absolute;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 4;
    pointer-events: none;
}

.efekt::before,
.efekt::after {
    content: '';
    position: absolute;
    border-radius: 50%;
}

.zablesk::before {
    left: -10px;
    top: -10px;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, #fff 0, #ffe27a 35%, rgba(255, 140, 0, 0) 70%);
    animation: vybuch .15s ease-out forwards;
}

.jiskra::before {
    left: -9px;
    top: -9px;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle, #fff 0, #ffd24d 40%, rgba(255, 120, 0, 0) 70%);
    animation: vybuch .3s ease-out forwards;
}

.vybuch-maly::before {
    left: -18px;
    top: -18px;
    width: 36px;
    height: 36px;
    background: radial-gradient(circle, #fff 0, #ffd34d 25%, #ff7b00 50%, rgba(200, 40, 0, 0) 70%);
    animation: vybuch .4s ease-out forwards;
}

.vybuch::before {
    left: -55px;
    top: -55px;
    width: 110px;
    height: 110px;
    background: radial-gradient(circle, #fff 0, #ffe066 20%, #ff8c00 40%, #c0300a 55%, rgba(60, 20, 0, 0) 70%);
    animation: vybuch .7s ease-out forwards;
}

.vybuch::after {
    left: -70px;
    top: -70px;
    width: 140px;
    height: 140px;
    opacity: 0;
    background: radial-gradient(circle, rgba(50, 45, 40, .7) 0, rgba(50, 45, 40, .4) 40%, rgba(50, 45, 40, 0) 70%);
    animation: kour .9s ease-out .15s forwards;
}

@keyframes vybuch {
    0% {
        transform: scale(.2);
        opacity: 1;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

@keyframes kour {
    0% {
        transform: scale(.4);
        opacity: .9;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes objeveni {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* skore a napoveda */
#skore {
    position: fixed;
    top: 10px;
    left: 50%;
    z-index: 10;
    transform: translateX(-50%);
    padding: 6px 18px;
    border-radius: 20px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    white-space: nowrap;
}

#skore b {
    display: inline-block;
    min-width: 1.2em;
    text-align: center;
}

#protihrac {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 8px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
}

#protihrac option {
    background: #2b2a22;
}

body.npc .jen-hraci,
body:not(.npc) .jen-npc {
    display: none;
}

/* dotykove ovladani */
.ovladac {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 50%;
    z-index: 8;
}

body.dotyk .ovladac {
    display: block;
}

body.dotyk.npc .ovladac-npc,
body.dotyk #napoveda {
    display: none;
}

.ovladac.nahore {
    top: 0;
    bottom: auto;
    transform: rotate(180deg);
}

.zona-pohyb {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 55%;
}

.joystick {
    position: absolute;
    left: 95px;
    top: calc(100% - 95px);
    width: 110px;
    height: 110px;
    margin: -55px 0 0 -55px;
    border: 2px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    background: rgba(255, 255, 255, .06);
    opacity: .45;
    pointer-events: none;
}

.joystick.aktivni {
    opacity: 1;
}

.paka {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .35);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

.ovladac-1 .paka {
    background: rgba(165, 209, 107, .6);
}

.ovladac-2 .paka {
    background: rgba(233, 197, 143, .6);
}

.tlacitka-boj {
    position: absolute;
    right: 24px;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.tl-strelba,
.tl-vez {
    border: 2px solid rgba(255, 255, 255, .3);
    border-radius: 50%;
    color: rgba(255, 255, 255, .85);
    text-align: center;
    font-weight: bold;
}

.tl-strelba {
    width: 84px;
    height: 84px;
    line-height: 84px;
    font-size: 16px;
    letter-spacing: 1px;
    background: conic-gradient(rgba(255, 190, 60, .45) calc(var(--nabito, 1) * 360deg), rgba(0, 0, 0, .35) 0);
}

.tl-strelba.nabito {
    border-color: rgba(255, 210, 63, .9);
    box-shadow: 0 0 16px rgba(255, 190, 60, .5);
}

.tl-vez {
    width: 54px;
    height: 54px;
    margin-bottom: 15px;
    line-height: 52px;
    font-size: 26px;
    background: rgba(0, 0, 0, .35);
}

.tl-strelba.drzeno,
.tl-vez.drzeno {
    transform: scale(.92);
    filter: brightness(1.4);
}

@media (max-width: 600px) {
    #skore {
        font-size: 16px;
    }

    #protihrac {
        top: 50px;
        right: 50%;
        transform: translateX(50%);
    }
}

#napoveda {
    position: fixed;
    bottom: 8px;
    left: 50%;
    z-index: 10;
    transform: translateX(-50%);
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(0, 0, 0, .45);
    color: rgba(255, 255, 255, .75);
    font-size: 12px;
    white-space: nowrap;
}
