/* =====================================================================
   Wspólny wygląd minigierek – ten sam styl HUD co strona główna
   Układ: plansza gry po lewej, ranking i konto po prawej
   ===================================================================== */
:root {
    --bg: #0e0e10;
    --surface: #18181b;
    --surface-2: #1f1f23;
    --line: #2f2f35;
    --text: #efeff1;
    --muted: #adadb8;
    --dim: #6b6b75;
    --accent: #9147ff;
    --accent-2: #a970ff;
    --accent-rgb: 145, 71, 255;
    --accent-2-rgb: 169, 112, 255;
    --on-accent: #ffffff;
    --good: #2fd17a;
    --bad: #ff4d4f;
    --gold: #f5c542;
    --silver-medal: #c9ccd3;
    --bronze: #cd8a4f;
    --discord: #5865f2;
    --silver: linear-gradient(160deg, #fafafa 0%, #d4d4d8 22%, #8a8a93 52%, #4a4a52 78%, #2a2a30 100%);
    --steel: linear-gradient(160deg, #55555e 0%, #34343b 45%, #202026 100%);
    --cut: 14px;
    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;
    color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0; min-height: 100vh;
    font-family: var(--font-body);
    background: var(--bg); color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 3px; }
.ic { display: inline-block; width: 1.15em; height: 1em; fill: currentColor; flex-shrink: 0; vertical-align: -0.125em; }

.bg-glow {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background: radial-gradient(ellipse 60% 40% at 50% -5%, rgba(var(--accent-rgb), 0.22), transparent 70%);
}
.bg-grid {
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    background-image: radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
    background-size: 26px 26px;
    mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 30%, transparent 85%);
}

/* ---------- ramki HUD ---------- */
.hud {
    position: relative; padding: 2px; background: var(--steel);
    clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
}
.hud.is-silver { background: var(--silver); }
.hud-in {
    position: relative; display: block; height: 100%; background: var(--surface);
    clip-path: polygon(calc(var(--cut) - 1px) 0, 100% 0, 100% calc(100% - var(--cut) + 1px), calc(100% - var(--cut) + 1px) 100%, 0 100%, 0 calc(var(--cut) - 1px));
}

/* ---------- przyciski ---------- */
.btn {
    --c: 10px;
    display: inline-flex; align-items: center; justify-content: center; gap: 10px;
    padding: 13px 22px;
    font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: 0.06em; text-transform: uppercase;
    clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
    transition: background-color 0.2s, transform 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: 0.6; cursor: wait; transform: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-2); }
