/* ==========================================================================
   Bilard Pro — shared "modern" layer.
   Loaded after each page's own <style>, so it only refines the look:
   same layout, livelier surfaces, motion, focus states and mobile polish.
   ========================================================================== */

:root {
    --m-radius: 1.15rem;
    --m-radius-sm: 0.75rem;
    --m-ease: cubic-bezier(.2, .8, .2, 1);
    --m-spring: cubic-bezier(.2, 1.35, .4, 1);
    --m-glass: linear-gradient(160deg, rgba(255, 255, 255, 0.075) 0%, rgba(255, 255, 255, 0.015) 38%, rgba(0, 0, 0, 0.08) 100%);
    --m-ring: 0 0 0 3px rgba(212, 248, 116, 0.22);
    --m-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 18px 50px -12px rgba(0, 0, 0, 0.6), 0 4px 14px rgba(0, 0, 0, 0.25);
    --m-shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 28px 70px -14px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(212, 248, 116, 0.22), 0 0 36px -6px rgba(184, 233, 134, 0.28);
}

html { scroll-behavior: smooth; }
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-tap-highlight-color: transparent;
    background-color: #0a0f0a;
}
::selection { background: rgba(212, 248, 116, 0.32); color: #fff; }

/* Thin themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(184, 233, 134, 0.35) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: rgba(184, 233, 134, 0.28); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background-color: rgba(184, 233, 134, 0.45); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------- Living background ---------- */
.shell__bg, .page__bg {
    animation: m-kenburns 38s ease-in-out infinite alternate;
    will-change: transform;
}
.shell__wash::after, .page__veil::after {
    content: "";
    position: absolute;
    inset: -20%;
    pointer-events: none;
    background:
        radial-gradient(closest-side at 30% 35%, rgba(184, 233, 134, 0.16), transparent 70%),
        radial-gradient(closest-side at 72% 65%, rgba(90, 200, 160, 0.12), transparent 70%),
        radial-gradient(closest-side at 55% 15%, rgba(255, 217, 120, 0.07), transparent 70%);
    filter: blur(10px);
    animation: m-aurora 22s ease-in-out infinite alternate;
    will-change: transform;
}
.shell__wash, .page__veil { overflow: hidden; }

@keyframes m-kenburns {
    from { transform: scale(1.04) translate3d(0, 0, 0); }
    to   { transform: scale(1.12) translate3d(-1.5%, -1%, 0); }
}
@keyframes m-aurora {
    0%   { transform: translate3d(-4%, -2%, 0) rotate(0deg); }
    50%  { transform: translate3d(3%, 3%, 0) rotate(6deg); }
    100% { transform: translate3d(5%, -3%, 0) rotate(-4deg); }
}

/* ---------- Header ---------- */
.top h1, .brand-block h1 {
    background: linear-gradient(100deg, #f4ffd8 0%, var(--lime-bright, #d4f874) 40%, #9fe08a 70%, var(--lime-bright, #d4f874) 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: m-shimmer-text 9s ease-in-out infinite;
    letter-spacing: 0.02em;
}
@keyframes m-shimmer-text {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.btn-back {
    gap: 0.35rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(0, 0, 0, 0.32);
    transition: background 0.2s var(--m-ease), transform 0.2s var(--m-ease), border-color 0.2s;
}
.btn-back:hover { transform: translateX(-2px); border-color: rgba(212, 248, 116, 0.4); }

.lang {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.lang button { transition: background 0.25s var(--m-ease), color 0.25s, box-shadow 0.25s; }
.lang button:hover { color: var(--text, #ecf8e8); }

/* ---------- Glass surfaces ---------- */
.menu-card,
.pool-card,
.section,
.an-card,
.an-filter,
.an-table-wrap,
.panel,
.card {
    position: relative;
    border-radius: var(--m-radius);
    background-image: var(--m-glass);
    box-shadow: var(--m-shadow);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.an-table-wrap { border-radius: var(--m-radius-sm); }

/* Gradient hairline on top edge */
.menu-card::before,
.pool-card::before,
.section::before,
.an-card::before,
.panel::before {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    top: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(212, 248, 116, 0.55), transparent);
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.3s, left 0.4s var(--m-ease), right 0.4s var(--m-ease);
}

/* Entrance motion (staggered) */
.menu-card,
.pool-card,
.section,
.an-card,
.an-filter,
.an-table-wrap,
.an-section-title,
.hist-toolbar,
.card,
.brand {
    animation: m-rise 0.6s var(--m-ease) both;
}
.menu-grid > :nth-child(1), .grid > :nth-child(1) { animation-delay: 0.03s; }
.menu-grid > :nth-child(2), .grid > :nth-child(2) { animation-delay: 0.08s; }
.menu-grid > :nth-child(3), .grid > :nth-child(3) { animation-delay: 0.13s; }
.menu-grid > :nth-child(4), .grid > :nth-child(4) { animation-delay: 0.18s; }
.menu-grid > :nth-child(5), .grid > :nth-child(5) { animation-delay: 0.23s; }
.menu-grid > :nth-child(6), .grid > :nth-child(6) { animation-delay: 0.28s; }
.menu-grid > :nth-child(7), .grid > :nth-child(7) { animation-delay: 0.33s; }
.menu-grid > :nth-child(n+8), .grid > :nth-child(n+8) { animation-delay: 0.38s; }
.main > .section:nth-of-type(2) { animation-delay: 0.08s; }
.main > .section:nth-of-type(3) { animation-delay: 0.16s; }
.card { animation-delay: 0.08s; }

@keyframes m-rise {
    from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.985); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Dashboard menu cards ---------- */
.menu-card {
    overflow: hidden;
    transition: transform 0.35s var(--m-ease), box-shadow 0.35s var(--m-ease), border-color 0.35s;
}
.menu-card::after {
    content: "";
    position: absolute;
    width: 14rem;
    height: 14rem;
    right: -5rem;
    bottom: -7rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(184, 233, 134, 0.18), transparent 65%);
    transition: transform 0.5s var(--m-ease), opacity 0.4s;
    opacity: 0.55;
    pointer-events: none;
}
.menu-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--m-shadow-hover);
    border-color: rgba(212, 248, 116, 0.38);
}
.menu-card:hover::after { transform: scale(1.35) translate(-1.5rem, -1.5rem); opacity: 1; }
.menu-card:hover::before { opacity: 1; left: 4%; right: 4%; }
.menu-card__icon {
    background: linear-gradient(140deg, rgba(212, 248, 116, 0.26), rgba(184, 233, 134, 0.06));
    box-shadow: inset 0 0 0 1px rgba(212, 248, 116, 0.22), 0 8px 22px -8px rgba(184, 233, 134, 0.5);
    transition: transform 0.45s var(--m-spring);
}
.menu-card:hover .menu-card__icon { transform: rotate(-8deg) scale(1.08); }
.menu-card h2 { transition: letter-spacing 0.3s var(--m-ease); }

/* ---------- Pool cards ---------- */
.pool-card {
    transition: transform 0.35s var(--m-ease), box-shadow 0.35s var(--m-ease), border-color 0.35s;
}
.pool-card:not(.is-focused):hover {
    transform: translateY(-4px);
    box-shadow: var(--m-shadow-hover);
}
.pool-card__icon img { transition: transform 0.5s var(--m-spring), filter 0.4s; }
.pool-card:not(.is-focused):hover .pool-card__icon img { transform: scale(1.06) rotate(-2deg); }

/* Live (running game) table: breathing glow + live dot */
.pool-card[data-pool-game-active] {
    border-color: rgba(212, 248, 116, 0.5);
    animation: m-rise 0.6s var(--m-ease) both, m-breathe 3.2s ease-in-out 0.6s infinite;
}
.pool-card[data-pool-game-active]::before { opacity: 1; left: 0; right: 0; height: 2px; }
@keyframes m-breathe {
    0%, 100% { box-shadow: var(--m-shadow), 0 0 0 1px rgba(212, 248, 116, 0.18), 0 0 26px -8px rgba(184, 233, 134, 0.35); }
    50%      { box-shadow: var(--m-shadow), 0 0 0 1px rgba(212, 248, 116, 0.38), 0 0 46px -4px rgba(184, 233, 134, 0.55); }
}
.pool-card__live {
    position: relative;
    border-radius: var(--m-radius-sm);
    background: linear-gradient(160deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.25));
    padding-left: 1.6rem;
}
.pool-card__live::before {
    content: "";
    position: absolute;
    left: 0.65rem;
    top: 0.95rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #6dff8a;
    box-shadow: 0 0 0 0 rgba(109, 255, 138, 0.6);
    animation: m-ping 1.6s ease-out infinite;
}
.pool-card.is-focused .pool-card__live::before { top: 1.6rem; width: 0.75rem; height: 0.75rem; }
@keyframes m-ping {
    0%   { box-shadow: 0 0 0 0 rgba(109, 255, 138, 0.55); }
    80%  { box-shadow: 0 0 0 9px rgba(109, 255, 138, 0); }
    100% { box-shadow: 0 0 0 0 rgba(109, 255, 138, 0); }
}
.pool-card__live strong { font-variant-numeric: tabular-nums; }
.pool-card--light.is-on { box-shadow: var(--m-shadow), 0 0 50px -10px rgba(255, 216, 77, 0.45); }
.pool-card__access {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(184, 233, 134, 0.14);
}
.pool-card__focus-hint { animation: none; }

/* ---------- Buttons ---------- */
.btn-start, .btn-end, .btn-add, .btn-shift, .btn-primary, .btn-logout,
.btn-modal, .btn, .btn-recent, .btn-icon, .btn-ghost, .btn-emp, .btn-del,
.an-filter button[type="submit"] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: transform 0.18s var(--m-ease), filter 0.2s, box-shadow 0.25s var(--m-ease), background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn-start, .btn-end, .btn-add, .btn-shift, .btn-primary, .btn-logout,
.btn-modal--primary, .btn--primary, .an-filter button[type="submit"] {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 8px 24px -6px rgba(184, 233, 134, 0.55);
}
.btn-end, .btn-modal--danger { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 8px 24px -6px rgba(220, 70, 70, 0.55); }
.btn-shift { box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset, 0 8px 24px -6px rgba(240, 180, 60, 0.6); }

/* light sweep */
.btn-start::after, .btn-end::after, .btn-add::after, .btn-shift::after, .btn-primary::after,
.btn-logout::after, .btn-modal--primary::after, .btn-modal--danger::after, .btn--primary::after,
.an-filter button[type="submit"]::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.45) 50%, transparent 70%);
    transform: translateX(-120%);
    transition: transform 0.7s var(--m-ease);
    pointer-events: none;
}
.btn-start:hover::after, .btn-end:hover::after, .btn-add:hover::after, .btn-shift:hover::after, .btn-primary:hover::after,
.btn-logout:hover::after, .btn-modal--primary:hover::after, .btn-modal--danger:hover::after, .btn--primary:hover::after,
.an-filter button[type="submit"]:hover::after { transform: translateX(120%); }

