/* ============================================================
   LOTNIK — ranking szkolnej waluty
   Motyw: nocne niebo lotniska / światła pasa startowego
   ============================================================ */

:root {
    --bg-deep: #060b16;
    --bg-mid: #0d1a33;
    --panel-bg: rgba(255, 255, 255, 0.045);
    --panel-border: rgba(255, 255, 255, 0.09);
    --text-primary: #f3f6fc;
    --text-muted: #8ca0c4;
    --text-faint: #56668a;

    --gold: #ffc93c;
    --cyan: #4cc9f0;

    --medal-gold: #ffd645;
    --medal-silver: #c9d3e0;
    --medal-bronze: #e0995e;

    --font-display: "Space Grotesk", "Inter", sans-serif;
    --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* ---------- Tło: nocne niebo + gwiazdy ---------- */
.sky {
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(ellipse 900px 500px at 20% -10%, rgba(76, 201, 240, 0.16), transparent 60%),
        radial-gradient(ellipse 700px 500px at 90% 0%, rgba(255, 201, 60, 0.10), transparent 55%),
        linear-gradient(180deg, var(--bg-deep) 0%, var(--bg-mid) 55%, var(--bg-deep) 100%);
}

.stars {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1.5px 1.5px at 15% 20%, rgba(255,255,255,0.55), transparent),
        radial-gradient(1.5px 1.5px at 75% 12%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 45% 35%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1.5px 1.5px at 88% 40%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 30% 55%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1.5px 1.5px at 60% 8%, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 10% 70%, rgba(255,255,255,0.3), transparent);
    background-repeat: no-repeat;
    opacity: 0.8;
}

/* Jeden zorkiestrowany moment ruchu przy wczytaniu strony */
.plane-trail {
    position: absolute;
    top: 46px;
    left: -60px;
    font-size: 22px;
    color: var(--gold);
    filter: drop-shadow(0 0 10px rgba(255, 201, 60, 0.7));
    animation: fly-across 3.2s ease-in-out 0.2s 1 forwards;
}

@keyframes fly-across {
    0%   { left: -60px; opacity: 0; transform: translateY(0) rotate(0deg); }
    8%   { opacity: 1; }
    50%  { transform: translateY(-14px) rotate(4deg); }
    92%  { opacity: 1; }
    100% { left: 104%; opacity: 0; transform: translateY(4px) rotate(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
    .plane-trail { display: none; }
}

/* ---------- Hero ---------- */
.hero {
    text-align: center;
    padding: 64px 20px 40px;
    position: relative;
}

.eyebrow-plain {
    margin: 0 0 6px;
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
}

.hero h1 {
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 7vw, 4.4rem);
    font-weight: 700;
    letter-spacing: 1px;
    margin: 0;
    background: linear-gradient(135deg, #ffffff 30%, var(--cyan) 75%, var(--gold) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero h1 .dot { color: var(--gold); -webkit-text-fill-color: var(--gold); }

.hero-sub {
    margin: 10px auto 0;
    max-width: 480px;
    color: var(--text-muted);
    font-size: 1.02rem;
}

/* Światła pasa startowego jako ozdobny separator */
.runway {
    margin: 34px auto 0;
    width: min(560px, 80%);
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(255,201,60,0.5), transparent);
    position: relative;
}
.runway::before {
    content: "";
    position: absolute;
    inset: -3px 0 auto 0;
    height: 8px;
    background-image: radial-gradient(circle, var(--gold) 1.6px, transparent 1.6px);
    background-size: 22px 8px;
    background-repeat: repeat-x;
    opacity: 0.85;
}

/* ---------- Layout rankingów ---------- */
main {
    max-width: 1080px;
    margin: 0 auto 70px;
    padding: 0 20px;
}

.rankings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 860px) {
    .rankings-grid { grid-template-columns: 1fr; }
}

/* Grid/flex potrafią liczyć minimalną szerokość po najdłuższym,
   niezawijanym tekście (np. "Krzysztof Lewandowski ⭐ Kapitan") i wypychać
   panel poza ekran mimo overflow:hidden. min-width:0 to koryguje. */
.rankings-grid > .panel,
.rank-item,
.rank-name,
.history-item {
    min-width: 0;
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 22px 18px 24px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
    padding: 0 4px;
}

.panel-head h2 {
    font-family: var(--font-display);
    margin: 0;
    font-size: 1.3rem;
    font-weight: 700;
}

.panel-count {
    font-size: 0.78rem;
    color: var(--text-faint);
}

/* ---------- Lista rankingowa ---------- */
.rank-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rank-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid transparent;
    transition: background 0.15s ease, transform 0.15s ease;
}

.rank-item:hover {
    background: rgba(255, 255, 255, 0.035);
}

.badge {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    transform: rotate(45deg);
}
.badge > * { transform: rotate(-45deg); }

.avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.92rem;
    border: 1.5px solid;
}

.rank-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rank-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.96rem;
    min-width: 0;
}

