:root {
    --primary-color: #2ecc71; /* Verde Esmeralda */
    --primary-dark: #27ae60;
    --accent-color: #e74c3c; /* Vermelho Crimson */
    --text-color: #ffffff;
    --bg-color: #1a1a1a;
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --font-main: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: var(--font-main);
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    background-color: #333; /* Cor do asfalto */
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-color);
    z-index: 10;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #3498db, var(--primary-color));
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(0,0,0,0.3);
    margin-bottom: 5px;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.subtitle {
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 2px;
    margin-bottom: 30px;
    opacity: 0.9;
}

.moto-icon {
    font-size: 80px;
    margin-bottom: 40px;
    animation: bounce 2s infinite ease-in-out, glow 2s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 20px rgba(46, 204, 113, 0.5));
}

@keyframes glow {
    from { filter: drop-shadow(0 0 20px rgba(46, 204, 113, 0.5)); }
    to { filter: drop-shadow(0 0 30px rgba(52, 152, 219, 0.8)); }
}

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

.main-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: 50px;
    color: #000;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.4);
    position: relative;
    overflow: hidden;
}

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

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

.main-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}

.main-btn:active {
    transform: scale(0.95);
}

.instructions {
    margin-top: 30px;
    font-size: 0.9rem;
    opacity: 0.7;
}

.stats {
    margin: 20px 0;
    font-size: 1.2rem;
}

.stats p {
    margin: 10px 0;
}

.record {
    color: var(--primary-color);
    font-weight: 700;
}

@keyframes fadeUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-50px); opacity: 0; }
}

.score-popup {
    position: absolute;
    color: var(--primary-color);
    font-size: 24px;
    font-weight: 700;
    pointer-events: none;
    animation: fadeUp 1s forwards;
    z-index: 5;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.instructions.desktop-only {
    display: block;
}

.instructions.mobile-only {
    display: none;
}

@media (max-width: 1200px) {
    .instructions.desktop-only {
        display: none;
    }
    .instructions.mobile-only {
        display: block;
    }
}

.tutorial-screen {
    background: linear-gradient(180deg, rgba(26,26,26,0.95), rgba(26,26,26,0.9));
    pointer-events: all;
}

.tutorial-card {
    max-width: 420px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    padding: 25px;
    box-shadow: 0 25px 40px rgba(0, 0, 0, 0.5);
    margin-bottom: 30px;
    backdrop-filter: blur(8px);
    text-align: left;
}

.tutorial-card h3 {
    font-size: 1.6rem;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.tutorial-card p {
    margin-bottom: 12px;
    line-height: 1.4;
}

.tutorial-card ul {
    list-style: none;
    padding-left: 0;
    margin: 0 0 10px;
}

.tutorial-card li {
    margin-bottom: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.tutorial-footnote {
    font-size: 0.85rem;
    opacity: 0.8;
}

#touch-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    display: none !important;
    pointer-events: none;
    z-index: 12;
}

/* Layout novo: direcionais nas laterais, ações no centro */
#touch-controls .touch-pad {
    position: absolute;
    bottom: 0;
    display: flex;
    gap: 24px;
    align-items: center;
    pointer-events: auto;
}

#touch-controls .touch-pad.left-pad {
    left: 20px;
}

#touch-controls .touch-pad.right-pad {
    right: 20px;
}

#touch-controls .action-pad {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 24px;
    align-items: center;
    pointer-events: auto;
}

/* Mostrar controles apenas durante o jogo em dispositivos mobile */
@media (max-width: 768px), (hover: none) {
    .game-playing #touch-controls {
        display: block !important;
    }
}

.touch-btn {
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.6), rgba(255, 255, 255, 0.1));
    border-radius: 50px;
    width: 65px;
    height: 65px;
    color: #fff;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.2s ease;
    cursor: pointer;
    touch-action: none;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.touch-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.touch-btn:active::before {
    width: 100px;
    height: 100px;
}

