/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ===== Auth Header Bar ===== */
#auth-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #2d3748;
    border-bottom: 2px solid #d69e2e;
    padding: 0 16px;
    height: 44px;
}
.auth-bar-inner {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}
.auth-home-link {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
}
.auth-home-link:hover { color: #d69e2e; }
.auth-login-link {
    color: #d69e2e;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 5px 14px;
    border: 1px solid #d69e2e;
    border-radius: 6px;
    transition: all 0.15s;
}
.auth-login-link:hover { background: #d69e2e; color: #2d3748; }
.auth-user-menu { position: relative; }
.auth-user-btn {
    background: none;
    border: 1px solid #4a5568;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 5px 12px;
    cursor: pointer;
    transition: all 0.15s;
}
.auth-user-btn:hover { border-color: #d69e2e; color: #d69e2e; }
.auth-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    overflow: hidden;
    z-index: 1001;
}
.auth-dropdown a, .auth-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.85rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: background 0.1s;
}
.auth-dropdown a:hover, .auth-dropdown button:hover { background: #4a5568; }
.hidden { display: none !important; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    color: #333;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 60px 16px 16px;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== Back Link ===== */
.back-link {
    display: inline-block;
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: #805ad5;
    text-decoration: none;
    font-weight: 600;
}

.back-link:hover {
    color: #6b46c1;
    text-decoration: underline;
}

#app {
    text-align: center;
    max-width: 600px;
    width: 100%;
    position: relative;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 4px;
    color: #2d3748;
}

.rules {
    font-size: 0.85rem;
    color: #718096;
    margin-bottom: 16px;
    line-height: 1.4;
}

/* ===== Collapsible Menu ===== */
.menu-toggle {
    display: none;
}

.menu-collapsible {
    /* Visible by default on desktop */
}

@media (max-width: 480px) {
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        padding: 8px 0;
        margin-bottom: 6px;
        border: 1px solid #cbd5e0;
        border-radius: 8px;
        background: #f7fafc;
        font-size: 0.85rem;
        font-weight: 600;
        color: #4a5568;
        cursor: pointer;
        transition: all 0.2s;
    }

    .menu-toggle:active {
        background: #edf2f7;
    }

    .menu-arrow {
        font-size: 0.7rem;
        transition: transform 0.25s;
    }

    .menu-toggle[aria-expanded="false"] .menu-arrow {
        transform: rotate(180deg);
    }

    .menu-collapsible {
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.25s ease;
        max-height: 500px;
        opacity: 1;
    }

    .menu-collapsible.collapsed {
        max-height: 0;
        opacity: 0;
        margin: 0;
    }
}

/* ===== Force Update Button ===== */
#force-update-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    background: #f7fafc;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #a0aec0;
    z-index: 10;
}

#force-update-btn:hover {
    background: #edf2f7;
    color: #4a5568;
    border-color: #cbd5e0;
}

#force-update-btn.updating {
    animation: spin-update 0.8s linear infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes spin-update {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== Game Switcher ===== */
#game-switcher {
    display: flex;
    gap: 0;
    justify-content: center;
    margin-bottom: 16px;
}

.game-tab {
    padding: 10px 24px;
    border: 2px solid #cbd5e0;
    background: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.game-tab:first-child {
    border-radius: 10px 0 0 10px;
    border-right: 1px solid #cbd5e0;
}

.game-tab:last-child {
    border-radius: 0 10px 10px 0;
    border-left: 1px solid #cbd5e0;
}

.game-tab:not(:first-child):not(:last-child) {
    border-left: 1px solid #cbd5e0;
    border-right: 1px solid #cbd5e0;
}

.game-tab:hover {
    background: #edf2f7;
}

.game-tab.active {
    background: #2d3748;
    color: #fff;
    border-color: #2d3748;
}

.game-panel.hidden {
    display: none;
}

/* ===== Crown Mode Buttons ===== */
#crown-mode {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 8px;
}

