:root {
    /* Barve po logotipu */
    --bg: #202925;
    --panel: #2b3530;

    --green: #2f8f57;
    --green-dark: #195537;
    --green-light: #9bd51f;
    --green-bright: #b7e51f;

    --disabled: #505a55;

    --text: #ffffff;
    --muted: #cbd3ce;

    --danger: #ff4d4d;
    --danger-dark: #8f1717;
    --danger-bg: #a73535;

    --outline: rgba(183, 229, 31, 0.25);
}

* {
    box-sizing: border-box;
}

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

body {
    background:
        radial-gradient(
            circle at top left,
            rgba(183, 229, 31, 0.08),
            transparent 28rem
        ),
        var(--bg);

    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;

    touch-action: manipulation;
    user-select: none;
}


/* =========================
   GLAVNA STRAN
   ========================= */

.page {
    min-height: 100vh;
    padding: 32px;

    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 24px;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 20px;
}

.actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.header-title {
    grid-column: 2;
    grid-row: 1;
    text-align: center;
}

.header-title h1 {
    font-size: 30px;
}

/* Enaka polja za QR-kodo in uro */
.clock,
#publicAccess {
    height: 90px;
    background: var(--panel);
    border: 2px solid rgba(183, 229, 31, 0.18);
    border-radius: 14px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2),
                inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.clock {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    min-width: 310px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 26px;
    font-weight: bold;
}

#publicAccess {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 16px;
    font-size: 20px;
    font-weight: 600;
    white-space: nowrap;
}

#publicAccess[hidden] {
    display: none !important;
}

#publicAccessQr {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    background: #ffffff;
    border-radius: 5px;
    flex-shrink: 0;
}

#publicAccessQr img,
#publicAccessQr canvas {
    width: 68px !important;
    height: 68px !important;
}

h1 {
    margin: 0;

    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.5px;
}




/* =========================
   TARČE
   ========================= */

.target-tabs {
    display: none;
}

.targets {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.target-row {
    display: grid;
    grid-template-columns: 1fr 210px 130px;

    gap: 20px;
    align-items: stretch;
}

.target-row.stopped {
    opacity: 0.72;
}

.target-button,
.secondary,
.stop-button,
select {
    border: 4px solid var(--green-dark);
    border-radius: 28px;

    background: var(--green);
    color: var(--text);

    font-weight: bold;

    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);

    cursor: pointer;

    transition:
        background 0.15s ease,
        border-color 0.15s ease,
        transform 0.1s ease,
        box-shadow 0.15s ease;
}

.target-button {
    display: flex;
    align-items: center;
    justify-content: flex-start;

    gap: 24px;

    padding-left: 8px;
}

.target-button:hover,
.secondary:hover,
select:hover {
    border-color: var(--green-light);

    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.22),
        0 0 0 3px var(--outline);
}

.target-logo {
    width: 120px;
    height: 120px;

    flex-shrink: 0;
    object-fit: contain;

    margin-top: -10px;
    margin-bottom: -10px;
}

.target-text {
    display: flex;
    flex-direction: column;
    justify-content: center;

    text-align: left;
}

.target-name {
    font-size: 32px;
    font-weight: 800;
}

.target-msg {
    margin-top: 2px;

    font-size: 23px;
    font-weight: 700;

    color: var(--green-bright);
}

.target-button.error {
    border-color: var(--danger-dark);
}

.target-button.error .target-msg {
    color: var(--danger);
}


/* =========================
   STOP
   ========================= */

