/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A90E2;
    --secondary-color: #7B68EE;
    --success-color: #50C878;
    --danger-color: #E74C3C;
    --warning-color: #F39C12;
    --bg-color: #F5F7FA;
    --text-color: #2C3E50;
    --card-bg: #FFFFFF;
    --border-color: #E1E8ED;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

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

/* Header */
.header {
    text-align: center;
    padding: 30px 20px;
    background: var(--card-bg);
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    animation: slideDown 0.5s ease-out;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    color: #7F8C8D;
    font-weight: 400;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.difficulty-selector {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--card-bg);
    padding: 10px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.difficulty-selector label {
    font-weight: 600;
    color: var(--text-color);
}

.difficulty-selector select {
    padding: 8px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.difficulty-selector select:hover {
    border-color: var(--primary-color);
}

.difficulty-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    margin-top: 20px;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 40px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 500px;
    animation: fadeIn 0.5s ease-out;
}

#drawingCanvas {
    border: 3px dashed var(--border-color);
    border-radius: 15px;
    cursor: crosshair;
    touch-action: none;
    transition: border-color 0.3s ease;
    background: #FAFBFC;
}

#drawingCanvas:hover {
    border-color: var(--primary-color);
}

#drawingCanvas.drawing {
    border-color: var(--success-color);
    border-style: solid;
}

.instruction {
    margin-top: 20px;
    font-size: 1.1rem;
    color: #7F8C8D;
    font-weight: 500;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

.score-display {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.score-display.visible {
    opacity: 1;
}

/* Result Panel */
.result-panel {
    display: none;
    text-align: center;
    animation: scaleIn 0.5s ease-out;
    padding: 20px;
}

.result-panel.visible {
    display: block;
}

.result-title {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

.score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-message {
    font-size: 1.3rem;
    color: #7F8C8D;
    margin-bottom: 20px;
    font-weight: 600;
}

.achievement-badge {
    margin: 20px 0;
    min-height: 80px;
}

.badge {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 5px;
    animation: bounceIn 0.6s ease-out;
    box-shadow: var(--shadow);
}

.badge-gold {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #8B4513;
}

.badge-silver {
    background: linear-gradient(135deg, #C0C0C0 0%, #A8A8A8 100%);
    color: #4A4A4A;
}

.badge-bronze {
    background: linear-gradient(135deg, #CD7F32 0%, #B87333 100%);
    color: white;
}

.badge-new {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Stats Panel */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    animation: fadeIn 0.7s ease-out;
}

.stat-item {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: all 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: #7F8C8D;
    margin-bottom: 10px;
    font-weight: 600;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Achievements Panel */
.achievements-panel {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    animation: fadeIn 0.9s ease-out;
}

.achievements-panel h3 {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.achievement-item {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.achievement-item:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-hover);
}

.achievement-item.unlocked {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: var(--success-color);
}

.achievement-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    filter: grayscale(100%);
    opacity: 0.5;
}

.achievement-item.unlocked .achievement-icon {
    filter: grayscale(0%);
    opacity: 1;
    animation: rotate 0.5s ease-out;
}

.achievement-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.achievement-desc {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s ease-out;
    overflow-y: auto;
}

.modal.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    position: relative;
    animation: scaleIn 0.3s ease-out;
    box-shadow: var(--shadow-hover);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    font-weight: 300;
    color: #7F8C8D;
    cursor: pointer;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-content h2 {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 20px;
}

.modal-body {
    color: var(--text-color);
}

.modal-body p {
    margin-bottom: 15px;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-body li {
    margin-bottom: 8px;
}

/* History List */
.history-item {
    background: var(--bg-color);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.history-score {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.history-info {
    flex: 1;
    margin-left: 15px;
}

.history-difficulty {
    font-size: 0.9rem;
    color: #7F8C8D;
}

.history-date {
    font-size: 0.85rem;
    color: #95A5A6;
}

.no-history {
    text-align: center;
    color: #7F8C8D;
    padding: 40px;
    font-size: 1.1rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 0.9rem;
    margin-top: 30px;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .title {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .controls {
        flex-direction: column;
        gap: 10px;
    }

    .difficulty-selector {
        flex-direction: column;
        text-align: center;
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .canvas-container {
        padding: 20px 10px;
        min-height: 400px;
    }

    #drawingCanvas {
        max-width: 100%;
    }

    .score-value {
        font-size: 3rem;
    }

    .result-actions {
        flex-direction: column;
        width: 100%;
    }

    .result-actions .btn {
        width: 100%;
    }

    .stats-panel {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }

    .modal-content {
        padding: 30px 20px;
        margin: 20px;
    }

    .achievement-icon {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .score-value {
        font-size: 2.5rem;
    }

    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .achievement-item {
        padding: 15px 10px;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Tablet specific */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 25px;
    }

    .achievements-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .stats-panel {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Print styles */
@media print {
    body {
        background: white;
    }

    .controls,
    .footer,
    .btn {
        display: none;
    }
}