.mode-btn {
    padding: 6px 18px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.mode-btn:hover {
    border-color: #d69e2e;
    color: #d69e2e;
}

.mode-btn.active {
    background: #d69e2e;
    color: #fff;
    border-color: #d69e2e;
}

/* ===== Difficulty Buttons ===== */
#difficulty {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.diff-btn {
    padding: 8px 16px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.diff-btn:hover {
    border-color: #805ad5;
    color: #805ad5;
}

.diff-btn.active {
    background: #805ad5;
    color: #fff;
    border-color: #805ad5;
}

/* ===== Toolbar ===== */
#toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

#new-game, #hint-btn, #draft-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#new-game {
    background: #4299e1;
    color: #fff;
}

#new-game:hover {
    background: #3182ce;
}

#hint-btn {
    background: #ed8936;
    color: #fff;
    position: relative;
}

#hint-btn:hover {
    background: #dd6b20;
}

#hint-btn.used {
    background: #a0aec0;
    cursor: not-allowed;
    opacity: 0.7;
}

#hint-btn.hint-active {
    background: #38a169;
    animation: pulse-hint 1s infinite;
}

@keyframes pulse-hint {
    0%, 100% { box-shadow: 0 0 0 0 rgba(56, 161, 105, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(56, 161, 105, 0); }
}

#hint-badge {
    background: #fff;
    color: #ed8936;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 4px;
    vertical-align: middle;
}

#hint-btn.used #hint-badge {
    display: none;
}

/* ===== Grid ===== */
#grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#grid {
    display: grid;
    gap: 0;
    width: min(85vw, 480px);
    height: min(85vw, 480px);
    touch-action: none;
}

.cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
    transition: filter 0.15s;
    border: 1px solid rgba(0,0,0,0.08);
}

.cell:hover {
    filter: brightness(0.93);
}

/* Thick borders between different-color regions */
.cell.border-top { border-top: 3px solid #4a5568; }
.cell.border-bottom { border-bottom: 3px solid #4a5568; }
.cell.border-left { border-left: 3px solid #4a5568; }
.cell.border-right { border-right: 3px solid #4a5568; }

/* Cell states */
.cell .icon {
    pointer-events: none;
    line-height: 1;
}

.cell .icon.cross {
    color: #000;
    font-size: 1.5em;
    font-weight: 900;
    text-shadow:
        -1px -1px 0 #fff,
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff;
}

.cell .icon.crown {
    font-size: 1.3em;
    text-shadow:
        -1px -1px 0 #fff,
         1px -1px 0 #fff,
        -1px  1px 0 #fff,
         1px  1px 0 #fff;
}

.cell.locked {
    cursor: default;
}

.cell.locked:hover {
    filter: none;
}

/* ===== Crown placement animation ===== */
@keyframes crown-pop {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.cell .icon.crown {
    animation: crown-pop 0.35s ease-out;
}

/* ===== Error flash ===== */
@keyframes error-flash {
    0%, 100% { background-color: inherit; }
    25%, 75% { background-color: #fc8181; }
}

.cell.error {
    animation: error-flash 0.6s ease;
}

/* ===== Messages ===== */
#message {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 10px;
    border-radius: 8px;
    margin-top: 8px;
}

#message.hidden {
    display: none;
}

#message.win {
    background: #c6f6d5;
    color: #276749;
}

#message.hint {
    background: #e2e8f0;
    color: #2d3748;
    font-weight: 600;
}

/* ===== Draft mode button ===== */
#draft-btn {
    background: #a0aec0;
    color: #fff;
}

#draft-btn:hover {
    background: #718096;
}

#draft-btn.draft-active {
    background: #9f7aea;
    animation: pulse-draft 1s infinite;
}

