/* Setup and friend-only reference. Load after game.html's inline styles. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#setupScreen #playerList {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 18px;
}
#setupScreen #playerList:empty { margin: 0 0 14px; }
#setupScreen #playerList .player-chip {
    min-width: 0;
    max-width: 100%;
    gap: 6px;
    padding: 0 2px 0 12px;
    border-color: #46515d;
    animation: none;
}
#setupScreen #playerList .name {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: .94rem;
    line-height: 1.3;
}
#setupScreen #playerList .remove { flex: 0 0 44px; }

/* Preserve the original Start button, tab order and disabled state. */
@media (max-width: 620px) and (orientation: portrait) {
    #setupScreen.active {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
        transform: none;
        animation: none;
    }
    #setupScreen > .card {
        overflow: visible;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        padding: 22px 18px;
    }
    #setupScreen .start-dock {
        position: fixed;
        z-index: 30;
        bottom: 0;
        left: 0;
        width: 100%;
        padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
        background: #151d28;
        border-top: 1px solid #3e4a57;
    }
    #setupScreen #startBtn { min-height: 52px; margin: 0; }
    #setupScreen #startBtn:disabled {
        opacity: 1;
        background: #38433b;
        color: #cbd0c6;
    }
    #setupScreen :is(input, select, button, a, summary) {
        scroll-margin-block: 24px 112px;
    }
    #setupScreen .game-title { font-size: 2.6rem; margin-bottom: 20px; }
    #setupScreen .play-preference { margin-bottom: 16px; }
}

/* The helper lives only inside the active, friends-facing answer screen. */
#answerScreen:not(.active) .ch-friend-helper,
.ch-friend-helper[hidden] { display: none !important; }
.ch-friend-helper {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    text-align: left;
    color: #faf8f3;
    font-size: .88rem;
    line-height: 1.45;
}
.ch-friend-helper > summary {
    min-height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    padding: 8px 14px;
    border: 1px solid #92a85a;
    border-radius: 10px;
    cursor: pointer;
    list-style: none;
    color: #faf8f3;
    background: #293628;
    font-weight: 700;
}
.ch-friend-helper > summary::-webkit-details-marker { display: none; }
.ch-friend-helper > summary::after { content: '+'; font-size: 1.15rem; }
.ch-friend-helper[open] > summary::after { content: '-'; }
.ch-friend-helper > summary:focus-visible,
.ch-friend-helper a:focus-visible {
    outline: 3px solid #d7ec72;
    outline-offset: 3px;
}
.ch-friend-helper .ch-friend-audience {
    color: #d7ec72;
    font-size: .76rem;
    font-weight: 600;
}
.ch-friend-panel {
    position: absolute;
    z-index: 3;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: min(100%, 660px);
    max-height: min(420px, calc(100dvh - 215px));
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 20px;
    border: 1px solid #7c8985;
    border-radius: 14px;
    background: #202b38;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .45);
    scrollbar-gutter: stable;
}
.ch-friend-reminder { margin: 0 0 10px; color: #d7ec72; font-weight: 700; }
.ch-friend-name { font-size: 1.12rem; line-height: 1.25; margin: 0 0 8px; }
.ch-friend-category { margin: 0 0 8px; font-weight: 700; font-size: 1rem; }
.ch-friend-facts { padding-left: 20px; margin: 0; }
.ch-friend-facts li + li { margin-top: 7px; }
.ch-friend-sources { margin-top: 12px; font-size: .76rem; display: flex; flex-wrap: wrap; gap: 6px 14px; }
.ch-friend-sources a { color: #dbe8ee; text-underline-offset: 3px; padding: 3px 0; }
#answerScreen:has(.ch-friend-helper:not([hidden])) .target-portrait img {
    max-height: calc(100dvh - 220px);
}
@media (orientation: portrait) {
    #answerScreen:has(.ch-friend-helper:not([hidden])) .target-portrait img {
        max-height: min(33dvh, calc(100dvh - 300px));
    }
}
@media (orientation: landscape) and (max-height: 500px) {
    .ch-friend-helper > summary { min-height: 38px; padding: 4px 12px; }
    .ch-friend-panel { max-height: calc(100dvh - 150px); padding: 12px 16px; }
    .ch-friend-reminder { margin-bottom: 6px; }
    #answerScreen:has(.ch-friend-helper:not([hidden])) .target-portrait img {
        max-height: calc(100dvh - 178px);
    }
}
@media (max-width: 360px) {
    .ch-friend-helper .ch-friend-audience { display: none; }
}

