/* ???????????????????????????????????????????????????????
   BOWLING SCORECARD  �  multi-ball editor panel
   ??????????????????????????????????????????????????????? */

/* ?? Outer shell ?? */
.bsc-outer {
    background: var(--bt-surface-card);
    border: 1px solid var(--bt-border);
    border-top: 3px solid var(--bt-orange);
    border-radius: var(--bt-radius-lg);
    box-shadow: var(--bt-shadow-md);
    overflow: hidden;
    font-family: 'Inter', 'Arial', sans-serif;
}

/* ?? Bowler name bar ?? */
.bsc-namebar {
    background: linear-gradient(110deg, #0e1016 0%, #1f2235 100%);
    border-bottom: 1px solid rgba(255,109,46,.25);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bt-text-light);
    font-size: 0.82rem;
}
.bsc-namebar-label  { text-transform:uppercase; letter-spacing:.08em; color:var(--bt-amber); font-size:0.7rem; font-weight:700; opacity:.75; }
.bsc-namebar-name   { font-weight:700; font-size:1rem; color:#fff; }
.bsc-namebar-league { font-size:0.78rem; color:rgba(255,255,255,.5); }
.bsc-total-display  { font-size:0.85rem; color:rgba(255,255,255,.65); }
.bsc-total-display strong { font-size:1.25rem; color:var(--bt-orange-glow); }

/* ?? Frame columns container ?? */
.bsc-frames {
    display: flex;
    width: 100%;
    overflow-x: auto;
    min-width: 0;
}

/* ?? Individual frame column ?? */
.bsc-frame {
    flex: 1 1 0;
    min-width: 62px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--bt-border);
    background: var(--bt-surface-card);
    transition: background var(--bt-transition), outline var(--bt-transition);
    cursor: pointer;
    user-select: none;
}
.bsc-frame:last-child { border-right: none; }
.bsc-frame-10 { flex: 1.7 1 0; min-width: 96px; }

.bsc-frame:hover { background: rgba(255,109,46,.05); }

/* Locked frame � previous frame not yet complete */
.bsc-frame-locked {
    opacity: 0.45;
    cursor: not-allowed !important;
    background: var(--bt-surface) !important;
}
.bsc-frame-locked:hover {
    background: var(--bt-surface) !important;
}
.bsc-frame-locked .bsc-frame-num {
    color: var(--bt-muted);
}

