/* ==========================================================================
   MOTYW "CYBER" - strona uczestnika
   Paleta i typografia wg projektu Claude Design (Cyber Quest, wrzesien 2026).
   Arkusz jest samodzielny: nie wymaga Bootstrapa ani Mazera (_app.css).
   ========================================================================== */

:root {
    --bg: #071525;
    --bg-deep: #050b13;
    --card: #0C2238;
    --card-active: #173B59;
    --panel: #102D47;
    --border: #285675;

    --accent: #19C6F4;
    --button: #1677D2;
    --link: #4EA8FF;

    --success: #39C978;
    --error: #F0523D;
    --warning: #F5A623;

    --text: #F4F8FC;
    --text-2: #A9BDD0;
    --text-muted: #718AA0;

    --head: 'Space Grotesk', 'Segoe UI', system-ui, sans-serif;
    --body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;

    --shell: 480px; /* szerokosc kolumny na tabletach i desktopie */
}

/* --------------------------------------------------------------- podstawy */

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background: var(--bg-deep);
    color: var(--text);
    font: 400 15px/1.6 var(--body);
    -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration: none; }
a:hover, a:focus { color: var(--accent); }

img { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5 { font-family: var(--head); font-weight: 700; margin: 0; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes tz-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(25, 198, 244, .45); }
    50%      { box-shadow: 0 0 0 10px rgba(25, 198, 244, 0); }
}

/* ------------------------------------------------------------------ shell */

.tz-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: var(--shell);
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

@media (min-width: 520px) {
    .tz-shell { box-shadow: 0 0 60px rgba(0, 0, 0, .6); }
}

.tz-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--card-active);
    background: linear-gradient(180deg, var(--card), var(--bg));
    position: sticky;
    top: 0;
    z-index: 5;
}

.tz-header__logo {
    width: 58px;
    height: 40px;
    flex: none;
    border-radius: 10px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 3px;
    /* obrazy gier to zwykle szerokie bannery z logotypami organizatorow,
       wiec pokazujemy caly obraz, a nie wykadrowany srodek */
    object-fit: contain;
}

.tz-header__titles { flex: 1; min-width: 0; }

.tz-header__title {
    font: 700 17px/1.2 var(--head);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tz-header__user {
    font: 600 9px/1.4 var(--body);
    color: var(--accent);
    letter-spacing: 2.2px;
    text-transform: uppercase;
}

.tz-header__logout {
    flex: none;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--text-2);
    background: var(--panel);
}

.tz-main {
    flex: 1;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tz-footer {
    padding: 16px 18px 22px;
    text-align: center;
    font: 400 11px/1.5 var(--body);
    color: var(--text-muted);
}

/* ------------------------------------------------------- dolna nawigacja */

.tz-nav {
    display: flex;
    gap: 4px;
    padding: 8px 10px 18px;
    border-top: 1px solid var(--card-active);
    background: var(--card);
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.tz-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 0;
    border-radius: 12px;
    font: 600 10px/1 var(--body);
    color: var(--text-muted);
}

.tz-nav__item svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; }

.tz-nav__item.is-active { color: var(--accent); background: rgba(25, 198, 244, .08); }

/* ------------------------------------------------------------------ karty */

.tz-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}

.tz-card--flush { padding: 0; overflow: hidden; }

.tz-card__header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.tz-card__header h4 { font-size: 19px; }

.tz-card__body { padding: 18px; }

.tz-card__footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    text-align: center;
    font: 400 11.5px/1.5 var(--body);
    color: var(--text-muted);
}

.tz-label {
    font: 600 11px/1 var(--body);
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.tz-muted { color: var(--text-muted); }

/* --------------------------------------------------------------- komunikaty */

.tz-alert {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
    font: 400 13.5px/1.55 var(--body);
    color: var(--text);
}

.tz-alert__icon {
    width: 26px;
    height: 26px;
    flex: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font: 700 14px/1 var(--head);
}

.tz-alert__title {
    display: block;
    font: 700 11px/1.4 var(--body);
    letter-spacing: 1.6px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.tz-alert--success { border-color: var(--success); }
.tz-alert--success .tz-alert__icon { background: rgba(57, 201, 120, .16); color: var(--success); }
.tz-alert--success .tz-alert__title { color: var(--success); }

.tz-alert--error { border-color: var(--error); }
.tz-alert--error .tz-alert__icon { background: rgba(240, 82, 61, .16); color: var(--error); }
.tz-alert--error .tz-alert__title { color: var(--error); }

.tz-alert--warning { border-color: var(--warning); }
.tz-alert--warning .tz-alert__icon { background: rgba(245, 166, 35, .16); color: var(--warning); }
.tz-alert--warning .tz-alert__title { color: var(--warning); }

.tz-alert--info { border-color: var(--accent); }
.tz-alert--info .tz-alert__icon { background: rgba(25, 198, 244, .16); color: var(--accent); }
.tz-alert--info .tz-alert__title { color: var(--accent); }

/* karta z wyjasnieniem po poprawnej odpowiedzi (tresc z CKEditora) */
.tz-explain { border-color: var(--accent); }
.tz-explain .tz-content { font-size: 13.5px; }

/* ------------------------------------------------------------- formularze */

.tz-field { display: flex; flex-direction: column; gap: 9px; }

.tz-input {
    width: 100%;
    height: 52px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 0 16px;
    font: 500 15px var(--body);
    color: var(--text);
    outline: none;
}

.tz-input::placeholder { color: var(--text-muted); }
.tz-input:focus { border-color: var(--accent); background: var(--card-active); }

select.tz-input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%);
    background-position: calc(100% - 20px) 23px, calc(100% - 14px) 23px;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 42px;
}

