  /* Enhanced CSS for 8-Puzzle Game */

  :root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --crypto-color: #f1c40f;
    --text-color: #ecf0f1;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --tile-size: 140px;
    --tile-gap: 12px;
    --border-radius: 12px;
    --transition-speed: 0.3s;
    --blur-amount: 10px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--primary-color), #34495e);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 3px 3px 6px var(--shadow-color);
    letter-spacing: 2px;
    background: linear-gradient(45deg, #3498db, #2ecc71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--crypto-color);
    font-weight: 500;
    margin-top: 10px;
}

/* Auth Section */
#auth-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-form {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: 0 15px 35px var(--shadow-color);
    border: 2px solid rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(var(--blur-amount));
    backdrop-filter: blur(var(--blur-amount));
    max-width: 400px;
    width: 100%;
}

.auth-form h2 {
    margin-bottom: 25px;
    text-align: center;
    font-size: 1.8rem;
    color: var(--text-color);
}

.form-group {
    margin-bottom: 20px;
}

.auth-form input {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    background: rgba(255, 255, 255, 0.9);
    transition: all var(--transition-speed) ease;
    box-shadow: inset 0 2px 5px var(--shadow-color);
}

.auth-form input:focus {
    outline: none;
    background: white;
    box-shadow: 
        inset 0 2px 5px var(--shadow-color), 
        0 0 0 3px rgba(52, 152, 219, 0.3);
    transform: translateY(-1px);
}

/* Game UI */
#game-ui {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    margin-top: 0 !important;
}

#user-header {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    box-shadow: 0 5px 15px var(--shadow-color);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary-color), var(--crypto-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
}

.user-stats {
    display: flex;
    gap: 20px;
}

.user-stat {
    text-align: center;
}

.user-stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--crypto-color);
}

.user-stat-label {
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Game Container */
#game-container {
    display: grid;
    grid-template-columns: repeat(4, var(--tile-size));
    grid-gap: var(--tile-gap);
    margin: 0 auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px var(--shadow-color);
    justify-content: center;
    align-items: center;
    width: fit-content;
}

.tile {
    width: var(--tile-size);
    height: var(--tile-size);
    background: linear-gradient(145deg, #3498db, #2980b9);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.7rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: var(--border-radius);
    transition: all var(--transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 16px var(--shadow-color), inset 0 1px 0 rgba(255,255,255,0.3);
    position: relative;
    -webkit-user-select: none;
    user-select: none;
    border: 2px solid rgba(255,255,255,0.1);
    padding: 0;
    line-height: 1;
    overflow: visible;
}

.tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4) 0%, 
        transparent 50%, 
        rgba(0, 0, 0, 0.2) 100%);
    border-radius: var(--border-radius);
    pointer-events: none;
}

.tile:not(.empty):hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 
        0 15px 30px var(--shadow-color),
        0 0 20px rgba(52, 152, 219, 0.3);
    background: linear-gradient(145deg, #5dade2, #3498db);
}

.tile.empty {
    background: rgba(255, 255, 255, 0.05);
    cursor: default;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.2);
}

.tile.highlight {
    animation: highlight 0.5s ease;
}

.tile.winner {
    animation: celebrate 0.8s ease;
}

@keyframes highlight {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); background: linear-gradient(145deg, #e74c3c, #c0392b); }
}

@keyframes celebrate {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.15) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* Controls */
#controls {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    padding: 25px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    box-shadow: 0 10px 25px var(--shadow-color);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    transition: all var(--transition-speed);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat:hover {
    background: rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

.stat span {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    margin-top: 5px;
}

.best-score {
    color: var(--crypto-color) !important;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    margin: 5px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 8px var(--shadow-color);
    position: relative;
    overflow: hidden;
    min-width: 120px;
}

.btn-primary {
    background: linear-gradient(145deg, var(--secondary-color), #2980b9);
    color: white;
}

.btn-primary:hover {
    background: linear-gradient(145deg, #5dade2, var(--secondary-color));
    transform: translateY(-2px);
    box-shadow: 0 8px 16px var(--shadow-color);
}

.btn-secondary {
    background: linear-gradient(145deg, #7f8c8d, #95a5a6);
    color: white;
}

.btn-secondary:hover {
    background: linear-gradient(145deg, #95a5a6, #bdc3c7);
    transform: translateY(-2px);
}

.btn-export {
    background: linear-gradient(145deg, var(--success-color), #229954);
    color: white;
}

.btn-export:hover {
    background: linear-gradient(145deg, #2ecc71, var(--success-color));
    transform: translateY(-2px);
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Difficulty and Settings */
.game-settings {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.difficulty-selector select,
.sound-toggle {
    padding: 10px 15px;
    border-radius: var(--border-radius);
    background: linear-gradient(145deg, #3498db, #2980b9);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all var(--transition-speed);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.difficulty-selector select:hover,
.sound-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-color);
}

/* Game Status */
.game-status {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: linear-gradient(145deg, #34495e, #2c3e50);
    border-radius: var(--border-radius);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.game-status.won {
    background: linear-gradient(145deg, var(--success-color), #229954);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Keyboard Controls Info */
.keyboard-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    text-align: center;
}

.keyboard-info h4 {
    margin-bottom: 10px;
    color: var(--crypto-color);
}

.key-combo {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px;
    font-family: monospace;
    font-size: 12px;
}

/* Game History */
#game-history {
    background: linear-gradient(145deg, #34495e, #2c3e50);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 30px;
    box-shadow: 0 5px 15px var(--shadow-color);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

#game-history h3 {
    margin-bottom: 15px;
    text-align: center;
    color: var(--crypto-color);
}

.history-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-wrap: wrap;
}

.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.history-filters select {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    font-size: 14px;
}

#history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
}

#history-stats div {
    text-align: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

#history-stats span {
    font-weight: bold;
    color: var(--crypto-color);
    font-size: 1.2rem;
}

#history-list-container {
    max-height: 400px;
    overflow-y: auto;
    margin-top: 15px;
}

#history-list {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--border-radius);
}

#history-list th {
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid var(--secondary-color);
    background: rgba(0, 0, 0, 0.3);
    position: sticky;
    top: 0;
}

#history-list td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#history-list tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

.win-result {
    color: var(--success-color);
    font-weight: bold;
}

.loss-result {
    color: var(--accent-color);
    font-weight: bold;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.message {
    padding: 12px;
    margin: 10px 0;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: opacity var(--transition-speed) ease;
}

.error-message {
    background: linear-gradient(145deg, #e74c3c, #c0392b);
    color: white;
    border: 1px solid #a93226;
}

.success-message {
    background: linear-gradient(145deg, #27ae60, #229954);
    color: white;
    border: 1px solid #1e8449;
}

/* Responsive Design */
@media (max-width: 768px) {
    :root {
        --tile-size: 90px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .user-header {
        flex-direction: column;
        gap: 15px;
    }
    
    .user-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-settings {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-group {
        flex-direction: column;
    }
    .tile {
        font-size: 1.7rem;
    }
}

@media (max-width: 450px) {
    :root {
        --tile-size: 60px;
    }
    
    .tile {
        font-size: 1.2rem;
    }
    
    .stats {
        grid-template-columns: 1fr;
    }
    
    #history-stats {
        grid-template-columns: 1fr;
    }
}