/* ================================================================
   PUZZLE GAMES - PROFESSIONAL RESPONSIVE STYLING
   All puzzle types: Sudoku, Word Search, Crossword, Jigsaw
   Fully responsive for mobile, tablet, desktop
================================================================ */

:root {
    --primary-color: #2563eb;
    --secondary-color: #1e40af;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #ea580c;
    --info-color: #0891b2;
    --light-bg: #f8fafc;
    --dark-bg: #0f172a;
    --border-color: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ================================================================
   GAME CONTAINER & LAYOUT
================================================================ */

.puzzle-game-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.puzzle-game-container {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 1200px;
    width: 100%;
    overflow: hidden;
}

.puzzle-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
    border-bottom: 4px solid var(--secondary-color);
}

.puzzle-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
}

.puzzle-header p {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.puzzle-content {
    padding: 30px 20px;
    background: var(--light-bg);
}

/* ================================================================
   GAME STATS & CONTROLS
================================================================ */

.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-left: 4px solid var(--primary-color);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-card.danger .stat-value {
    color: var(--danger-color);
}

.stat-card.success .stat-value {
    color: var(--success-color);
}

.stat-card.warning .stat-value {
    color: var(--warning-color);
}

.game-controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.game-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.game-btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--secondary-color), #1e3a8a);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--light-bg);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #c2410c;
}

.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-disabled:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ================================================================
   DIFFICULTY BADGE
================================================================ */

.difficulty-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.difficulty-easy {
    background: #dcfce7;
    color: #166534;
}

.difficulty-medium {
    background: #fef3c7;
    color: #92400e;
}

.difficulty-hard {
    background: #fee2e2;
    color: #991b1b;
}

/* ================================================================
   SUDOKU STYLING
================================================================ */

.sudoku-board {
    background: white;
    border: 3px solid var(--text-primary);
    border-radius: 8px;
    padding: 10px;
    display: inline-block;
    box-shadow: var(--shadow);
    margin: 20px auto;
}

.sudoku-row {
    display: flex;
    margin-bottom: 0;
}

.sudoku-row:nth-child(3n) {
    margin-bottom: 8px;
}

.sudoku-cell {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    background: white;
    color: var(--text-primary);
    transition: var(--transition);
    position: relative;
}

.sudoku-cell:nth-child(3n) {
    margin-right: 8px;
}

.sudoku-cell:hover {
    background: #e8f1ff;
    border-color: var(--primary-color);
}

.sudoku-cell.selected {
    background: #dbeafe;
    border-color: var(--primary-color);
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.sudoku-cell.filled {
    background: white;
    color: var(--primary-color);
    font-weight: 700;
}

.sudoku-cell.fixed {
    background: #f1f5f9;
    color: var(--text-primary);
    font-weight: 700;
}

.sudoku-cell.error {
    background: #fee2e2;
    color: var(--danger-color);
}

.sudoku-cell.hint {
    background: #fef3c7;
}

.sudoku-cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    background: transparent;
    color: var(--primary-color);
}

.sudoku-cell input:focus {
    outline: none;
}

.sudoku-keyboard {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 20px;
}

.sudoku-key {
    padding: 12px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.sudoku-key:hover {
    border-color: var(--primary-color);
    background: #dbeafe;
}

.sudoku-key.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ================================================================
   WORD SEARCH STYLING
================================================================ */

.word-search-grid {
    background: white;
    border: 3px solid var(--text-primary);
    border-radius: 8px;
    padding: 15px;
    display: inline-block;
    box-shadow: var(--shadow);
    margin: 20px auto;
    user-select: none;
}

.ws-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ws-cell {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    color: var(--text-primary);
}

.ws-cell:hover {
    background: #e8f1ff;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.ws-cell.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.ws-cell.found {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.ws-cell.hint {
    background: #fef3c7;
    border-color: var(--warning-color);
}

.word-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.word-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.word-item.found {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.word-item.found .word-text {
    text-decoration: line-through;
    color: var(--text-secondary);
}

.word-text {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 16px;
}

/* ================================================================
   CROSSWORD STYLING
================================================================ */

.crossword-grid {
    background: white;
    border: 3px solid var(--text-primary);
    border-radius: 8px;
    padding: 10px;
    display: inline-block;
    box-shadow: var(--shadow);
    margin: 20px auto;
}

.cw-row {
    display: flex;
    margin-bottom: 0;
}

.cw-cell {
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--text-primary);
    background: white;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary);
    cursor: text;
    position: relative;
}

.cw-cell.blocked {
    background: var(--text-primary);
    cursor: not-allowed;
}

.cw-cell input {
    width: 100%;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    background: transparent;
    color: var(--primary-color);
}

.cw-cell input:focus {
    outline: none;
    background: #e8f1ff;
}

.cw-cell.error input {
    color: var(--danger-color);
}

.cw-clue-number {
    position: absolute;
    top: 1px;
    left: 1px;
    font-size: 8px;
    font-weight: 700;
    line-height: 1;
}