.btn-start:hover:not(:disabled), .btn-end:hover, .btn-add:hover, .btn-shift:hover, .btn-primary:hover,
.btn-logout:hover, .btn-modal:hover:not(:disabled), .an-filter button[type="submit"]:hover {
    transform: translateY(-1px);
}
.btn-start:active:not(:disabled), .btn-end:active, .btn-add:active, .btn-shift:active, .btn-primary:active,
.btn-logout:active, .btn-modal:active:not(:disabled), .btn-recent:active, .btn-icon:active, .btn-ghost:active,
.an-filter button[type="submit"]:active {
    transform: translateY(0) scale(0.97);
}
.btn-icon svg { transition: transform 0.5s var(--m-spring); }
.btn-icon:hover svg { transform: rotate(75deg); }

:where(a, button, input, select, textarea, summary):focus-visible {
    outline: 2px solid var(--lime-bright, #d4f874);
    outline-offset: 2px;
}

/* ---------- Form fields ---------- */
.field input, .field select, .field textarea,
.an-filter select, .an-filter input,
.add-row input, input[type="time"] {
    transition: border-color 0.2s, box-shadow 0.25s var(--m-ease), background-color 0.2s;
}
.field input:hover, .an-filter select:hover, .an-filter input:hover { border-color: rgba(212, 248, 116, 0.28); }
.field input:focus, .field select:focus, .field textarea:focus,
.an-filter select:focus, .an-filter input:focus {
    outline: none;
    border-color: rgba(212, 248, 116, 0.6);
    box-shadow: var(--m-ring);
    background-color: rgba(0, 0, 0, 0.45);
}
.an-filter select, .an-filter input { color-scheme: dark; }

/* ---------- Alerts ---------- */
.alert {
    border-radius: var(--m-radius-sm);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: m-slide 0.45s var(--m-ease) both;
}
@keyframes m-slide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

/* ---------- Modals ---------- */
.modal-overlay {
    background: radial-gradient(ellipse at 50% 30%, rgba(10, 30, 16, 0.55), rgba(0, 0, 0, 0.82));
    backdrop-filter: blur(10px) saturate(120%);
    -webkit-backdrop-filter: blur(10px) saturate(120%);
    animation: m-fade 0.25s ease-out both;
}
.modal-box {
    border-radius: 1.25rem;
    background-image: linear-gradient(165deg, rgba(26, 48, 30, 0.6), rgba(6, 14, 8, 0.2));
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07) inset, 0 40px 90px -20px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(212, 248, 116, 0.08);
    animation: m-pop 0.38s var(--m-spring) both;
}
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-pop {
    from { opacity: 0; transform: translateY(14px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}
.modal-sum__value { text-shadow: 0 0 30px rgba(212, 248, 116, 0.35); }

/* ---------- Tables ---------- */
.an-table tbody tr, .last-games-table tbody tr, .section table tbody tr {
    transition: background-color 0.2s;
}
.an-table tbody tr:hover, .last-games-table tbody tr:hover, .section table tbody tr:hover {
    background: rgba(184, 233, 134, 0.06);
}
.an-table th, .last-games-table th { position: sticky; top: 0; z-index: 1; backdrop-filter: blur(8px); }

/* ---------- Stats ---------- */
.an-card__val { text-shadow: 0 0 28px rgba(212, 248, 116, 0.25); font-variant-numeric: tabular-nums; }
.an-card { transition: transform 0.3s var(--m-ease), box-shadow 0.3s var(--m-ease); }
.an-card:hover { transform: translateY(-3px); box-shadow: var(--m-shadow-hover); }

/* ---------- Footer ---------- */
.site-footer {
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
}

/* ---------- Login ---------- */
.brand__badge span { display: inline-block; animation: m-blink 2.4s ease-in-out infinite; }
@keyframes m-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.card .btn { position: relative; overflow: hidden; }

/* ==========================================================================
   Responsive polish
   ========================================================================== */
@media (max-width: 640px) {
    .top { gap: 0.6rem; }
    .top-actions { width: 100%; margin-left: 0; justify-content: flex-start; }
    .top-actions .btn-add, .top-actions .btn-shift { flex: 1 1 auto; justify-content: center; }
    .top-actions .lang { margin-left: auto; }
    .menu-card { min-height: 0; }
    .pool-card__actions .btn-start, .pool-card__actions .btn-end { min-height: 2.9rem; }
    .an-filter button[type="submit"] { width: 100%; }
    .modal-actions .btn-modal { flex: 1 1 auto; }
}

/* Modals become bottom sheets on phones */
@media (max-width: 520px) {
    .modal-overlay { place-items: end center; padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom, 0px)); }
    .modal-box {
        width: 100%;
        max-width: 100% !important;
        max-height: 88vh;
        border-radius: 1.4rem 1.4rem 1rem 1rem;
        animation: m-sheet 0.42s var(--m-spring) both;
    }
    .modal-box::before {
        content: "";
        display: block;
        width: 2.6rem;
        height: 0.28rem;
        border-radius: 99px;
        margin: -0.35rem auto 0.85rem;
        background: rgba(236, 248, 232, 0.25);
    }
    .modal-sum__stats { gap: 0.6rem; }
}
@keyframes m-sheet {
    from { opacity: 0; transform: translateY(40px); }
    to   { opacity: 1; transform: none; }
}

@media (hover: none) {
    .menu-card:hover, .pool-card:not(.is-focused):hover, .an-card:hover { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
