/* Homepage-specific layout. Base elements and tokens live in public.css. */
.home-page h1, .home-page h2, .home-page p { margin: 0; }
.home-page .page-heading { gap: 24px; align-items: flex-start; margin-bottom: 30px; }
.home-page .subtitle { margin-top: 8px; color: var(--secondary); }
.home-page .header-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 0; max-width: 100%; }
.home-page .online-link { min-height: 44px; display: inline-flex; gap: 16px; align-items: center; padding: 8px 0; font-size: 14px; }
.home-page .monitor-label { color: var(--secondary); font-size: 12px; }
.home-page .collection-status { margin: 0; background: var(--surface); border-color: var(--border); color: var(--secondary); gap: 6px 16px; max-width: 100%; }
.home-page .collection-detail { color: var(--secondary); }
.home-page .tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.home-page .tabs [role="tab"] { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font: inherit; min-height: 44px; padding: 10px 18px; border: 1px solid transparent; border-radius: 8px; color: var(--secondary); background: transparent; font-weight: 600; }
.home-page .tabs [role="tab"]:hover { background: var(--surface); color: var(--text); }
.home-page .tabs [role="tab"].active { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-border); }
.home-page .panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 26px 0 20px; }
.home-page .view-description { color: var(--secondary); font-size: 14px; margin-top: 6px; }
.home-page .periods { display: flex; flex-wrap: wrap; gap: 6px; }
.home-page .periods button, .home-page .retry-button { min-height: 44px; padding: 8px 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--secondary); }
.home-page .periods button:hover, .home-page .retry-button:hover { color: var(--text); background: var(--surface-raised); }
.home-page .periods button.active { color: var(--text); background: var(--surface-raised); border-color: #758396; }
.home-page .summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.home-page .stat-card { border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; background: var(--surface); min-width: 0; }
.home-page .stat-label { font-size: 13px; color: var(--secondary); margin-bottom: 6px; }
.home-page .stat-value { font-size: 22px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.home-page .stat-value a { text-decoration-thickness: 1px; }
.home-page .stat-detail { font-size: 13px; color: var(--secondary); margin-top: 5px; overflow-wrap: anywhere; }
.home-page .event-teaser { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 24px; padding: 13px 16px; margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.home-page .teaser-item { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; min-width: 0; }
.home-page .teaser-item a { overflow-wrap: anywhere; }
.home-page .event-teaser #showEvents { min-height: 44px; margin-left: auto; padding: 8px 0; color: var(--accent); border: 0; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
.home-page .notice { margin: 16px 0; padding: 13px 16px; background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning); border-radius: 8px; font-size: 14px; }
.home-page .data-meta { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 16px 0 12px; color: var(--secondary); font-size: 13px; }
.home-page .data-surface { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.home-page .table-wrap { overflow-x: auto; }
.home-page table { width: 100%; border-collapse: collapse; font-size: 14px; }
.home-page th { color: var(--secondary); font-size: 12px; font-weight: 400; white-space: nowrap; background: var(--table-head); }
.home-page th, .home-page td { text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.home-page tbody tr:last-child td { border-bottom: 0; }
.home-page tbody tr:hover { background: var(--surface-raised); }
.home-page .numeric { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-page .rank-cell { color: var(--secondary); width: 54px; }
.home-page .player-link { font-weight: 600; overflow-wrap: anywhere; }
.home-page td .entity-link { overflow-wrap: anywhere; }
.home-page .identity-cell { min-width: 120px; width: 20%; }
.home-page .movement { font-size: 13px; white-space: nowrap; }
.home-page .muted { color: var(--secondary); }
.home-page .positive { color: var(--accent); }
.home-page .negative { color: var(--negative); }
.home-page .new-label { font-size: 12px; color: var(--warning); white-space: normal; }
.home-page .clan-display { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.home-page .emblem { width: auto; height: 12px; flex: 0 0 auto; }
.home-page .alliance-display { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; }
.home-page img.entity-emblem { width: 16px; height: 12px; object-fit: contain; flex: 0 0 16px; margin: 0; }
.home-page img.entity-emblem.alliance { width: 8px; flex-basis: 8px; margin: 0; }
.home-page img.entity-emblem.entity-fallback { width: 16px; flex-basis: 16px; }
.home-page .mobile-ranking { display: none; }
.home-page .profession-cell { display: inline-flex; align-items: center; flex-wrap: nowrap; gap: 14px; white-space: nowrap; }
.home-page .profession-cell > .entity-link { overflow-wrap: normal; }
.home-page .profession-distribution { position: relative; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 22px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--secondary); }
.home-page .profession-distribution::after { content: ""; position: absolute; inset: -11px; }
.home-page .profession-distribution:hover, .home-page .profession-distribution[aria-expanded="true"] { color: var(--accent); }
.home-page .profession-breakdown { position: fixed; z-index: 1000; inset: auto; margin: 0; width: max-content; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-raised); color: var(--text); box-shadow: 0 8px 24px #0006; font-size: 13px; overflow-wrap: anywhere; }
.home-page .profession-breakdown ul { margin: 0; padding: 0; list-style: none; }
.home-page .profession-breakdown li { display: flex; align-items: center; gap: 4px; min-height: 44px; }
.home-page .loading, .home-page .error, .home-page .empty { padding: 40px 20px; text-align: center; color: var(--secondary); }
.home-page .error { color: var(--negative); }
.home-page .error p, .home-page .empty p { margin: 8px 0 16px; }
.home-page .state-title { font-size: 17px; font-weight: 600; color: var(--text); }
.home-page .roster-changes { display: grid; gap: 10px; margin-top: 14px; }
.home-page .roster-group { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.home-page summary { cursor: pointer; min-height: 44px; padding: 12px 16px; color: var(--text); }
.home-page .roster-body { padding: 0 16px 14px; }
.home-page .roster-body p { color: var(--secondary); font-size: 13px; }
.home-page .roster-body ul { padding-left: 20px; margin-bottom: 0; }
.home-page .roster-body li { padding: 4px 0; overflow-wrap: anywhere; }
.home-page .event-group { padding: 18px; }
.home-page .event-group + .event-group { border-top: 1px solid var(--border); }
.home-page .event-group-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.home-page .event-archive { padding: 0; }
.home-page .event-archive > summary { padding: 18px; font-weight: 600; }
.home-page .event-archive .events-list { padding: 0 18px 18px; }
.home-page .events-list { display: grid; gap: 10px; }
.home-page .event-card { display: grid; grid-template-columns: 100px minmax(0, 1fr) minmax(130px, 230px) 150px; gap: 16px; align-items: center; padding: 16px; border: 1px solid var(--border); border-radius: 8px; text-decoration: none; background: var(--bg); }
.home-page .event-card:hover { background: var(--surface-raised); border-color: #697a8b; color: var(--text); }
.home-page .event-date, .home-page .event-time { color: var(--secondary); font-size: 13px; }
.home-page .event-name { overflow-wrap: anywhere; font-weight: 600; }
.home-page .event-hint { display: block; margin-top: 4px; font-size: 12px; font-weight: 400; color: var(--secondary); }
.home-page .status-badge { display: inline-block; padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; color: var(--secondary); width: fit-content; }
.home-page .event-card .status-badge { justify-self: end; }
.home-page .status-active { color: var(--accent); background: var(--accent-bg); border-color: var(--accent-border); }
.home-page .status-awaiting_data { color: var(--warning); background: var(--warning-bg); border-color: var(--warning-border); }
.home-page .footer { margin-top: 14px; color: var(--secondary); font-size: 13px; }
.home-page .coverage-note { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--secondary); font-size: 13px; max-width: 850px; }
@media (max-width: 1000px) {
    .home-page .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .home-page .table-wrap table { min-width: 850px; }
    .home-page .event-card { grid-template-columns: 90px minmax(0, 1fr); gap: 8px 16px; }
    .home-page .event-card .status-badge { justify-self: start; }
}
@media (max-width: 700px) {
    .home-page { --secondary: #bec9d7; }
    .home-page .container { width: calc(100% - 32px); padding-top: 16px; }
    .home-page h1 { font-size: 28px; }
    .home-page h2 { font-size: 20px; }
    .home-page .brand { margin-bottom: 6px; }
    .home-page .subtitle { margin-top: 6px; }
    .home-page .page-heading { gap: 8px; margin-bottom: 16px; }
    .home-page .header-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; width: 100%; gap: 4px 12px; }
    .home-page .monitor-label { text-align: right; font-size: 13px; }
    .home-page .online-link { align-self: flex-start; }
    .home-page .collection-status { grid-column: 1 / -1; width: 100%; padding: 8px 12px; }
    .home-page .collection-state { flex-basis: 100%; }
    .home-page .tabs { gap: 4px; padding-bottom: 8px; }
    .home-page .tabs [role="tab"] { flex: 1; padding: 8px 6px; font-size: 13px; min-width: 0; }
    .home-page .panel-heading { margin: 16px 0 14px; gap: 10px; }
    .home-page .periods { width: 100%; gap: 6px; }
    .home-page .periods button { flex: 1; padding: 8px 6px; font-size: 13px; white-space: nowrap; }
    .home-page .summary-grid { gap: 6px; margin-bottom: 12px; }
    .home-page .stat-card { padding: 10px 12px; }
    .home-page .stat-value { font-size: 20px; }
    .home-page .desktop-ranking { display: none; }
    .home-page .mobile-ranking { display: block; }
    .home-page .player-card { padding: 16px; border-bottom: 1px solid var(--border); }
    .home-page .player-card:last-child { border-bottom: 0; }
    .home-page .player-card-heading { display: flex; gap: 12px; align-items: baseline; }
    .home-page .player-card-heading .rank-cell { flex: 0 0 28px; width: auto; font-variant-numeric: tabular-nums; }
    .home-page .player-card-heading .player-link { min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
    .home-page .player-card-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0 4px; }
    .home-page .metric-label { display: block; font-size: 13px; color: var(--secondary); margin-bottom: 3px; }
    .home-page .metric-value { font-size: 18px; font-variant-numeric: tabular-nums; }
    .home-page .player-details > summary { padding: 10px 0; color: var(--secondary); font-size: 14px; }
    .home-page .player-details dl { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 12px; margin: 4px 0; font-size: 14px; }
    .home-page .player-details dt { color: var(--secondary); }
    .home-page .player-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
    .home-page .entity-link { display: inline-block; padding: 4px 0; }
    .home-page .event-teaser { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 8px 12px; gap: 8px 10px; margin-bottom: 12px; }
    .home-page .teaser-item { gap: 2px 8px; }
    .home-page .teaser-item > .muted { flex-basis: 100%; font-size: 13px; }
    .home-page .event-teaser .teaser-item + .teaser-item { display: none; }
    .home-page .event-teaser button { margin-left: 0; font-size: 13px; white-space: nowrap; }
    .home-page .event-group { padding: 14px; }
    .home-page .event-archive { padding: 0; }
    .home-page .event-card { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 14px; }
    .home-page .data-meta { display: block; margin: 12px 0 10px; font-size: 14px; overflow-wrap: anywhere; }
    .home-page .data-meta span { display: block; margin-top: 4px; }
}
@media (max-width: 480px) {
    .home-page .summary-grid { grid-template-columns: minmax(0, 1fr); }
    .home-page .stat-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 8px 12px; }
    .home-page .stat-label { margin: 0; }
    .home-page .stat-value { grid-column: 2; grid-row: 1 / 3; text-align: right; font-size: 18px; }
    .home-page .stat-detail { grid-column: 1; margin-top: 0; }
    .home-page .stat-card:nth-child(2) .stat-detail { display: none; }
}

.home-page .custom-window { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 16px; }
.home-page .custom-window label { display: grid; gap: 6px; color: var(--secondary); font-size: 13px; }
.home-page .custom-window input { min-height: 44px; max-width: 100%; padding: 8px 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 7px; color-scheme: dark; }
.home-page .periodic-group { margin-bottom: 16px; }
.home-page .periodic-group button { flex: 0 1 auto; min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.home-page .periodic-details { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 8px 12px; margin: 12px 0 0; font-size: 14px; }
.home-page .periodic-details dt { color: var(--secondary); }
.home-page .periodic-details dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.home-page .player-card-heading .entity-link { min-width: 0; overflow-wrap: anywhere; }
.home-page .periodic-ranking table { min-width: 0; }
.home-page .periodic-ranking th:last-child { text-align: right; }
.home-page .periodic-ranking td { overflow-wrap: anywhere; }
.home-page #periodError { color: var(--negative); }

/* Approved official ranking pages. Desktop presentation only. */
@media (min-width: 1024px) {
    .home-page.official-mode .page-heading { align-items: center; margin-bottom: 0; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
    .home-page.official-mode .header-actions { justify-content: center; }
    .home-page.official-mode :is(.online-link, .monitor-label, .collection-detail) { display: none; }
    .home-page.official-mode .tabs { padding: 18px 0; }
    .home-page.official-mode .panel-heading { align-items: center; flex-wrap: nowrap; gap: 24px; margin: 24px 0 20px; }
    .home-page.official-mode .panel-heading h2 { margin: 0; font-size: 28px; }
    .home-page.official-mode .official-groups { flex-wrap: nowrap; flex: 0 0 auto; }
    .home-page.official-mode .official-groups a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--secondary); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
    .home-page.official-mode .official-groups a.active { color: var(--text); background: var(--surface-raised); border-color: #758396; }
    .home-page.official-mode .data-meta { justify-content: space-between; align-items: baseline; gap: 6px 20px; margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px 8px 0 0; background: var(--surface); font-size: 12px; }
    .home-page.official-mode .data-meta strong { color: var(--text); }
    .home-page.official-mode .data-meta:not([hidden]) + .data-surface { border-top: 0; border-radius: 0 0 8px 8px; }
    .home-page.official-mode .data-surface { overflow: visible; }
    .home-page.official-mode .data-surface .table-wrap { overflow: visible; border: 0; border-radius: 0 0 8px 8px; }
    .home-page.official-mode th, .home-page.official-mode td { padding: 10px 14px; }
    .home-page.official-mode th { position: sticky; top: 0; z-index: 2; background: var(--table-head); }
    .home-page.official-mode td a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
    .home-page.official-mode img.entity-emblem { image-rendering: pixelated; }
}

/* Approved activity presentation. Existing narrow-screen rules stay untouched. */
@media (min-width: 1024px) {
    .home-page.activity-mode .page-heading { align-items: center; margin-bottom: 0; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
    .home-page.activity-mode .header-actions { justify-content: center; }
    .home-page.activity-mode :is(.online-link, .monitor-label, .collection-detail) { display: none; }
    .home-page.activity-mode .tabs { padding: 18px 0; }
    .home-page.activity-mode #rankingPanel { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 24px; }
    .home-page.activity-mode #rankingPanel > * { grid-column: 1 / -1; }
    .home-page.activity-mode .panel-heading { display: contents; }
    .home-page.activity-mode .panel-heading > div:first-child { grid-column: 1 / -1; grid-row: 1; margin: 24px 0 18px; }
    .home-page.activity-mode .panel-heading h2 { margin: 0; font-size: 28px; }
    .home-page.activity-mode :is(#viewDescription, #summary, #rankingHint, #rankingDetails, #activityCoverage) { display: none; }
    .home-page.activity-mode #periodicGroups { grid-column: 1; grid-row: 2; margin: 0 0 16px; }
    .home-page.activity-mode #periods { grid-column: 2; grid-row: 2; margin: 0 0 16px; }
    .home-page.activity-mode :is(#periods, #periodicGroups) { flex-wrap: nowrap; align-items: center; }
    .home-page.activity-mode :is(#periods, #periodicGroups) button { flex: 0 0 auto; white-space: nowrap; }
    .home-page.activity-mode #customWindow { grid-row: 3; }
    .home-page.activity-mode .data-meta { justify-content: space-between; align-items: baseline; gap: 6px 20px; margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px 8px 0 0; background: var(--surface); font-size: 12px; }
    .home-page.activity-mode .data-meta strong { font-weight: 500; color: var(--text); }
    .home-page.activity-mode .data-meta:not([hidden]) + .data-surface { border-top: 0; border-radius: 0 0 8px 8px; }
    .home-page.activity-mode .data-surface, .home-page.activity-mode .periodic-ranking { overflow: visible; }
    .home-page.activity-mode .data-surface .table-wrap { border: 0; border-radius: 0 0 8px 8px; }
    .home-page.activity-mode .periodic-ranking table { table-layout: fixed; }
    .home-page.activity-mode th, .home-page.activity-mode td { padding: 10px 14px; }
    .home-page.activity-mode th { position: sticky; top: 0; z-index: 2; background: var(--table-head); }
    .home-page.activity-mode :is(th, td):first-child { width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
    .home-page.activity-mode :is(th, td):last-child { width: 150px; text-align: right; white-space: nowrap; }
    .home-page.activity-mode td a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
    .home-page.activity-mode img.entity-emblem { image-rendering: pixelated; }
    .home-page.activity-mode .profession-cell { gap: 8px; white-space: normal; }
    .home-page.activity-mode .profession-cell > .entity-link { overflow-wrap: anywhere; }
    .home-page.activity-mode .activity-composition { display: flex; flex-wrap: wrap; gap: 8px 18px; }
    .home-page.activity-mode[data-activity-group="players"] th:nth-child(2) { width: 22%; }
    .home-page.activity-mode[data-activity-group="players"] th:nth-child(3) { width: 25%; }
    .home-page.activity-mode[data-activity-group="clans"] th:nth-child(2) { width: 38%; }
    .home-page.activity-mode[data-activity-group="alliances"] th:nth-child(2) { width: 25%; }
    .home-page.activity-mode[data-activity-group="professions"] :is(.data-meta, .data-surface) { width: 100%; }
    .home-page.activity-mode[data-activity-group="professions"] th:nth-child(2) { width: 25%; }
    .home-page.activity-mode[data-activity-group="professions"] td { padding-top: 12px; padding-bottom: 12px; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representatives { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative > .player-link { font-weight: 400; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative-affiliations { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative-emblem { display: inline-flex; align-items: center; justify-content: center; min-width: 8px; height: 16px; flex-shrink: 0; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative-emblem img { display: block; width: auto; max-width: 16px; flex-basis: auto; }
    .home-page.activity-mode[data-activity-group="professions"] .profession-representative-gain { font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
}

.home-page .nickname-cell { display: inline-flex; align-items: center; gap: 7px; }
.home-page .nickname-history { display: inline-grid; place-items: center; width: 26px; height: 28px; padding: 0; border: 0; border-radius: 5px; background: transparent; color: #f7c57b; cursor: pointer; }
.home-page .nickname-history:hover, .home-page .nickname-history[aria-expanded="true"] { background: #f7c57b18; }
.home-page .nickname-history:focus-visible { outline: 2px solid currentColor; }
.home-page .nickname-list li { min-height: 32px; }
.home-page .nickname-list li:first-child { font-weight: 700; }
