/*
 * Global Product Shell & Home
 *
 * Normative owner for the AppShell surface, Home composition, semantic button
 * variants, compact account/tools screen, and mobile navigation. The Material
 * Board, profile/replay, auth, and legacy inner-screen components remain owned
 * by their dedicated stylesheets.
 */

body:not(.game-active) > .app-container.tp-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: none;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    display: block;
    overflow-x: clip;
    overflow-y: auto;
    background: var(--tp-color-page) !important;
    color: var(--tp-color-text);
    font-family: var(--tp-font-sans);
}

.tp-shell-main {
    width: 100%;
    min-width: 0;
    min-height: calc(100dvh - var(--tp-topbar-height));
}

.tp-shell-main > #screen-home.tp-home.active {
    width: 100%;
    min-height: calc(100dvh - var(--tp-topbar-height));
    display: block;
    overflow: visible;
    background: var(--tp-color-page);
}

/* The only four semantic button variants used by the product shell. */
.tp-button {
    min-height: 44px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--tp-radius-sm);
    background: transparent;
    color: var(--tp-color-text);
    font: inherit;
    font-size: var(--tp-text-sm);
    font-weight: 750;
    line-height: 1.2;
    text-align: center;
    cursor: pointer;
    transition: background var(--tp-motion-fast) var(--tp-ease-standard), border-color var(--tp-motion-fast) var(--tp-ease-standard), color var(--tp-motion-fast) var(--tp-ease-standard), transform var(--tp-motion-fast) var(--tp-ease-standard);
}

.tp-button--primary {
    border-color: var(--tp-color-primary);
    background: var(--tp-color-primary);
    color: var(--tp-color-primary-ink);
}

.tp-button--primary:hover { background: var(--tp-color-primary-hover); border-color: var(--tp-color-primary-hover); }

.tp-button--secondary {
    border-color: var(--tp-color-border-strong);
    background: var(--tp-color-surface);
    color: var(--tp-color-text);
}

.tp-button--secondary:hover { border-color: var(--tp-color-primary); background: var(--tp-color-surface-raised); }

.tp-button--tertiary {
    border-color: var(--tp-color-border);
    background: var(--tp-color-surface-raised);
    color: var(--tp-color-text-muted);
}

.tp-button--tertiary:hover { color: var(--tp-color-text); border-color: var(--tp-color-border-strong); }

.tp-button--ghost {
    border-color: transparent;
    background: transparent;
    color: var(--tp-color-primary);
}

.tp-button--ghost:hover { background: color-mix(in srgb, var(--tp-color-primary) 10%, transparent); color: var(--tp-color-primary-hover); }

.tp-button--danger {
    border-color: color-mix(in srgb, var(--tp-color-danger) 58%, transparent);
    background: transparent;
    color: var(--tp-color-danger);
}

.tp-button--danger:hover { background: color-mix(in srgb, var(--tp-color-danger) 12%, transparent); }

.tp-button--icon { width: 44px; min-width: 44px; padding: 0; border-radius: 50%; }
.tp-button[data-state="success"] { color: var(--tp-color-success); border-color: color-mix(in srgb, var(--tp-color-success) 42%, transparent); }
.tp-button[data-state="error"] { color: var(--tp-color-danger); border-color: color-mix(in srgb, var(--tp-color-danger) 52%, transparent); }

.tp-button:active:not(:disabled):not([aria-disabled="true"]) { transform: scale(0.985); }
.tp-button:disabled,
.tp-button[aria-disabled="true"],
.tp-button[aria-busy="true"] { opacity: 0.52; cursor: not-allowed; }
.tp-button[aria-busy="true"] i { animation: tp-button-spin .8s linear infinite; }
.tp-button:focus-visible,
.tp-tools-link:focus-visible,
.tp-history-row:focus-visible,
.tp-news-item__link:focus-visible,
.tp-mobile-nav__item:focus-visible { outline: 2px solid var(--tp-color-focus); outline-offset: 2px; box-shadow: var(--tp-focus-ring); }

.tp-button--inline { min-height: 36px; padding-inline: 8px; font-size: var(--tp-text-xs); }

@keyframes tp-button-spin { to { transform: rotate(360deg); } }

.tp-home__content {
    width: min(100%, 1280px);
    margin: 0 auto;
    padding: 22px 28px calc(var(--tp-space-12) + 20px);
}

