.page-wrap {
    width: min(100%, 96rem);
    margin: 0 auto;
    padding: 2rem 2.4rem 4rem;
}

/* Shared sticky brand header (home, book, play, end, scores, admin) */
.site-top {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    padding: 0.9rem 5.5rem 0.9rem 1.6rem;
    background: color-mix(in srgb, var(--bg-panel-solid) 88%, transparent);
    border-bottom: 1px solid rgba(123, 163, 201, 0.28);
    backdrop-filter: blur(12px);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    text-decoration: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 1.45rem;
    font-weight: 700;
}

.brand-mark .brand-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Tiny landscape mark matching the logo artwork (~1.6:1) */
    width: 6.3rem;
    height: 4rem;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 6px;
    border: 1px solid rgba(123, 163, 201, 0.35);
    background: #444ccc;
}

.brand-mark .brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    border: 0;
    border-radius: 0;
    transform: none;
}

.brand-mark .tamil,
.brand-mark em.tamil {
    font-style: normal;
    font-family: var(--font-tamil);
    color: var(--tone-b-deep);
}

html[data-theme="dark"] .site-top {
    background: rgba(18, 32, 54, 0.92);
    border-bottom-color: rgba(111, 155, 196, 0.25);
}

html[data-theme="light"] .site-top {
    background: color-mix(in srgb, #fffdfb 90%, transparent);
    border-bottom-color: rgba(123, 163, 201, 0.28);
}

@media screen and (max-width: 768px) {
    .site-top {
        padding: 0.8rem 4.4rem 0.8rem 1.2rem;
    }

    .brand-mark span:not(.brand-logo) {
        font-size: 1.3rem;
    }

    .brand-mark .brand-logo {
        width: 5.5rem;
        height: 3.5rem;
    }
}

.back-link {
    display: inline-block;
    margin-bottom: 1.2rem;
    color: var(--tone-a-deep);
    font-size: 1.5rem;
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    color: var(--tone-b-deep);
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    margin-bottom: 0.6rem;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chapter-card {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    padding: 1.6rem 1.8rem;
    background: var(--bg-panel);
    border: 1px solid rgba(123, 163, 201, 0.35);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chapter-card h2 {
    font-size: 2rem;
    margin-bottom: 0.4rem;
}

.chapter-meta {
    color: var(--text-muted);
    font-size: 1.4rem;
}

.chapter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.chapter-actions .btn {
    width: auto;
    min-width: 12rem;
    margin-bottom: 0;
    padding: 1.1rem 1.6rem;
}

.btn-secondary {
    background: linear-gradient(135deg, rgba(123, 163, 201, 0.85), rgba(90, 134, 173, 0.95));
}

.fill-wrap {
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    width: 100%;
    max-width: 48rem;
}

.fill-wrap.is-visible {
    display: flex;
}

.fill-wrap[hidden] {
    display: none !important;
}

.fill-wrap .btn {
    width: 100%;
}

.empty-hint {
    color: var(--text-muted);
    font-size: 1.6rem;
}

.celebrate-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: rgba(20, 30, 50, 0.45);
    backdrop-filter: blur(6px);
    animation: riseIn 280ms ease both;
}

.celebrate-overlay[hidden] {
    display: none !important;
}

.celebrate-card {
    position: relative;
    width: min(100%, 40rem);
    padding: 2.6rem 2rem;
    text-align: center;
    background: var(--bg-panel);
    border: 1px solid rgba(232, 165, 152, 0.45);
    border-radius: calc(var(--radius) + 6px);
    box-shadow: var(--shadow);
    overflow: auto;
    max-height: min(90vh, 640px);
}

.celebrate-rank {
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--tone-b-deep);
    margin: 1rem 0 1.6rem;
}

.celebrate-burst {
    pointer-events: none;
    position: absolute;
    inset: 0;
}

.confetti {
    position: absolute;
    left: 50%;
    top: 40%;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: hsl(calc(var(--i) * 18), 70%, 65%);
    animation: confetti-fly 900ms ease-out forwards;
    animation-delay: calc(var(--i) * 18ms);
}

@keyframes confetti-fly {
    to {
        transform: translate(var(--x), calc(-1 * var(--y))) rotate(220deg);
        opacity: 0;
    }
}

@media screen and (max-width: 768px) {
    .page-wrap {
        padding: 1.4rem 1.2rem 3rem;
    }

    .chapter-actions {
        width: 100%;
    }

    .chapter-actions .btn {
        flex: 1;
        min-width: 0;
    }

    .share-row {
        flex-direction: column;
    }

    .share-row .btn {
        width: 100%;
    }

    .share-icons {
        gap: 1rem;
    }
}

.share-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: center;
    align-items: center;
    width: 100%;
    max-width: 42rem;
    margin: 0.4rem 0 1rem;
}

.share-row[hidden] {
    display: none !important;
}

.share-label {
    flex: 1 0 100%;
    margin: 0.4rem 0 0.2rem;
    text-align: center;
    font-size: 1.45rem;
    font-weight: 600;
    color: var(--text-muted);
}

.share-row--top {
    margin: 0.4rem 0 1.6rem;
}

.share-icons {
    display: flex;
    flex-wrap: wrap;
    gap: 1.1rem;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 4.4rem;
    height: 4.4rem;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 999px;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(40, 60, 90, 0.18);
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.share-icon svg {
    width: 2.2rem;
    height: 2.2rem;
    display: block;
}

.share-icon:hover {
    transform: translateY(-2px) scale(1.06);
    box-shadow: 0 12px 22px rgba(40, 60, 90, 0.24);
    filter: brightness(1.05);
}

.share-icon--wa {
    background: linear-gradient(145deg, #25d366, #128c7e);
}

.share-icon--x {
    background: linear-gradient(145deg, #3a3a3a, #111);
}

.share-icon--fb {
    background: linear-gradient(145deg, #4b7bd6, #1877f2);
}

.share-icon--copy {
    background: linear-gradient(145deg, var(--tone-a), var(--tone-a-deep));
}

.celebrate-share {
    margin: 0.8rem 0 1.2rem;
}