.name-text {
    min-width: 0;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-meta {
    font-size: 0.76rem;
    color: var(--text-faint);
}

.bar-track {
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    overflow: hidden;
    margin-top: 2px;
}
.bar-fill {
    display: block;
    height: 100%;
    border-radius: 4px;
    opacity: 0.85;
}

.rank-points {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.15rem;
    text-align: right;
}
.rank-points small {
    display: block;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.68rem;
    color: var(--text-faint);
    text-align: right;
}

/* ---------- Top 3: więksi, z poświatą medalu ---------- */
.rank-item.top {
    padding: 16px 16px;
}
.rank-item.top .avatar { width: 48px; height: 48px; font-size: 1.05rem; }
.rank-item.top .rank-name { font-size: 1.08rem; }
.rank-item.top .rank-points { font-size: 1.4rem; }
.rank-item.top .badge { width: 30px; height: 30px; }

.top1 {
    border-color: rgba(255, 214, 69, 0.55);
    background: linear-gradient(120deg, rgba(255,214,69,0.10), rgba(255,214,69,0.02));
    box-shadow: 0 0 0 1px rgba(255,214,69,0.12), 0 10px 30px -12px rgba(255,214,69,0.35);
}
.top1 .badge { background: var(--medal-gold); color: #382a00; }

.top2 {
    border-color: rgba(201, 211, 224, 0.5);
    background: linear-gradient(120deg, rgba(201,211,224,0.10), rgba(201,211,224,0.02));
    box-shadow: 0 0 0 1px rgba(201,211,224,0.10), 0 8px 24px -12px rgba(201,211,224,0.28);
}
.top2 .badge { background: var(--medal-silver); color: #2a3140; }

.top3 {
    border-color: rgba(224, 153, 94, 0.5);
    background: linear-gradient(120deg, rgba(224,153,94,0.10), rgba(224,153,94,0.02));
    box-shadow: 0 0 0 1px rgba(224,153,94,0.10), 0 8px 22px -12px rgba(224,153,94,0.3);
}
.top3 .badge { background: var(--medal-bronze); color: #341c04; }

.empty-state {
    text-align: center;
    color: var(--text-faint);
    padding: 34px 10px;
    font-size: 0.94rem;
}

footer {
    text-align: center;
    padding: 10px 20px 40px;
    color: var(--text-faint);
    font-size: 0.82rem;
}

/* ============================================================
   Panel administratora
   ============================================================ */
.admin-wrap {
    max-width: 640px;
    margin: 60px auto;
    padding: 0 20px;
    position: relative;
    z-index: 1;
}

.admin-card {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.admin-card h1 {
    font-family: var(--font-display);
    margin-top: 0;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.admin-card label {
    display: block;
    font-weight: 600;
    margin: 14px 0 6px;
    color: var(--text-muted);
    font-size: 0.86rem;
}

.admin-card input[type="text"],
.admin-card input[type="number"],
.admin-card input[type="password"] {
    width: 100%;
    padding: 11px 13px;
    border-radius: 10px;
    border: 1.5px solid var(--panel-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-body);
}
.admin-card input::placeholder { color: var(--text-faint); }

.admin-card input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(76,201,240,0.15);
}

.btn {
    display: inline-block;
    margin-top: 18px;
    background: var(--cyan);
    color: #052033;
    border: none;
    padding: 11px 22px;
    border-radius: 10px;
    font-size: 0.96rem;
    font-weight: 700;
    font-family: var(--font-display);
    cursor: pointer;
    transition: filter 0.15s;
}
.btn:hover { filter: brightness(1.1); }

.btn.yellow { background: var(--gold); color: #382a00; }

.btn.danger { background: #ff5c72; color: #350008; }

.flash {
    background: rgba(255, 201, 60, 0.12);
    border-left: 3px solid var(--gold);
    color: var(--text-primary);
    padding: 11px 14px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

table.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 22px;
    font-size: 0.88rem;
}

table.admin-table th, table.admin-table td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--panel-border);
}

table.admin-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: none;
}

.top-link {
    display: inline-block;
    margin-bottom: 14px;
    color: var(--cyan);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}
.top-link:hover { text-decoration: underline; }

/* ============================================================
   Nowe komponenty — nawigacja, licznik, filtr, rangi, historia
   ============================================================ */

.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 20px 0;
    position: relative;
    z-index: 2;
}

.nav-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: 0.5px;
    padding: 6px 4px;
    display: inline-block;
}
.nav-brand .dot { color: var(--gold); }
.nav-brand:hover { color: var(--cyan); }

.nav-link {
    color: #052033;
    background: var(--cyan);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 700;
    padding: 11px 20px;
    border-radius: 999px;
    display: inline-block;
    box-shadow: 0 6px 18px -6px rgba(76,201,240,0.55);
    transition: filter 0.15s, transform 0.15s;
}
.nav-link:hover { filter: brightness(1.1); transform: translateY(-1px); }

/* ---------- Kompaktowy licznik w nawigacji ---------- */
.nav-countdown {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(255,201,60,0.08);
    border: 1px solid rgba(255,201,60,0.28);
    border-radius: 999px;
    padding: 8px 16px;
    cursor: default;
}
.nav-cd-flag { font-size: 0.95rem; }
.nav-cd-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.nav-cd-num {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--gold);
}
.nav-cd-sep {
    margin-left: 4px;
    color: var(--text-faint);
    font-weight: 500;
}

@media (max-width: 640px) {
    .nav-brand { font-size: 1.25rem; }
    .nav-link { font-size: 0.85rem; padding: 9px 14px; }
    .top-nav { flex-wrap: wrap; gap: 10px; }
    .nav-cd-sep { display: none; }
}

/* ---------- Duża wyszukiwarka na stronie głównej ---------- */
.search-hero {
    text-align: center;
    background: linear-gradient(120deg, rgba(76,201,240,0.10), rgba(255,201,60,0.06));
    border: 1px solid rgba(76,201,240,0.3);
    border-radius: 20px;
    padding: 32px 24px;
    margin-bottom: 22px;
}

.search-hero h2 {
    font-family: var(--font-display);
    margin: 0 0 6px;
    font-size: 1.5rem;
}

.search-hero p {
    margin: 0 auto 18px;
    color: var(--text-muted);
    font-size: 0.94rem;
    max-width: 440px;
}

.search-form-inline {
    display: flex;
    gap: 10px;
    max-width: 480px;
    margin: 0 auto;
}
.search-form-inline input[type="text"] {
    flex: 1;
    padding: 13px 18px;
    border-radius: 12px;
    border: 1.5px solid var(--panel-border);
    background: rgba(255,255,255,0.04);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-body);
}
.search-form-inline input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(76,201,240,0.15);
}