.tz-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 54px;
    border: none;
    border-radius: 14px;
    background: var(--button);
    color: #FFFFFF;
    font: 600 15px var(--body);
    letter-spacing: .5px;
    text-transform: uppercase;
    box-shadow: 0 8px 24px rgba(22, 119, 210, .4);
    cursor: pointer;
}

.tz-btn:hover, .tz-btn:focus { background: var(--accent); color: #071525; }

.tz-btn--ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-2);
    box-shadow: none;
    text-transform: none;
}

.tz-btn--ghost:hover, .tz-btn--ghost:focus { background: var(--panel); color: var(--text); }

.tz-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font: 400 13.5px/1.5 var(--body);
    color: var(--text-2);
    user-select: none;
}

.tz-check input {
    width: 22px;
    height: 22px;
    flex: none;
    margin: 0;
    accent-color: var(--success);
}

/* ------------------------------------------------------------ pasek postepu */

.tz-progress__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
}

.tz-progress__count { font: 700 15px var(--head); color: var(--accent); }

.tz-progress__track {
    height: 7px;
    border-radius: 4px;
    background: var(--card);
    border: 1px solid var(--border);
    overflow: hidden;
}

.tz-progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--button), var(--accent));
}

/* --------------------------------------------------------- kafelki zadan */

.tz-tiles {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Gesta siatka: liczba kolumn dopasowuje sie do szerokosci ekranu, wiec gra
   z 30 zadaniami nie robi z listy postepu osmiu rzedow wielkich kwadratow.
   46px to wciaz sensowny cel dotyku na telefonie. */
.tz-tiles--dense { grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 7px; }

.tz-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    border-radius: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    font: 700 20px var(--head);
    color: var(--link);
}

.tz-tiles--dense .tz-tile { border-radius: 10px; font-size: 15px; }

/* zaliczone */
.tz-tile--success {
    background: rgba(57, 201, 120, .14);
    border-color: var(--success);
    color: var(--success);
}

/* otwarte, brak poprawnej odpowiedzi */
.tz-tile--during {
    background: rgba(245, 166, 35, .14);
    border-color: var(--warning);
    color: var(--warning);
}

/* bledna odpowiedz */
.tz-tile--mistake {
    background: rgba(240, 82, 61, .14);
    border-color: var(--error);
    color: var(--error);
}

/* aktualnie otwarte zadanie */
.tz-tile--current { animation: tz-pulse 2.4s infinite; }

.tz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 12px;
    font: 400 10.5px var(--body);
    color: var(--text-muted);
}

.tz-legend span { display: flex; align-items: center; gap: 6px; }
.tz-legend i { width: 9px; height: 9px; border-radius: 3px; display: block; }

/* ------------------------------------------------------------ ekran zadania */

.tz-taskbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--card-active);
    background: var(--bg);
}

.tz-taskbar__back {
    width: 34px;
    height: 34px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 18px;
}