.btn-discord { background: var(--discord); color: #fff; }
.btn-discord:hover { background: #6d78f5; }
.btn-ghost { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.btn-ghost:hover { background: #2a2a30; }
.btn-sm { padding: 9px 14px; font-size: 15px; }

/* ---------- układ strony ---------- */
main {
    position: relative; z-index: 2;
    width: 100%; max-width: 1180px; margin: 0 auto;
    padding: 22px 20px 40px;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.back {
    display: inline-flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
    transition: color 0.2s;
}
.back:hover { color: #fff; }
.back .ic { transform: scaleX(-1); }
.title-row { margin: 22px 0 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.kicker { margin: 0; font-size: 11px; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; color: var(--accent-2); }
h1 {
    margin: 4px 0 0;
    font-family: var(--font-display); font-weight: 900;
    font-size: clamp(46px, 8vw, 72px); line-height: 0.92; letter-spacing: 0.02em; text-transform: uppercase;
    background: linear-gradient(180deg, #fff 0%, #d4d4d8 55%, #8a8a93 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.rules { margin: 0; max-width: 46ch; font-size: 14px; line-height: 1.55; color: var(--muted); }
.rules b { color: var(--text); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }

/* ---------- pasek statystyk ---------- */
.hudbar {
    display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
    margin: 0 0 10px;
    background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.hudbar > div { padding: 10px 14px; }
.hudbar > div + div { border-left: 1px solid var(--line); }
.hudbar dt { font-size: 10px; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim); }
.hudbar dd {
    margin: 2px 0 0;
    font-family: var(--font-display); font-weight: 800; font-size: 28px; line-height: 1;
    font-variant-numeric: tabular-nums;
}
.hudbar dd.is-low { color: var(--bad); }

/* ---------- plansza ---------- */
.stage-frame { --cut: 18px; }
.stage {
    position: relative;
    aspect-ratio: 16 / 10;
    min-height: 300px;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 120%, rgba(var(--accent-rgb), 0.18), transparent 60%),
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px) 0 0 / 40px 40px,
        #111114;
    touch-action: none;
    user-select: none; -webkit-user-select: none;
}

/* nakładki: start / odliczanie / wynik */
.overlay {
    position: absolute; inset: 0; z-index: 20;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    padding: 20px; text-align: center;
    background: rgba(14, 14, 16, 0.88);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.overlay h2 {
    margin: 0;
    font-family: var(--font-display); font-weight: 900; font-size: clamp(30px, 5vw, 44px); line-height: 1; text-transform: uppercase;
}
.overlay p { margin: 0; max-width: 42ch; font-size: 14px; line-height: 1.5; color: var(--muted); }
.overlay-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.countdown {
    font-family: var(--font-display); font-weight: 900; font-size: clamp(90px, 18vw, 160px); line-height: 1;
    color: #fff; text-shadow: 0 0 40px rgba(var(--accent-2-rgb), 0.7);
    animation: tick 0.9s ease-out;
}
@keyframes tick { from { transform: scale(1.4); opacity: 0; } }
.big-score {
    font-family: var(--font-display); font-weight: 900; font-size: clamp(60px, 12vw, 100px); line-height: 0.9;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(180deg, #fff 0%, #d4d4d8 55%, #8a8a93 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.result-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; font-size: 13px; font-weight: 700; color: var(--muted); }
.result-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.result-msg { min-height: 1.4em; font-weight: 700; font-size: 14px; }
.result-msg.good { color: var(--good); }
.result-msg.bad { color: var(--bad); }

/* ---------- panel boczny ---------- */
.side { display: grid; gap: 14px; }
.panel { --cut: 14px; }
.panel .hud-in { padding: 18px; }
.panel-title {
    margin: 0 0 12px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    font-family: var(--font-display); font-weight: 800; font-size: 24px; letter-spacing: 0.03em; text-transform: uppercase;
}
.panel-title small { font-family: var(--font-body); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: none; color: var(--dim); }

.board { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.row {
    display: grid; grid-template-columns: 30px 32px minmax(0, 1fr) auto; align-items: center; gap: 10px;
    padding: 8px 10px;
    background: var(--surface-2);
}
.row.is-me { box-shadow: inset 3px 0 0 var(--accent-2); }
.rank { font-family: var(--font-display); font-weight: 900; font-size: 20px; text-align: center; color: var(--dim); }
.row:nth-child(1) .rank { color: var(--gold); }
.row:nth-child(2) .rank { color: var(--silver-medal); }
.row:nth-child(3) .rank { color: var(--bronze); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: #2a2a30; }
.avatar-fallback { display: grid; place-items: center; font-weight: 800; font-size: 13px; color: var(--muted); }
.pname { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pscore { font-family: var(--font-display); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-empty { padding: 16px 10px; font-size: 13px; font-weight: 600; color: var(--dim); text-align: center; background: var(--surface-2); }
.skeleton-row { height: 48px; background: linear-gradient(90deg, #1c1c20 25%, #26262b 50%, #1c1c20 75%); background-size: 200% 100%; animation: sk 1.4s infinite; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.me { display: flex; align-items: center; gap: 12px; }
.me .avatar { width: 44px; height: 44px; }
.me-name { font-weight: 800; font-size: 15px; }
.me-best { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.me-best b { color: var(--text); font-variant-numeric: tabular-nums; }
.me-actions { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.account-note { margin: 0 0 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.other-games { justify-self: start; }

.toast {
    position: fixed; bottom: -120px; left: 50%; transform: translateX(-50%); z-index: 9999;
    padding: 14px 22px; max-width: calc(100vw - 32px);
    background: #1f1f23; border-left: 3px solid var(--accent);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    font-size: 14px; font-weight: 700;
    transition: bottom 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.toast.show { bottom: 28px; }
.toast.error { border-left-color: var(--bad); }

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
    .other-games { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
    main { padding: 18px 16px 32px; }
    .side { grid-template-columns: 1fr; }
    .hudbar dd { font-size: 22px; }
    .hudbar > div { padding: 8px 10px; }
    .stage { aspect-ratio: 3 / 4; }
}
/* ---------- drabinka rang (profil, ranking) ---------- */
.ladder-head { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.ladder-head b { color: #fff; }
.ladder { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.rung {
    --c: 12px;
    position: relative; display: grid; justify-items: center; align-content: start; gap: 4px;
    padding: 16px 10px 14px; text-align: center;
    background: var(--surface-2);
    clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
    box-shadow: inset 0 3px 0 var(--rc);
}
.rung-ico { font-size: 32px; line-height: 1.1; }
.rung-name { font-family: var(--font-display); font-weight: 900; font-size: 19px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--rc); }
.rung-req { font-family: var(--font-display); font-weight: 800; font-size: 16px; color: #fff; font-variant-numeric: tabular-nums; }
.rung-desc { font-size: 11.5px; line-height: 1.35; color: var(--muted); }
.rung-tag { min-height: 18px; margin-top: 4px; font-size: 11px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.rung.is-current { background: linear-gradient(180deg, color-mix(in srgb, var(--rc) 22%, #1f1f23) 0%, #1f1f23 100%); box-shadow: inset 0 3px 0 var(--rc), inset 0 0 0 1px color-mix(in srgb, var(--rc) 60%, transparent); }
.rung.is-current .rung-tag { padding: 2px 8px; color: #0e0e10; background: var(--rc); }
.rung.is-done .rung-tag { color: var(--rc); }
.rung.is-locked { opacity: 0.5; }
.rung.is-locked .rung-ico { filter: grayscale(0.8); }
.rung.is-next { opacity: 0.95; }
.rung-bar { display: block; width: 80px; height: 6px; margin-top: 4px; background: #2a2a30; overflow: hidden; }
.rung-bar span { display: block; height: 100%; background: var(--rc); }
@media (max-width: 900px) { .ladder { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 480px) {
    .ladder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rung-name { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
