/* Main Layout */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f5f5;
    color: #333;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 10px 15px;
    border-radius: 8px 8px 0 0;
    margin-bottom: 15px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 5px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 14px;
}

#puzzle-timer {
    font-family: 'Courier New', monospace;
    color: #fff;
}

header h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1;
}

.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    align-items: center;
}

.puzzle-navigation {
    display: flex;
    gap: 4px;
    margin: 0 4px;
}

button, select {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    background-color: #3498db;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

button i {
    font-size: 12px;
}

button:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:active {
    transform: translateY(0);
    box-shadow: none;
}

button:disabled {
    background-color: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background-color: #2ecc71;
}

.btn-primary:hover {
    background-color: #27ae60;
}

.btn-warning {
    background-color: #e67e22;
}

.btn-warning:hover {
    background-color: #d35400;
}

select {
    background-color: white;
    color: #333;
    border: 1px solid #bdc3c7;
}

/* Puzzle Board */
.main-content {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.puzzle-container {
    flex: 1;
    min-width: 280px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 12px;
    margin-bottom: 15px;
    overflow-x: auto;
}

.puzzle-board {
    display: grid;
    gap: 1px;
    background-color: #bdc3c7;
    border: 2px solid #7f8c8d;
    margin: 0 auto;
    max-width: 100%;
    min-width: 280px;
    transition: all 0.3s ease;
}

/* Grid size specific styles */
.puzzle-board.size-4x4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    max-width: 400px;
}

.puzzle-board.size-6x6 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    max-width: 500px;
}

.puzzle-board.size-8x8 {
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    max-width: 600px;
}

.puzzle-board.size-10x10 {
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    max-width: 600px;
}

.puzzle-board.size-12x12 {
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(12, 1fr);
    max-width: 600px;
}

.puzzle-board.size-14x14 {
    grid-template-columns: repeat(14, 1fr);
    grid-template-rows: repeat(14, 1fr);
    max-width: 602px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1400px) {
    .puzzle-board.size-14x14 {
        grid-template-columns: repeat(12, 1fr);
        grid-template-rows: repeat(12, 1fr);
        max-width: 600px;
    }
}

@media (max-width: 1200px) {
    .puzzle-board.size-14x14 {
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(10, 1fr);
        max-width: 600px;
    }
}

@media (max-width: 992px) {
    .puzzle-board.size-12x12,
    .puzzle-board.size-14x14 {
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .puzzle-board.size-10x10,
    .puzzle-board.size-12x12,
    .puzzle-board.size-14x14 {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(6, 1fr);
        max-width: 500px;
    }
}

@media (max-width: 576px) {
    .puzzle-board {
        min-width: 240px;
    }
    
    .puzzle-board.size-8x8,
    .puzzle-board.size-10x10,
    .puzzle-board.size-12x12,
    .puzzle-board.size-14x14 {
        grid-template-columns: repeat(4, 1fr);
        grid-template-rows: repeat(4, 1fr);
        max-width: 400px;
    }
}

.cell {
    aspect-ratio: 1;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 72px;
    font-weight: bold;
    cursor: pointer;
    position: relative;
    user-select: none;
    min-width: 40px;
    min-height: 40px;
    transition: background-color 0.2s, transform 0.1s;
    border: 1px solid #e0e0e0;
}

.cell:hover {
    background-color: #aff1d2;
    transform: scale(1.05);
    z-index: 1;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.cell.fixed {
    background-color: #e1fbef;
    color: #2c3e50;
    cursor: default;
    font-family: 'Courier New', monospace;
    font-weight: 900;
}

.cell.x {
    color: #e74c3c;
}

.cell.o {
    color: #3498db;
}

.cell.highlight {
    background-color: #f1c40f;
    opacity: 0.7;
}

/* Puzzle Info */
.puzzle-info {
    display: flex;
    justify-content: space-between;
    padding: 8px 0 0;
    border-top: 1px solid #ecf0f1;
    margin-top: 8px;
    font-size: 12px;
    color: #7f8c8d;
}

/* Puzzle Library */
.puzzle-library {
    width: 250px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 12px;
    max-height: 580px;
    overflow-y: auto;
    font-size: 13px;
}

.puzzle-library h3 {
    margin-top: 0;
    color: #2c3e50;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 10px;
}

.puzzle-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.puzzle-item {
    padding: 10px 15px;
    margin: 8px 0;
    background-color: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.puzzle-item:hover {
    background-color: #e9ecef;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.puzzle-item.active {
    background-color: #e7f1ff;
    border-left: 3px solid #0d6efd;
    padding-left: 12px;
}

.puzzle-id {
    font-weight: bold;
    min-width: 40px;
    display: inline-block;
}

.difficulty-selector {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.difficulty-btn {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.difficulty-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.difficulty-btn:active {
    transform: translateY(0);
}

/* Difficulty-specific styles */
.difficulty-btn.easy { 
    background-color: #d4edda; 
    color: #0f5132;
    border-color: #badbcc;
}

.difficulty-btn.medium { 
    background-color: #fff3cd; 
    color: #664d03;
    border-color: #ffecb5;
}

.difficulty-btn.hard { 
    background-color: #f8d7da; 
    color: #842029;
    border-color: #f5c2c7;
}

.difficulty-btn.expert { 
    background-color: #cfe2ff; 
    color: #084298;
    border-color: #b6d4fe;
}

.difficulty-btn.master { 
    background-color: #e2e3e5; 
    color: #2b2f32;
    border-color: #d3d6d8;
}

/* Active state for difficulty buttons */
.puzzle-item.active .difficulty-btn.active {
    transform: scale(1.05);
    box-shadow: 0 0 0 2px #0d6efd;
}

/* Feedback */
.feedback {
    margin: 0;
    padding: 6px 10px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    display: none;
    font-size: 13px;
    max-width: 300px;
}

.feedback.success {
    background-color: rgba(46, 125, 50, 0.8);
}

.feedback.error {
    background-color: rgba(198, 40, 40, 0.8);
}

.feedback.info {
    background-color: rgba(41, 98, 255, 0.8);
}

.feedback.error {
    background-color: #ffebee;
    color: #c62828;
}

.feedback.success {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
    
    .puzzle-library {
        width: 100%;
    }
}