.tz-taskbar__label {
    flex: 1;
    font: 600 13px var(--body);
    color: var(--text-2);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

/* numer zadania w ramce naroznikowej (wg wariantu 1c) */
.tz-tasknum {
    position: relative;
    width: 66px;
    height: 66px;
    flex: none;
    border-radius: 12px;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.tz-tasknum__caption {
    font: 600 8px var(--body);
    color: var(--accent);
    letter-spacing: 1.6px;
}

.tz-tasknum__value { font: 700 28px/1 var(--head); color: var(--accent); }

.tz-tasknum i { position: absolute; width: 14px; height: 14px; }
.tz-tasknum i:nth-child(1) { top: 0; left: 0;  border-top: 2px solid var(--accent); border-left: 2px solid var(--accent); border-radius: 6px 0 0 0; }
.tz-tasknum i:nth-child(2) { top: 0; right: 0; border-top: 2px solid var(--accent); border-right: 2px solid var(--accent); border-radius: 0 6px 0 0; }
.tz-tasknum i:nth-child(3) { bottom: 0; left: 0;  border-bottom: 2px solid var(--accent); border-left: 2px solid var(--accent); border-radius: 0 0 0 6px; }
.tz-tasknum i:nth-child(4) { bottom: 0; right: 0; border-bottom: 2px solid var(--accent); border-right: 2px solid var(--accent); border-radius: 0 0 6px 0; }

.tz-task__head { display: flex; align-items: center; gap: 14px; }

.tz-task__title { font: 700 21px/1.15 var(--head); color: var(--text); }

.tz-task__subtitle {
    font: 600 10px var(--body);
    color: var(--link);
    letter-spacing: 1.6px;
    text-transform: uppercase;
    margin-top: 6px;
}

/* tresc zadania z CKEditora - dowolny HTML od organizatora */
.tz-content { font: 400 14px/1.65 var(--body); color: var(--text-2); overflow-wrap: break-word; }
.tz-content > *:first-child { margin-top: 0; }
.tz-content > *:last-child { margin-bottom: 0; }
.tz-content h1, .tz-content h2, .tz-content h3, .tz-content h4 { color: var(--text); margin: 18px 0 10px; }
.tz-content h1 { font-size: 22px; }
.tz-content h2 { font-size: 20px; }
.tz-content h3 { font-size: 18px; }
.tz-content strong, .tz-content b { color: var(--text); }
.tz-content img { border-radius: 12px; display: block; margin: 14px auto; }
.tz-content iframe { width: 100%; max-width: 100%; aspect-ratio: 16 / 9; height: auto; border: 0; border-radius: 12px; }
.tz-content table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.tz-content td, .tz-content th { border: 1px solid var(--border); padding: 8px; }
.tz-content ul, .tz-content ol { padding-left: 22px; }
.tz-content blockquote {
    margin: 14px 0;
    padding: 2px 0 2px 14px;
    border-left: 3px solid var(--accent);
    color: var(--text-2);
}

/* -------------------------------------------------------------- logowanie */

.tz-login {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    padding: 32px 26px;
    position: relative;
}

.tz-login::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 18%, rgba(25, 198, 244, .18), transparent 55%);
    pointer-events: none;
}

.tz-login > * { position: relative; width: 100%; }

.tz-login__logo {
    width: 88px;
    height: 88px;
    margin: 0 auto;
    border-radius: 24px;
    background: var(--panel);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(25, 198, 244, .35);
    padding: 12px;
}

.tz-login__title {
    text-align: center;
    font: 700 28px/1.15 var(--head);
    color: var(--text);
    letter-spacing: .5px;
}

.tz-login__sub {
    text-align: center;
    font: 600 12px/1.2 var(--body);
    color: var(--accent);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-top: 8px;
}

.tz-stack { display: flex; flex-direction: column; gap: 12px; }

/* --------------------------------------------------------------- regulamin */

.tz-rules {
    max-height: 45vh;
    overflow-y: auto;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
}

/* --------------------------------------------------- czytnik QR i siatka gry */

/* Kontener czytnika: biblioteka html5-qrcode wstawia tu podglad kamery.
   min-height trzyma ramke, dopoki kamera sie nie uruchomi (albo gdy odmowi). */
#qrcode-reader {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 14px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 13px;
}

#qrcode-reader video { display: block; width: 100% !important; height: auto !important; }

/* --------------------------------------------------------------- mozaika gry */

/* Wyjscie renderImage(): obrazek gry pocietny na tyle kawalkow, ile jest zadan.
   Liczba kolumn i proporcja kawalka przychodzi ze zmiennych CSS ustawianych
   przez PHP, wiec siatka sklada sie poprawnie dla kazdej gry - 4x3, 5x5, 6x5.
   Tlo siatki przeswituje przez 1px odstepy i tworzy linie miedzy kawalkami. */
.grid {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(var(--grid-cols, 6), 1fr);
    gap: 1px;
    background: var(--border);
}

.grid .image-section {
    position: relative;
    aspect-ratio: var(--slice-ratio, 1.235294117647059);
    background: var(--panel);
}

.grid .image-section img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Numer zadania nad zakrytym kawalkiem - ukryty, tak jak w wersji klasycznej */
.grid .image-section .numeros {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    padding: 2px 5px;
    font: 600 11px var(--head);
    color: var(--text);
    background: rgba(7, 21, 37, .55);
    border-radius: 0 0 6px 0;
}

/* ---------------------------------------------- informacja o ciasteczkach */

.tz-cookiealert {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: none;
    gap: 12px;
    align-items: center;
    padding: 14px 18px;
    background: var(--card);
    border-top: 1px solid var(--border);
    font: 400 12px/1.5 var(--body);
    color: var(--text-2);
}

.tz-cookiealert.is-visible { display: flex; }
.tz-cookiealert > div { flex: 1 1 200px; min-width: 0; }
.tz-cookiealert { flex-wrap: wrap; }

.tz-cookiealert__accept {
    flex: none;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 10px;
    background: var(--button);
    color: #FFFFFF;
    font: 600 13px var(--body);
    cursor: pointer;
}

.tz-cookiealert__accept:hover { background: var(--accent); color: #071525; }