.stop-button {
    min-width: 130px;
    width: 100%;

    padding: 0 10px;

    font-size: 18px;

    border-color: var(--danger-dark);
    background: var(--danger-bg);

    border-radius: 28px;

    box-shadow:
        0 5px 14px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stop-button:hover {
    background: #b43a3a;
    border-color: #b71919;
}


/* =========================
   ACTIVE / DISABLED
   ========================= */

.target-button:active,
.secondary:active,
select:active {
    background: var(--green-light);
    color: #173018;

    transform: translateY(1px);
}

.stop-button:active {
    background: var(--danger-dark);
    transform: translateY(1px);
}

.target-button:disabled,
select:disabled,
.secondary:disabled,
.stop-button:disabled {
    background: var(--disabled);
    border-color: #3d4641;

    color: var(--muted);

    cursor: not-allowed;

    box-shadow: none;
}


/* =========================
   SELECT
   ========================= */

select {
    width: 100%;

    padding: 18px;

    font-size: 36px;
    text-align: center;

    appearance: auto;
}


/* =========================
   SPODNJI GUMBI
   ========================= */

.secondary {
    min-height: 58px;

    padding: 12px 22px;

    border-radius: 14px;

    font-size: 22px;

    background: #26784a;
}

.actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}


/* =========================
   DIALOG
   ========================= */

dialog {
    width: min(900px, 92vw);
    max-height: 82vh;

    background: var(--panel);
    color: var(--text);

    border: 3px solid var(--green-light);
    border-radius: 18px;

    padding: 20px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

pre {
    max-height: 60vh;
    overflow: auto;

    white-space: pre-wrap;

    font-size: 18px;

    user-select: text;
}


/* =========================
   LANDSCAPE
   ========================= */

@media (orientation: landscape) {

    .target-button,
    select,
    .stop-button {
        min-height: 110px;
    }
}


/* =========================
   CURSOR
   ========================= */

button,
.target-button,
.stop-button,
.secondary,
select {
    cursor: url("/static/img/bb.png") 16 16, pointer;
}


/* =========================
   REMOTE OVERLAY
   ========================= */

.remote-overlay[hidden] {
    display: none !important;
}

.remote-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;

    pointer-events: none;
}

.remote-window {
    position: absolute;

    top: 10vh;
    right: 300px;

    width: 33.333vw;
    height: 80vh;

    border: 4px solid var(--green-light);
    border-radius: 18px;

    background: #ffffff;
    overflow: hidden;

    pointer-events: auto;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.45),
        0 0 0 3px var(--outline);
}

.remote-window iframe {
    display: block;

    width: 100%;
    height: 100%;

    border: 0;
    background: #ffffff;
}

.remote-close {
    position: absolute;

    top: 10px;
    right: 10px;

    z-index: 10;

    min-width: 55px;
    min-height: 55px;

    border: 3px solid var(--green-light);
    border-radius: 12px;

    background: var(--green);
    color: var(--text);

    font-size: 24px;
    font-weight: bold;

    cursor: pointer;
}

/* =========================
   INSTRUCTION OVERLAY
   ========================= */

.instruction-overlay[hidden] {
    display: none !important;
}

.instruction-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(20, 30, 25, 0.78);

    pointer-events: none;
}

.instruction-box {
    min-width: min(650px, 85vw);
    max-width: 1200px;

    padding: 20px 55px;

    text-align: center;

    background: var(--green);
    color: var(--text);

    border: 5px solid var(--green-light);
    border-radius: 30px;

    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.45),
        0 0 0 6px rgba(183, 229, 31, 0.12);

    animation: instruction-in 0.18s ease-out;
}

.instruction-title {
    font-size: 24px;
    font-weight: 500;
}

.instruction-text {
    margin-top: 12px;

    font-size: 36px;
    font-weight: 600;

    color: var(--green-bright);
}

