/* --- ESTILOS GERAIS --- */
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: "Geo", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    cursor: none; /* Esconde o mouse padrão no Desktop */
    touch-action: manipulation;

    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-size: cover;
}

.grid-background {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: 0;
}

/* --- UI LAYER --- */
#ui-layer {
    position: absolute;
    top: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    padding: 0 40px;
    box-sizing: border-box;
    z-index: 100;
    pointer-events: none;
}

#ui-right {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 12px;
}

#settings-button {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 10px;
    border: 2px solid #2c3e50;
    background: rgba(255,255,255,0.8);
    cursor: pointer;
}

#settings-button img {
    width: 24px;
    height: 24px;
    display: block;
    filter: grayscale(1) brightness(0.4);
}

.hud-text {
    display: inline-flex;
    align-items: center;
    font-size: 24px;
    font-weight: 900;
    color: #2c3e50;
    text-transform: uppercase;
    text-shadow: 2px 2px 0px rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.6);
    padding: 10px 20px;
    border-radius: 10px;
    border: 2px solid #2c3e50;
    height: 46px;
    line-height: 1;
}

.hud-number {
    font-size: 1.35em;
    margin-left: 6px;
}

#audio-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(255,255,255,0.6);
    padding: 10px 12px;
    border-radius: 10px;
    border: 2px solid #2c3e50;
    color: #2c3e50;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
}

#settings-panel {
    background: #f5f7fa;
    border: 4px solid #2c3e50;
    border-radius: 16px;
    padding: 24px 28px;
    color: #2c3e50;
    min-width: 320px;
    box-shadow: 0 12px 0 rgba(0,0,0,0.25);
}

#settings-panel h1 {
    margin-top: 0;
    color: #d32f2f;
    text-shadow: none;
}

.audio-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-row label {
    min-width: 60px;
}

.audio-row input[type="range"] {
    width: 140px;
}

.audio-row button {
    background: #ffeb3b;
    color: #d32f2f;
    border: 2px solid #2c3e50;
    border-radius: 8px;
    padding: 4px 10px;
    font-weight: 800;
    cursor: pointer;
}

/* --- TELAS --- */
.screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    color: white;
    text-align: center;
    cursor: default;
}

#start-screen {
    padding: 32px 20px;
    box-sizing: border-box;
}

#start-content,
#game-over-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(8px, 1.5vw, 16px);
    max-width: 900px;
    padding: 0 20px;
}

#start-portrait,
#game-over-portrait {
    width: clamp(180px, 30vw, 200px);
    height: auto;
    filter: drop-shadow(0 16px 20px rgba(0,0,0,0.45));
}

#start-logo,
#game-over-logo {
    width: clamp(260px, 70vw, 380px);
    height: auto;
    margin-top: -6px;
}

#start-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#game-over-score {
    margin: 0;
}

#game-over-score #final-score {
    color: #ffeb3b;
    font-size: 2.2rem;
}

#game-over-score {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

#start-text p {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-size: clamp(1rem, 2.2vw, 1.4rem);
    margin: 0;
    line-height: 1.3;
}

#start-button,
#game-over-button {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

#start-button img,
#game-over-button img {
    width: clamp(220px, 55vw, 420px);
    height: auto;
    display: block;
    filter: drop-shadow(0 10px 0 rgba(0,0,0,0.35));
}

.hidden { display: none !important; }

h1 { font-size: 4rem; margin-bottom: 10px; color: #ffeb3b; text-shadow: 4px 4px #d32f2f; }
p { font-size: 1.5rem; margin-bottom: 30px; max-width: 600px; padding: 0 20px; }

.btn-start {
    background-color: #ffeb3b;
    color: #d32f2f;
    border: none;
    padding: 20px 50px;
    font-size: 2rem;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #fbc02d;
    transition: transform 0.1s, box-shadow 0.1s;
    text-transform: uppercase;
}
.btn-start:active { transform: translateY(4px); box-shadow: 0 2px 0 #fbc02d; }

/* --- JOGO --- */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    z-index: 10;
}

.shake { animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both; }
@keyframes shake {
    10%, 90% { transform: translate3d(-2px, -1px, 0); }
    20%, 80% { transform: translate3d(3px, 2px, 0); }
    30%, 50%, 70% { transform: translate3d(-5px, -3px, 0); }
    40%, 60% { transform: translate3d(5px, 3px, 0); }
}

/* CURSOR / RAQUETE */
#custom-cursor {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    width: 160px;
    display: block;
    transform-origin: bottom right;
    transform: translate(-30%, -30%);
}