@keyframes pulse-draft {
    0%, 100% { box-shadow: 0 0 0 0 rgba(159, 122, 234, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(159, 122, 234, 0); }
}

/* ===== Undo Button ===== */
.undo-bar {
    display: flex;
    justify-content: center;
    margin: 12px 0 8px;
}

.undo-btn {
    padding: 8px 24px;
    border: 2px solid #cbd5e0;
    border-radius: 10px;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    color: #4a5568;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.undo-btn:hover:not(:disabled) {
    border-color: #4299e1;
    color: #4299e1;
    background: #ebf8ff;
}

.undo-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.undo-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== Draft cell styles ===== */
.cell.draft-cell {
    position: relative;
}

.cell .icon.cross.draft {
    color: #a0aec0;
    font-weight: 700;
}

.cell .icon.crown.draft {
    opacity: 0.4;
    text-shadow:
        -1px -1px 0 #805ad5,
         1px -1px 0 #805ad5,
        -1px  1px 0 #805ad5,
         1px  1px 0 #805ad5;
}

.cell .draft-badge {
    position: absolute;
    top: 1px;
    right: 2px;
    font-size: 0.55em;
    color: #805ad5;
    font-weight: 700;
    pointer-events: none;
    line-height: 1;
}

#message.lose {
    background: #fed7d7;
    color: #9b2c2c;
}

/* ===== Overlay (popup) ===== */
#overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

#overlay.hidden {
    display: none;
}

#overlay-content {
    background: #fff;
    border-radius: 16px;
    padding: 32px 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 90vw;
}

#overlay-text {
    font-size: 1.2rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

#overlay-close {
    padding: 8px 32px;
    border: none;
    border-radius: 8px;
    background: #805ad5;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

#overlay-close:hover {
    background: #6b46c1;
}

/* ===== Victory confetti ===== */
@keyframes confetti-fall {
    0% { transform: translateY(-10px) rotate(0deg); opacity: 1; }
    100% { transform: translateY(60px) rotate(720deg); opacity: 0; }
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confetti-fall 1.2s ease-out forwards;
    pointer-events: none;
}