.tp-home-hero,
.tp-home-section {
    border: 1px solid var(--tp-color-border);
    border-radius: 15px;
    background: var(--tp-color-surface);
    box-shadow: var(--tp-shadow-xs);
}

.tp-home-hero {
    min-height: 322px;
    padding: clamp(28px, 3vw, 38px);
    display: grid;
    grid-template-areas:
        "copy visual"
        "actions visual";
    grid-template-columns: minmax(0, 1.04fr) minmax(410px, 0.96fr);
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--tp-space-4) clamp(24px, 4vw, 56px);
    overflow: hidden;
    background: linear-gradient(135deg, var(--tp-color-surface-raised) 0%, var(--tp-color-surface) 64%, var(--tp-color-muted-surface) 100%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--tp-color-text) 3%, transparent), var(--tp-shadow-sm);
}

.tp-home-hero__copy { grid-area: copy; min-width: 0; }

.tp-home__eyebrow,
.tp-section-heading__kicker {
    margin: 0 0 6px;
    color: var(--tp-color-primary);
    font-size: var(--tp-text-xs);
    font-weight: 650;
    letter-spacing: 0.06em;
}

.tp-home-hero h1 {
    max-width: 610px;
    margin: 0;
    color: var(--tp-color-text);
    font-family: var(--tp-font-sans);
    font-size: clamp(31px, 3.25vw, 43px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.045em;
}

.tp-home-hero__subtitle {
    max-width: 520px;
    margin: 14px 0 0;
    color: var(--tp-color-text-muted);
    font-size: 15px;
    line-height: 1.48;
}

.tp-home-hero__meta {
    margin-top: var(--tp-space-5);
    display: flex;
    flex-wrap: wrap;
    gap: var(--tp-space-3);
}

.tp-home__rating,
.tp-home__status {
    min-height: 32px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--tp-color-border);
    border-radius: var(--tp-radius-pill);
    background: color-mix(in srgb, var(--tp-color-text) 3%, transparent);
    color: var(--tp-color-text-muted);
    font-size: var(--tp-text-xs);
    font-weight: 600;
}

.tp-home__rating i,
.tp-home__rating strong { color: var(--tp-color-primary); }
.tp-home__rating strong { font-family: var(--tp-font-sans); font-size: 13px; font-weight: 700; }
.tp-home__status i { font-size: 8px; color: var(--tp-color-text-subtle); }
.tp-home__status[data-online-status="ready"] i { color: var(--tp-color-success); }
.tp-home__status[data-online-status="unavailable"] i { color: var(--tp-color-danger); }

.tp-home-hero__actions {
    grid-area: actions;
    width: fit-content;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--tp-space-3);
    align-self: end;
}

.tp-home-hero__actions .tp-button { min-width: 172px; min-height: 48px; }

/* R-04: one dominant action. The primary CTA carries the weight; the lobby and
 * the AI Dossier stay reachable as low-weight ghost actions instead of
 * competing with it. No destination is removed. */
.tp-home-hero__actions--single {
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    gap: var(--tp-space-3);
}

/* Specificity note: phase-one.css caps `.tp-home .tp-button` at 44px and loads
 * later, so the dominant CTA qualifies on `.tp-home` rather than using
 * !important. */
.tp-home .tp-home-hero__actions--single .tp-home-hero__cta {
    min-width: 232px;
    min-height: 54px;
    padding-inline: var(--tp-space-6);
    font-size: var(--tp-text-md);
    font-weight: 700;
}

.tp-home-hero__secondary {
    display: flex;
    flex-wrap: wrap;
    gap: var(--tp-space-2) var(--tp-space-4);
    align-items: center;
}

.tp-home-hero__secondary .tp-button {
    min-width: 0;
    min-height: 44px;
    padding-inline: var(--tp-space-2);
}

/* A static, local crop of the user-provided physical board. It is decorative
 * only and deliberately does not reuse Material Board markup or logic. */
.tp-home-hero__visual {
    grid-area: visual;
    min-width: 0;
    min-height: 238px;
    display: grid;
    place-items: center;
}

.tp-home-hero__board-art {
    position: relative;
    width: min(100%, 510px);
    aspect-ratio: 16 / 9;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--tp-color-border-strong);
    border-radius: 20px;
    background: var(--tp-color-muted-surface);
    box-shadow: 0 28px 46px rgba(0,0,0,0.38), inset 0 1px 0 color-mix(in srgb, var(--tp-color-text) 7%, transparent);
    isolation: isolate;
}

