/* scoreBoard.css
   CURRENT SCORE BOARD pop-up (scoreBoard.js). Its colours follow
   V-PopupStyle (the colour sets and the frame are shared with Records and
   History, recordsHistory.css), through the class popupStyles.js puts on #wargrid-viewport:
       A -> popstyle-console | B -> popstyle-fieldmanual | C -> popstyle-nightops
   Sized so a 6-round game fits without scrolling. */

/* ---------- Style A: Command Console (default) ---------- */
#POP-ScoreBoard,
#POP-RecordsHistory {
    --sb-bg: linear-gradient(180deg, #153d11, #0d290a);
    --sb-solid: #123510;
    --sb-border: 3px solid #a3915e;
    --sb-shadow: 0 0 0 1px #000, inset 0 0 0 2px #0a1a07, 0 18px 60px rgba(0, 0, 0, .75);
    --sb-ink: #f1edd5;
    --sb-title-font: 'Freeman', sans-serif;
    --sb-track: .05em;
    --sb-title: #f2d16b;
    --sb-title2: #f2d16b;
    --sb-head-bg: linear-gradient(180deg, #0b130a, #050905);
    --sb-line: 2px solid #5e5536;
    --sb-x-border: 2px solid #a3915e;
    --sb-grid: #7a6d45;
    --sb-who-ink: #fff;
    --sb-you-bg: #24601a;
    --sb-opp-bg: #6b2412;
    --sb-tag: #f2d16b;
    --sb-ch-bg: #071406;
    --sb-ch-ink: #f2d16b;
    --sb-alt: rgba(0, 0, 0, .25);
    --sb-accent: #f2d16b;
    --sb-label: #d8cf9f;
    --sb-foot-bg: rgba(0, 0, 0, .3);
    --sb-grand-bg: #2b2a10;
    --sb-strong: #a3915e;
    --sb-win-bg: #3fae3a;
    --sb-win-ink: #06200a;
    --sb-lose-bg: #a3261a;
    --sb-lose-ink: #fff;
    --sb-drawn-bg: #a3915e;
    --sb-drawn-ink: #050905;
    /* The loser's section at game end: dark red */
    --sb-lost-bar: #7a1a12;
    --sb-lost-head-bg: #4f130c;
    --sb-lost-head-ink: #ffd2c6;
    --sb-lost-foot-bg: rgba(150, 30, 20, .3);
    --sb-lost-label: #ffc2b4;
    --sb-lost-grand-bg: #5c160e;
    --sb-lost-accent: #ffb4a3;
}

/* ---------- Style B: Field Manual ---------- */
.popstyle-fieldmanual #POP-ScoreBoard,
.popstyle-fieldmanual #POP-RecordsHistory {
    --sb-bg:
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(80, 96, 40, .08) 31px 32px),
        repeating-linear-gradient(90deg, transparent 0 31px, rgba(80, 96, 40, .08) 31px 32px),
        #efe7cd;
    --sb-solid: #efe7cd;
    --sb-border: 4px solid #3f4b22;
    --sb-shadow: inset 0 0 0 2px #c9b98a, 0 18px 60px rgba(0, 0, 0, .7);
    --sb-ink: #22290f;
    --sb-track: .06em;
    --sb-title: #f4ecd0;
    --sb-title2: #3f4b22;
    --sb-head-bg: #3f4b22;
    --sb-line: 2px solid #c9b98a;
    --sb-x-border: 2px solid #c9b98a;
    --sb-grid: #8f8259;
    --sb-who-ink: #f4ecd0;
    --sb-you-bg: #55672b;
    --sb-opp-bg: #8a2414;
    --sb-tag: #f4e3a8;
    --sb-ch-bg: #d9cda3;
    --sb-ch-ink: #2c3517;
    --sb-alt: rgba(63, 75, 34, .08);
    --sb-accent: #7a1f0f;
    --sb-label: #3f4b22;
    --sb-foot-bg: #e6dcb8;
    --sb-grand-bg: #d4c58f;
    --sb-strong: #3f4b22;
    --sb-win-bg: #3f6b1f;
    --sb-win-ink: #f4ecd0;
    --sb-lose-bg: #f4ecd0;          /* Light: it sits on the red opponent header */
    --sb-lose-ink: #8a2414;
    --sb-drawn-bg: #c9b98a;
    --sb-drawn-ink: #22290f;
    --sb-lost-bar: #8a2414;
    --sb-lost-head-bg: #8a2414;
    --sb-lost-head-ink: #fff4e4;
    --sb-lost-foot-bg: rgba(138, 36, 20, .14);
    --sb-lost-label: #7a1f0f;
    --sb-lost-grand-bg: #e3bcae;
    --sb-lost-accent: #7a1f0f;
}

