* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    text-align: left;
}

h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 24px;
}

.game-wrapper {
    background-color: white;
    border-radius: 10px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    gap: 24px;
    justify-content: flex-start;
    align-items: flex-start;
    flex-wrap: nowrap;
}



.sudoku-grid {
    display: grid;
    grid-template-columns: repeat(16, 50px);
    grid-template-rows: repeat(16, 50px);
    gap: 0px;
    background-color: #333;
    border: 3px solid #333;
    width: fit-content;
}

.cell {
    width: 50px;
    height: 50px;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    position: relative;
    border: 1px solid #ccc;
    cursor: pointer;
    outline: none;
    transition: background-color 0.15s ease;
}

/* Value display inside cell */
.cell-value {
    position: relative;
    z-index: 2;
    color: #1a237e;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.cell.conflict .cell-value {
    color: #ff1744;
    animation: conflictPop 0.25s ease;
}

/* ── Notes grid inside cell (4×4 for numbers 1-16) ────────────────── */
.notes-grid {
    display: none; /* shown via JS when notes exist */
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    z-index: 4;
    pointer-events: none;
    padding: 2px;
    background: transparent;
}


/* Notes grid in cells that carry a cage-sum label:
   The label sits at top:4px, is ~16px tall → offset the grid so digits don't hide behind it. */
.cell.has-cage-label .notes-grid {
    top: 17px;
    bottom: 0;
    padding: 1px 2px 2px 2px;
    grid-template-rows: repeat(4, 1fr);
}

.note-digit {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: 700;
    color: #1565c0;
    line-height: 1;
    user-select: none;
    overflow: hidden;
}

/* When notes are showing, hide the input text (managed via JS class) */


.cell:hover {
    background-color: rgba(255, 255, 200, 0.5) !important;
}



/* Cage background colors with transparency */
.cell.cage-color-1 { background-color: rgba(255, 99, 132, 0.25); }  /* Light pink */
.cell.cage-color-2 { background-color: rgba(54, 162, 235, 0.25); }  /* Light blue */
.cell.cage-color-3 { background-color: rgba(255, 206, 86, 0.25); }  /* Light yellow */
.cell.cage-color-4 { background-color: rgba(75, 192, 192, 0.25); }  /* Light teal */
.cell.cage-color-5 { background-color: rgba(153, 102, 255, 0.25); } /* Light purple */
.cell.cage-color-6 { background-color: rgba(255, 159, 64, 0.25); }  /* Light orange */
.cell.cage-color-7 { background-color: rgba(199, 199, 199, 0.25); } /* Light gray */
.cell.cage-color-8 { background-color: rgba(233, 30, 99, 0.2); }    /* Light pink 2 */
.cell.cage-color-9 { background-color: rgba(33, 150, 243, 0.2); }   /* Light blue 2 */
.cell.cage-color-10 { background-color: rgba(255, 235, 59, 0.25); } /* Light yellow 2 */
.cell.cage-color-11 { background-color: rgba(76, 175, 80, 0.25); }  /* Light green */
.cell.cage-color-12 { background-color: rgba(156, 39, 176, 0.2); }  /* Light purple 2 */
.cell.cage-color-13 { background-color: rgba(255, 87, 34, 0.2); }   /* Light orange 2 */
.cell.cage-color-14 { background-color: rgba(121, 85, 72, 0.2); }   /* Light brown */
.cell.cage-color-15 { background-color: rgba(158, 158, 158, 0.25); } /* Light gray 2 */
.cell.cage-color-16 { background-color: rgba(0, 150, 136, 0.2); }   /* Light teal 2 */

/* 4x4 subgrid borders - thick black lines */
.cell[row="3"], .cell[row="7"], .cell[row="11"] {
    border-bottom: 3px solid #000 !important;
}

.cell[col="3"], .cell[col="7"], .cell[col="11"] {
    border-right: 3px solid #000 !important;
}

/* Top row of each 4x4 block */
.cell[row="0"], .cell[row="4"], .cell[row="8"], .cell[row="12"] {
    border-top: 3px solid #000;
}

