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

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

#device-container {
    position: relative;
    background: #8B0000;
    padding: 15px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 
                0 0 20px rgba(139, 0, 0, 0.3);
    max-width: 100%;
}

canvas {
    display: block;
    border-radius: 10px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

#controls {
    margin-top: 20px;
}

.button-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 15px;
}

.direction-button {
    background: linear-gradient(180deg, #FF6B6B 0%, #CC5555 100%);
    border: 3px solid #8B0000;
    border-radius: 50%;
    width: 80px;
    height: 80px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 
                inset 0 -2px 6px rgba(0, 0, 0, 0.3),
                inset 0 1px 2px rgba(255, 255, 255, 0.3);
    transition: all 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.direction-button:hover {
    background: linear-gradient(180deg, #FF7B7B 0%, #DD6565 100%);
}

.direction-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 
                inset 0 2px 6px rgba(0, 0, 0, 0.4);
}

.button-label {
    font-size: 10px;
    margin-bottom: 2px;
}

.arrow {
    font-size: 24px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mode-button {
    background: linear-gradient(180deg, #F5F5DC 0%, #D5D5BC 100%);
    border: 2px solid #8B0000;
    border-radius: 15px;
    padding: 8px 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 11px;
    color: #8B0000;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transition: all 0.1s;
}

.mode-button:hover {
    background: linear-gradient(180deg, #FFFFF0 0%, #E5E5CC 100%);
}

.mode-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.utility-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.utility-button {
    background: linear-gradient(180deg, #F5F5DC 0%, #D5D5BC 100%);
    border: 2px solid #8B0000;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
                inset 0 1px 2px rgba(255, 255, 255, 0.5);
    transition: all 0.1s;
}

.utility-button:hover {
    background: linear-gradient(180deg, #FFFFF0 0%, #E5E5CC 100%);
}

.utility-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3),
                inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

#instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

#instructions-overlay.hidden {
    display: none;
}

.instructions-content {
    background: #F5F5DC;
    border: 5px solid #8B0000;
    border-radius: 15px;
    padding: 30px;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.instructions-content h2 {
    color: #8B0000;
    margin-bottom: 20px;
    font-size: 24px;
}

.history-note {
    background: rgba(139, 0, 0, 0.1);
    border-left: 4px solid #8B0000;
    padding: 15px;
    margin: 15px 0;
    text-align: left;
    border-radius: 5px;
}

.history-note p {
    font-size: 13px;
    line-height: 1.5;
    color: #2F4F2F;
}

.instructions-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #2F4F2F;
}

.instructions-content button {
    background: linear-gradient(180deg, #FF6B6B 0%, #CC5555 100%);
    border: 3px solid #8B0000;
    border-radius: 10px;
    padding: 15px 30px;
    cursor: pointer;
    font-weight: bold;
    color: white;
    font-size: 16px;
    margin-top: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.1s;
}

.instructions-content button:hover {
    background: linear-gradient(180deg, #FF7B7B 0%, #DD6565 100%);
}

.instructions-content button:active {
    transform: translateY(2px);
}

#achievement-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(139, 0, 0, 0.95);
    color: white;
    padding: 15px 30px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    animation: slideDown 0.3s ease;
}

#achievement-toast.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

footer {
    margin-top: 30px;
    color: white;
    text-align: center;
    font-size: 12px;
    opacity: 0.9;
}

footer a {
    color: #FFD93D;
    text-decoration: none;
    font-weight: bold;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 600px) {
    canvas {
        max-width: 100%;
        height: auto;
    }
    
    .direction-button {
        width: 60px;
        height: 60px;
    }
    
    .button-label {
        font-size: 8px;
    }
    
    .arrow {
        font-size: 20px;
    }
    
    .mode-button {
        padding: 6px 15px;
        font-size: 10px;
    }
    
    .instructions-content {
        max-width: 90%;
        padding: 20px;
    }
}