/* DL2CC Pileup — web port of the desktop FormPileUpCompetition in the
   desktop's V2 dark-console skin (ClassRemoteControlV2Theme): graphite
   panels, engraved caption labels, amber digit readouts, LED-tinted result
   rows. A serious competition instrument, not an arcade game. */

:root {
    --panel: #1c1f26;         /* PanelBase rgb(28,31,38) — form background */
    --chrome: #2e333f;        /* ChromeBar rgb(46,51,63) */
    --surface: #21252d;       /* Surface rgb(33,37,45) — cards, rows */
    --surface-alt: #1d2128;   /* SurfaceAlternate rgb(29,33,40) */
    --divider: #343842;       /* SurfaceDivider rgb(52,56,66) */
    --border: #545b6e;        /* WindowBorder rgb(84,91,110) */
    --engraved: #aaaaaf;      /* EngravedLight rgb(170,170,175) — captions */
    --engraved-dim: #6e6e76;  /* EngravedDim rgb(110,110,118) */
    --text: #d7d8de;          /* TextPrimary rgb(215,216,222) */
    --text-strong: #ebecf0;   /* TextStrong rgb(235,236,240) */
    --well: #0a0d12;          /* ReadoutWell rgb(10,13,18) — digit wells */
    --btn-text: #dcdce1;      /* ButtonText rgb(220,220,225) */
    --btn-active: #ffc85a;    /* ButtonTextActive rgb(255,200,90) */
    --amber: #ffb230;         /* DigitActive rgb(255,178,48) — value readouts */
    --brand: #ffbe5a;         /* ChromeBrandText rgb(255,190,90) */
    --green-on: #64f582;      /* LedGreenOn rgb(100,245,130) */
    --green-off: #16341c;     /* LedGreenOff rgb(22,52,28) */
    --red-on: #ff5a46;        /* LedRedOn rgb(255,90,70) */
    --red-off: #341412;       /* LedRedOff rgb(52,20,18) */
    --mono: Consolas, "Cascadia Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--panel);
    color: var(--text);
    font-size: 15px;
    display: flex;
    flex-direction: column;
}

.app {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px 0;
    min-height: 0;
}

/* ── Header (site chrome, matches the other apps) ──────────────── */

.app-header {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--divider); padding-bottom: 10px; margin-bottom: 10px;
    flex: 0 0 auto;
}
.app-header h1 { font-size: 1.15rem; margin: 0; flex: 0 0 auto; color: var(--text-strong); }
.app-nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }

.nav-switch {
    align-self: center;
    color: var(--engraved-dim);
    padding: 6px 8px;
    font-size: .9rem;
    text-decoration: none;
    white-space: nowrap;
}
.nav-switch:hover { color: var(--text); text-decoration: underline; }

/* ── Console: chrome bar + shell ───────────────────────────────── */

.console {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.game-shell {
    flex: 1 1 auto;
    display: flex;
    gap: 1px;
    min-height: 480px;
    background: var(--divider);   /* hairline between panel and board */
    overflow: hidden;
}

.arcade-sidebar {
    position: relative;
    flex: 0 0 180px;
    background: var(--panel);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: var(--mono);
}

.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
}

/* ── Panel building blocks ─────────────────────────────────────── */

.arcade-title-row {
    display: flex; align-items: center; justify-content: space-between;
    min-height: 28px;
}
.arcade-title {
    flex: 1 1 auto;
    color: var(--engraved-dim);
    font-weight: 700;
    font-size: .66rem;
    letter-spacing: .22em;
}

.arcade-sep { border: none; border-top: 1px solid var(--divider); margin: 5px 0; width: 100%; }

.arcade-stat { display: flex; flex-direction: column; gap: 1px; }
.cap {
    color: var(--engraved-dim);
    font-size: .64rem;
    letter-spacing: .12em;
}
.section-cap { margin-top: 9px; }
.val { font-weight: 700; line-height: 1.15; color: var(--amber); }
.val.big { font-size: 1.45rem; }
.val.mid { font-size: 1rem; color: var(--text); }

/* ── Buttons (flat machined faces, V2 rig-button styling) ──────── */

