:root {
    --bg-1: #eef2ff;
    --bg-2: #fce7f3;
    --bg-3: #fef3c7;
    --ink: #1f2937;
    --muted: #6b7280;
    --card: #ffffff;
    --shadow: 0 10px 30px rgba(31, 41, 55, 0.12);
    --shadow-hover: 0 16px 40px rgba(31, 41, 55, 0.18);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 24px 16px 40px;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 55%, var(--bg-3) 100%);
    background-attachment: fixed;
}

.page {
    max-width: 1100px;
    margin: 0 auto;
}

/* ---------- Hero ---------- */
.hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px 28px;
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    letter-spacing: -0.5px;
}

.greeting {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 1.05rem;
}

.clock {
    text-align: right;
    line-height: 1.1;
}

.clock-time {
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.clock-date {
    color: var(--muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* ---------- Family chips ---------- */
.family {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 8px;
}

.member {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(31, 41, 55, 0.06);
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(31, 41, 55, 0.05);
}

/* ---------- Section headings ---------- */
.section-title {
    margin: 30px 0 4px;
    font-size: 1.35rem;
}

.section-sub {
    margin: 0 0 18px;
    color: var(--muted);
}

/* ---------- Service category tabs ---------- */
/* The whole area is one frosted-glass card so it stands out from the page
   gradient; the white service tiles still pop against the translucent panel. */
.services-tabs {
    display: flex;
    align-items: stretch;
    padding: 16px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.tablist {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 196px;
    padding-right: 16px;
    margin-right: 16px;
    border-right: 1px solid rgba(31, 41, 55, 0.08);
}

.tab {
    appearance: none;
    display: flex;
    align-items: center;
    gap: 8px;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    border-radius: 10px;
    padding: 11px 14px;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.tab:hover {
    background: rgba(255, 255, 255, 0.75);
}

.tab:focus-visible {
    outline: 2px solid var(--accent, #6366f1);
    outline-offset: 2px;
}

.tab.is-active {
    background: color-mix(in srgb, var(--accent, #6366f1) 16%, white);
    border-left-color: var(--accent, #6366f1);
    color: color-mix(in srgb, var(--accent, #6366f1) 45%, var(--ink));
    box-shadow: 0 4px 14px color-mix(in srgb, var(--accent, #6366f1) 22%, transparent);
}

.panels {
    flex: 1 1 auto;
    min-width: 0;
}

/* ---------- Services grid ---------- */
.services {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

/* A class rule beats the UA [hidden] style, so hide inactive panels explicitly. */
.services[hidden] {
    display: none;
}

.service {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none;
    color: var(--ink);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--accent, #6366f1);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.service:hover,
.service:focus-visible {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    outline: none;
}

/* Non-linked tiles (admin/infra services) — shown for completeness but not clickable */
.service.is-static {
    cursor: default;
}

.service.is-static:hover {
    transform: none;
    box-shadow: var(--shadow);
}

.service-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    font-size: 1.5rem;
    margin-bottom: 6px;
    background: color-mix(in srgb, var(--accent, #6366f1) 16%, white);
}

.service-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.service-desc {
    color: var(--muted);
    font-size: 0.88rem;
}

/* ---------- Game ---------- */
.game {
    background: var(--card);
    border-radius: var(--radius);
    padding: 22px;
    margin-top: 14px;
    box-shadow: var(--shadow);
}

.game-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 14px;
}

.scoreboard {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.game-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-item {
    background: var(--bg-1);
    border-radius: 12px;
    padding: 8px 16px;
    font-size: 0.95rem;
    color: var(--muted);
}

.score-item b {
    color: var(--ink);
    font-size: 1.1rem;
    margin-left: 4px;
    font-variant-numeric: tabular-nums;
}

.canvas-wrap {
    position: relative;
    width: 100%;
}

#game {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
    border-radius: 14px;
    background: linear-gradient(160deg, #1e293b, #312e81);
    touch-action: manipulation;
    cursor: crosshair;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: #fff;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    border-radius: 14px;
    padding: 20px;
    transition: opacity 0.25s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#overlay-title {
    margin: 0;
    font-size: 1.6rem;
    font-weight: 700;
}

#overlay-sub {
    margin: 0;
    opacity: 0.85;
}

.btn {
    margin-top: 8px;
    background: #fff;
    color: #312e81;
    border: none;
    padding: 12px 28px;
    font-size: 1.05rem;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease;
}

.btn:hover {
    transform: scale(1.05);
}

.btn-ghost {
    background: var(--bg-1);
    color: var(--ink);
    border: none;
    padding: 10px 18px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
    transition: transform 0.15s ease, background 0.15s ease;
}

.btn-ghost:hover {
    transform: scale(1.04);
}

/* ---------- Full-screen play mode (touch devices only) ---------- */
body.no-scroll {
    overflow: hidden;
}

/* Full screen is a touch-only convenience. Desktops have the inline game and
   the browser's own F11, and the stretched canvas looks poor on a wide screen,
   so hide the button on devices driven by a precise pointer. */
@media (hover: hover) and (pointer: fine) {
    #fullscreen {
        display: none;
    }
}

.game.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    margin: 0;
    /* Keep the bar and canvas clear of notches / home indicators. */
    padding: calc(12px + env(safe-area-inset-top))
        calc(12px + env(safe-area-inset-right))
        calc(12px + env(safe-area-inset-bottom))
        calc(12px + env(safe-area-inset-left));
    border-radius: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Match the canvas gradient so its rounded edge blends into the backdrop. */
    background: linear-gradient(160deg, #1e293b, #312e81);
}

.game.is-fullscreen .section-title,
.game.is-fullscreen .section-sub {
    display: none;
}

.game.is-fullscreen .game-bar {
    margin-bottom: 0;
}

.game.is-fullscreen .score-item {
    background: rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
}

.game.is-fullscreen .score-item b {
    color: #fff;
}

.game.is-fullscreen .btn-ghost {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    padding: 12px 20px;
}

.game.is-fullscreen .canvas-wrap {
    flex: 1;
    min-height: 0;
}

.game.is-fullscreen #game {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-radius: 12px;
}

/* ---------- Footer ---------- */
footer {
    margin-top: 32px;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    /* Stack tabs above the panels and let them scroll horizontally. */
    .services-tabs {
        flex-direction: column;
        align-items: stretch;
        padding: 14px;
    }

    .tablist {
        flex: 0 0 auto;
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        margin: 0 0 14px;
        padding: 0 0 12px;
        border-right: none;
        border-bottom: 1px solid rgba(31, 41, 55, 0.08);
        -webkit-overflow-scrolling: touch;
    }

    .tab {
        flex: 0 0 auto;
        white-space: nowrap;
        /* Accent bar moves to the bottom edge now that tabs sit in a row. */
        border-left: none;
        border-bottom: 3px solid transparent;
    }

    .tab.is-active {
        border-bottom-color: var(--accent, #6366f1);
    }
}

@media (max-width: 520px) {
    .hero {
        flex-direction: column;
        align-items: flex-start;
    }

    .clock {
        text-align: left;
    }

    .services {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}
