* {
    box-sizing: border-box;
}

:root {
    --bg: #fbfaf7;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #ece9e2;
    --tile-mix: 100%; /* how much of each tile's pastel color shows */
    --daily-done-bg: #15803d;
    --daily-done-text: #ffffff;
    --daily-started-bg: #c2410c;
    --daily-started-text: #ffffff;
    --dailies-bg: #f3efe6;
}

/* Dark mode: shared/theme.js sets data-theme="dark" (chosen, or Auto on a dark device) */
:root[data-theme="dark"] {
    --bg: #15161a;
    --card: #1e2026;
    --text: #e7e9ee;
    --muted: #9aa0ab;
    --border: #2c2f37;
    --tile-mix: 30%;
    --daily-done-bg: #4ade80;
    --daily-done-text: #052e16;
    --daily-started-bg: #fbbf24;
    --daily-started-text: #422006;
    --dailies-bg: #1b1c21;
}

/* No double-tap zoom (pinch zoom still works) */
html {
    touch-action: manipulation;
}

body {
    margin: 0;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.hub {
    max-width: 1040px;
    margin: auto;
    padding: 56px 16px 64px;
}

.hub-header {
    text-align: center;
    margin-bottom: 40px;
}

.hub-header h1 {
    margin: 0;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 0;
}

/* WordArt logo, drawn by _tools/logo.mjs. Waves and spins on hover, toggles on click/tap (hub.js). */
.hub-logo-wrap {
    display: inline-block;
    cursor: pointer;
    border-radius: 8px;
}

.hub-logo-wrap:focus-visible {
    outline: 2px solid var(--muted);
    outline-offset: 4px;
}

.hub-logo {
    display: block;
    max-width: 100%;
    height: auto;
    image-rendering: pixelated;
}

.hub-header p {
    margin: 8px 0 0;
    color: var(--muted);
}
/* "Today's dailies" strip above the sections (hub.js): progress, then a link to each daily game */
.hub-dailies {
    margin-bottom: 40px;
    padding: 16px 18px 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--dailies-bg);
}

.hub-dailies-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
}

.hub-dailies-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.hub-dailies-count {
    margin: 0;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
}

.hub-dailies-bar {
    height: 6px;
    margin: 10px 0 14px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.hub-dailies-bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--daily-done-bg);
    transition: width .3s;
}

.hub-dailies-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.hub-daily {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px 6px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--card);
    color: inherit;
    font-size: .85rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .15s, box-shadow .15s;
}

.hub-daily:hover,
.hub-daily:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, .08);
}

.hub-daily img {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

.hub-daily-mark:empty {
    display: none;
}

.hub-daily-mark {
    display: grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
}

.hub-daily[data-status="started"] .hub-daily-mark {
    background: var(--daily-started-bg);
    color: var(--daily-started-text);
}

.hub-daily[data-status="done"] {
    color: var(--muted);
}

.hub-daily[data-status="done"] img {
    opacity: .5;
}

.hub-daily[data-status="done"] .hub-daily-mark {
    background: var(--daily-done-bg);
    color: var(--daily-done-text);
}

/* One section per category (HUB_CATEGORIES in apps.js), headed by a label and a divider line */
.hub-section + .hub-section {
    margin-top: 40px;
}

.hub-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px;
    color: var(--muted);
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.hub-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.hub-section-count {
    font-weight: 600;
    letter-spacing: 0;
    opacity: .7;
}

.hub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.tile {
    display: flex;
    flex-direction: column;
    padding: 12px 12px 16px;
    border-radius: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}

.tile:hover,
.tile:focus-visible {
    transform: translateY(-3px) rotate(-.4deg);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .08);
}