/* ===== Pastel Colors ===== */
.color-0 { background-color: #FFB3B3; } /* Rouge rosé     — 0° */
.color-1 { background-color: #FFD1A3; } /* Orange doux    — 30° */
.color-2 { background-color: #FFF0A0; } /* Jaune soleil   — 55° */
.color-3 { background-color: #C8EAA0; } /* Vert pomme     — 95° */
.color-4 { background-color: #A3E4C8; } /* Menthe claire  — 155° */
.color-5 { background-color: #A3D8F4; } /* Bleu ciel vif  — 200° */
.color-6 { background-color: #A8B8F8; } /* Bleu pervenche — 230° */
.color-7 { background-color: #CCA8F0; } /* Violet doux    — 270° */
.color-8 { background-color: #F4A8D8; } /* Rose bonbon    — 320° */
.color-9 { background-color: #D4C8A8; } /* Beige sable    — 40° neutre */

/* ===== Sudoku ===== */
#sudoku-difficulty {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.sdiff-btn {
    padding: 8px 20px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.sdiff-btn:hover {
    border-color: #3182ce;
    color: #3182ce;
}

.sdiff-btn.active {
    background: #3182ce;
    color: #fff;
    border-color: #3182ce;
}

#sudoku-toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

#sudoku-new-game, #sudoku-draft-btn, #sudoku-hint-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#sudoku-new-game {
    background: #4299e1;
    color: #fff;
}

#sudoku-new-game:hover {
    background: #3182ce;
}

#sudoku-hint-btn {
    background: #ed8936;
    color: #fff;
}

#sudoku-hint-btn:hover {
    background: #dd6b20;
}

#sudoku-draft-btn {
    background: #a0aec0;
    color: #fff;
}

#sudoku-draft-btn:hover {
    background: #718096;
}

#sudoku-draft-btn.draft-active {
    background: #9f7aea;
    animation: pulse-draft 1s infinite;
}

#sudoku-grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

#sudoku-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    gap: 0;
    width: min(85vw, 450px);
    height: min(85vw, 450px);
    background: #2d3748;
    border: 3px solid #2d3748;
}

.sudoku-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    position: relative;
    transition: background 0.15s;
    color: #2d3748;
    border: 1px solid #cbd5e0;
    user-select: none;
}

.sudoku-cell:hover {
    background: #edf2f7;
}

.sudoku-cell.given {
    background: #f7fafc;
    color: #2d3748;
    cursor: default;
}

.sudoku-cell.hinted {
    background: #f0fff4;
    color: #276749;
    cursor: default;
    font-weight: 700;
}

.sudoku-cell.selected {
    background: #bee3f8;
}

.sudoku-cell.user-input {
    color: #3182ce;
}

/* Sudoku draft notes */
.sudoku-cell .sudoku-notes {
    position: absolute;
    top: 1px;
    right: 2px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0;
    max-width: 80%;
    pointer-events: none;
}

.sudoku-cell .sudoku-note {
    font-size: 0.45em;
    font-weight: 700;
    color: #805ad5;
    line-height: 1.1;
    width: 0.9em;
    text-align: center;
}

/* Thick borders for 3×3 blocks */
.sudoku-cell.block-border-top { border-top: 2px solid #2d3748; }
.sudoku-cell.block-border-bottom { border-bottom: 2px solid #2d3748; }
.sudoku-cell.block-border-left { border-left: 2px solid #2d3748; }
.sudoku-cell.block-border-right { border-right: 2px solid #2d3748; }

/* Sudoku number pad */
#sudoku-numpad {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.numpad-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    color: #2d3748;
}

.numpad-btn:hover {
    background: #bee3f8;
    border-color: #3182ce;
}

.numpad-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #edf2f7;
    border-color: #e2e8f0;
}

.numpad-btn.disabled:hover {
    background: #edf2f7;
    border-color: #e2e8f0;
}

.numpad-btn.completed {
    opacity: 0.35;
    cursor: not-allowed;
    text-decoration: line-through;
    background: #edf2f7;
    border-color: #e2e8f0;
}

.numpad-btn.completed:hover {
    background: #edf2f7;
    border-color: #e2e8f0;
}

.numpad-btn.erase {
    width: auto;
    padding: 0 14px;
    font-size: 0.9rem;
}

#sudoku-message {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 10px;
    border-radius: 8px;
    margin-top: 8px;
}

#sudoku-message.hidden {
    display: none;
}

#sudoku-message.win {
    background: #c6f6d5;
    color: #276749;
}

/* ===== Sudoku Error (wrong number) ===== */
@keyframes sudoku-error-blink {
    0%, 100% { color: #e53e3e; }
    25% { color: #fff; }
    50% { color: #e53e3e; }
    75% { color: #fff; }
}

.sudoku-cell.sudoku-error {
    animation: sudoku-error-blink 1s ease infinite;
    color: #e53e3e !important;
    font-weight: 900;
}

/* Explosion particles */
@keyframes sudoku-explode {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--dx), var(--dy)) scale(0.2);
        opacity: 0;
    }
}

.sudoku-explosion-particle {
    position: absolute;
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 50;
    animation: sudoku-explode 0.7s ease-out forwards;
    transform-origin: center;
}

@keyframes sudoku-flash {
    0% { transform: scale(0.3); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

.sudoku-explosion-flash {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,100,0,0.8) 0%, rgba(255,50,0,0.4) 40%, transparent 70%);
    pointer-events: none;
    z-index: 49;
    animation: sudoku-flash 0.5s ease-out forwards;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    body { padding: 8px; }
    h1 { font-size: 1.4rem; }
    .rules { font-size: 0.75rem; margin-bottom: 10px; }
    .diff-btn { padding: 6px 12px; font-size: 0.78rem; }
    .sdiff-btn { padding: 6px 12px; font-size: 0.78rem; }
    .pdiff-btn { padding: 6px 12px; font-size: 0.78rem; }
    #new-game, #hint-btn { padding: 7px 14px; font-size: 0.82rem; }
    .cell { font-size: 1.2rem; }
    #grid {
        width: min(96vw, 480px);
        height: min(96vw, 480px);
    }
    #sudoku-grid {
        width: min(96vw, 480px);
        height: min(96vw, 480px);
    }
    .sudoku-cell { font-size: 1.15rem; }
    .numpad-btn { width: 38px; height: 38px; font-size: 1.05rem; }
    #picross-table { font-size: 0.55rem; }
    .picross-cell { width: 28px; height: 28px; min-width: 28px; min-height: 28px; font-size: 0.9rem; }
    .picross-clue-col { font-size: 0.7rem; padding: 2px 1px; }
    .picross-clue-row { font-size: 0.7rem; padding: 0 4px 0 1px; }
}

