/* ==========================================================================
   Nonogram (Picross / Griddlers) Stylesheet
   Bildschirmfüllendes, harmonisches Spielfeld mit Zeilen- & Spalten-Hinweisen,
   5er-Block-Trennern, fehlerfreien Kantenlinien und voller Theme-Unterstützung.
   ========================================================================== */

.nonogram-board {
    display: grid !important;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    width: 100%;
    height: 100%;
    max-width: 440px;
    max-height: 440px;
    margin: 0 auto;
    aspect-ratio: 1 / 1;
    background-color: var(--cell-bg);
    border: 2.5px solid var(--accent-sun) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 10px 30px var(--shadow-color);
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

body.theme-cyberpunk .nonogram-board {
    border-color: #ff007f !important;
    box-shadow: 0 0 25px rgba(255, 0, 127, 0.25);
}

body.theme-amoled .nonogram-board {
    border-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
}

body.theme-wood .nonogram-board {
    border-color: #78350f !important;
    box-shadow: 0 10px 30px rgba(20, 10, 5, 0.7);
}

/* Oben-Links: Leere Ecke */
.nonogram-corner {
    background: rgba(0, 0, 0, 0.18);
    border-right: 2px solid var(--accent-sun);
    border-bottom: 2px solid var(--accent-sun);
    box-sizing: border-box;
}

body.theme-cyberpunk .nonogram-corner {
    border-right: 2px solid #ff007f !important;
    border-bottom: 2px solid #ff007f !important;
}

body.theme-amoled .nonogram-corner {
    border-right: 2px solid rgba(255, 255, 255, 0.2) !important;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
}

body.theme-wood .nonogram-corner {
    border-right: 2px solid #78350f !important;
    border-bottom: 2px solid #78350f !important;
}

/* Oben: Spalten-Hinweise */
.nonogram-col-clues {
    display: grid;
    background: rgba(0, 0, 0, 0.10);
    border-bottom: 2px solid var(--accent-sun);
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

body.theme-cyberpunk .nonogram-col-clues {
    border-bottom: 2px solid #ff007f !important;
}

body.theme-amoled .nonogram-col-clues {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
}

body.theme-wood .nonogram-col-clues {
    border-bottom: 2px solid #78350f !important;
}

.col-clue-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 3px 1px 4px 1px;
    gap: 1px;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    min-width: 0;
    transition: opacity 0.2s ease;
}

.col-clue-box:last-child {
    border-right: none !important;
}

.col-clue-box.major-edge-right {
    border-right: 2px solid var(--accent-sun) !important;
}

body.theme-cyberpunk .col-clue-box.major-edge-right {
    border-right: 2px solid #ff007f !important;
}

body.theme-amoled .col-clue-box.major-edge-right {
    border-right: 2px solid rgba(255, 255, 255, 0.2) !important;
}

body.theme-wood .col-clue-box.major-edge-right {
    border-right: 2px solid #92400e !important;
}

/* Links: Zeilen-Hinweise */
.nonogram-row-clues {
    display: grid;
    background: rgba(0, 0, 0, 0.10);
    border-right: 2px solid var(--accent-sun);
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

body.theme-cyberpunk .nonogram-row-clues {
    border-right: 2px solid #ff007f !important;
}

body.theme-amoled .nonogram-row-clues {
    border-right: 2px solid rgba(255, 255, 255, 0.2) !important;
}

body.theme-wood .nonogram-row-clues {
    border-right: 2px solid #78350f !important;
}

.row-clue-box {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    padding: 1px 6px 1px 4px;
    gap: 3px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
    min-height: 0;
    white-space: nowrap;
    transition: opacity 0.2s ease;
}

.row-clue-box:last-child {
    border-bottom: none !important;
}

.row-clue-box.major-edge-bottom {
    border-bottom: 2px solid var(--accent-sun) !important;
}

body.theme-cyberpunk .row-clue-box.major-edge-bottom {
    border-bottom: 2px solid #ff007f !important;
}

body.theme-amoled .row-clue-box.major-edge-bottom {
    border-bottom: 2px solid rgba(255, 255, 255, 0.2) !important;
}

body.theme-wood .row-clue-box.major-edge-bottom {
    border-bottom: 2px solid #92400e !important;
}

/* Clue-Nummern */
.clue-num {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, monospace;
    flex-shrink: 0;
}

body.theme-cyberpunk .clue-num {
    color: #00f0ff;
}

.size-5 .clue-num {
    font-size: 0.85rem;
}

.size-10 .clue-num {
    font-size: 0.70rem;
}

.size-15 .clue-num {
    font-size: 0.52rem;
}

.clue-satisfied {
    opacity: 0.35;
}

.clue-satisfied .clue-num {
    text-decoration: line-through;
    color: var(--text-secondary);
}

/* Haupt-Gitter (Cells) */
.nonogram-grid {
    display: grid !important;
    gap: 0 !important;
    padding: 0 !important;
    background-color: var(--cell-bg);
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

.nonogram-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--cell-bg);
    border-right: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    font-weight: 800;
    font-size: clamp(0.7rem, 2.5vw, 1.1rem);
    color: var(--text-secondary);
    min-width: 0 !important;
    min-height: 0 !important;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    transition: background-color 0.12s ease, transform 0.08s ease;
}

body.theme-light .nonogram-cell {
    border-right: 1px solid rgba(0, 0, 0, 0.1) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

body.theme-cyberpunk .nonogram-cell {
    border-right: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* Letzte Spalte & letzte Zeile: Kein doppelter Rand gegen den Außenrahmen */
.nonogram-board.size-5 .nonogram-cell[data-c="4"],
.nonogram-board.size-10 .nonogram-cell[data-c="9"],
.nonogram-board.size-15 .nonogram-cell[data-c="14"] {
    border-right: none !important;
}

.nonogram-board.size-5 .nonogram-cell[data-r="4"],
.nonogram-board.size-10 .nonogram-cell[data-r="9"],
.nonogram-board.size-15 .nonogram-cell[data-r="14"] {
    border-bottom: none !important;
}

/* 5er-Block-Trennlinien - Spezifisch nur die betroffene Kante anpassen */
.nonogram-cell.major-edge-right {
    border-right: 2px solid var(--accent-sun) !important;
}

.nonogram-cell.major-edge-bottom {
    border-bottom: 2px solid var(--accent-sun) !important;
}

body.theme-cyberpunk .nonogram-cell.major-edge-right {
    border-right-color: #ff007f !important;
}

body.theme-cyberpunk .nonogram-cell.major-edge-bottom {
    border-bottom-color: #ff007f !important;
}

body.theme-amoled .nonogram-cell.major-edge-right {
    border-right-color: rgba(255, 255, 255, 0.25) !important;
}

body.theme-amoled .nonogram-cell.major-edge-bottom {
    border-bottom-color: rgba(255, 255, 255, 0.25) !important;
}

body.theme-wood .nonogram-cell.major-edge-right {
    border-right-color: #92400e !important;
}

body.theme-wood .nonogram-cell.major-edge-bottom {
    border-bottom-color: #92400e !important;
}

/* Gefüllte Kachel (Pixel) */
.nonogram-cell.cell-filled {
    background-color: var(--accent-sun) !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

body.theme-cyberpunk .nonogram-cell.cell-filled {
    background-color: #ff007f !important;
    box-shadow: inset 0 0 8px rgba(255, 0, 127, 0.6);
}

body.theme-light .nonogram-cell.cell-filled {
    background-color: #1e293b !important;
}

body.theme-amoled .nonogram-cell.cell-filled {
    background-color: #ffffff !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4);
}

body.theme-wood .nonogram-cell.cell-filled {
    background-color: #f59e0b !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}

/* Ausgekreuzte Kachel (Cross ✕) */
.nonogram-cell.cell-cross {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 900;
    background-color: rgba(255, 255, 255, 0.02);
}

.size-15 .nonogram-cell.cell-cross {
    font-size: 0.65rem;
}

/* Aktive / Ausgewählte Kachel */
.nonogram-cell.selected {
    box-shadow: inset 0 0 0 2px var(--accent-moon) !important;
    z-index: 5;
}

/* Zoomed Cell */
.nonogram-cell.cell-zoom {
    border: none !important;
    border-right: none !important;
    border-bottom: none !important;
}

.nonogram-cell.selected.cell-zoom {
    transform: scale(var(--zoom-factor, 1.5)) !important;
    z-index: 25 !important;
    outline: 2.5px solid var(--accent-sun) !important;
    outline-offset: -1px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 14px rgba(251, 191, 36, 0.45) !important;
    border-radius: var(--radius-sm) !important;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, background-color 0.15s ease;
}

body.theme-cyberpunk .nonogram-cell.selected.cell-zoom {
    outline-color: #00f0ff !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(0, 240, 255, 0.6) !important;
}



/* Lösungsaufdeckung */
.nonogram-cell.revealed-filled {
    background-color: rgba(34, 197, 94, 0.75) !important;
}

.nonogram-cell.revealed-error {
    background-color: rgba(239, 68, 68, 0.4) !important;
    color: #ef4444 !important;
}

/* Nonogram Keypad */
.nonogram-keypad {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 380px;
    margin: 8px auto;
}

.nono-key-btn {
    flex: 1;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background-color: var(--cell-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.15s ease;
}

.nono-key-btn:active {
    transform: scale(0.94);
}

.nono-key-btn .key-icon {
    font-size: 1.1rem;
}

.nono-key-btn.key-fill {
    border-color: var(--accent-sun);
    color: var(--accent-sun);
}

.nono-key-btn.key-cross {
    border-color: var(--accent-moon);
    color: var(--accent-moon);
}

.nono-key-btn.key-clear {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

/* Responsive Anpassungen für kleine Smartphones */
@media (max-width: 380px) {
    .row-clue-box {
        padding: 1px 3px 1px 2px;
        gap: 1.5px;
    }
    .col-clue-box {
        padding: 2px 0.5px 3px 0.5px;
        gap: 0.5px;
    }
    .clue-num {
        font-size: 0.65rem;
    }
    .size-10 .clue-num {
        font-size: 0.58rem;
    }
    .size-15 .clue-num {
        font-size: 0.44rem;
    }
}