.tp-home-hero__board-art::after {
    content: '';
    position: absolute;
    z-index: 2;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(90deg, color-mix(in srgb, var(--tp-color-page) 22%, transparent), transparent 30%, color-mix(in srgb, var(--tp-color-page) 8%, transparent) 64%, color-mix(in srgb, var(--tp-color-page) 28%, transparent)),
        linear-gradient(180deg, transparent, color-mix(in srgb, var(--tp-color-page) 22%, transparent));
}

.tp-home-hero__board-art img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    filter: brightness(1.02) saturate(0.96) contrast(1.03);
    transform: translate(-50%, -50%);
    transform-origin: center;
}

.tp-home__play-grid {
    margin-top: var(--tp-space-4);
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(292px, 0.82fr);
    gap: var(--tp-space-4);
    align-items: stretch;
}

.tp-home__play-grid > .tp-home-section { margin-top: 0; }

.tp-home-section { margin-top: var(--tp-space-4); padding: 21px; }
.tp-home-quick { background: var(--tp-color-surface); }
.tp-home-news { background: var(--tp-color-surface); box-shadow: inset 2px 0 0 color-mix(in srgb, var(--tp-color-primary) 28%, transparent), var(--tp-shadow-xs); }
.tp-home-recent { background: var(--tp-color-surface); }

.tp-section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--tp-space-4);
}

.tp-section-heading h2 {
    margin: 0;
    color: var(--tp-color-text);
    font-family: var(--tp-font-sans);
    font-size: 19px;
    font-weight: 650;
    line-height: 1.3;
    letter-spacing: -0.02em;
}

.tp-section-heading__note { color: var(--tp-color-text-subtle); font-size: var(--tp-text-xs); font-weight: 700; white-space: nowrap; }

.tp-quick-play__controls {
    margin-top: var(--tp-space-5);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tp-space-3);
}

.tp-time-control {
    min-width: 0;
    min-height: 82px;
    justify-content: space-between;
    padding: 12px 16px;
    text-align: left;
}

.tp-time-control span { display: grid; gap: 3px; }
.tp-time-control strong { font-size: var(--tp-text-md); font-weight: 650; }
.tp-time-control small { color: var(--tp-color-text-muted); font-size: var(--tp-text-xs); font-weight: 500; }
.tp-time-control > i { color: var(--tp-color-primary); font-size: 18px; }
.tp-time-control--featured { border-color: color-mix(in srgb, var(--tp-color-primary) 68%, var(--tp-color-border)); background: color-mix(in srgb, var(--tp-color-primary) 7%, var(--tp-color-surface)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tp-color-primary) 8%, transparent); }
.tp-home-continue { position: relative; min-height: 0; overflow: hidden; border-color: var(--tp-color-border-strong); background: linear-gradient(145deg, var(--tp-color-surface-raised), var(--tp-color-surface)); }
.tp-home-continue::after { content: '\f140'; position: absolute; right: 16px; bottom: -13px; color: color-mix(in srgb, var(--tp-color-primary) 11%, transparent); font-family: 'Font Awesome 6 Free'; font-size: 98px; font-weight: 900; pointer-events: none; }
.tp-home-continue > * { position: relative; z-index: 1; }
.tp-continue-card { margin-top: var(--tp-space-3); display: grid; align-items: start; justify-items: start; gap: 4px; }
.tp-continue-card__title { margin: 0; color: var(--tp-color-text); font-size: 17px; font-weight: 650; }
.tp-continue-card__detail { margin: 0; color: var(--tp-color-text-muted); font-size: var(--tp-text-sm); line-height: 1.45; }
.tp-continue-card .tp-button { margin-top: 6px; }

.tp-home__information-grid {
    margin-top: var(--tp-space-4);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.3fr) minmax(250px, 0.95fr);
    gap: var(--tp-space-4);
    align-items: start;
}

.tp-home__information-grid .tp-home-section { min-height: 194px; margin-top: 0; }
.tp-home-news:has(.tp-home-empty),
.tp-home-event:has(.tp-home-empty) { min-height: 184px; }

.tp-news-list { margin-top: var(--tp-space-4); display: grid; gap: var(--tp-space-3); }

.tp-news-item {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: var(--tp-space-3);
    padding: 12px 0;
    border-top: 1px solid var(--tp-color-border);
}