/* Tints */
.bsc-frame-strike { background: #fff8f3; }
.bsc-frame-spare  { background: #f3f6ff; }

/* Selected frame highlight */
.bsc-frame-selected {
    outline: 2px solid var(--bt-orange);
    outline-offset: -2px;
    background: #fff3ea !important;
    position: relative;
    z-index: 1;
}

/* Frame number header */
.bsc-frame-num {
    background: var(--bt-bg-mid);
    border-bottom: 2px solid var(--bt-orange-deep);
    text-align: center;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: .06em;
    color: var(--bt-amber);
    padding: 0.25rem 0 0.2rem;
    text-transform: uppercase;
}

/* ?? Ball display boxes in the scorecard grid ?? */
.bsc-balls {
    display: flex;
    justify-content: flex-end;
}
.bsc-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 34px;
    color: var(--bt-text);
    font-size: 1.45rem;
    font-family: 'Courier New', monospace;
    user-select: none;
}
.bsc-ball-strike { color: var(--bt-orange-deep) !important; background: #fff7ee !important; font-size: 1.7rem !important; }
.bsc-ball-spare  { color: #1a6faa !important; background: #eef6fd !important; }
.bsc-ball-miss   { color: var(--bt-muted) !important; }
.bsc-ball-2      { border-left: 1px solid var(--bt-border); }
.bsc-ball-3      { border-left: 2px solid var(--bt-orange); }
.bsc-frame[data-frame="9"] #bdisp_9_1 { border-left: 0; }

/* ?? Cumulative score ?? */
.bsc-score {
    text-align: center;
    font-size: 2.85rem;
    color: var(--bt-text);
    padding: 0.2rem 0.1rem;
    min-height: 2.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 1px solid var(--bt-border);
    background: #fff;
}
.bsc-score-perfect { color: var(--bt-orange-deep) !important; text-shadow: 0 0 12px rgba(255,109,46,.35) !important; }

/* ???????????????????????????????????????????????????????
   EDITOR PANEL
   ??????????????????????????????????????????????????????? */
/* Positioning context so the popup panel can be absolute within the section */
#pinfallSection { position: relative; }

.bsc-editor-panel {
    position: absolute;
    z-index: 500;
    width: 380px;
    background: var(--bt-surface-card);
    border: 1px solid var(--bt-border);
    border-top: 3px solid var(--bt-orange);
    border-radius: var(--bt-radius-lg);
    box-shadow: 0 8px 30px rgba(0,0,0,.3);
    overflow: hidden;
    display: none; /* hidden until a frame is selected */
    flex-direction: column;
    font-family: 'Inter', 'Arial', sans-serif;
}

/* Header bar */
.bsc-editor-header {
    background: linear-gradient(110deg, #0e1016 0%, #1f2235 100%);
    border-bottom: 1px solid rgba(255,109,46,.25);
    padding: 0.45rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: .03em;
}

/* Close button */
.bsc-editor-close {
    width: 26px; height: 26px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 5px;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--bt-transition);
    flex-shrink: 0;
    margin-left: auto;
    padding: 0;
}
.bsc-editor-close:hover { background: rgba(220,53,69,.6); border-color: #dc3545; }

/* ?? Ball columns row ?? */
.bsc-editor-balls {
    display: flex;
    width: 100%;
    gap: 0;
    background: var(--bt-surface);
    min-height: 220px; /* keeps panel stable while no frame is selected */
}

/* Each ball column */
.bsc-ball-col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--bt-border);
    background: var(--bt-surface);
    transition: background var(--bt-transition);
    cursor: pointer;
}
.bsc-ball-col:last-child { border-right: none; }

/* Active (selected) ball column */
.bsc-ball-col-active {
    background: #fff3ea;
    outline: none; /* outline handled by header highlight */
}

/* Blocked ball column (B1 not entered yet, or strike in fr 1-9) */
.bsc-ball-col-blocked {
    opacity: 0.38;
    pointer-events: none;
    position: relative;
}
.bsc-ball-col-blocked::after {
    content: '';
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
        -45deg, transparent, transparent 5px,
        rgba(0,0,0,.05) 5px, rgba(0,0,0,.05) 10px
    );
    pointer-events: none;
}

/* Ball column header tab */
.bsc-ball-col-hdr {
    background: rgb(33, 33, 33, .57);
    width: 100%;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: black; x:var(--bt-muted);
    padding: 5px 4px 4px;
    border-bottom: 2px solid transparent;
    xbackground: var(--bt-bg-mid);
    user-select: none;
    transition: color var(--bt-transition), border-color var(--bt-transition), background var(--bt-transition);
}
.bsc-ball-col-hdr.active,
.bsc-ball-col-active .bsc-ball-col-hdr {
    color: var(--bt-orange-deep);
    border-bottom-color: var(--bt-orange);
    background: #fff3ea;
}
.bsc-ball-col-hdr:hover:not(.active) { color: var(--bt-text); background: rgba(255,109,46,.07); }

/* Pin diagram within a ball column */
.bsc-ball-col-pins {
    padding: 10px 8px 20px;
    display: flex;
    justify-content: center;
    width: 100%;
}
.bsc-pin-svg-lg {
    width: 100%;
    max-width: 200px;
    display: block;
}

/* Pin circles */
.bsc-pin-lg                                              { transition: fill .12s; }
.bsc-pin-lg:not(.bsc-pin-up):not(.bsc-pin-down):not(.bsc-pin-locked) {
    fill: #dde3ed; stroke: #aab4c8; stroke-width: 1.2;
}
.bsc-pin-lg.bsc-pin-up {
    fill: #fff;
    stroke: var(--bt-orange);
    stroke-width: 1.6;
    filter: drop-shadow(0 0 3px rgba(255,109,46,.5));
}
.bsc-pin-lg.bsc-pin-down   { fill: #dde1ec; stroke: #c5cad8; stroke-width:1.2; opacity:.45; }
.bsc-pin-lg.bsc-pin-locked { fill:#c8cdd9!important; stroke:#b0b6c4!important; opacity:.22!important; cursor:default!important; }

/* Side action buttons flanking the pin SVG */
.bsc-ball-col-body {
    display: flex;
    align-items: stretch;
    padding-bottom: 10px;
}
.bsc-act-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px;
}
.bsc-act-side-right {
    justify-content: center;
}
.bsc-act-btn {
    min-width: 44px; height: 34px;
    font-size: 1rem; font-weight: 900;
    font-family: 'Courier New', monospace;
    border-radius: var(--bt-radius);
    border: 1px solid var(--bt-border);
    background: #fff; color: var(--bt-text);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background var(--bt-transition), border-color var(--bt-transition), box-shadow var(--bt-transition);
    padding: 0 8px;
}
.bsc-act-btn:hover         { background: var(--bt-surface); border-color: var(--bt-orange); }
.bsc-act-btn[disabled]     { opacity:.35; cursor:not-allowed; pointer-events:none; }
.bsc-act-strike            { color:var(--bt-orange-deep); border-color:var(--bt-amber); background:#fff7ee; }
.bsc-act-strike:hover      { background:#ffe8d0; border-color:var(--bt-orange); box-shadow:0 0 6px rgba(255,109,46,.3); }
.bsc-act-spare             { color:#1a6faa; border-color:#9ecbe8; background:#eef6fd; }
.bsc-act-spare:hover       { background:#d6edf9; border-color:#5aaad4; }
.bsc-act-miss              { color:var(--bt-muted); }
.bsc-act-miss:hover        { color:var(--bt-text); border-color:var(--bt-muted); }
.bsc-act-next              { color:#2e7d32; border-color:#a5d6a7; background:#f1f8f1; flex-shrink:0; }
.bsc-act-next:hover        { background:#d4edda; border-color:#4caf50; }

/* ?? Frame notes (multiline) ?? */
.bsc-editor-notes {
    width: 100%;
    padding: 6px 12px 10px;
    background: var(--bt-surface-card);
    border-top: 1px solid var(--bt-border);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.bsc-notes-lbl {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--bt-muted);
}
.bsc-frame-note {
    width: 100%;
    background: #fff;
    border: 1px solid var(--bt-border);
    border-radius: 4px;
    color: var(--bt-text);
    font-size: 0.85rem;
    padding: 5px 8px;
    outline: none;
    resize: vertical;
    transition: border-color var(--bt-transition);
    font-family: 'Inter', 'Arial', sans-serif;
}
.bsc-frame-note:focus     { border-color: var(--bt-orange); box-shadow: 0 0 0 2px rgba(255,109,46,.15); }
.bsc-frame-note[readonly] { opacity:.65; cursor:default; background: var(--bt-surface); }

/* ?? Page header ?? */
.bt-page-header {
    background: var(--bt-surface-card);
    border: 1px solid var(--bt-border);
    border-radius: var(--bt-radius-lg);
    padding: 0.85rem 1rem;
    box-shadow: var(--bt-shadow-sm);
}
.text-orange { color: var(--bt-orange) !important; }

/* ?? Mini pin diagram in read-only scorecard ball cells ?? */
.bsc-ball-pins  { padding: 1px; overflow: hidden; }
.bsc-pin-mini-svg { display: block; }  /* size is set via width/height attrs */

/* ?? Print-only frame notes list ?? */
.bsc-print-frame-notes { display: none; }
.bsc-print-notes-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: #666;
    margin-bottom: 2px;
}
.bsc-print-frame-note-line {
    margin: 0 0 2px 0;
    font-size: 0.88rem;
    color: #222;
    white-space: pre-wrap;
}

/* ?? Print ?? */
@media print {
    .suppress-print   { display: none !important; }
    .bsc-editor-panel { display: none !important; }
    .bsc-outer        { box-shadow: none; border: 1px solid #ccc; border-top: 3px solid #d94f10; }
    .bsc-print-frame-notes { display: block; margin-top: 0.6rem; }
}

/* ?? Responsive ?? */
@media (max-width: 600px) {
    .bsc-frame    { min-width: 44px; }
    .bsc-frame-10 { min-width: 76px; }
    .bsc-ball     { height: 28px; font-size: 1.05rem; }
    .bsc-score    { font-size: 1.15rem; min-height: 2rem; }
    .bsc-pin-svg-lg  { max-width: 140px; }
    .bsc-pin-mini-svg { max-height: 22px; }
    .bsc-act-btn    { min-width: 36px; height: 30px; font-size: 0.88rem; }
}

/* ?? Editor panel: locked-frame placeholder message ?? */
.bsc-frame-locked-msg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: var(--bt-muted);
    font-size: 0.88rem;
    font-style: italic;
    text-align: center;
}

/* ?? Week-scorecard notes panel (WeekScorecard.cshtml) ?? */
.wsc-notes-panel {
    border-top: 1px solid var(--bt-border);
    background: #fafafa;
    padding: 0.55rem 1rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* ?? Week-scorecard notes section (below all scorecards) ?? */
.wsc-notes-section {
    background: var(--bt-surface-card);
    border: 1px solid var(--bt-border);
    border-top: 3px solid var(--bt-orange);
    border-radius: var(--bt-radius-lg);
    overflow: hidden;
}

.wsc-notes-section-heading {
    background: linear-gradient(110deg, #0e1016 0%, #1f2235 100%);
    border-bottom: 1px solid rgba(255,109,46,.25);
    padding: 0.45rem 1rem;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: .04em;
}

.wsc-notes-game-block {
    padding: 0.6rem 1rem 0.7rem;
    border-bottom: 1px solid var(--bt-border);
}
.wsc-notes-game-block:last-child {
    border-bottom: none;
}

.wsc-notes-game-heading {
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--bt-orange-deep);
    margin-bottom: 0.35rem;
}

@media print {
    .wsc-notes-panel { background: #fff; border-top: 1px solid #ccc; }
    .wsc-frame-num-badge { background: #666; }
    .wsc-notes-section { border: 1px solid #ccc; border-top: 3px solid #d94f10; box-shadow: none; }
    .wsc-notes-section-heading { background: #333; }
    .wsc-notes-game-block { border-bottom-color: #ddd; }
}