.arcade-primary {
    margin-top: 6px;
    background: linear-gradient(#2a2f3a, #232730);
    border: 1px solid var(--border);
    color: var(--btn-active);
    font-family: var(--mono);
    font-weight: 700;
    font-size: .88rem;
    letter-spacing: .06em;
    padding: 9px 0;
    border-radius: 4px;
    cursor: pointer;
}
.arcade-primary:hover { background: linear-gradient(#313848, #262b35); }
.arcade-primary:active { background: #20242c; }

.leaderboard-eligibility {
    margin-top: 4px;
    padding: 7px 8px;
    border-left: 3px solid var(--green-on);
    background: rgba(100, 245, 130, .06);
    color: var(--green-on);
    font-size: .58rem;
    font-weight: 700;
    line-height: 1.45;
    letter-spacing: .055em;
}
.leaderboard-eligibility.local-only {
    border-left-color: var(--amber);
    background: rgba(255, 178, 48, .06);
    color: var(--amber);
}

.arcade-btn {
    background: linear-gradient(#2a2f3a, #232730);
    border: 1px solid var(--divider);
    color: var(--btn-text);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1rem;
    width: 36px; height: 28px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1;
}
.arcade-btn:hover:not(:disabled) { border-color: var(--border); color: var(--text-strong); }
.arcade-btn:active:not(:disabled) { background: #20242c; }
.arcade-btn:disabled { color: #787c86; border-color: var(--surface-alt); cursor: not-allowed; opacity: .6; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.stepper-val {
    flex: 1 1 auto;
    text-align: center;
    color: var(--amber);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 1rem;
}
.stepper-val.small { font-size: .8rem; }

.toggle-row { display: flex; gap: 4px; }
.arcade-toggle {
    flex: 1 1 0;
    background: var(--surface-alt);
    border: 1px solid var(--divider);
    color: var(--engraved-dim);
    font-family: var(--mono);
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .08em;
    padding: 7px 0;
    border-radius: 4px;
    cursor: pointer;
}
.arcade-toggle.active {
    background: var(--chrome);
    color: var(--btn-active);
    border-color: var(--border);
}
.arcade-toggle:disabled { opacity: .4; cursor: not-allowed; }

/* Sliders in console colours. */
#vol-slider, #width-slider {
    width: 100%;
    margin: 4px 0 8px;
    accent-color: var(--amber);
}
#width-row[hidden] { display: none; }
#val-width { color: var(--amber); }

/* ── Operating area (message, input line, results table) ───────── */

.board {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--panel);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 28px 20px 20px;
    overflow-y: auto;
    font-family: var(--mono);
}

.board-message {
    min-height: 1.4em;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-strong);
    text-align: center;
}
.board-message.ok { color: var(--green-on); }
.board-message.err { color: var(--red-on); }

/* The typed-callsigns line — digit well (ReadoutWell + DigitActive, the V2
   styling the desktop applies to TextBoxDecoded). */
.pileup-input {
    width: min(560px, 100%);
    min-height: 74px;
    background: var(--well);
    border: 1px solid var(--divider);
    border-radius: 6px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,.55);
    font-family: var(--mono);
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: .12em;
    color: var(--amber);
    text-transform: uppercase;
    text-align: center;
    padding: 8px 14px;
    outline: none;
    caret-color: var(--amber);
    transition: background-color .12s, border-color .12s;
}
.pileup-input:focus { border-color: var(--border); }
.pileup-input:disabled { color: #3a3f4a; cursor: not-allowed; }
.pileup-input::placeholder { color: #3a3f4a; }

.board-instructions {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: .85rem;
    color: var(--engraved-dim);
    text-align: center;
    max-width: 560px;
}

/* Results — revealed at run end; LED row tints like the desktop dgvResults
   (green = correct, red = wrong attempt, neutral = sent but never copied). */
.results-wrap {
    width: min(560px, 100%);
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--divider);
    border-radius: 6px;
}
.results-wrap[hidden] { display: none; }
.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
}
.results-table th {
    position: sticky; top: 0;
    background: var(--chrome);
    color: var(--engraved);
    font-size: .68rem;
    letter-spacing: .1em;
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--divider);
}
.results-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--surface-alt);
    color: var(--text);
    background: var(--surface);
    white-space: nowrap;
}
.results-table tr.correct td { background: var(--green-off); color: var(--green-on); }
.results-table tr.wrong td { background: var(--red-off); color: var(--red-on); }
.results-table tr.missed td { background: var(--surface); color: var(--text); }
.results-table td.num { text-align: right; }

/* ── Legal footer ──────────────────────────────────────────────── */

.legal-footer {
    flex: 0 0 auto;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
    font-size: .8rem; color: var(--engraved-dim);
}
.legal-footer a, .legal-footer a:visited { color: inherit; text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; }
.legal-footer .sep { color: var(--divider); }
.legal-footer .copy { margin-left: auto; }

/* ── Small screens: panel shrinks, shell stacks ────────────────── */

@media (max-width: 640px) {
    .app { padding: 8px 8px 0; }
    .game-shell { flex-direction: column; min-height: 0; }
    .arcade-sidebar { flex: 0 0 auto; max-height: 44vh; }
    .sidebar-scroll {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        align-items: start;
        column-gap: 8px;
    }
    .sidebar-scroll > * { grid-column: 1 / -1; }
    .sidebar-scroll > .arcade-stat { grid-column: auto; }
    .sidebar-scroll > .leaderboard-eligibility { grid-column: 1 / -1; }
    .board { flex: 1 1 auto; min-height: 320px; padding: 18px 10px 14px; }
    .pileup-input { font-size: 1.5rem; }
    .legal-footer .copy { margin-left: 0; flex-basis: 100%; }
}