/* The turn recap and running total answer different questions. */
.running-standings {
    margin: 22px 0 18px;
    padding-top: 18px;
    border-top: 1px solid #46515d;
}
.running-standings h3 { font-size: 1.05rem; margin: 0 0 5px; }
.running-standings > p { color: var(--text-muted); font-size: .84rem; line-height: 1.5; }
.running-standings .player-list { margin: 12px 0 0; }
.running-standings .player-chip { padding: 10px 12px; }
.round-recap-label { margin: 18px 0 6px; font-size: .92rem; color: var(--text-muted); }
.hof-eligibility {
    margin: 12px 0 18px;
    padding: 12px 14px;
    border: 1px solid #46515d;
    border-radius: 12px;
    color: #dbe2e8;
    font-size: .86rem;
    line-height: 1.5;
}
.hof-eligibility:empty { display: none; }
.result-score { text-align: right; flex: 0 1 auto; margin-left: 12px; }
.result-score > .result-subject { max-width: 210px; font-size: .76rem; line-height: 1.4; }

/* Current-rules ladder: region means the question pack used in the game. */
#bestScoresScreen > .card { max-width: 760px; margin-inline: auto; }
#bestScoresScreen #bestScoresIntro {
    max-width: 54ch;
    margin: 0 0 18px;
    color: #ccd5de;
    font-size: .92rem;
    line-height: 1.55;
}
#bestScoresScreen label[for="leaderboardRegion"] {
    display: block;
    margin: 0 0 7px;
    font-size: .86rem;
    font-weight: 700;
    color: #faf8f3;
}
#bestScoresScreen #leaderboardRegion {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-bottom: 9px;
    padding: 11px 40px 11px 14px;
    border: 1px solid #75828d;
    border-radius: 10px;
    color: #faf8f3;
    background-color: #151d28;
    font-size: 1rem;
}
#bestScoresScreen .ladder-region-note {
    color: #bfc9d3;
    font-size: .79rem;
    line-height: 1.5;
    margin: 0 0 14px;
}
#bestScoresScreen #ladderRules {
    margin: 14px 0 22px;
    border-top: 1px solid #46515d;
    border-bottom: 1px solid #46515d;
    color: #d3dce4;
    font-size: .84rem;
    line-height: 1.55;
}
#bestScoresScreen #ladderRules > summary {
    min-height: 44px;
    padding: 11px 0;
    color: #faf8f3;
    cursor: pointer;
    font-weight: 600;
}
#bestScoresScreen #ladderRules > :not(summary) { margin: 0 0 12px; }
#bestScoresScreen #ladderRules :is(ul, ol) { padding-left: 22px; }
#bestScoresScreen #ladderRules li + li { margin-top: 6px; }
#bestScoresScreen :is(#leaderboardRegion, #ladderRules > summary):focus-visible {
    outline: 3px solid #d7ec72;
    outline-offset: 3px;
}
#bestScoresScreen #globalScoresList { gap: 8px; max-height: none; overflow: visible; }
#bestScoresScreen .ladder-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 14px 12px;
    border: 1px solid #46515d;
    border-radius: 12px;
    background: #202b38;
    animation: none;
}
#bestScoresScreen .ladder-row.first {
    border-color: #a6b85d;
    background: #25302c;
}
#bestScoresScreen .ladder-row .rank {
    width: auto;
    min-width: 0;
    margin: 0;
    color: #d7ec72;
    font-size: 1rem;
    font-weight: 750;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
#bestScoresScreen .ladder-row .name {
    min-width: 0;
    overflow-wrap: anywhere;
    color: #faf8f3;
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.35;
}
#bestScoresScreen .ladder-row .detail {
    display: block;
    margin-top: 5px;
    color: #c0cad4;
    font-size: .76rem;
    font-weight: 400;
    line-height: 1.55;
    overflow-wrap: anywhere;
}
#bestScoresScreen .ladder-row > :last-child {
    min-width: 0;
    font-size: 1.12rem;
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}
#bestScoresScreen .ladder-row .ladder-average-label {
    display: block;
    color: #bfc9d3;
    font-size: .67rem;
    font-weight: 400;
    line-height: 1.4;
}
@media (max-width: 420px) {
    #bestScoresScreen > .card { padding: 22px 14px; }
    #bestScoresScreen .ladder-row { grid-template-columns: 24px minmax(0, 1fr) auto; gap: 9px; padding: 12px 9px; }
    #bestScoresScreen .ladder-row .name { font-size: .94rem; }
    #bestScoresScreen .ladder-row > :last-child { font-size: 1rem; }
    #bestScoresScreen .ladder-row .detail { font-size: .72rem; }
}