.search-hero .rank-list { text-align: left; max-width: 640px; margin-left: auto; margin-right: auto; }

/* ---------- Licznik do nagrody ---------- */
.countdown-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: linear-gradient(120deg, rgba(255,201,60,0.12), rgba(76,201,240,0.06));
    border: 1px solid rgba(255,201,60,0.3);
    border-radius: 16px;
    padding: 16px 20px;
    margin-bottom: 22px;
}

.countdown-text { display: flex; flex-direction: column; gap: 2px; }
.countdown-text strong { font-size: 0.96rem; color: var(--text-primary); }
.countdown-text span { font-size: 0.8rem; color: var(--text-muted); }

.countdown-timer { display: flex; gap: 8px; }
.cd-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0,0,0,0.25);
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 46px;
}
.cd-num { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--gold); }
.cd-label { font-size: 0.62rem; color: var(--text-faint); text-transform: lowercase; }

/* ---------- Panel klas (najważniejszy) ---------- */
.panel-primary {
    border-color: rgba(255, 201, 60, 0.3);
}

.prize-tag {
    display: inline-block;
    margin-left: 8px;
    font-size: 0.64rem;
    font-weight: 700;
    color: #382a00;
    background: var(--gold);
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
    font-family: var(--font-body);
}

.panel-head { align-items: flex-start; }

.export-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
}
.export-btn:hover { background: rgba(255,255,255,0.12); }

/* ---------- Filtr poziomów ---------- */
.level-filter {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.pill {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--panel-border);
    padding: 6px 13px;
    border-radius: 999px;
    text-decoration: none;
}
.pill.active {
    color: #382a00;
    background: var(--gold);
    border-color: var(--gold);
}
.pill:not(.active):hover { background: rgba(255,255,255,0.08); }

.filter-note {
    font-size: 0.76rem;
    color: var(--text-faint);
    margin: 0 4px 14px;
}

/* ---------- Rangi / tier ---------- */
.tier-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 999px;
    vertical-align: middle;
}

.badge-row {
    display: flex;
    gap: 5px;
    margin-top: 3px;
}
.mini-badge {
    font-size: 0.82rem;
    cursor: default;
}

/* ---------- Historia lotów ---------- */
.history-panel { margin-top: 22px; }

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-item {
    display: grid;
    grid-template-columns: 90px 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 9px 10px;
    border-bottom: 1px solid var(--panel-border);
    font-size: 0.86rem;
}
.history-item:last-child { border-bottom: none; }

.history-date { color: var(--text-faint); font-size: 0.78rem; }
.history-who { font-weight: 600; color: var(--text-primary); }
.history-class { font-weight: 400; color: var(--text-faint); }
.history-reason { color: var(--text-muted); font-size: 0.82rem; }
.history-points { font-family: var(--font-display); font-weight: 700; color: var(--cyan); text-align: right; }
.history-points.negative { color: #ff5c72; }

@media (max-width: 640px) {
    .history-item { grid-template-columns: 1fr auto; row-gap: 2px; }
    .history-date { grid-column: 1 / -1; order: -1; }
    .history-reason { grid-column: 1 / -1; }
}

/* ---------- Strona wyszukiwarki ---------- */
.search-form {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}
.search-form input[type="text"] {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--panel-border);
    background: rgba(255,255,255,0.03);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-body);
}
.search-form input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(76,201,240,0.15);
}

/* Poprawka: pole wyszukiwania nie może wypychać strony poza ekran telefonu */
.search-form-inline { align-items: stretch; }
.search-form-inline input[type="text"] { min-width: 0; }
.search-form-inline .btn { flex-shrink: 0; margin-top: 0; }