.touch-btn:active {
    transform: translateY(2px) scale(0.95);
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.4));
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.action-btn {
    min-width: 65px;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    background: linear-gradient(145deg, rgba(52, 152, 219, 0.8), rgba(41, 128, 185, 0.8));
    border-color: rgba(52, 152, 219, 0.8);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.action-btn:active {
    background: linear-gradient(145deg, rgba(52, 152, 219, 1), rgba(41, 128, 185, 1));
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.touch-btn.arrow-btn {
    font-size: 1.6rem;
    background: linear-gradient(145deg, rgba(46, 204, 113, 0.8), rgba(39, 174, 96, 0.8));
    border-color: rgba(46, 204, 113, 0.8);
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.touch-btn.arrow-btn:active {
    background: linear-gradient(145deg, rgba(46, 204, 113, 1), rgba(39, 174, 96, 1));
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Melhorias para telas pequenas */
@media (max-width: 480px) {
    .touch-btn {
        width: 55px;
        height: 55px;
        font-size: 1rem;
    }
    
    .action-btn {
        min-width: 55px;
        font-size: 0.75rem;
    }
    
    .touch-btn.arrow-btn {
        font-size: 1.3rem;
    }
    
    #touch-controls {
        bottom: 30px;
        padding: 0 12px;
    }
    
    #touch-controls .touch-pad,
    #touch-controls .action-pad {
        gap: 16px;
    }
}

/* Indicadores de zonas de toque (apenas para debug) */
.touch-zone-indicator {
    position: absolute;
    bottom: 20px;
    width: 25vw;
    height: 40vh;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    pointer-events: none;
    z-index: 11;
    display: none;
}

.touch-zone-indicator.left {
    left: 0;
}

.touch-zone-indicator.right {
    right: 0;
}

/* Mostrar indicadores apenas em modo debug */
.touch-zone-indicator {
    display: none !important;
}

body:has(#debug-mode) .touch-zone-indicator,
.touch-zone-indicator.debug-visible {
    display: block !important;
}

@media (max-width: 1200) {
    body:has(#debug-mode) .game-playing .touch-zone-indicator,
    .game-playing .touch-zone-indicator.debug-visible {
        display: block !important;
    }
}

/* Safe areas para dispositivos modernos */
@supports (padding: max(0px)) {
    #touch-controls {
        bottom: max(15px, env(safe-area-inset-bottom));
        padding: 0 max(20px, env(safe-area-inset-left));
    }
    
    .overlay {
        padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    }
}

/* Estilos de Acessibilidade */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Modo de Alto Contraste */
.high-contrast {
    --bg-color: #000000;
    --text-color: #ffffff;
    --overlay-bg: rgba(0, 0, 0, 0.95);
    --primary-color: #ffff00;
    --primary-dark: #cccc00;
    --accent-color: #ff0000;
}

.high-contrast body {
    background-color: #000000;
}

.high-contrast #gameCanvas {
    background-color: #000000;
}

.high-contrast .title {
    background: linear-gradient(135deg, #ffff00, #ffffff, #ffff00);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 10px rgba(255, 255, 0, 0.5);
}

.high-contrast .main-btn {
    background: linear-gradient(135deg, #ffff00, #cccc00);
    color: #000000;
    border: 3px solid #ffffff;
    box-shadow: 0 4px 15px rgba(255, 255, 0, 0.6);
}

.high-contrast .main-btn:hover {
    background: linear-gradient(135deg, #ffffff, #ffff00);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.8);
}

.high-contrast .touch-btn {
    border: 3px solid #ffffff;
    background: linear-gradient(145deg, #000000, #333333);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.5);
}

.high-contrast .touch-btn:active {
    background: linear-gradient(145deg, #ffffff, #cccccc);
    color: #000000;
    border-color: #ffff00;
}

.high-contrast .action-btn {
    background: linear-gradient(145deg, #0066cc, #004499);
    border-color: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 102, 204, 0.6);
}

.high-contrast .touch-btn.arrow-btn {
    background: linear-gradient(145deg, #00cc00, #009900);
    border-color: #ffffff;
    box-shadow: 0 8px 20px rgba(0, 204, 0, 0.6);
}

.high-contrast .score-popup {
    color: #ffff00;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.high-contrast .record {
    color: #ffff00;
}

/* Foco melhorado para navegação por teclado */
*:focus {
    outline: 3px solid #ffff00 !important;
    outline-offset: 2px !important;
}

.high-contrast *:focus {
    outline: 3px solid #ffffff !important;
    outline-offset: 2px !important;
}

/* Redução de movimento para usuários sensíveis */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .moto-icon {
        animation: none !important;
    }
    
    .title {
        animation: none !important;
    }
    
    .score-popup {
        animation: none !important;
        opacity: 1;
        transform: translateY(-20px);
    }
    
    .main-btn::before {
        transition: none !important;
    }
}

/* Otimizações para alto DPI */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .touch-btn {
        border-width: 0.5px;
    }
}


.touch-device .instructions.desktop-only {
    display: none !important;
}

.touch-device .instructions.mobile-only {
    display: block !important;
}

@media (min-width: 769px) {
    #touch-controls {
        display: none !important;
    }
    
    /* Override para touch devices apenas durante o jogo */
    .touch-device.game-playing #touch-controls {
        display: block !important;
    }
}