.crossword-clues {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.clue-section h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.clue-item {
    margin-bottom: 12px;
    padding: 10px;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.clue-item:hover {
    background: var(--light-bg);
    border-left: 3px solid var(--primary-color);
    padding-left: 13px;
}

.clue-number {
    font-weight: 700;
    color: var(--primary-color);
    margin-right: 8px;
}

.clue-text {
    color: var(--text-primary);
    font-size: 14px;
}

/* ================================================================
   JIGSAW STYLING
================================================================ */

.jigsaw-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    margin-top: 20px;
}

.jigsaw-board {
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
    box-shadow: var(--shadow);
}

.jigsaw-image-preview {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    opacity: 0.2;
    z-index: 1;
}

.jigsaw-pieces {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-height: 500px;
    overflow-y: auto;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.jigsaw-piece {
    aspect-ratio: 1;
    background-size: cover;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: grab;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.jigsaw-piece:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.jigsaw-piece:active {
    cursor: grabbing;
}

.jigsaw-piece.placed {
    opacity: 0.3;
    border-style: dashed;
    cursor: not-allowed;
}

/* ================================================================
   HINTS & HELP
================================================================ */

.hints-section {
    background: #fffbeb;
    border-left: 4px solid var(--warning-color);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.hints-header {
    font-weight: 700;
    color: var(--warning-color);
    margin-bottom: 10px;
}

.hints-available {
    display: flex;
    gap: 6px;
    margin: 10px 0;
}

.hint-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--warning-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.hint-dot.used {
    background: var(--border-color);
    color: var(--text-secondary);
}

.hint-content {
    background: white;
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    color: var(--text-primary);
    font-size: 14px;
}

/* ================================================================
   MODAL & FULLSCREEN
================================================================ */

.puzzle-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.puzzle-modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 40px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.modal-body {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 16px;
    line-height: 1.6;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.fullscreen-btn {
    background: var(--primary-color);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.fullscreen-btn:hover {
    background: var(--secondary-color);
}

/* ================================================================
   MOBILE RESPONSIVE
================================================================ */

@media (max-width: 1024px) {
    .jigsaw-container {
        grid-template-columns: 1fr;
    }
    
    .jigsaw-pieces {
        grid-template-columns: repeat(4, 1fr);
        max-height: 300px;
    }
    
    .puzzle-content {
        padding: 20px 15px;
    }
    
    .game-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .puzzle-game-wrapper {
        padding: 10px;
    }
    
    .puzzle-header {
        padding: 20px 15px;
    }
    
    .puzzle-header h1 {
        font-size: 24px;
    }
    
    .puzzle-content {
        padding: 15px 10px;
    }
    
    .game-stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .stat-card {
        padding: 12px;
    }
    
    .stat-card .stat-label {
        font-size: 11px;
    }
    
    .stat-card .stat-value {
        font-size: 20px;
    }
    
    .game-controls {
        gap: 8px;
    }
    
    .game-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .sudoku-cell {
        width: 35px;
        height: 35px;
        font-size: 16px;
    }
    
    .ws-cell {
        width: 30px;
        height: 30px;
        font-size: 12px;
        gap: 6px;
    }
    
    .cw-cell {
        width: 32px;
        height: 32px;
        font-size: 11px;
    }
    
    .crossword-clues {
        grid-template-columns: 1fr;
    }
    
    .word-list {
        grid-template-columns: 1fr;
    }
    
    .sudoku-keyboard {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .jigsaw-pieces {
        grid-template-columns: repeat(3, 1fr);
        max-height: 250px;
    }
}

@media (max-width: 480px) {
    .puzzle-header h1 {
        font-size: 20px;
    }
    
    .game-stats {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .stat-card {
        padding: 10px;
    }
    
    .stat-card .stat-label {
        font-size: 10px;
    }
    
    .stat-card .stat-value {
        font-size: 18px;
    }
    
    .game-btn {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1 1 calc(50% - 5px);
    }
    
    .sudoku-board {
        padding: 8px;
        margin: 15px auto;
    }
    
    .sudoku-cell {
        width: 30px;
        height: 30px;
        font-size: 14px;
        border: 1px solid var(--border-color);
    }
    
    .sudoku-cell:nth-child(3n) {
        margin-right: 5px;
    }
    
    .sudoku-row:nth-child(3n) {
        margin-bottom: 5px;
    }
    
    .sudoku-keyboard {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
    
    .sudoku-key {
        padding: 10px;
        font-size: 12px;
    }
    
    .word-search-grid {
        padding: 10px;
    }
    
    .ws-row {
        gap: 6px;
        margin-bottom: 6px;
    }
    
    .ws-cell {
        width: 28px;
        height: 28px;
        font-size: 11px;
        border: 1px solid var(--border-color);
    }
    
    .word-list {
        grid-template-columns: 1fr;
    }
    
    .cw-cell {
        width: 28px;
        height: 28px;
        font-size: 10px;
    }
    
    .crossword-clues {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .clue-section h3 {
        font-size: 14px;
    }
    
    .clue-item {
        margin-bottom: 10px;
        padding: 8px;
    }
    
    .clue-text {
        font-size: 13px;
    }
    
    .jigsaw-board {
        min-height: 300px;
    }
    
    .jigsaw-container {
        gap: 15px;
    }
    
    .jigsaw-pieces {
        grid-template-columns: repeat(3, 1fr);
        max-height: 200px;
        padding: 10px;
        gap: 8px;
    }
    
    .modal-content {
        padding: 25px;
        width: 95%;
    }
    
    .modal-header {
        font-size: 20px;
    }
    
    .modal-body {
        font-size: 14px;
    }
}

/* ================================================================
   ANIMATIONS
================================================================ */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.loading {
    animation: spin 1s linear infinite;
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

/* ================================================================
   UTILITY CLASSES
================================================================ */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}