/* A quieter game shell: clear hierarchy, compact controls and no decoration. */
.game-brand { margin: 0 0 24px; text-align: left; }
.brand-kicker { display: inline-block; margin-bottom: 10px; color: #bcc6d0; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-decoration: none; }
#setupScreen .game-title { margin: 0; font-size: clamp(2rem, 7.8vw, 2.8rem); font-weight: 700; text-align: left; line-height: 1.1; letter-spacing: -.055em; }
.setup-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 24px; }
.setup-heading .section-title { margin: 0; font-size: 1.2rem; font-weight: 650; text-align: left; }
.setup-tools { display: flex; gap: 8px; }
.setup-tools .help-fab { position: static; width: 44px; height: 44px; min-width: 44px; background: transparent; border: 1px solid #52606e; color: #d4dce3; border-radius: 10px; box-shadow: none; }
.sound-muted, .is-muted .sound-waves { display: none; }
.is-muted .sound-muted { display: block; }
#setupScreen .select-label { text-transform: none; letter-spacing: 0; font-size: .8rem; color: #c8d0d7; }
#setupScreen .input-field { border-width: 1px; border-radius: 10px; font-size: 1rem; }
#setupScreen .input-label { font-size: .95rem; }
#setupScreen #playerName { padding-right: 88px; }
#setupScreen #startBtn { border-radius: 10px; font-size: 1rem; font-weight: 650; gap: 12px; }
#setupScreen > .card { border-color: #3e4a57; }
#playerSelectionScreen .player-chip { border-radius: 12px; background: #202b38; box-shadow: none; }
#playerSelectionScreen .player-chip .name { display: flex; justify-content: space-between; align-items: center; }
#playerSelectionScreen .player-chip .ui-icon { color: #bcc6d0; width: 20px; }
.game-title:not(h1) { font-weight: 650; letter-spacing: -.035em; line-height: 1.15; margin-bottom: 20px; }
.result-kicker { color: #c5d97a; font-size: .74rem; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 12px; }
.winner-hero { border-radius: 12px; border: 1px solid #536044; text-align: left; padding: 24px; }
.winner-hero .who { font-family: 'DM Sans', sans-serif; font-size: 2rem; font-weight: 650; }
.winner-hero .stat { margin-top: 10px; }
.action-btn { border-radius: 12px; font-weight: 650; gap: 4px; }
.action-btn .ui-icon { width: 26px; height: 26px; }
.btn-clue { background: #ead6a7; color: #302614; }
.btn-give-up { background: #663b42; color: #fff; }
#bestScoresScreen .game-title { font-size: 1.9rem !important; }
@media (max-width: 620px) and (orientation: portrait) {
    .game-brand { margin: 4px 0 20px; }
    .setup-heading { margin-bottom: 20px; }
    #setupScreen > .card { padding: 18px; }
}

#setupScreen .setup-links { gap: 4px !important; border-top: 1px solid #3e4a57; padding-top: 12px; }
#setupScreen .setup-links .btn { width: auto; padding: 10px 12px !important; min-height: 44px; font-size: .82rem !important; font-weight: 500; border: 0; border-radius: 6px; color: #c8d0d7; }
#setupScreen .setup-links .btn:hover { color: #faf8f3; background: #2d3845; }

/* Mobile first play: one clear action, with settings available on demand. */
.setup-intro { color: #c8d0d7; font-size: .95rem; line-height: 1.5; margin: -8px 0 18px; }
.quick-players { display: block; width: 100%; min-height: 56px; padding: 12px 16px; border: 1px solid #83964f; border-radius: 10px; background: #293628; color: #e4efa5; text-align: left; font: 600 1rem/1.4 'DM Sans', sans-serif; cursor: pointer; }
.quick-players[hidden] { display: none; }
.quick-players span { display: block; color: #c0cab1; font-size: .8rem; font-weight: 400; }
.player-entry-label { margin: 18px 0 10px; font-size: .8rem; color: #c8d0d7; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.setup-tip { margin: -8px 0 6px; color: #b9c5cf; font-size: .8rem; }
.relaxed-option { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 44px; color: #e4e8eb; font-size: .86rem; cursor: pointer; }
.relaxed-option input { width: 18px; height: 18px; margin: 0 3px 0 0; accent-color: var(--accent-primary); }
.relaxed-option span { color: #b9c5cf; font-size: .8rem; }
.relaxed-option input:focus-visible { outline: 3px solid #d7ec72; outline-offset: 3px; }
.share-game-controls[hidden], #shareGameFallback[hidden] { display: none; }
#shareGameStatus { margin: 8px 0 0; color: #d7ec72; line-height: 1.5; }
#shareGameStatus:empty { display: none; }
#shareGameFallback { margin-top: 12px; }
#shareGameFallback label { display: block; margin-bottom: 8px; }
#shareGameUrl { font-size: .85rem; }
.game-options { margin: 18px 0; border-block: 1px solid #46515d; }
.game-options > summary, .play-preference > summary { min-height: 48px; padding: 12px 0; cursor: pointer; font-weight: 600; color: #e4e8eb; }
.game-options > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; }
.game-options > summary::-webkit-details-marker { display: none; }
.game-options > summary::after { content: '+'; font-size: 1.4rem; font-weight: 400; }
.game-options[open] > summary::after { content: '-'; }
#settingsSummary { display: block; margin-top: 4px; color: #b9c5cf; font-size: .75rem; font-weight: 400; }
.game-options .setup-grid > :last-child { grid-column: 1 / -1; }
#setupScreen .game-options .play-preference { margin: 0 0 14px; }
#setupScreen #startBtnHint { margin: 8px 0 0; color: #c8d0d7; font-size: .8rem; opacity: 1; }
.catalogue-retry { display: block; min-height: 44px; padding: 8px 16px; margin: 4px auto 0; border: 1px solid #75828d; border-radius: 8px; background: #202b38; color: #faf8f3; font: inherit; cursor: pointer; }
.catalogue-retry[hidden] { display: none; }
.ready-friends { display: block; max-width: 26ch; margin: 14px auto 0; color: #c8d0d7; font-size: .95rem; }
.modal-box { max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
#resultPrimaryActions { margin-bottom: 20px; }
#resultPrimaryActions .btn { margin-top: 0; }
.result-end { border: 0; color: #c8d0d7; }
.quick-players:focus-visible, .game-options > summary:focus-visible, .play-preference > summary:focus-visible { outline: 3px solid #d7ec72; outline-offset: 3px; }
@media (max-width: 620px) and (orientation: portrait) {
    #setupScreen.active { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
    .game-brand { margin-bottom: 16px; }
    .setup-heading { margin-bottom: 14px; }
    #setupScreen .game-title { font-size: clamp(1.9rem, 7vw, 2.6rem); }
    #setupScreen .setup-intro { font-size: .88rem; margin-bottom: 16px; }
    #setupScreen:has(input:focus) .start-dock { position: static; padding: 12px 0 0; border-top: 0; background: transparent; }
}
@media (orientation: landscape) and (max-height: 500px) {
    .modal-box { padding: 20px; border-radius: 16px; }
    #rulesModal .modal-box { max-width: 680px; padding: 14px 20px; }
    #rulesModal h2 { font-size: 1.2rem; }
    #rulesModal ul { font-size: .9rem; line-height: 1.4 !important; margin-bottom: 12px !important; }
    #rulesModal .btn { min-height: 44px; padding: 10px 16px; }
    .container { justify-content: flex-start; }
    .screen { flex-shrink: 0; }
    .countdown-wrapper { padding-block: 12px; }
    #countdownPlayerName { margin-bottom: 12px !important; }
    #readyGate > p { margin-bottom: 14px !important; font-size: 1rem !important; }
    .ready-friends { max-width: none; margin-top: 8px; font-size: .85rem; }
}
@media (orientation: landscape) and (max-height: 500px) {
    #turnRevealModal .modal-box { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 4px 18px; padding: 14px 20px !important; text-align: left; }
    #turnRevealPicture { grid-column: 1; grid-row: 1 / 3; height: 92px !important; margin: 0 auto !important; }
    #turnRevealTitle { grid-column: 2; align-self: end; font-size: 1rem; }
    #turnRevealName { grid-column: 2; margin: 2px 0 !important; font-size: 1.5rem !important; }
    #turnRevealDetail { grid-column: 1 / -1; margin: 6px 0 !important; font-size: .82rem; }
    #turnRevealContinue { grid-column: 1 / -1; min-height: 44px; padding: 10px 16px; }
}