.tp-news-item:first-child { padding-top: 0; border-top: 0; }
.tp-news-item__link,
.tp-news-item__copy { min-width: 0; color: inherit; text-decoration: none; }
.tp-news-item__link:hover h3 { color: var(--tp-color-primary); }
.tp-news-item__meta { margin: 0 0 3px; color: var(--tp-color-text-subtle); font-size: var(--tp-text-xs); font-weight: 700; }
.tp-news-item h3 { margin: 0; color: var(--tp-color-text); font-size: var(--tp-text-sm); font-weight: 800; line-height: 1.35; }
.tp-news-item__summary { margin: 4px 0 0; color: var(--tp-color-text-muted); font-size: var(--tp-text-xs); line-height: 1.45; }
.tp-news-item__image { width: 72px; height: 56px; object-fit: cover; border-radius: var(--tp-radius-xs); background: var(--tp-color-surface-soft); }

.tp-home-event { position: relative; overflow: hidden; background: var(--tp-color-surface); }
.tp-home-event::after { content: '\f091'; position: absolute; right: 18px; bottom: -19px; color: color-mix(in srgb, var(--tp-color-primary) 11%, transparent); font-family: 'Font Awesome 6 Free'; font-size: 115px; font-weight: 900; pointer-events: none; }
.tp-home-event > * { position: relative; z-index: 1; }
.tp-event-card { margin-top: var(--tp-space-5); display: grid; justify-items: start; gap: 8px; }
.tp-event-card__name { margin: 0; color: var(--tp-color-text); font-size: 17px; font-weight: 650; }
.tp-event-card__meta { margin: 0; color: var(--tp-color-text-muted); font-size: var(--tp-text-sm); line-height: 1.45; }

.tp-home-recent { margin-top: 0; }
.tp-history-list { margin-top: var(--tp-space-4); display: grid; gap: 2px; }

.tp-history-row {
    width: 100%;
    min-height: 64px;
    padding: 8px 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) auto;
    align-items: center;
    gap: var(--tp-space-4);
    border: 0;
    border-top: 1px solid var(--tp-color-border);
    background: transparent;
    color: var(--tp-color-text-muted);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.tp-history-row:hover { background: color-mix(in srgb, var(--tp-color-surface-soft) 48%, transparent); }
.tp-history-row:first-child { border-top: 0; }
.tp-history-row__primary { min-width: 0; display: flex; align-items: center; gap: var(--tp-space-3); }
.tp-history-row__opponent { min-width: 0; overflow: hidden; color: var(--tp-color-text); font-size: var(--tp-text-sm); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.tp-history-row__meta { min-width: 0; display: grid; gap: 2px; color: var(--tp-color-text-subtle); font-size: var(--tp-text-xs); }
.tp-history-row__delta { color: var(--tp-color-text-muted); }
.tp-history-row > i { padding-right: 6px; color: var(--tp-color-text-subtle); font-size: 11px; }

.tp-result-badge {
    min-height: 26px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    border-radius: var(--tp-radius-pill);
    background: color-mix(in srgb, var(--tp-color-success) 14%, transparent);
    color: var(--tp-color-success);
    font-size: 11px;
    font-weight: 650;
}

.tp-result-badge--loss { background: color-mix(in srgb, var(--tp-color-danger) 14%, transparent); color: var(--tp-color-danger); }
.tp-result-badge--draw { background: var(--tp-color-surface-soft); color: var(--tp-color-text-muted); }

.tp-home-empty {
    min-height: 96px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 5px;
}

.tp-home-empty strong { color: var(--tp-color-text); font-size: var(--tp-text-sm); }
.tp-home-empty p { max-width: 510px; margin: 0; color: var(--tp-color-text-muted); font-size: 13px; line-height: 1.45; }
.tp-home-empty .tp-button { margin-top: 4px; }

.tp-skeleton {
    border-radius: var(--tp-radius-xs);
    background: var(--tp-color-surface-soft);
    opacity: 0.82;
    animation: tpHomeSkeleton 1.2s ease-in-out infinite alternate;
}

.tp-skeleton--line { width: 100%; height: 12px; margin-top: 14px; }
.tp-skeleton--title { width: min(310px, 72%); height: 24px; margin-top: 16px; }
.tp-skeleton--button { width: 140px; height: 42px; margin-top: var(--tp-space-4); }
@keyframes tpHomeSkeleton { to { opacity: 0.48; } }

.tp-home-learn {
    margin-top: var(--tp-space-4);
    padding: var(--tp-space-5);
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--tp-space-4);
    border: 1px solid var(--tp-color-border);
    border-radius: var(--tp-radius-md);
    background: var(--tp-color-surface);
    box-shadow: var(--tp-shadow-xs);
}