@keyframes whack-mobile {
    0% { transform: translate(-50%, -50%) rotate(-45deg) scale(0.8); opacity: 0; }
    20% { opacity: 1; }
    50% { transform: translate(-50%, -50%) rotate(0deg) scale(1.2); }
    100% { transform: translate(-50%, -50%) rotate(0deg) scale(1); opacity: 0; }
}

.mobile-whack-anim {
    animation: whack-mobile 0.2s ease-out forwards; /* Mais rápido a animação da raquete tb */
}

/* ALVO (MARIANO) */
#target-container {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 20;
    cursor: none;
    touch-action: none;
    /* Transição será injetada via JS */
}

#head-image {
    width: 160px;
    filter: drop-shadow(0 10px 10px rgba(0,0,0,0.3));
    user-select: none;
    -webkit-user-drag: none;
    -webkit-tap-highlight-color: transparent;
}

/* BALÃO */
#speech-bubble {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 3px solid #000;
    border-radius: 20px;
    padding: 15px;
    width: 240px;
    text-align: center;
    font-weight: 800;
    font-size: 16px;
    color: #000;
    box-shadow: 5px 5px 0px rgba(0,0,0,0.2);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    z-index: 30;
}
#speech-bubble.show { opacity: 1; visibility: visible; }
#speech-bubble::after {
    content: ''; position: absolute; top: 100%; left: 50%; margin-left: -10px;
    border-width: 10px; border-style: solid; border-color: #fff transparent transparent transparent;
}
#speech-bubble::before {
    content: ''; position: absolute; top: 100%; left: 50%; margin-left: -14px;
    border-width: 14px; border-style: solid; border-color: #000 transparent transparent transparent;
}

#speech-bubble.bubble-down {
    bottom: auto !important; top: 110% !important;
}
#speech-bubble.bubble-down::after {
    top: auto; bottom: 100%; border-color: transparent transparent #fff transparent;
}
#speech-bubble.bubble-down::before {
    top: auto; bottom: 100%; border-color: transparent transparent #000 transparent;
}

@media (max-width: 768px) {
    body { cursor: auto; }
    #custom-cursor { display: none; width: 140px; }
    #custom-cursor.active { display: block; position: absolute; pointer-events: none; }
    #head-image { width: 130px; }
    #speech-bubble { width: 200px; font-size: 14px; }
    #ui-layer { padding: 0 16px; }
    #ui-right { gap: 8px; }
    .hud-text { font-size: 14px; padding: 6px 10px; height: 38px; }
    .hud-number { font-size: 1.5em; }
    h1 { font-size: 2.5rem; }
    .btn-start { font-size: 1.5rem; padding: 15px 30px; }
    #audio-controls { font-size: 10px; }
    .audio-row input[type="range"] { width: 110px; }
    .audio-row button { padding: 3px 8px; }
    #settings-panel { min-width: 0; width: 85vw; padding: 20px; }
    #start-content,
    #game-over-content { gap: 10px; padding: 0 10px; }
    #start-portrait,
    #game-over-portrait { width: min(32vw, 260px); }
    #start-logo,
    #game-over-logo { width: min(90vw, 480px); margin-top: -4px; }
    #start-text p { font-size: 1.05rem; }
    #start-button img,
    #game-over-button img { width: min(60vw, 360px); }
    #game-over-score #final-score { font-size: 1.9rem; }
}

@media (max-height: 700px) {
    #start-portrait,
    #game-over-portrait { width: min(35vw, 220px); }
    #start-logo,
    #game-over-logo { width: min(70vw, 520px); }
    #start-text p { font-size: 1rem; }
    #start-button img,
    #game-over-button img { width: min(55vw, 340px); }
    #game-over-score #final-score { font-size: 1.8rem; }
}