@keyframes instruction-in {
    from {
        opacity: 0;
        transform: scale(0.94);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}


/* =========================
   LANDSCAPE - ANDROID 1920x1080
   Tarce levo, akcijska gumba desno
   ========================= */

@media (orientation: landscape) and (min-width: 901px) {

    /* Širši gumbi za razdaljo in STOP */
    .target-row {
        grid-template-columns: minmax(0, 1fr) 250px 170px;
        gap: 16px;
    }

    /* Več notranjega odmika glavnih gumbov */
    .target-button {
        padding: 16px 28px;
        gap: 28px;
    }

    /* Več notranjega odmika razdalje in STOP */
    .target-row select {
        padding: 16px 24px;
    }

    .stop-button {
        padding: 16px 20px;
    }

    /* Desna gumba navpično na sredino */
    .actions {
        justify-content: center;
        align-items: stretch;
        gap: 20px;
    }
    .target-pin {
    margin-left: auto;
    padding: 0 12px;
    font-size: 44px;
    font-weight: 700;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

    .secondary {
        min-height: 90px;
        padding: 20px 24px;
    }
     /* Ime tarče */
    .target-name {
        font-size: 48px;
        font-weight: 800;
    }

    /* Besedilo pod imenom tarče */
    .target-msg {
        font-size: 36px;
        font-weight: 700;
    }

    /* Gumb STOP */
    .stop-button {
        font-size: 36px;
        font-weight: 800;
    }
     /* Prikazana razdalja, npr. 25m */
    .target-row select {
        font-size: 48px;
        font-weight: 800;
        padding: 12px 20px;
    }

    /* Možnosti v spustnem seznamu */
    .target-row select option {
        font-size: 40px;
        font-weight: 700;
    }
}

/* =========================
   MOBILE / PORTRAIT
   ========================= */

@media (max-width: 900px), (orientation: portrait) {

    .page {
        grid-template-rows: auto auto 1fr auto;
        min-height: 100svh;

        padding: 16px;
        gap: 14px;
    }

    .topbar {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
    }

    .header-title {
        text-align: left;
        min-width: 0;
    }

    .header-title h1 {
        font-size: 26px;
    }

    #publicAccess {
        display: none !important;
    }



    .clock {
        height: auto;
        min-height: 54px;
        min-width: 150px;
        padding: 10px 12px;
        border-radius: 10px;
        font-size: 17px;
    }


    /* TABI */

    .target-tabs[hidden] {
        display: none;
    }

    .target-tabs {
        display: flex;

        gap: 6px;

        width: 100%;

        margin-bottom: 6px;
    }

    .target-tab {
        flex: 1;
        min-width: 0;

        height: 48px;

        display: flex;
        align-items: center;
        justify-content: center;

        padding: 0 8px;

        border: 3px solid var(--green-dark);
        border-radius: 16px;

        background: var(--panel);
        color: var(--text);

        font-size: 18px;
        font-weight: 700;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        cursor: pointer;

        transition:
            background 0.15s,
            border-color 0.15s;
    }

    .target-tab:hover {
        background: #39443e;
    }

    .target-tab.active {
        background: var(--green);
        border-color: var(--green-light);

        box-shadow: 0 0 0 2px var(--outline);
    }

    .target-tab.stopped {
        border-color: var(--danger-dark);
    }

    .target-tab.error {
        color: var(--danger);
    }

    .target-tab.disabled {
        opacity: 0.55;
    }


    /* TARČA */

    .targets {
        align-content: start;
    }

    .target-row {
        grid-template-columns: 1fr 130px;

        grid-template-areas:
            "target target"
            "distance stop";

        gap: 12px;
    }

    .target-button {
        grid-area: target;

        display: flex;
        align-items: center;
        justify-content: flex-start;

        gap: 12px;

        padding: 30px 20px;

        font-size: 22px;
    }

    select {
        grid-area: distance;

        font-size: 24px;
        border-radius: 26px;
    }

    .stop-button {
        grid-area: stop;

        font-size: 15px;
        border-radius: 24px;
    }


    /* ACTION BUTTONS */

    .actions {
        display: grid;
        grid-template-columns: 1fr;

        gap: 6px;
    }

    .secondary {
        width: 100%;

        font-size: 18px;
    }
    #remoteBtn { /*skrij mosfet gumb na telefonu*/
        display: none !important;
    }

    /* Obvestila na telefonu */
    .instruction-box {
        min-width: 85vw;

        padding: 20px 20px;

        border-radius: 24px;
    }

    .instruction-title {
        font-size: 18px;
    }

    .instruction-text {
        font-size: 20px;
    }
}

/* QR-koda pred napisom, tudi če je v HTML za besedilom. */
#publicAccessQr { order: -1; }