.tp-home-learn__icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--tp-color-primary) 38%, var(--tp-color-border));
    border-radius: 50%;
    color: var(--tp-color-primary);
    background: color-mix(in srgb, var(--tp-color-primary) 10%, transparent);
}

.tp-home-learn__copy { min-width: 0; }
.tp-home-learn__copy .tp-section-heading__kicker { margin-bottom: 3px; }
.tp-home-learn h2 { margin: 0; color: var(--tp-color-text); font-size: var(--tp-text-md); font-weight: 800; }
.tp-home-learn__copy > p:last-child { margin: 4px 0 0; color: var(--tp-color-text-muted); font-size: var(--tp-text-sm); line-height: 1.45; }

/* Compact mobile/in-page counterpart to the desktop account/tools popover. */
.tp-more-screen { background: var(--tp-color-page); }
.tp-more-page {
    width: min(100%, var(--tp-home-max));
    margin: 0 auto;
    padding: var(--tp-space-8) var(--tp-space-6) calc(var(--tp-space-12) + 12px);
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--tp-space-5);
}

.tp-tools-group {
    min-width: 0;
    padding: var(--tp-space-5);
    border: 1px solid var(--tp-color-border);
    border-radius: var(--tp-radius-md);
    background: var(--tp-color-surface);
    box-shadow: var(--tp-shadow-xs);
}

.tp-tools-group h2 { margin: 0; color: var(--tp-color-text); font-size: var(--tp-text-md); font-weight: 800; }
.tp-tools-group__links { margin-top: var(--tp-space-4); display: grid; gap: 2px; }

.tp-tools-link {
    width: 100%;
    min-height: 46px;
    padding: 0 10px;
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 16px;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: var(--tp-radius-sm);
    background: transparent;
    color: var(--tp-color-text);
    font: inherit;
    font-size: var(--tp-text-sm);
    font-weight: 700;
    text-align: left;
    cursor: pointer;
}

.tp-tools-link:hover { background: var(--tp-color-surface-soft); }
.tp-tools-link > i:first-child { color: var(--tp-color-primary); }
.tp-tools-link > i:last-child { color: var(--tp-color-text-subtle); font-size: 11px; }
.tp-tools-link--danger { color: var(--tp-color-danger); }
.tp-tools-link--danger > i:first-child { color: var(--tp-color-danger); }

.tp-mobile-nav { display: none; }
.tp-mobile-nav[hidden],
body.global-nav-hidden .tp-mobile-nav { display: none; }

@media (max-width: 1023px) {
    .tp-home__content { padding: var(--tp-space-8) var(--tp-space-5) calc(104px + env(safe-area-inset-bottom)); }
    .tp-home-hero {
        grid-template-areas: "copy" "actions";
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto;
        padding: var(--tp-space-8);
    }
    .tp-home-hero__visual { display: none; }
    .tp-home__play-grid { grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.65fr); }
    .tp-home__information-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tp-home__information-grid .tp-home-event { grid-column: 1 / -1; }
    .tp-more-page { padding: var(--tp-space-6) var(--tp-space-5) calc(104px + env(safe-area-inset-bottom)); grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .tp-mobile-nav {
        position: fixed;
        z-index: 100;
        left: 0;
        right: 0;
        bottom: 0;
        min-height: calc(var(--tp-mobile-nav-height) + env(safe-area-inset-bottom));
        padding: 6px max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        align-items: start;
        border-top: 1px solid var(--tp-color-border-strong);
        background: var(--tp-color-surface-raised);
        box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.18);
    }

    .tp-mobile-nav__item {
        min-width: 44px;
        min-height: 56px;
        padding: 6px 3px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border: 0;
        border-radius: var(--tp-radius-sm);
        background: transparent;
        color: var(--tp-color-text-muted);
        font: inherit;
        font-size: 10px;
        font-weight: 750;
        cursor: pointer;
    }

    .tp-mobile-nav__item i { font-size: 16px; }
    .tp-mobile-nav__item.is-active { background: color-mix(in srgb, var(--tp-color-primary) 12%, transparent); color: var(--tp-color-primary); }
    .tp-shell-main > .screen.active:not(#screen-game) { padding-bottom: calc(var(--tp-mobile-nav-height) + env(safe-area-inset-bottom)); }
    .tp-shell-main > #screen-home.tp-home.active { padding-bottom: 0; }
}