/* Left column of each 4x4 block */
.cell[col="0"], .cell[col="4"], .cell[col="8"], .cell[col="12"] {
    border-left: 3px solid #000;
}

/* Bottom row of the grid */
.cell[row="15"] {
    border-bottom: 3px solid #000;
}

/* Right column of the grid */
.cell[col="15"] {
    border-right: 3px solid #000;
}

/* Dotted cage borders - positioned inside cells */
.cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

/* Top cage border - 2px from top */
.cell.has-cage-border-top::before {
    border-top: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
}

/* Right cage border - 2px from right */
.cell.has-cage-border-right::before {
    border-right: 2px dotted #ff4444;
    top: 2px;
    right: 2px;
    bottom: 2px;
}

/* Bottom cage border - 2px from bottom */
.cell.has-cage-border-bottom::before {
    border-bottom: 2px dotted #ff4444;
    bottom: 2px;
    left: 2px;
    right: 2px;
}

/* Left cage border - 2px from left */
.cell.has-cage-border-left::before {
    border-left: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    bottom: 2px;
}

/* Handle corners */
.cell.has-cage-border-top.has-cage-border-left::before {
    border-top: 2px dotted #ff4444;
    border-left: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-top.has-cage-border-right::before {
    border-top: 2px dotted #ff4444;
    border-right: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-bottom.has-cage-border-left::before {
    border-bottom: 2px dotted #ff4444;
    border-left: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-bottom.has-cage-border-right::before {
    border-bottom: 2px dotted #ff4444;
    border-right: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

/* Three borders */
.cell.has-cage-border-top.has-cage-border-right.has-cage-border-bottom::before {
    border-top: 2px dotted #ff4444;
    border-right: 2px dotted #ff4444;
    border-bottom: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-top.has-cage-border-left.has-cage-border-bottom::before {
    border-top: 2px dotted #ff4444;
    border-left: 2px dotted #ff4444;
    border-bottom: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-top.has-cage-border-left.has-cage-border-right::before {
    border-top: 2px dotted #ff4444;
    border-left: 2px dotted #ff4444;
    border-right: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell.has-cage-border-bottom.has-cage-border-left.has-cage-border-right::before {
    border-bottom: 2px dotted #ff4444;
    border-left: 2px dotted #ff4444;
    border-right: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

/* All four borders */
.cell.has-cage-border-top.has-cage-border-right.has-cage-border-bottom.has-cage-border-left::before {
    border: 2px dotted #ff4444;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
}

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: left;
    font-size: 18px;
    font-weight: bold;
    background: transparent;
    z-index: 2;
    position: relative;
    cursor: pointer;
}

.cell input:focus {
    outline: 2px solid #4CAF50;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    z-index: 3;
}

/* Cage sum display */
.cage-sum {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 10px;
    color: #000;
    font-weight: bold;
    background-color: rgba(255, 255, 255, 0.85);
    padding: 1px 3px;
    border-radius: 3px;
    z-index: 5;
    border: 1px solid #ccc;
    pointer-events: none;
}

/* Help panel styles */
.help-panel {
    flex: 0 0 300px;
    max-height: 860px;
    overflow-y: auto;
    background-color: #f9f9f9;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    text-align: left;
    align-self: flex-start;
}

.help-panel h2 {
    color: #333;
    font-size: 20px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4CAF50;
}

.help-panel h3 {
    color: #666;
    font-size: 16px;
    margin: 15px 0 10px 0;
}

.cage-info {
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #4CAF50;
}

.cage-info p {
    margin: 5px 0;
    font-size: 14px;
}

.cage-info .cage-sum-large {
    font-size: 24px;
    font-weight: bold;
    color: #4CAF50;
}

.cage-info .cage-size {
    color: #666;
}

.combinations-list {
    max-height: 500px;
    overflow-y: auto;
    background-color: white;
    border-radius: 8px;
    padding: 10px;
}

.combination-item {
    padding: 8px 12px;
    margin: 5px 0;
    background-color: #f5f5f5;
    border-radius: 5px;
    font-family: monospace;
    font-size: 14px;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.combination-item:hover {
    background-color: #e8f5e8;
    border-color: #4CAF50;
    transform: translateX(5px);
}

.combination-item .numbers {
    font-weight: bold;
    color: #333;
}

.combination-item .sum-check {
    float: right;
    color: #4CAF50;
    font-size: 12px;
}

.no-selection {
    color: #999;
    text-align: left;
    padding: 24px 20px;
    font-style: italic;
    background-color: white;
    border-radius: 8px;
}

.controls {
    margin-top: 20px;
    display: flex;
    justify-content: flex-start;
    gap: 20px;
    flex-wrap: nowrap;
}

.btn {
    padding: 12px 40px;
    font-size: 18px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
}

.btn:hover {
    background-color: #45a049;
}

.btn#clear-btn {
    background-color: #f44336;
}

.btn#clear-btn:hover {
    background-color: #da190b;
}

.message {
    margin-top: 20px;
    padding: 15px;
    font-size: 20px;
    font-weight: bold;
    min-height: 70px;
    border-radius: 5px;
    max-width: 800px;
    
    
}

.success {
    color: #4CAF50;
    background-color: #e8f5e8;
    border: 2px solid #4CAF50;
}

.error {
    color: #f44336;
    background-color: #ffebee;
    border: 2px solid #f44336;
}

/* Side-by-side layout always maintained for desktop */
@media (max-width: 1200px) {
    .game-wrapper {
        overflow-x: auto;
    }
}

@media (max-width: 1080px) {
    .sudoku-grid {
        grid-template-columns: repeat(16, 48px);
        grid-template-rows: repeat(16, 48px);
    }
    
    .cell {
        width: 48px;
        height: 48px;
        font-size: 16px;
    }
    
    .cell input {
        font-size: 16px;
    }
    
    .cage-sum {
        font-size: 8px;
        top: 3px;
        left: 3px;
    }

    .note-digit {
        font-size: 8px;
    }
}

@media (max-width: 900px) {
    .sudoku-grid {
        grid-template-columns: repeat(16, 36px);
        grid-template-rows: repeat(16, 36px);
    }
    
    .cell {
        width: 36px;
        height: 36px;
        font-size: 13px;
    }
    
    .cell input {
        font-size: 13px;
    }
    
    .cage-sum {
        font-size: 7px;
        top: 2px;
        left: 2px;
        padding: 0 1px;
    }

    .note-digit {
        font-size: 6px;
    }
    
    /* Adjust dotted borders for smaller cells */
    .cell.has-cage-border-top::before,
    .cell.has-cage-border-right::before,
    .cell.has-cage-border-bottom::before,
    .cell.has-cage-border-left::before {
        border-width: 1px;
    }
}

/* Cell focus / selection */
.cell:focus {
    outline: none;
}

.cell.selected {
    box-shadow: inset 0 0 0 3px #4CAF50;
    z-index: 10;
}

.cell.conflict {
    background-color: rgba(255, 23, 68, 0.08) !important;
}

@keyframes conflictPop {
    0%   { transform: scale(1);   }
    50%  { transform: scale(1.3); }
    100% { transform: scale(1);   }
}



/* =============================================================================
   ROW / COLUMN HEADERS  (R1–R16, C1–C16)
   ============================================================================= */

/* grid-container: CSS grid with number bar, col headers, row headers, and puzzle */
.grid-container {
    flex: 0 0 auto;
    display: grid;
    grid-template-areas:
        "numbar  numbar"
        "corner  colhdrs"
        "rowhdrs puzzle";
    grid-template-columns: 28px auto;
    grid-template-rows:    auto 20px auto;
    gap: 0;
}

.grid-container > .number-bar   { grid-area: numbar; }
#grid-col-headers                { grid-area: colhdrs; }
#grid-row-headers                { grid-area: rowhdrs; }
.grid-container > .sudoku-grid   { grid-area: puzzle; }

/* Column header strip */
.grid-col-headers {
    display: grid;
    grid-template-columns: repeat(16, 50px);
    gap: 0;
    background: transparent;
    align-items: center;
}

.grid-header-corner {
    display: none;  /* handled by grid-template-areas */
}

.grid-col-header {
    width: 50px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #555;
    background: #eef;
    border: 1px solid #ccc;
    border-bottom: none;
    box-sizing: border-box;
    cursor: default;
    user-select: none;
}

/* Row header strip */
.grid-row-headers {
    display: grid;
    grid-template-rows: repeat(16, 50px);
    gap: 0;
    background: transparent;
    align-items: center;
}

.grid-row-header {
    width: 28px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #555;
    background: #eef;
    border: 1px solid #ccc;
    border-right: none;
    box-sizing: border-box;
    cursor: default;
    user-select: none;
    writing-mode: horizontal-tb;
}

/* Highlight active row/col headers when a cell is selected */
.grid-col-header.header-active,
.grid-row-header.header-active {
    background: #c5cae9;
    color: #1a237e;
}

/* Sync header cell sizes with responsive breakpoints */
@media (max-width: 1080px) {
    .grid-col-headers { grid-template-columns: repeat(16, 48px); }
    .grid-col-header  { width: 48px; }
    .grid-row-headers { grid-template-rows: repeat(16, 48px); }
    .grid-row-header  { height: 48px; }
    .grid-container   { grid-template-columns: 26px auto; }
    .grid-row-header  { width: 26px; }
}

@media (max-width: 900px) {
    .grid-col-headers { grid-template-columns: repeat(16, 36px); }
    .grid-col-header  { width: 36px; font-size: 9px; }
    .grid-row-headers { grid-template-rows: repeat(16, 36px); }
    .grid-row-header  { height: 36px; font-size: 9px; }
    .grid-container   { grid-template-columns: 22px auto; }
    .grid-row-header  { width: 22px; }
}

/* =============================================================================
   NUMBER INPUT BAR  (1–16 buttons above the grid)
   ============================================================================= */

.number-bar {
    display: flex;
    gap: 2px;
    margin-bottom: 0;   /* gap handled by grid row spacing */
    width: 100%;        /* spans the full grid-container width (row-hdr + grid) */
    box-sizing: border-box;
    padding-left: 28px; /* align buttons with grid columns, not row-header */
}

.num-btn {
    flex: 1;
    height: 32px;
    font-size: 13px;
    font-weight: bold;
    border: 2px solid #bbb;
    border-radius: 5px;
    background: #f8f8f8;
    color: #333;
    cursor: pointer;
    transition: all 0.12s ease;
    line-height: 1;
    padding: 0;
}

.num-btn:hover {
    background: #e0e0e0;
    border-color: #888;
}

/* Active in pencil mode — highlighted blue */
.pencil-active-bar .num-btn {
    background: #e3f2fd;
    border-color: #1976D2;
    color: #1565c0;
}

.pencil-active-bar .num-btn:hover {
    background: #bbdefb;
}

/* Active in normal mode — highlighted green */
.normal-active-bar .num-btn {
    background: #e8f5e9;
    border-color: #388e3c;
    color: #2e7d32;
}

.normal-active-bar .num-btn:hover {
    background: #c8e6c9;
}

/* The ✕ clear button */
.num-btn-clear {
    background: #ffebee !important;
    border-color: #f44336 !important;
    color: #c62828 !important;
    font-size: 15px;
}
.num-btn-clear:hover {
    background: #ffcdd2 !important;
}

/* Pressed / last-used highlight */
.num-btn.num-btn-active {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px currentColor;
    transform: scale(0.95);
}


/* Button highlights based on selected cell content */

/* Normal mode: cell has this value → solid green fill */
.num-btn.num-btn-has-value {
    background: #2e7d32 !important;
    border-color: #1b5e20 !important;
    color: #fff !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}
.num-btn.num-btn-has-value:hover {
    background: #c62828 !important;
    border-color: #b71c1c !important;
}

/* Pencil mode: cell has this note → solid blue fill */
.num-btn.num-btn-has-note {
    background: #1565c0 !important;
    border-color: #0d47a1 !important;
    color: #fff !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.25);
}
.num-btn.num-btn-has-note:hover {
    background: #c62828 !important;
    border-color: #b71c1c !important;
}


/* =============================================================================
   BOX (4×4) STATS WIDGET — shown above cage combination helper
   ============================================================================= */

.box-stats {
    background: white;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border-left: 4px solid #1565c0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.box-stats-title {
    font-size: 14px;
    font-weight: bold;
    color: #1565c0;
    margin-bottom: 7px;
}

.box-coords {
    font-size: 11px;
    font-weight: normal;
    color: #888;
    margin-left: 4px;
}

.box-stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    margin: 3px 0;
}

.box-label {
    color: #555;
}

.box-value {
    font-weight: bold;
    color: #222;
}

.box-remaining {
    font-size: 15px;
}

.box-progress-bar {
    height: 5px;
    background: #e0e0e0;
    border-radius: 3px;
    margin: 7px 0 5px;
    overflow: hidden;
}

.box-progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.box-filled-nums {
    font-size: 11px;
    color: #777;
    text-align: center;
    letter-spacing: 0.5px;
    margin-top: 2px;
}


/* =============================================================================
   CAGE INTERSECTION TABLE inside the box-stats widget
   ============================================================================= */

.ci-section-title {
    font-size: 12px;
    font-weight: bold;
    color: #555;
    margin: 10px 0 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ci-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 6px;
}

.ci-table th {
    background: #e8eaf6;
    color: #3949ab;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 3px 4px;
    text-align: left;
    border-bottom: 1px solid #c5cae9;
}

.ci-table td {
    padding: 3px 4px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

.ci-cage-id   { font-weight: bold; color: #555; white-space: nowrap; }
.ci-cage-sum  { font-weight: bold; color: #222; }
.ci-cells     { color: #888; font-size: 11px; white-space: nowrap; }
.ci-contrib   { color: #333; }

/* Row tinting by type */
.ci-full td              { background: #f1f8e9; }  /* fully inside — green tint */
.ci-partial-known td     { background: #e3f2fd; }  /* crossing, outside known — blue tint */
.ci-partial-unknown td   { background: #fff8e1; }  /* crossing, outside unknown — amber tint */

.ci-unknown {
    color: #e65100;
    font-weight: bold;
}

/* Equation summary line */
.ci-equation {
    font-size: 12px;
    padding: 6px 8px;
    border-radius: 5px;
    margin-top: 4px;
    line-height: 1.5;
}
.ci-eq-ok      { background: #e8f5e9; color: #2e7d32; }
.ci-eq-warn    { background: #ffebee; color: #c62828; }
.ci-eq-partial { background: #fff3e0; color: #e65100; }


/* =============================================================================
   PUZZLE SELECTOR BAR
   ============================================================================= */

.puzzle-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
    background: white;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
}

.puzzle-bar-left  { display: flex; align-items: center; gap: 10px; flex-wrap: nowrap; }
.puzzle-bar-right { display: flex; gap: 10px; }

.puzzle-bar label { font-weight: bold; color: #444; font-size: 15px; white-space: nowrap; }

#puzzle-select {
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid #4CAF50;
    border-radius: 6px;
    background: white;
    color: #333;
    cursor: pointer;
    max-width: 280px;
    outline: none;
}
#puzzle-select:focus { border-color: #2e7d32; }

/* Difficulty badge */
.difficulty-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.diff-easy   { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.diff-medium { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.diff-hard   { background: #fce4ec; color: #c62828; border: 1px solid #f48fb1; }
.diff-expert { background: #ede7f6; color: #4527a0; border: 1px solid #b39ddb; }

/* Solved counter */
.puzzle-counter {
    font-size: 13px;
    color: #666;
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #ddd;
}

/* Button variants */
.btn-random { background-color: #FF9800; padding: 8px 18px; font-size: 14px; }
.btn-random:hover { background-color: #e65100; }

.btn-new    { background-color: #2196F3; padding: 8px 18px; font-size: 14px; }
.btn-new:hover    { background-color: #1565c0; }

.btn-danger { background-color: #f44336 !important; }
.btn-danger:hover { background-color: #b71c1c !important; }

/* =============================================================================
   INPUT COLOURS  (white text + conflict red)
   ============================================================================= */

.cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: left;
    font-size: 20px;
    font-weight: bold;
    background: transparent;
    z-index: 2;
    position: relative;
    cursor: pointer;
    color: #1a237e;
    text-shadow: none;
}

.cell input:focus {
    outline: 2px solid #4CAF50;
    background-color: rgba(255,255,255,0.9);
    border-radius: 3px;
    z-index: 3;
    color: #1a237e;
    text-shadow: none;
}

.cell input.conflict {
    color: #ff1744 !important;
    text-shadow: 0 0 6px rgba(255,23,68,0.55);
    animation: conflictPop 0.25s ease;
}


    100% { transform: scale(1);    }
}

/* =============================================================================
   COMBINATION PANEL  additions
   ============================================================================= */

.no-combos-box {
    color: #c62828;
    background: #ffebee;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
    font-size: 13px;
}
.no-combos-box p { margin: 4px 0; }

.valid-count  { color: #2e7d32; margin-top: 6px; font-weight: bold; font-size: 13px; }
.match        { color: #4CAF50; font-weight: bold; text-decoration: underline;
                background: #e8f5e9; padding: 0 2px; border-radius: 3px; }
.match-sample { color: #4CAF50; font-weight: bold; }
.more-combos  { text-align: left; padding: 8px; color: #888; font-style: italic; font-size: 13px; }

.panel-hint {
    font-size: 12px;
    color: #666;
    margin-top: 10px;
    text-align: left;
    background: #e3f2fd;
    padding: 6px;
    border-radius: 5px;
}

/* =============================================================================
   MESSAGE  —  info variant
   ============================================================================= */

.message.info {
    color: #1565c0;
    background-color: #e3f2fd;
    border: 2px solid #1565c0;
}

/* =============================================================================
   PENCIL / NOTES MODE BUTTON
   ============================================================================= */

.btn-pencil {
    background-color: #607D8B;
    padding: 8px 18px;
    font-size: 14px;
    border: 2px solid transparent;
}
.btn-pencil:hover { background-color: #455A64; }

.btn-pencil.pencil-active {
    background-color: #1976D2;
    border-color: #0d47a1;
    box-shadow: 0 0 0 3px rgba(25,118,210,0.3);
    animation: pencilPulse 2s ease-in-out infinite;
}

@keyframes pencilPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(25,118,210,0.3); }
    50%       { box-shadow: 0 0 0 6px rgba(25,118,210,0.15); }
}

/* =============================================================================
   PANEL TABS
   ============================================================================= */

.panel-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0;
}

.panel-tab {
    flex: 1;
    padding: 7px 6px;
    font-size: 13px;
    font-weight: bold;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    color: #666;
    transition: all 0.15s ease;
}
.panel-tab:hover  { background: #e8e8e8; color: #333; }
.panel-tab.active { background: white; color: #1565c0; border-color: #c5cae9; border-bottom: 2px solid white; margin-bottom: -2px; }

.tab-content        { display: none; }
.tab-content.active { display: block; }


/* =============================================================================
   ROW / COL CALCULATOR
   ============================================================================= */

.rc-section  { margin-bottom: 10px; }

.rc-label {
    font-size: 12px;
    font-weight: bold;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.rc-hint { font-weight: normal; color: #999; text-transform: none; letter-spacing: 0; font-size: 11px; }

.rc-clear-btn {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 6px;
    background: #ffebee;
    border: 1px solid #f44336;
    border-radius: 4px;
    color: #c62828;
    cursor: pointer;
}
.rc-clear-btn:hover { background: #ffcdd2; }

.rc-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.rc-tog {
    width: 30px;
    height: 24px;
    font-size: 10px;
    font-weight: bold;
    border: 1px solid #bbb;
    border-radius: 4px;
    background: #f8f8f8;
    color: #444;
    cursor: pointer;
    transition: all 0.1s;
    padding: 0;
}
.rc-tog:hover   { background: #e0e0e0; border-color: #888; }
.rc-tog.rc-tog-on {
    background: #1565c0;
    border-color: #0d47a1;
    color: white;
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.2);
}

/* Grid highlight when rows/cols selected */
.cell.rc-highlight-row  { background-color: rgba(33, 150, 243, 0.12) !important; }
.cell.rc-highlight-col  { background-color: rgba(76, 175, 80,  0.12) !important; }
.cell.rc-highlight-both { background-color: rgba(156, 39, 176, 0.15) !important; }

/* Result area */
.rc-empty {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
    font-size: 13px;
}

.rc-result-header {
    font-size: 12px;
    font-weight: bold;
    color: #1565c0;
    margin-bottom: 8px;
    padding: 4px 6px;
    background: #e3f2fd;
    border-radius: 4px;
}

.rc-overlap-note {
    font-size: 11px;
    color: #795548;
    background: #efebe9;
    padding: 4px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.rc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-bottom: 8px;
}
.rc-table th {
    background: #e8eaf6;
    color: #3949ab;
    font-size: 10px;
    text-transform: uppercase;
    padding: 3px 3px;
    text-align: left;
    border-bottom: 1px solid #c5cae9;
}
.rc-table td {
    padding: 3px 3px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

/* Row types */
.rc-type-full    td { background: #f1f8e9; }
.rc-type-innie   td { background: #e3f2fd; }
.rc-type-outie   td { background: #fce4ec; }
.rc-type-partial td { background: #fff8e1; }

.rc-deduced {
    display: block;
    font-weight: bold;
    color: #2e7d32;
    font-size: 11px;
    margin-top: 2px;
}

/* Summary box */
.rc-summary {
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 12px;
    line-height: 1.6;
}
.rc-sum-ok      { background: #e8f5e9; border-left: 4px solid #2e7d32; }
.rc-sum-innie   { background: #e3f2fd; border-left: 4px solid #1565c0; }
.rc-sum-outie   { background: #fce4ec; border-left: 4px solid #c62828; }
.rc-sum-partial { background: #fff8e1; border-left: 4px solid #f57f17; }

.rc-sum-line        { margin: 2px 0; color: #333; }
.rc-sum-result      { font-weight: bold; margin-top: 5px; font-size: 13px; }

/* =============================================================================
   CAGE ID CHIP  — hoverable badge in panel tables
   ============================================================================= */

.cage-id-chip {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 4px;
    background: #e8eaf6;
    border: 1px solid #9fa8da;
    color: #283593;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
    user-select: none;
    white-space: nowrap;
}
.cage-id-chip:hover {
    background: #283593;
    border-color: #1a237e;
    color: white;
    transform: scale(1.1);
}

/* Grid cells highlighted on cage hover */
.cell.cage-hover-highlight {
    outline: 3px solid #f57f17 !important;
    outline-offset: -3px;
    background-color: rgba(255, 152, 0, 0.35) !important;
    z-index: 20;
    animation: cageFlash 0.3s ease;
}

@keyframes cageFlash {
    0%   { background-color: rgba(255, 152, 0, 0.7) !important; }
    100% { background-color: rgba(255, 152, 0, 0.35) !important; }
}

/* =============================================================================
   CELL INFO SUB-TABS  (Box/Cage  |  Combos)
   ============================================================================= */

.cell-subtabs {
    display: flex;
    gap: 3px;
    margin-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.cell-subtab {
    flex: 1;
    padding: 5px 4px;
    font-size: 12px;
    font-weight: bold;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    border-radius: 5px 5px 0 0;
    cursor: pointer;
    color: #777;
    transition: all 0.12s;
}
.cell-subtab:hover:not(:disabled) { background: #e8e8e8; color: #333; }
.cell-subtab.active {
    background: white;
    color: #1565c0;
    border-color: #c5cae9;
    border-bottom: 2px solid white;
    margin-bottom: -2px;
}
.cell-subtab:disabled { opacity: 0.4; cursor: default; }

.cell-subtab-content        { display: none; }
.cell-subtab-content.active { display: block; }
