/* Front ambasadora — korzysta z tokenów i komponentów z admin.css */

body.app-body {
    --accent: #c80000;
    --accent-600: #a30000;
    --accent-ring: rgba(200, 0, 0, .16);
    --ink: #222326;
    --pill: #e1e3e7;
    --pill-text: #8b8c91;
    --avatar-bg: #ced1d6;
    --stage: #2a1519;
    font-family: Lexend, Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: #f4f5f8;
    color: var(--ink);
}
.app-body .avatar { background: var(--avatar-bg); color: #fff; font-weight: 600; }
/* Zdjęcia portretowe: przycinamy dół, a nie głowę */
.app-body img.avatar { object-position: 50% 0; }

/* Górny pasek */
.app-top { position: sticky; top: 0; z-index: 20; background: #fff; }
.app-top-inner { max-width: 881px; margin: 0 auto; padding: 0 20px; height: 63px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-brand { display: flex; align-items: center; gap: 11px; font-weight: 500; font-size: 15px; text-decoration: none; color: var(--ink); }
.app-brand .brand-mark { width: 35px; height: 35px; border-radius: 8px; background: var(--accent); box-shadow: none; }
.app-nav { display: flex; gap: 4px; }
.app-nav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px; text-decoration: none; color: #3a3b3f; }
.app-nav a:hover { background: #f1f2f5; color: var(--ink); }
.app { max-width: 881px; margin: 0 auto; padding: 32px 20px 72px; }

/* Zakładki */
.tabs { display: flex; gap: 20px; margin: -3px 0 26px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 0 42px 9px 0;
    font-weight: 600; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap;
    border-bottom: 2px solid transparent; transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--accent); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Nagłówek okresu */
.hero { margin-bottom: 26px; }
.eyebrow { display: flex; flex-wrap: wrap; font-size: 14px; font-weight: 500; color: var(--accent); text-transform: uppercase; letter-spacing: .02em; }
.eyebrow span + span::before { content: "·"; margin: 0 9px; }
.hero h1 { margin: 0; font-size: 35px; font-weight: 700; letter-spacing: -.015em; line-height: 1.15; color: var(--ink); }

/* Pasek wyboru okresu */
.period-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.pills { display: flex; gap: 3px; }
.pills a {
    display: block; min-width: 89px; padding: 9px 16px; border-radius: 6px; text-align: center;
    background: var(--pill); color: var(--pill-text); font-weight: 500; font-size: 14px; line-height: 19px;
    text-decoration: none; white-space: nowrap; transition: background .15s, color .15s;
}
.pills a:hover { color: var(--ink); }
.pills a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(16, 24, 40, .1); }
.period-steps { display: flex; gap: 8px; align-items: center; }
.step { display: grid; place-items: center; width: 24px; height: 37px; color: #b4b6bb; text-decoration: none; }
.step:hover { color: var(--ink); }
.step.is-disabled { opacity: .5; pointer-events: none; }
.period-pick {
    position: relative; display: grid; place-items: center; min-width: 153px; height: 37px; padding: 0 18px;
    background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(16, 24, 40, .1);
    font-weight: 500; font-size: 14px; cursor: pointer;
}
.period-pick select { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; font: inherit; }
.period-pick:focus-within { box-shadow: 0 0 0 3px var(--accent-ring); }

/* Podium */
.stage {
    position: relative; overflow: hidden; isolation: isolate;
    border-radius: 20px; margin-bottom: 28px; padding: 58px 20px 0; color: #fff;
    background:
        radial-gradient(240px 300px at 50% 38%, rgba(214, 18, 24, .95), rgba(196, 18, 24, .6) 45%, transparent 100%),
        linear-gradient(90deg, #351317 0%, #4a1a20 25%, #5e1a20 45%, #5e1a20 55%, #34161b 78%, #23121a 100%);
}
.stage::before, .stage::after {
    content: ""; position: absolute; z-index: -1; top: calc(50% - 210px); width: 420px; height: 420px; transform: rotate(45deg);
}
/* Romby w tle: czubki skierowane do środka sceny */
.stage::before { left: calc(35% - 507px); background: rgba(255, 255, 255, .025); }
.stage::after { right: calc(35% - 507px); background: rgba(0, 0, 0, .09); }
.stage-empty { margin: 0; padding: 0 0 46px; text-align: center; color: rgba(255, 255, 255, .7); }
.podium { display: grid; grid-template-columns: repeat(3, 150px); justify-content: center; align-items: end; column-gap: 80px; }
.podium-spot { display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; color: inherit; text-decoration: none; }
.podium-spot:hover .podium-block { transform: translateY(-4px); }
.podium-avatar { position: relative; margin-bottom: 8px; }
.podium-avatar .avatar { width: 63px; height: 63px; font-size: 22px; background: rgba(255, 255, 255, .33); color: #fff; }
.p1 .podium-avatar .avatar { width: 83px; height: 83px; font-size: 28px; }
.podium-avatar .sparkle { position: absolute; top: -16px; right: -15px; color: #ff2429; }
.podium-name { font-weight: 700; font-size: 14px; line-height: 1.2; max-width: 100%; overflow-wrap: anywhere; }
.podium-points { font-size: 12px; font-weight: 500; margin-top: 1px; }
.podium-block { width: 100%; margin-top: 4px; border-radius: 10px 10px 0 0; background: #fff; transition: transform .15s; }
.p1 .podium-block { height: 120px; }
.p2 .podium-block { height: 80px; }
.p3 .podium-block { height: 30px; }

/* Pełny ranking */
.list-title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 15px; font-size: 16px; font-weight: 600; color: var(--ink); }
.list-title span { font-size: 13px; font-weight: 400; color: #8b8c91; }
.rank-wrap { position: relative; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-wrap.is-collapsed .rank-list {
    max-height: 372px; overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, #000 58%, rgba(0, 0, 0, .55) 80%, transparent);
    mask-image: linear-gradient(180deg, #000 58%, rgba(0, 0, 0, .55) 80%, transparent);
}
.rank-more { display: none; }
.rank-wrap.is-collapsed .rank-more {
    display: grid; place-items: center; position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%);
    width: 44px; height: 32px; padding: 0; border: 0; background: none; color: #8b8c91; cursor: pointer;
}
.rank-more:hover { color: var(--ink); }
.rank-row {
    display: flex; align-items: center; gap: 9px; height: 70px; padding: 0 16px 0 9px;
    background: #fff; border: 3px solid transparent; border-radius: 16px; text-decoration: none; color: var(--ink);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .04);
    transition: transform .12s, box-shadow .12s;
}
.rank-row:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(16, 24, 40, .08); }
.rank-row.top-1 { background: linear-gradient(#fff, #fff) padding-box, linear-gradient(90deg, #5e0000, #c80000 45%, #c80000) border-box; }
.rank-place { width: 43px; height: 43px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: #6d6b6c; color: #fff; font-weight: 500; font-size: 22px; }
.rank-row.top-1 .rank-place { background: var(--accent); }
.rank-row.top-2 .rank-place, .rank-row.top-3 .rank-place { background: #333130; }
.rank-row .avatar { width: 43px; height: 43px; font-size: 14px; }
.rank-name { flex: 1; min-width: 0; margin-left: 6px; font-weight: 500; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-points { font-weight: 700; font-size: 22px; white-space: nowrap; }
.rank-points small { font-size: 15px; font-weight: 400; }
.rank-points.negative { color: var(--accent); }
.rank-chevron { color: #b4b6bb; margin-left: 4px; }

/* Profil */
.back { display: inline-flex; align-items: center; gap: 4px; margin: -2px 0 31px -4px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 16px; }
.back .icon { color: #b4b6bb; }
.back span { margin: 0 6px; }
.back:hover .icon { color: var(--ink); }
.profile-hero {
    position: relative;
    display: flex; align-items: center; gap: 33px; min-height: 166px; padding: 23px 33px 23px 19px;
    border-radius: 20px; color: #fff;
    background:
        conic-gradient(from 225deg at 70% 50%, rgba(255, 255, 255, .025) 0 90deg, transparent 90deg),
        radial-gradient(420px 260px at 33% 75%, rgba(205, 20, 25, .9), transparent 70%),
        linear-gradient(90deg, #461a20 0%, #93171b 18%, #b9151a 35%, #86171c 55%, #48181e 72%, #2f161a 100%);
}
.profile-hero .avatar { width: 120px; height: 120px; font-size: 44px; }
.profile-info { flex: 1; min-width: 0; }
.profile-hero h1 { margin: 3px 0 0; font-size: 34px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.profile-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 14px; }
.tag { position: relative; display: inline-flex; align-items: center; height: 37px; padding: 0 17px; border-radius: 6px; background: rgba(255, 255, 255, .33); color: #fff; font-weight: 500; font-size: 14px; white-space: nowrap; }
.tag-winner { background: #fff; color: var(--ink); padding-right: 21px; }
.tag-winner .sparkle { position: absolute; top: 2px; right: 4px; color: #ff2429; }
.profile-score {
    flex-shrink: 0; display: grid; place-items: center; width: 102px; height: 102px; border-radius: 50%;
    background: #fff; color: var(--accent); font-weight: 700; font-size: 44px; letter-spacing: -.01em;
    box-shadow: 0 0 50px 12px rgba(255, 140, 150, .28);
}
.history { margin-top: 6px; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 1px 3px rgba(16, 24, 40, .04); }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 17px 46px 15px 26px; border-bottom: 1px solid #dcdde1; }
.history-head h2 { margin: 0; font-size: 22px; font-weight: 500; color: var(--ink); }
.history-head .pills { gap: 6px; }
.history-head .pills a { padding: 9px 16px; }
.entries { list-style: none; margin: 0; padding: 0; }
.entries li { display: flex; align-items: center; gap: 12px; min-height: 70px; padding: 10px 44px 10px 28px; }
.entries li + li { border-top: 1px solid #dcdde1; }
.entry-date { width: 81px; flex-shrink: 0; font-size: 14px; color: #a0a1a6; font-variant-numeric: tabular-nums; }
.entry-note { flex: 1; min-width: 0; font-weight: 500; font-size: 16px; overflow-wrap: anywhere; }
.entry-points { font-weight: 700; font-size: 22px; color: var(--accent); white-space: nowrap; }
.entry-points small { font-size: 15px; font-weight: 400; }
.entry-points.negative { color: #6d6b6c; }

/* Logowanie PIN-em */
body.auth.app-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: #f4f5f8; }
.login {
    display: grid; grid-template-columns: 504px 335px; width: 839px; min-height: 375px;
    background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 1px 3px rgba(16, 24, 40, .04), 0 16px 40px rgba(16, 24, 40, .1);
}
.login-hero {
    position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; padding: 40px 55px; color: #fff;
    background:
        radial-gradient(230px 270px at 30% 52%, rgba(214, 18, 24, .9), rgba(170, 18, 24, .45) 55%, transparent 100%),
        linear-gradient(90deg, #4a1519 0%, #5a171c 35%, #3f171b 70%, #2c1418 100%);
}
/* Wielki „X” w tle */
.login-hero::before {
    content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: 0; width: 66%;
    background:
        linear-gradient(to top right, transparent calc(50% - 46px), rgba(255, 255, 255, .03) calc(50% - 46px) calc(50% + 46px), transparent calc(50% + 46px)),
        linear-gradient(to bottom right, transparent calc(50% - 46px), rgba(0, 0, 0, .1) calc(50% - 46px) calc(50% + 46px), transparent calc(50% + 46px));
    -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
    mask-image: radial-gradient(closest-side, #000 55%, transparent 100%);
}
/* Ziarno */
.login-hero::after {
    content: ""; position: absolute; z-index: -1; inset: 0; opacity: .45; mix-blend-mode: overlay; pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.login-watermark {
    position: absolute; left: -8px; top: 0; writing-mode: vertical-rl; transform: rotate(180deg);
    font-size: 64px; font-weight: 700; line-height: 1; color: rgba(0, 0, 0, .16);
}
.login-title { position: relative; margin: 0; font-size: 26px; font-weight: 700; line-height: 1.05; text-transform: uppercase; }
.login-title .sparkle { position: relative; top: -14px; margin-left: 2px; color: #ff2429; vertical-align: top; }
.login-body { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 42px 26px; text-align: center; }
.login-mark { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 8px; background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(200, 0, 0, .25); }
.login-label { margin: 10px 0 0; font-weight: 600; font-size: 14px; color: var(--ink); }
.login-body h1 { margin: 32px 0 0; font-size: 21px; font-weight: 700; line-height: 1.2; }
.login-sub { margin: 2px 0 12px; font-size: 13px; color: var(--ink); }
.login-body .alert { width: 100%; margin: 0 0 12px; text-align: left; }
.pin-field { position: relative; width: 100%; }
.login .pin-input {
    display: block; width: 100%; height: 59px; padding: 0 14px; border: 2px solid transparent; border-radius: 6px; background: #fff;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .12); font: inherit; font-size: 24px; font-weight: 700; letter-spacing: .4em; text-align: center; color: var(--ink);
}
.login .pin-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
/* Z JS: prawdziwe pole jest przezroczyste i leży na kafelkach */
.pin-cells { display: none; }
.pin-field.is-enhanced .pin-cells { display: flex; gap: 5px; }
.pin-field.is-enhanced .pin-input { position: absolute; inset: 0; z-index: 1; height: 100%; opacity: 0; cursor: pointer; }
.pin-cell {
    position: relative; flex: 1; min-width: 0; height: 59px; border: 2px solid transparent; border-radius: 6px; background: #fff;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .12); transition: border-color .15s, box-shadow .15s;
}
.pin-cell.is-filled::after { content: ""; position: absolute; inset: 0; margin: auto; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.pin-field.is-long .pin-cells { gap: 3px; }
.pin-field.is-long .pin-cell { height: 44px; }
.pin-field.is-long .pin-cell.is-filled::after { width: 8px; height: 8px; }
.login .pin-input:focus + .pin-cells .pin-cell.is-current { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.login-btn {
    display: block; width: 100%; height: 45px; margin-top: 34px; border: 0; border-radius: 6px; cursor: pointer;
    background: var(--accent); color: #fff; font: inherit; font-weight: 600; font-size: 15px; transition: background .15s, transform .05s;
}
.login-btn:hover { background: var(--accent-600); }
.login-btn:active { transform: translateY(1px); }
.login-btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }

@media (max-width: 880px) {
    .login { grid-template-columns: 1fr; width: min(420px, 100%); min-height: 0; }
    .login-hero { min-height: 170px; padding: 32px 28px 32px 72px; }
    .login-title { font-size: 23px; }
    .login-watermark { font-size: 52px; }
    .login-body { padding: 30px 24px 24px; }
    .login-body h1 { margin-top: 22px; }
}

@media (max-width: 720px) {
    .podium { grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 14px; max-width: 480px; margin: 0 auto; }
}

@media (max-width: 600px) {
    .app { padding: 20px 16px 56px; }
    .app-top-inner { height: 56px; padding: 0 16px; }
    .app-brand .brand-mark { width: 32px; height: 32px; }
    .app-nav a { padding: 8px 10px; }
    .app-nav a span { display: none; }
    .tabs { gap: 16px; margin-bottom: 20px; }
    .tabs a { font-size: 15px; padding-right: 8px; }
    .hero { margin-bottom: 20px; }
    .eyebrow { font-size: 12px; }
    .hero h1 { font-size: 28px; }
    .period-bar { flex-direction: column; align-items: stretch; gap: 10px; }
    .period-bar .pills a { flex: 1; min-width: 0; padding: 9px 4px; }
    .period-steps { justify-content: space-between; }
    .period-pick { flex: 1; }
    .stage { padding: 34px 12px 0; border-radius: 18px; margin-bottom: 22px; }
    .stage::before { left: -30%; }
    .podium { column-gap: 8px; }
    .podium-avatar .avatar { width: 48px; height: 48px; font-size: 16px; }
    .p1 .podium-avatar .avatar { width: 64px; height: 64px; font-size: 22px; }
    .podium-avatar .sparkle { width: 24px; height: 24px; top: -12px; right: -12px; }
    .podium-name { font-size: 12px; }
    .podium-points { font-size: 11px; }
    .p1 .podium-block { height: 96px; }
    .p2 .podium-block { height: 64px; }
    .p3 .podium-block { height: 26px; }
    .rank-row { height: 60px; gap: 8px; padding: 0 10px 0 7px; border-radius: 14px; }
    .rank-place { width: 36px; height: 36px; font-size: 18px; }
    .rank-row .avatar { width: 36px; height: 36px; font-size: 12px; }
    .rank-name { margin-left: 2px; font-size: 15px; }
    .rank-points { font-size: 19px; }
    .rank-points small { font-size: 13px; }
    .rank-chevron { display: none; }
    .rank-wrap.is-collapsed .rank-list { max-height: 318px; }
    .back { font-size: 15px; margin-bottom: 18px; }
    .profile-hero { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "avatar score" "info info"; gap: 16px; padding: 18px; min-height: 0; border-radius: 18px; }
    .profile-hero .avatar { grid-area: avatar; width: 72px; height: 72px; font-size: 26px; }
    .profile-score { grid-area: score; justify-self: end; width: 72px; height: 72px; font-size: 30px; }
    .profile-info { grid-area: info; }
    .profile-hero h1 { font-size: 26px; }
    .profile-tags { margin-top: 10px; }
    .tag { height: 32px; padding: 0 13px; font-size: 13px; }
    .tag-winner { padding-right: 19px; }
    .history { border-radius: 18px; }
    .history-head { padding: 16px; }
    .history-head h2 { font-size: 19px; }
    .history-head .pills { width: 100%; gap: 4px; }
    .history-head .pills a { flex: 1; min-width: 0; padding: 9px 6px; }
    .entries li { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "note points" "date points"; column-gap: 12px; row-gap: 2px; min-height: 64px; padding: 12px 16px; }
    .entry-date { grid-area: date; width: auto; font-size: 13px; }
    .entry-note { grid-area: note; font-size: 15px; }
    .entry-points { grid-area: points; font-size: 19px; }
    .entry-points small { font-size: 13px; }
    .login-hero { min-height: 140px; padding: 26px 20px 26px 64px; }
    .login-watermark { font-size: 44px; }
    .login-body { padding: 26px 20px 22px; }
}