@media (max-width: 820px) {
    .tp-home__play-grid { grid-template-columns: 1fr; }
    .tp-home__information-grid { grid-template-columns: 1fr; }
    .tp-home__information-grid .tp-home-event { grid-column: auto; }
    .tp-home__information-grid .tp-home-section { min-height: auto; }
}

/* Keep the continuation card readable before the mobile breakpoint rather
 * than compressing it into a narrow desktop-side column. */
@media (min-width: 821px) and (max-width: 1120px) {
    .tp-home__play-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
    .tp-shell-main { min-height: calc(100dvh - 60px); }
    .tp-shell-main > #screen-home.tp-home.active { min-height: calc(100dvh - 60px); }
    .tp-home__content { padding: var(--tp-space-4) var(--tp-space-4) calc(96px + env(safe-area-inset-bottom)); }
    .tp-home-hero { min-height: auto; padding: var(--tp-space-5); display: flex; flex-direction: column; align-items: stretch; gap: var(--tp-space-4); }
    .tp-home-hero h1 { font-size: clamp(25px, 7vw, 31px); }
    .tp-home-hero__subtitle { margin-top: 10px; font-size: var(--tp-text-sm); line-height: 1.42; }
    .tp-home-hero__meta { margin-top: 12px; }
    .tp-home-hero__actions { grid-template-columns: 1fr 1fr; }
    .tp-home-hero__actions .tp-button { min-width: 0; padding-inline: 10px; font-size: 12px; }
    /* The dominant CTA stays full width and finger-sized on mobile. */
    .tp-home-hero__actions--single { grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
    .tp-home .tp-home-hero__actions--single .tp-home-hero__cta { width: 100%; min-height: 52px; font-size: var(--tp-text-sm); }
    .tp-home-hero__secondary { gap: var(--tp-space-1) var(--tp-space-3); }
    .tp-home-hero__secondary .tp-button { min-height: 44px; font-size: 12px; }
    .tp-home-section { margin-top: 12px; padding: var(--tp-space-5); }
    .tp-section-heading h2 { font-size: 18px; }
    .tp-section-heading__note { display: none; }
    .tp-quick-play__controls { margin-top: var(--tp-space-4); grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .tp-time-control { min-height: 72px; padding: 10px 8px; gap: 5px; }
    .tp-time-control strong { font-size: 12px; }
    .tp-time-control small { font-size: 10px; }
    .tp-time-control > i { font-size: 14px; }
    .tp-home-continue { min-height: 0; }
    .tp-home__information-grid { margin-top: 12px; gap: 12px; }
    .tp-home__information-grid .tp-home-section { margin-top: 0; }
    .tp-history-row { min-height: 70px; grid-template-columns: minmax(0, 1fr) auto; gap: var(--tp-space-3); }
    .tp-history-row__meta { grid-column: 1; grid-row: 2; padding-left: 0; }
    .tp-history-row > i { grid-column: 2; grid-row: 1 / span 2; }
    .tp-history-row__primary { min-width: 0; }
    .tp-history-row__delta { display: none; }
    .tp-home-learn { grid-template-columns: 40px minmax(0, 1fr); padding: var(--tp-space-5); }
    .tp-home-learn__icon { width: 40px; height: 40px; }
    .tp-home-learn .tp-button { grid-column: 1 / -1; justify-self: start; min-height: 40px; padding-inline: 0; }
    .tp-more-page { padding: var(--tp-space-5) var(--tp-space-4) calc(96px + env(safe-area-inset-bottom)); grid-template-columns: 1fr; gap: var(--tp-space-4); }
    .tp-tools-group { padding: var(--tp-space-4); }
}

@media (max-width: 430px) {
    .tp-home__content { padding-inline: 12px; }
    .tp-home-hero,
    .tp-home-section { border-radius: var(--tp-radius-sm); }
    .tp-home-hero { padding: var(--tp-space-4); }
    .tp-home-section { padding: var(--tp-space-4); }
    .tp-home__rating,
    .tp-home__status { font-size: 11px; }
    .tp-time-control { padding: 9px 7px; }
    .tp-home-learn { padding: var(--tp-space-4); }
    .tp-mobile-nav { padding-inline: 4px; }
    .tp-mobile-nav__item { min-width: 44px; font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
    .tp-button,
    .tp-tools-link,
    .tp-mobile-nav__item { transition: none; }
    .tp-skeleton { animation: none; }
}