@media (max-width: 400px) {
    .picross-cell { width: 24px; height: 24px; min-width: 24px; min-height: 24px; font-size: 0.8rem; }
    .picross-clue-col { font-size: 0.6rem; padding: 1px 1px; }
    .picross-clue-row { font-size: 0.6rem; padding: 0 3px 0 1px; }
}

/* Picross: shrink for medium (10×10) */
#picross-grid-container.picross-medium .picross-cell {
    width: 28px; height: 28px; min-width: 28px; min-height: 28px; font-size: 0.9rem;
}
#picross-grid-container.picross-medium .picross-clue-col { font-size: 0.8rem; padding: 2px 1px; }
#picross-grid-container.picross-medium .picross-clue-row { font-size: 0.8rem; padding: 0 5px 0 1px; }

/* Picross: shrink for hard (15×15) */
#picross-grid-container.picross-hard .picross-cell {
    width: 22px; height: 22px; min-width: 22px; min-height: 22px; font-size: 0.75rem;
}
#picross-grid-container.picross-hard .picross-clue-col { font-size: 0.7rem; padding: 1px 1px; }
#picross-grid-container.picross-hard .picross-clue-row { font-size: 0.7rem; padding: 0 3px 0 1px; }

@media (max-width: 480px) {
    #picross-grid-container.picross-medium .picross-cell {
        width: 24px; height: 24px; min-width: 24px; min-height: 24px; font-size: 0.8rem;
    }
    #picross-grid-container.picross-medium .picross-clue-col { font-size: 0.65rem; }
    #picross-grid-container.picross-medium .picross-clue-row { font-size: 0.65rem; }

    #picross-grid-container.picross-hard .picross-cell {
        width: 18px; height: 18px; min-width: 18px; min-height: 18px; font-size: 0.65rem;
    }
    #picross-grid-container.picross-hard .picross-clue-col { font-size: 0.55rem; padding: 1px 0; }
    #picross-grid-container.picross-hard .picross-clue-row { font-size: 0.55rem; padding: 0 2px 0 0; }
}

/* ===== Picross ===== */
#picross-difficulty {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.pdiff-btn {
    padding: 8px 20px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.pdiff-btn:hover {
    border-color: #38a169;
    color: #38a169;
}

.pdiff-btn.active {
    background: #38a169;
    color: #fff;
    border-color: #38a169;
}

#picross-toolbar {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 16px;
}

#picross-new-game, #picross-draft-btn, #picross-hint-btn, #picross-verify-btn {
    padding: 8px 18px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#picross-new-game {
    background: #4299e1;
    color: #fff;
}

#picross-new-game:hover {
    background: #3182ce;
}

#picross-verify-btn {
    background: #48bb78;
    color: #fff;
}

#picross-verify-btn:hover {
    background: #38a169;
}

#picross-hint-btn {
    background: #ed8936;
    color: #fff;
}

#picross-hint-btn:hover {
    background: #dd6b20;
}

#picross-draft-btn {
    background: #a0aec0;
    color: #fff;
}

#picross-draft-btn:hover {
    background: #718096;
}

#picross-draft-btn.draft-active {
    background: #9f7aea;
    animation: pulse-draft 1s infinite;
}

#picross-grid-container {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    overflow-x: auto;
}

