:root {
    /* bigger cards centered on screen: min 64px, prefers 14vw, max 140px */
    --card-size: clamp(64px, 14vw, 140px);
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    padding: 20px
}

.card {
    border: 1px solid #ccc;
    padding: 6px;
    margin: 6px;
    box-sizing: border-box;
    /* responsive square card */
    width: var(--card-size);
    height: var(--card-size);
    min-width: 48px;
    min-height: 48px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    /* prevent overflowing SVGs */
    border-radius: 6px;
    /* compute a default symbol size so each symbol stays the same regardless of count */
    --symbol-size: calc((var(--card-size) - 12px) / 3);
    transition: transform 160ms ease, box-shadow 160ms ease, outline-color 120ms ease;
}

.leaderboard {
    margin-top: 16px
}

.controls {
    margin-bottom: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.timer-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: auto;
}

.timer {
    font-weight: 600;
    font-size: 1.1em;
    color: #2563eb;
}

.countdown {
    font-size: 0.9em;
    color: #6b7280;
}

/* Skeleton loading styles */
.card.skeleton {
    background: #f3f4f6;
    border-color: #e5e7eb;
    cursor: default;
}

.skeleton-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.skeleton-symbols {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
}

.skeleton-symbol {
    width: var(--symbol-size);
    height: calc(var(--symbol-size) * 0.9);
    background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Fixed footer with always-clickable GitHub link */
.app-footer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* make the footer bar span full width at the very bottom */
    display: block;
    z-index: 9999;
    /* above overlays */
    pointer-events: auto;
    /* ensure clicks pass to footer */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Unique footer bar container */
.app-footer .footer-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    /* bar spanning the width */
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    background: rgba(127, 127, 127, 0.08);
    border-top: 1px solid rgba(127, 127, 127, 0.2);
    /* optional glassy touch */
    -webkit-backdrop-filter: saturate(120%) blur(6px);
    backdrop-filter: saturate(120%) blur(6px);
}

.app-footer .footer-left,
.app-footer .footer-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-footer .menu-btn,
.app-footer .footer-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    color: inherit;
    /* theme-aware via currentColor */
    text-decoration: none;
}

.app-footer .menu-btn svg,
.app-footer .footer-btn svg {
    width: 18px;
    height: 18px;
}

/* brand link, with small logo and unique title font treatment */
.app-footer .brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: inherit;
    text-decoration: none;
}

.app-footer .brand-logo {
    width: 18px;
    height: 18px;
    image-rendering: -webkit-optimize-contrast;
    /* original is white; invert on light theme, keep white on dark */
    filter: none;
}

/* Respect explicit theme toggle via data-theme */
[data-theme="light"] .app-footer .brand-logo {
    filter: invert(1) brightness(0.1);
}

[data-theme="dark"] .app-footer .brand-logo {
    filter: none;
}

.app-footer .brand-title {
    font-size: 0.9rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    /* Rounded-first stack plus system fallbacks */
    font-family: "SF Pro Rounded", "SF Rounded", "Avenir Next Rounded", "Segoe UI Rounded", ui-rounded, "Nunito", "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Gradient text for a distinct brand feel */
    background: linear-gradient(90deg, #d3d3d3 0%, #c5c5c5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* Improve contrast by theme */
[data-theme="light"] .app-footer .brand-title {
    background: linear-gradient(90deg, #1f2937 0%, #4b5563 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

[data-theme="dark"] .app-footer .brand-title {
    background: linear-gradient(90deg, #f3f4f6 0%, #a3a3a3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* board container should wrap cards and remain responsive and centered */
#board {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    max-width: calc(var(--card-size) * 6 + 96px);
    /* allow up to 6 cards per row comfortably */
    padding: 12px;
}

/* center the layout content so main column is centered on narrow screens */
/* layout helpers: centered on narrow screens */
.layout {
    display: flex;
    flex-direction: column;
    /* stack by default on small screens */
    gap: 20px;
    align-items: stretch;
    justify-content: center;
}

#events {
    max-height: 200px;
    overflow: auto;
    border: 1px solid #eee;
    padding: 8px;
    font-family: system-ui, -apple-system, sans-serif;
}

.event-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border-bottom: 1px solid #f0f0f0;
}

.event-row:last-child {
    border-bottom: none;
}

.event-time {
    font-size: 0.8em;
    color: #666;
    min-width: 60px;
}

.username-badge {
    background: #3b82f6;
    color: white;
    padding: 2px 6px;
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85em;
}

.event-text {
    flex: 1;
    font-size: 0.9em;
}

.toast {
    background: #333;
    color: #fff;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 6px;
    opacity: 0.95
}

.sel {
    outline: 3px solid gold;
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.card:focus {
    outline: 3px solid rgba(59, 130, 246, 0.9);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.08);
    transform: translateY(-2px);
}

/* (previously merged into .layout above) */

.main-column {
    flex: 1;
    order: 1;
}

.top-gap {
    margin-top: 8px
}

.sidebar {
    width: 100%;
    /* full width on narrow screens */
    order: 2;
}

/* on larger screens, show main + sidebar side-by-side with sidebar to the right */
@media (min-width: 900px) {
    .layout {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
    }

    .sidebar {
        width: 320px;
        order: 2;
        flex: 0 0 320px;
    }

    .main-column {
        order: 1;
    }
}

.leader-badge {
    padding: 3px 6px;
    border-radius: 6px;
    font-size: 0.8em;
    margin-left: 8px
}

.leader-new {
    background: #16a34a;
    color: #fff
}

/* green for new entry */
.leader-up {
    background: #f59e0b;
    color: #fff
}

/* amber for improvement */
.leader-same {
    background: #94a3b8;
    color: #fff
}

/* neutral */
.event-highlight {
    background: linear-gradient(90deg, rgba(96, 165, 250, 0.08), rgba(16, 185, 129, 0.03));
}


.card .symbols {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
}

/* size each symbol proportionally so 1-3 symbols fit without overflow */
.card .symbol {
    /* allow up to 3 symbols; each symbol uses the computed symbol size so all match */
    width: var(--symbol-size);
    height: calc(var(--symbol-size) * 0.9);
    flex: 0 0 auto;
}

.card svg,
.card .symbol svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* no special sizing for single symbol: every symbol uses the same size */

/* small screens / mobile: strict two-column grid and larger tap targets */
@media (max-width: 520px) {

    #board {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px !important;
        max-width: 100% !important;
        padding: 10px !important;
        align-items: stretch;
        justify-items: stretch;
    }

    .card {
        width: auto !important;
        height: auto !important;
        min-width: 0 !important;
        min-height: 120px !important;
        margin: 0 !important;
        padding: 10px !important;
        aspect-ratio: 5 / 4;
        /* larger symbols on mobile for better tap targets */
        --symbol-size: clamp(28px, 12vw, 56px);
    }

    .card .symbols {
        gap: 8px;
    }
}