/* ---------- Style C: Night Ops HUD ---------- */
.popstyle-nightops #POP-ScoreBoard,
.popstyle-nightops #POP-RecordsHistory {
    --sb-bg:
        repeating-linear-gradient(0deg, rgba(120, 255, 150, .035) 0 1px, transparent 1px 4px),
        #040c07;
    --sb-solid: #040c07;
    --sb-border: 2px solid rgba(120, 255, 150, .55);
    --sb-shadow: 0 0 24px rgba(90, 255, 130, .18), 0 18px 60px rgba(0, 0, 0, .8);
    --sb-ink: #d6f5dc;
    --sb-title-font: 'Share Tech Mono', 'Roboto Condensed', monospace;
    --sb-track: .12em;
    --sb-title: #7dff9a;
    --sb-title2: #7dff9a;
    --sb-head-bg: rgba(120, 255, 150, .07);
    --sb-line: 1px solid rgba(120, 255, 150, .3);
    --sb-x-border: 1px solid rgba(120, 255, 150, .55);
    --sb-grid: rgba(120, 255, 150, .35);
    --sb-who-ink: #eafff0;
    --sb-you-bg: rgba(125, 255, 154, .18);
    --sb-opp-bg: rgba(255, 176, 46, .16);
    --sb-tag: #ffb02e;
    --sb-ch-bg: rgba(120, 255, 150, .08);
    --sb-ch-ink: #7dff9a;
    --sb-alt: rgba(120, 255, 150, .04);
    --sb-accent: #7dff9a;
    --sb-label: #9fd8ad;
    --sb-foot-bg: rgba(0, 0, 0, .35);
    --sb-grand-bg: rgba(125, 255, 154, .1);
    --sb-strong: #7dff9a;
    --sb-win-bg: #7dff9a;
    --sb-win-ink: #031006;
    --sb-lose-bg: #b3261e;
    --sb-lose-ink: #fff;
    --sb-drawn-bg: #ffb02e;
    --sb-drawn-ink: #031006;
    --sb-lost-bar: #6e1a14;
    --sb-lost-head-bg: #3d0d0a;
    --sb-lost-head-ink: #ff9a8a;
    --sb-lost-foot-bg: rgba(255, 80, 60, .1);
    --sb-lost-label: #ff9a8a;
    --sb-lost-grand-bg: rgba(255, 80, 60, .22);
    --sb-lost-accent: #ff9a8a;
}

/* ---------- Frame (shared with Records and History) ---------- */
#POP-ScoreBoard,
#POP-RecordsHistory {
    position: absolute;
    z-index: 5500;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    background: var(--sb-bg);
    border: var(--sb-border);
    box-shadow: var(--sb-shadow);
    color: var(--sb-ink);
    font-family: 'Roboto Condensed', sans-serif;
    pointer-events: auto;
}

#POP-ScoreBoard .sb-head,
#POP-RecordsHistory .sb-head {
    display: flex;
    align-items: baseline;
    gap: 24px;
    padding: 6px 18px;
    background: var(--sb-head-bg);
    border-bottom: var(--sb-line);
}
#POP-ScoreBoard .sb-title,
#POP-RecordsHistory .sb-title {
    font-family: var(--sb-title-font, 'Freeman', sans-serif);
    font-size: 30px;
    font-weight: bold;
    letter-spacing: var(--sb-track);
    color: var(--sb-title);
}
#POP-ScoreBoard .sb-sub,
#POP-RecordsHistory .sb-sub {
    flex: 1;
    font-size: 22px;
    color: var(--sb-title);
    opacity: .85;
}
#POP-ScoreBoard .sb-close,
#POP-RecordsHistory .sb-close {
    align-self: center;
    padding: 2px 9px;
    border: var(--sb-x-border);
    color: var(--sb-title);
    font: 26px Arial, sans-serif;
    cursor: pointer;
}
#POP-ScoreBoard .sb-close:hover,
#POP-RecordsHistory .sb-close:hover { filter: brightness(1.25); }

/* Longer games scroll under the fixed headings. */
#POP-ScoreBoard .sb-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 18px 12px;
    scrollbar-width: thin;
}

/* ---------- Round table ---------- */
#POP-ScoreBoard table { border-collapse: collapse; color: var(--sb-ink); }
#POP-ScoreBoard .sb-table { width: 100%; table-layout: fixed; font-size: 22px; }
#POP-ScoreBoard .sb-c-round { width: 84px; }
#POP-ScoreBoard .sb-c-gap { width: 18px; }