#picross-mode-toggle {
    display: flex;
    gap: 0;
    justify-content: center;
    margin-bottom: 14px;
}

.picross-toggle-btn {
    padding: 8px 20px;
    border: 2px solid #cbd5e0;
    background: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: #4a5568;
}

.picross-toggle-btn:first-child {
    border-radius: 8px 0 0 8px;
    border-right: 1px solid #cbd5e0;
}

.picross-toggle-btn:last-child {
    border-radius: 0 8px 8px 0;
    border-left: 1px solid #cbd5e0;
}

.picross-toggle-btn.active[data-mode="fill"] {
    background: #2d3748;
    color: #fff;
    border-color: #2d3748;
}

.picross-toggle-btn.active[data-mode="cross"] {
    background: #e53e3e;
    color: #fff;
    border-color: #e53e3e;
}

#picross-table {
    border-collapse: collapse;
    user-select: none;
    touch-action: none;
}

.picross-clue-col {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4a5568;
    text-align: center;
    vertical-align: bottom;
    padding: 3px 2px;
    line-height: 1.3;
}

.picross-clue-row {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4a5568;
    text-align: right;
    padding: 0 8px 0 2px;
    white-space: nowrap;
}

.picross-cell {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    border: 1px solid #cbd5e0;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    transition: background 0.1s;
    font-size: 1.1rem;
    font-weight: 700;
    position: relative;
}

.picross-cell:hover {
    background: #edf2f7;
}

.picross-cell.filled {
    background: #2d3748;
}

.picross-cell.filled:hover {
    background: #4a5568;
}

.picross-cell.crossed {
    color: #e53e3e;
    font-size: 1rem;
    background: #fff;
}

.picross-cell.draft-filled {
    background: #a0aec0;
}

.picross-cell.draft-filled:hover {
    background: #8a9ab5;
}

.picross-cell.draft-crossed {
    color: #b794f4;
    font-size: 1rem;
    background: #fff;
}

.picross-cell.locked {
    cursor: default;
}

.picross-cell.hinted {
    background: #276749;
}

.picross-cell.hinted:hover {
    background: #276749;
}

/* Thick borders every 5 cells */
.picross-cell.block-border-right {
    border-right: 2px solid #2d3748;
}

.picross-cell.block-border-bottom {
    border-bottom: 2px solid #2d3748;
}

.picross-clue-row.block-border-bottom {
    border-bottom: 2px solid #2d3748;
}

.picross-clue-col.block-border-right {
    border-right: 2px solid #2d3748;
}

/* Row/col completion */
.picross-clue-row.completed {
    color: #38a169;
    cursor: pointer;
}

.picross-clue-col.completed {
    color: #38a169;
    cursor: pointer;
}

/* Individual clue number states */
.picross-clue-num.clue-matched {
    color: #3182ce;
}

.picross-clue-num.clue-complete {
    color: #38a169;
}

.picross-clue-col.clue-matched {
    color: #3182ce;
}

.picross-clue-col.clue-complete {
    color: #38a169;
}

/* Verification error highlight */
.picross-cell.picross-verify-error {
    outline: 3px solid #e53e3e;
    outline-offset: -3px;
    animation: picross-verify-pulse 0.6s ease 3;
}

@keyframes picross-verify-pulse {
    0%, 100% { outline-color: #e53e3e; }
    50% { outline-color: #feb2b2; }
}

@keyframes picross-error-flash {
    0%, 100% { background-color: inherit; }
    25%, 75% { background-color: #fc8181; }
}

.picross-cell.picross-error {
    animation: picross-error-flash 0.6s ease;
}

#picross-message {
    font-size: 1.1rem;
    font-weight: 700;
    padding: 10px;
    border-radius: 8px;
    margin-top: 8px;
}

#picross-message.hidden {
    display: none;
}

#picross-message.win {
    background: #c6f6d5;
    color: #276749;
}

#picross-message.hint {
    background: #e2e8f0;
    color: #2d3748;
    font-weight: 600;
}
