/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    color: #fff;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    position: relative;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen-container {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

/* Game Cards */
.game-card, .victory-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 32px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    text-align: center;
}

.control-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    height: fit-content;
}

/* Game Header */
.game-header {
    margin-bottom: 32px;
}

.game-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.game-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #fff, #f0f0f0);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 500;
}

/* Settings Section */
.settings-section {
    margin-bottom: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.setting-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.setting-select {
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.setting-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.setting-select option {
    background: #333;
    color: #fff;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover:before {
    left: 100%;
}

.btn-large {
    padding: 16px 32px;
    font-size: 1.1rem;
    border-radius: 16px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(255, 107, 107, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.3);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 25px rgba(78, 205, 196, 0.4);
}

.btn-hint {
    background: linear-gradient(135deg, #ffd93d, #ffb74d);
    color: #333;
    box-shadow: 0 6px 15px rgba(255, 217, 61, 0.3);
}

.btn-undo {
    background: linear-gradient(135deg, #9c27b0, #7b1fa2);
    color: white;
    box-shadow: 0 6px 15px rgba(156, 39, 176, 0.3);
}

.btn-quit {
    background: linear-gradient(135deg, #ff5722, #d84315);
    color: white;
    box-shadow: 0 6px 15px rgba(255, 87, 34, 0.3);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.2em;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 32px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.8;
    font-weight: 500;
}

/* Game Layout */
.game-layout {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.game-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 16px 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 16px;
}

.player-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    border: 3px solid #fff;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.player-avatar.player2 {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.3);
}

.turn-text {
    font-size: 1.2rem;
    font-weight: 600;
}

.game-stats {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.9;
}

/* Game Content */
.game-content {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 32px;
    flex: 1;
    align-items: start;
}

.canvas-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

.canvas-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Pixel Grid */
.pixel-grid {
    display: grid;
    gap: 2px;
    background: #333;
    border: 4px solid #fff;
    border-radius: 12px;
    padding: 8px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pixel-grid.size-16 {
    grid-template-columns: repeat(16, 22px);
    grid-template-rows: repeat(16, 22px);
}

.pixel-grid.size-20 {
    grid-template-columns: repeat(20, 18px);
    grid-template-rows: repeat(20, 18px);
}

.pixel-grid.small.size-16 {
    grid-template-columns: repeat(16, 12px);
    grid-template-rows: repeat(16, 12px);
}

.pixel-grid.small.size-20 {
    grid-template-columns: repeat(20, 10px);
    grid-template-rows: repeat(20, 10px);
}

.pixel {
    background: #f0f0f0;
    cursor: crosshair;
    transition: all 0.2s ease;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.pixel:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
    z-index: 1;
    position: relative;
}

.pixel.painted {
    cursor: not-allowed;
}

/* Hint Overlay */
.hint-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    display: grid;
    gap: 2px;
    border-radius: 8px;
    overflow: hidden;
}

.hint-overlay.show {
    opacity: 0.6;
}

.hint-overlay.size-16 {
    grid-template-columns: repeat(16, 22px);
    grid-template-rows: repeat(16, 22px);
}

.hint-overlay.size-20 {
    grid-template-columns: repeat(20, 18px);
    grid-template-rows: repeat(20, 18px);
}

/* Controls Section */
.controls-section {
    display: flex;
    flex-direction: column;
}

.control-group {
    margin-bottom: 24px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.control-icon {
    font-size: 1.2em;
}

/* Color Picker */
.color-palette {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.color-btn {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
}

.color-btn.active {
    border-width: 4px;
    border-color: #fff;
    transform: scale(1.15);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

/* Guess Section */
.guess-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.guess-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.3s ease;
}

.guess-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.guess-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Victory Screen */
.victory-header {
    margin-bottom: 32px;
}

.victory-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    animation: bounce 1s ease-in-out infinite;
}

.victory-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-message {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 500;
}

.final-images {
    margin: 32px 0;
}

.image-comparison {
    display: flex;
    justify-content: center;
    gap: 32px;
    flex-wrap: wrap;
}

.final-canvas, .original-image {
    text-align: center;
}

.comparison-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: rgba(255, 255, 255, 0.9);
}

.victory-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.victory-stat {
    text-align: center;
}

.victory-stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 4px;
}

.victory-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
}

.victory-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Confetti Animation */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confetti-fall 3s linear forwards;
}

@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .game-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .controls-section {
        order: -1;
    }
    
    .control-card {
        padding: 20px;
    }
    
    .game-header-bar {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .screen-container {
        padding: 16px;
    }
    
    .game-card, .victory-card {
        padding: 24px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .pixel-grid.size-16 {
        grid-template-columns: repeat(16, 18px);
        grid-template-rows: repeat(16, 18px);
    }
    
    .pixel-grid.size-20 {
        grid-template-columns: repeat(20, 15px);
        grid-template-rows: repeat(20, 15px);
    }
    
    .hint-overlay.size-16 {
        grid-template-columns: repeat(16, 18px);
        grid-template-rows: repeat(16, 18px);
    }
    
    .hint-overlay.size-20 {
        grid-template-columns: repeat(20, 15px);
        grid-template-rows: repeat(20, 15px);
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .color-palette {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .image-comparison {
        flex-direction: column;
        align-items: center;
        gap: 24px;
    }
    
    .victory-stats {
        flex-direction: column;
        gap: 16px;
    }
    
    .victory-buttons {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }
    
    .pixel-grid.size-16 {
        grid-template-columns: repeat(16, 15px);
        grid-template-rows: repeat(16, 15px);
    }
    
    .pixel-grid.size-20 {
        grid-template-columns: repeat(20, 12px);
        grid-template-rows: repeat(20, 12px);
    }
    
    .hint-overlay.size-16 {
        grid-template-columns: repeat(16, 15px);
        grid-template-rows: repeat(16, 15px);
    }
    
    .hint-overlay.size-20 {
        grid-template-columns: repeat(20, 12px);
        grid-template-rows: repeat(20, 12px);
    }
    
    .btn {
        font-size: 0.9rem;
        padding: 12px 20px;
    }
    
    .btn-large {
        padding: 14px 24px;
        font-size: 1rem;
    }
    
    .color-btn {
        width: 40px;
        height: 40px;
    }
}

/* Loading and Transition Effects */
.screen {
    transition: opacity 0.3s ease-in-out;
}

.btn, .color-btn, .pixel {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus Styles for Accessibility */
.btn:focus,
.color-btn:focus,
.setting-select:focus,
.guess-input:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .game-card, .victory-card, .control-card {
        border: 2px solid #fff;
    }
    
    .btn {
        border: 2px solid currentColor;
    }
}