#POP-ScoreBoard .sb-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--sb-solid);
    box-shadow: 0 -10px 0 var(--sb-solid);   /* Covers the body's top padding while scrolling */
}
#POP-ScoreBoard .sb-table thead tr:first-child th { border-top: 10px solid var(--sb-solid); }

#POP-ScoreBoard .sb-table th,
#POP-ScoreBoard .sb-table td {
    border: 1.5px solid var(--sb-grid);
    padding: 1px 4px;
    text-align: center;
    line-height: 1.12;
}
#POP-ScoreBoard .sb-table .sb-gap {
    border: none !important;
    background: transparent !important;
}

#POP-ScoreBoard .sb-who {
    text-align: left !important;
    padding: 4px 10px !important;
    font-size: 25px;
    font-weight: bold;
    color: var(--sb-who-ink);
    white-space: nowrap;
}
#POP-ScoreBoard .sb-who.you { background: var(--sb-you-bg); }
#POP-ScoreBoard .sb-who.opp { background: var(--sb-opp-bg); }
#POP-ScoreBoard .sb-who.lost { background: var(--sb-lost-bar); }
#POP-ScoreBoard .sb-name { display: inline-block; max-width: 52%; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
#POP-ScoreBoard .sb-tag { float: right; font-size: 22px; font-weight: normal; color: var(--sb-tag); }

#POP-ScoreBoard .sb-badge {
    display: inline-block;
    margin-left: 16px;
    padding: 0 12px;
    font-size: 21px;
    letter-spacing: 2px;
    border-radius: 2px;
    vertical-align: 2px;
}
#POP-ScoreBoard .sb-badge.win { background: var(--sb-win-bg); color: var(--sb-win-ink); }
#POP-ScoreBoard .sb-badge.lose { background: var(--sb-lose-bg); color: var(--sb-lose-ink); }
#POP-ScoreBoard .sb-badge.drawn { background: var(--sb-drawn-bg); color: var(--sb-drawn-ink); }

#POP-ScoreBoard .sb-heads th {
    font-size: 23px;
    font-weight: bold;
    font-style: italic;
    color: var(--sb-ch-ink);
    background: var(--sb-ch-bg);
    padding: 2px;
    line-height: 1.05;
    white-space: pre-line;
}

#POP-ScoreBoard .sb-round { font-weight: bold; color: var(--sb-title2); }
#POP-ScoreBoard tr.sb-alt td:not(.sb-gap) { background: var(--sb-alt); }
#POP-ScoreBoard .sb-tot { font-weight: bold; color: var(--sb-accent); }
#POP-ScoreBoard .sb-nil { opacity: .6; }

#POP-ScoreBoard tr.sb-space td { border: none; height: 5px; }
#POP-ScoreBoard tr.sb-foot td:not(.sb-gap) { background: var(--sb-foot-bg); }
#POP-ScoreBoard td.sb-label { text-align: right; font-style: italic; color: var(--sb-label); padding-right: 10px; }
#POP-ScoreBoard td.sb-value { font-weight: bold; color: var(--sb-accent); }
#POP-ScoreBoard tr.sb-grand td:not(.sb-gap) {
    font-size: 25px;
    font-weight: bold;
    font-style: normal;
    color: var(--sb-accent);
    background: var(--sb-grand-bg);
    border-top: 3px solid var(--sb-strong);
}

/* The tie-break line under TOTAL POINTS (level totals only). */
#POP-ScoreBoard tr.sb-tiebreak td {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    color: var(--sb-accent);
    background: var(--sb-foot-bg);
    padding: 6px 4px;
}

/* ---------- Scoring formula and notes ---------- */
/* The chart is as tall as the notes beside it. */
#POP-ScoreBoard .sb-bottom {
    display: flex;
    gap: 22px;
    align-items: stretch;
}
#POP-ScoreBoard .sb-ftitle {
    margin: 10px 0 4px;
    font-family: var(--sb-title-font, 'Freeman', sans-serif);
    font-size: 24px;
    font-weight: bold;
    letter-spacing: var(--sb-track);
    color: var(--sb-title2);
}
#POP-ScoreBoard .sb-formula { flex: none; font-size: 22px; }
#POP-ScoreBoard .sb-formula th,
#POP-ScoreBoard .sb-formula td {
    border: 1.5px solid var(--sb-grid);
    width: 44px;
    padding: 1px 6px;
    text-align: center;
}
#POP-ScoreBoard .sb-formula th {
    font-size: 23px;
    font-weight: bold;
    font-style: italic;
    background: var(--sb-ch-bg);
    color: var(--sb-ch-ink);
}
#POP-ScoreBoard .sb-flabel {
    text-align: left !important;
    font-style: italic;
    font-weight: bold;
    color: var(--sb-label);
    white-space: nowrap;
}
#POP-ScoreBoard .sb-notes {
    flex: 1;
    margin: 0;
    padding-left: 22px;
    font-size: 21px;
    line-height: 1.3;
}
#POP-ScoreBoard .sb-notes b { color: var(--sb-title2); }