.tile-art {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    /* --tile-color comes from the app's `color` in apps.js; dark mode mutes it.
       The first line is the fallback for browsers without color-mix (Safari < 16.2). */
    background: var(--tile-color, #eef2ff);
    background: color-mix(in srgb, var(--tile-color, #eef2ff) var(--tile-mix), var(--card));
    font-size: 4rem;
    overflow: hidden;
    position: relative;
}

/* "New" / "Updated" badges for apps created or changed in the last 7 days (`created` / `updated` in apps.js) */
.tile-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
}

.tile-badge {
    padding: 3px 9px;
    border-radius: 999px;
    background: #ff71ce;
    color: #ffffff;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.tile-badge-updated {
    background: #01cdfe;
    color: #1a0b2e;
}

.tile-badge-old {
    background: #8a8f99;
    color: #ffffff;
}

/* Daily games (`daily` in apps.js): whether today's daily is finished or started, set by hub.js (empty, so hidden, when not played) */
.tile-daily {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
}

.tile-daily:empty {
    display: none;
}

.tile-daily[data-status="done"] {
    background: var(--daily-done-bg);
    color: var(--daily-done-text);
}

.tile-daily[data-status="started"] {
    background: var(--daily-started-bg);
    color: var(--daily-started-text);
}

.tile-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile h3 {
    margin: 12px 4px 2px;
    font-size: 1.05rem;
    text-align: center;
}

.tile-dates {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 4px 4px 0;
    color: var(--muted);
    font-size: .75rem;
}

.hub-footer {
    margin-top: 56px;
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
}

.hub-footer p {
    margin: 12px 0 0;
}

.hub-footer .hub-footer-disclaimer {
    max-width: 420px;
    margin: 8px auto 0;
    font-size: .7rem;
    line-height: 1.5;
    opacity: .8;
}

.hub-footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: .9rem;
}

.hub-footer-links a,
.hub-footer p a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    text-decoration: none;
    transition: color .15s;
}

.hub-footer-links a:hover,
.hub-footer-links a:focus-visible,
.hub-footer p a:hover,
.hub-footer p a:focus-visible {
    color: var(--text);
}

/* Phones: two small tiles per row (art and name only, no card or dates), and a shorter header,
   so more games fit on screen */
@media (max-width: 600px) {
    .hub {
        padding-top: 28px;
    }

    .hub-header {
        margin-bottom: 24px;
    }

    .hub-logo {
        width: 192px;
        margin: auto;
    }

    .hub-header p {
        margin-top: 4px;
        font-size: .85rem;
    }

    .hub-section + .hub-section {
        margin-top: 24px;
    }

    /* One row of dailies that scrolls sideways, so the strip stays short */
    .hub-dailies {
        margin-bottom: 24px;
        padding: 12px 0 14px;
        border-radius: 14px;
    }

    .hub-dailies-head,
    .hub-dailies-bar {
        margin-left: 14px;
        margin-right: 14px;
    }

    .hub-dailies-title {
        font-size: .95rem;
    }

    .hub-dailies-count {
        font-size: .78rem;
    }

    .hub-dailies-bar {
        margin-top: 8px;
        margin-bottom: 10px;
    }

    .hub-dailies-list {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 2px 14px 4px;
        scrollbar-width: none;
    }

    .hub-dailies-list::-webkit-scrollbar {
        display: none;
    }

    .hub-daily {
        font-size: .8rem;
    }

    .hub-section-title {
        margin-bottom: 12px;
        font-size: .75rem;
    }

    .hub-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 12px;
    }

    .tile {
        padding: 0;
        border: none;
        border-radius: 14px;
        background: none;
    }

    .tile:hover,
    .tile:focus-visible {
        box-shadow: none;
    }

    .tile-art {
        border-radius: 14px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .06);
    }

    .tile-badges {
        top: 6px;
        right: 6px;
        gap: 4px;
    }

    .tile-badge,
    .tile-daily {
        padding: 2px 7px;
        font-size: .58rem;
    }

    .tile-daily {
        bottom: 6px;
        left: 6px;
    }

    .tile h3 {
        margin: 6px 2px 0;
        font-size: .9rem;
    }

    .tile-dates {
        display: none;
    }
}