/* ---------- The loser's section at game end (dark red) ---------- */
#POP-ScoreBoard .sb-heads th.sb-lost {
    background: var(--sb-lost-head-bg);
    color: var(--sb-lost-head-ink);
}
#POP-ScoreBoard tr.sb-foot td.sb-lost { background: var(--sb-lost-foot-bg); }
#POP-ScoreBoard td.sb-label.sb-lost { color: var(--sb-lost-label); }
#POP-ScoreBoard td.sb-value.sb-lost { color: var(--sb-lost-accent); }
#POP-ScoreBoard tr.sb-grand td.sb-lost {
    background: var(--sb-lost-grand-bg);
    color: var(--sb-lost-accent);
    border-top-color: var(--sb-lost-accent);
}

/* ---------- Mobile (scoreBoard.js: .sb-mobile) ----------
   One side under the other, then the formula and notes; the whole board
   scrolls under the menu. Sizes for a phone (900-wide stage). */
#POP-ScoreBoard.sb-mobile {
    left: 8px;
    top: 150px;
    width: 884px;
    height: 1350px;
}
#POP-ScoreBoard.sb-mobile .sb-head {
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 16px;
    padding: 10px 16px;
}
#POP-ScoreBoard.sb-mobile .sb-title { font-size: 44px; flex: 1; }
#POP-ScoreBoard.sb-mobile .sb-close {
    order: 2;
    width: 60px;
    height: 60px;
    box-sizing: border-box;
    padding: 0;
    text-align: center;
    font: 700 38px/54px 'Roboto Condensed', sans-serif;
}
#POP-ScoreBoard.sb-mobile .sb-sub { order: 3; flex-basis: 100%; font-size: 30px; }
#POP-ScoreBoard.sb-mobile .sb-body { padding: 0 12px 24px; scrollbar-width: none; }
#POP-ScoreBoard.sb-mobile .sb-body::-webkit-scrollbar { display: none; }
#POP-ScoreBoard.sb-mobile .sb-side { font-size: 36px; margin-bottom: 26px; }
#POP-ScoreBoard.sb-mobile .sb-c-round { width: 88px; }
#POP-ScoreBoard.sb-mobile .sb-table th,
#POP-ScoreBoard.sb-mobile .sb-table td { padding: 3px 4px; }
#POP-ScoreBoard.sb-mobile .sb-who { font-size: 36px; padding: 6px 12px !important; }
#POP-ScoreBoard.sb-mobile .sb-name { max-width: 60%; }
#POP-ScoreBoard.sb-mobile .sb-tag { font-size: 30px; line-height: 44px; }
#POP-ScoreBoard.sb-mobile .sb-badge { font-size: 28px; }
#POP-ScoreBoard.sb-mobile .sb-heads th { font-size: 30px; }
#POP-ScoreBoard.sb-mobile td.sb-label { font-size: 32px; }
#POP-ScoreBoard.sb-mobile tr.sb-grand td { font-size: 38px; }
#POP-ScoreBoard.sb-mobile .sb-tieline {
    margin: -10px 0 20px;
    padding: 8px;
    text-align: center;
    font-size: 32px;
    font-weight: bold;
    color: var(--sb-accent);
    background: var(--sb-foot-bg);
}
#POP-ScoreBoard.sb-mobile .sb-ftitle { font-size: 36px; margin: 6px 0 10px; }
#POP-ScoreBoard.sb-mobile .sb-bottom { flex-direction: column; gap: 20px; }
#POP-ScoreBoard.sb-mobile .sb-formula { width: 100%; font-size: 32px; }
#POP-ScoreBoard.sb-mobile .sb-notes { font-size: 30px; line-height: 1.3; margin: 0; }
#POP-ScoreBoard.sb-mobile .sb-formula th { font-size: 30px; }
/* Two tables one under the other: their headings scroll with them. */
#POP-ScoreBoard.sb-mobile .sb-table thead { position: static; box-shadow: none; }
