@import url('https://fonts.googleapis.com/css2?family=Titan+One&family=Roboto:wght@400;700&display=swap');

:root {
    --clash-blue: #3b82f6;
    --clash-red: #ef4444;
    --rarity-common: #94a3b8;
    --rarity-rare: #f97316;
    --rarity-epic: #a855f7;
    --rarity-legendary: #eab308;
}

html {
    height: 100%;
    height: -webkit-fill-available;
    width: 100%;
    position: fixed;
    overflow: hidden;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #1a1a2e;
    color: white;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    height: 100%;
    height: -webkit-fill-available;
    width: 100%;
    position: fixed;
    margin: 0;
    padding: 0;
}

.clash-font {
    font-family: 'Titan One', cursive;
    text-shadow: 2px 2px 0px #000;
}

/* --- GAME BOARD --- */
#game-area {
    background-image: 
        linear-gradient(rgba(0,0,0,0.05), rgba(0,0,0,0.05)),
        repeating-linear-gradient(0deg, transparent, transparent 49px, #58904a 50px),
        repeating-linear-gradient(90deg, transparent, transparent 49px, #58904a 50px),
        linear-gradient(#70a338, #70a338);
    background-size: 50px 50px;
    perspective: 600px;
    transition: transform 0.5s ease;
}

.client-view { transform: rotate(180deg); }
.client-view .damage-text, 
.client-view .elixir-gen-text,
.client-view .emote-bubble,
.client-view .health-bar-container,
.client-view .spell-effect,
.client-view .projectile,
.client-view .hitbox-indicator,
.client-view .hp-text { transform: rotate(-180deg); }
.client-view .unit { transform: rotate(-180deg) !important; }

.river { background: #4fc3f7; border-top: 4px solid #0288d1; border-bottom: 4px solid #0288d1; }
.bridge { background-image: repeating-linear-gradient(90deg, #8d6e63, #8d6e63 10px, #5d4037 12px); box-shadow: 2px 2px 5px rgba(0,0,0,0.5); }

/* --- TOWERS --- */
.tower-base {
    position: absolute; transform: translate(-50%, -50%);
    display: flex; flex-direction: column; align-items: center; justify-content: flex-end; z-index: 10;
}
.tower-base.destroyed {
    opacity: 0.3;
    transform: translate(-50%, -50%) scale(0.8) grayscale(100%);
    pointer-events: none;
}
.tower-base.destroyed .health-bar-container { display: none; }

.tower-structure {
    background: #999; border: 3px solid #333; position: relative;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.6);
}
.team-player .tower-structure { background: #3b82f6; border-color: #1e3a8a; }
.team-enemy .tower-structure { background: #ef4444; border-color: #7f1d1d; }
.tower-princess { width: 50px; height: 60px; border-radius: 4px; }
.tower-king { width: 70px; height: 70px; border-radius: 8px; }

/* --- UNITS & BARS --- */
.unit { transition: top 0.1s linear, left 0.1s linear; will-change: top, left; }

/* Health Bar Improvements */
.health-bar-container { 
    background: #000; border: 1px solid #fff; position: absolute; 
    width: 140%; left: -20%; height: 10px; border-radius: 4px;
    overflow: hidden; z-index: 200; pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.tower-base .health-bar-container { top: -25px; width: 140%; left: -20%; height: 14px; border: 2px solid white; }
.unit .health-bar-container { top: -18px; }

.health-bar-fill { transition: width 0.2s; height: 100%; }

.hp-text {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
    white-space: nowrap;
    z-index: 201;
    pointer-events: none;
}
.tower-base .hp-text { top: -40px; font-size: 10px; }

/* --- VISUAL EFFECTS --- */
.spell-effect { position: absolute; pointer-events: none; z-index: 60; animation: spellPop 0.5s forwards; display: flex; align-items: center; justify-content: center; font-size: 40px; }
@keyframes spellPop { 0% { transform: scale(0); opacity: 1; } 50% { transform: scale(1.5); opacity: 1; } 100% { transform: scale(2); opacity: 0; } }

.damage-text { 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

.elixir-gen-text { 
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-size: 0.875rem;
}

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

/* HITBOX INDICATORS */
.hitbox-indicator {
    position: absolute;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    opacity: 0.6;
    animation: fadeOut 1s forwards;
}
.hitbox-zap { background: radial-gradient(circle, rgba(0,255,255,0.5) 0%, rgba(0,0,255,0.2) 70%, transparent 100%); border: 2px solid cyan; }
.hitbox-fireball { background: radial-gradient(circle, rgba(255,100,0,0.6) 0%, rgba(255,0,0,0.2) 70%, transparent 100%); border: 2px solid orange; }
.hitbox-valk { background: radial-gradient(circle, rgba(255,0,0,0.4) 0%, rgba(255,0,0,0.2) 50%, transparent 80%); border: 2px solid #ef4444; border-radius: 50%; box-shadow: 0 0 15px rgba(255,0,0,0.6); }

@keyframes fadeOut { 0% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.8); } 20% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1); } }

/* PROJECTILES */
.projectile {
    position: absolute;
    z-index: 50;
    pointer-events: none;
    font-size: 20px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    will-change: top, left;
}
.proj-arrow { font-size: 16px; text-shadow: 1px 1px 0 #000; }
.proj-fireball { font-size: 30px; filter: drop-shadow(0 0 5px orange); }
.proj-magic { font-size: 24px; filter: drop-shadow(0 0 5px cyan); }
.proj-dart { font-size: 18px; filter: drop-shadow(0 0 2px lime); }
.proj-musket { font-size: 10px; background: black; width: 6px; height: 6px; border-radius: 50%; box-shadow: 0 0 2px white; }
.proj-cannon { font-size: 12px; background: #333; width: 8px; height: 8px; border-radius: 50%; }

/* --- EMOTES --- */
.emote-bubble {
    position: absolute; width: 80px; height: 80px;
    background: white; border-radius: 50%; border: 4px solid black;
    display: flex; align-items: center; justify-content: center;
    font-size: 45px; z-index: 100;
    box-shadow: 0 6px 15px rgba(0,0,0,0.6);
    animation: emotePopup 2.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    overflow: hidden; /* Garantir que GIFs não saiam do círculo */
    will-change: transform, opacity;
}
.emote-bubble img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: auto; /* Permitir animação de GIFs */
    pointer-events: none;
}
.emote-bubble::after { 
    content: ''; 
    position: absolute; 
    bottom: -10px; 
    left: 50%; 
    transform: translateX(-50%); 
    border-width: 12px 12px 0; 
    border-style: solid; 
    border-color: black transparent transparent transparent; 
}
@keyframes emotePopup { 
    0% { transform: scale(0) rotate(-180deg); opacity: 0; } 
    15% { transform: scale(1.3) rotate(10deg); opacity: 1; } 
    25% { transform: scale(0.95) rotate(-5deg); opacity: 1; } 
    35% { transform: scale(1.05) rotate(3deg); opacity: 1; } 
    85% { transform: scale(1) rotate(0deg); opacity: 1; } 
    100% { transform: scale(0.8) rotate(90deg); opacity: 0; } 
}

/* Emote Specifics - Animações Melhoradas */
.anim-gale { animation: galePanic 0.6s infinite ease-in-out; }
@keyframes galePanic { 
    0%, 100% { transform: scale(1) rotate(0deg); } 
    25% { transform: scale(1.15) rotate(-20deg); } 
    50% { transform: scale(1.1) rotate(0deg); }
    75% { transform: scale(1.15) rotate(20deg); } 
}
.anim-laugh { animation: bounce 0.4s infinite cubic-bezier(0.68, -0.55, 0.265, 1.55); }
@keyframes bounce { 
    0%, 100% { transform: translateY(0) scale(1); } 
    50% { transform: translateY(-12px) scale(1.1); } 
}
.anim-angry { animation: rage 0.15s infinite; filter: hue-rotate(-50deg) saturate(2) brightness(1.2); }
@keyframes rage { 
    0% { transform: translateX(0) rotate(0deg) scale(1); } 
    25% { transform: translateX(-4px) rotate(-8deg) scale(1.05); } 
    50% { transform: translateX(0) rotate(0deg) scale(1); }
    75% { transform: translateX(4px) rotate(8deg) scale(1.05); } 
    100% { transform: translateX(0) rotate(0deg) scale(1); }
}
.anim-cry { animation: cry 0.8s infinite ease-in-out; }
@keyframes cry { 
    0%, 100% { transform: scale(1) translateY(0); } 
    50% { transform: scale(0.85) translateY(8px); } 
}
.anim-cool { animation: cool 1.5s infinite ease-in-out; }
@keyframes cool { 
    0%, 100% { transform: scale(1) rotate(0deg); } 
    25% { transform: scale(1.12) rotate(8deg); } 
    50% { transform: scale(1.05) rotate(0deg); }
    75% { transform: scale(1.12) rotate(-8deg); } 
}
.anim-love { animation: heartbeat 0.8s infinite ease-in-out; }
@keyframes heartbeat { 
    0%, 100% { transform: scale(1); } 
    15% { transform: scale(1.4); } 
    30% { transform: scale(1.1); }
    45% { transform: scale(1.35); } 
    60% { transform: scale(1); }
}
.anim-hammer-crown { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.anim-hammer-crown::before { content: '👑'; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%); font-size: 30px; animation: crownAppear 2s forwards; opacity: 0; }
.anim-hammer-crown::after { content: '🔨'; position: absolute; top: -10px; right: 0; font-size: 40px; transform-origin: bottom right; animation: hammerHit 1.2s infinite ease-in-out; }
@keyframes crownAppear { 
    0% { opacity:0; transform:translateX(-50%) scale(0.3) rotate(-180deg); } 
    15% { opacity:1; transform:translateX(-50%) scale(1.2) rotate(10deg); } 
    25% { transform:translateX(-50%) scale(1) rotate(0deg); }
    90% { opacity:1; transform:translateX(-50%) scale(1) rotate(0deg); } 
    100% { opacity:0; transform:translateX(-50%) scale(0.8) rotate(90deg); } 
}
@keyframes hammerHit { 
    0%, 100% { transform: rotate(0deg) scale(1); } 
    20% { transform: rotate(-50deg) scale(1.1); } 
    40% { transform: rotate(15deg) scale(1.3); }
    60% { transform: rotate(-10deg) scale(1.1); }
    80% { transform: rotate(5deg) scale(1); }
}
.anim-barb { animation: barbShake 0.5s infinite; }
@keyframes barbShake { 0% { transform:translate(0,0); } 25% { transform:translate(-2px, 2px); } 50% { transform:translate(2px, -2px); } 75% { transform:translate(-2px, -2px); } }
.anim-fire { animation: burn 0.5s infinite alternate; color: #ff4500; }
@keyframes burn { 0% { transform: scale(1); filter: brightness(100%); } 100% { transform: scale(1.1); filter: brightness(150%); } }

.anim-gg-fish { position: relative; font-size: 30px; animation: fishSwim 1.5s infinite ease-in-out; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.anim-gg-fish::after { content: 'GG'; position: absolute; top: -20px; right: 0; font-size: 30px; font-weight: 900; color: #fbbf24; text-shadow: 2px 2px 0px black, -1px -1px 0 black; animation: popText 0.8s infinite alternate ease-in-out; }
@keyframes fishSwim { 
    0%, 100% { transform: translateX(0) rotate(0deg) scale(1); } 
    25% { transform: translateX(-8px) rotate(-15deg) scale(1.05); } 
    50% { transform: translateX(0) rotate(0deg) scale(1); }
    75% { transform: translateX(8px) rotate(15deg) scale(1.05); } 
}
@keyframes popText { 
    0% { transform: scale(1) rotate(-8deg); opacity: 0.9; } 
    100% { transform: scale(1.3) rotate(8deg); opacity: 1; } 
}

.anim-cry-gob { animation: cryGob 0.9s infinite ease-in-out; position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.anim-cry-gob::after { content: '😭'; position: absolute; bottom: -5px; right: -5px; font-size: 25px; animation: tearDrop 1.2s infinite ease-in-out; }
@keyframes cryGob { 
    0%, 100% { transform: scale(1) translateY(0); } 
    50% { transform: scale(0.9) translateY(6px); } 
}
@keyframes tearDrop {
    0%, 100% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(8px) scale(1.2); opacity: 0.7; }
}
/* Animação cry-more removida - GIFs devem animar por si só */
.anim-cry-more { 
    position: relative; 
    width: 100%; 
    height: 100%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.anim-cry-more { animation: cryMore 1.5s infinite; position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
@keyframes cryMore { 
    0%, 100% { transform: scale(1) translateY(0); opacity: 1; } 
    25% { transform: scale(1.05) translateY(-3px); opacity: 0.9; } 
    50% { transform: scale(0.95) translateY(3px); opacity: 0.95; } 
    75% { transform: scale(1.02) translateY(-2px); opacity: 0.9; } 
}

/* --- SCREENS --- */
.screen { display: none; }
.screen.active { display: flex; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.lobby-item { transition: all 0.2s; }
.lobby-item:hover { transform: scale(1.02); background-color: rgba(59, 130, 246, 0.3); }
.btn-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.chest-anim { animation: chestShake 1s infinite; }
@keyframes chestShake { 0% { transform: rotate(0deg); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }

/* --- MOBILE RESPONSIVE --- */
@media screen and (max-width: 768px) {
    /* Ajustar viewport para mobile */
    html {
        height: 100%;
        height: -webkit-fill-available;
    }
    
    body {
        height: 100%;
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
        position: fixed;
        width: 100%;
        overflow: hidden;
    }
    
    /* Ajustar tamanhos de fonte */
    .clash-font {
        font-size: clamp(1.5rem, 8vw, 3rem);
    }
    
    /* Ajustar tela de autenticação */
    #auth-screen h1 {
        font-size: clamp(2rem, 10vw, 3rem);
        padding: 0 1rem;
    }
    
    #auth-screen .bg-slate-800 {
        margin: 1rem;
        padding: 1.5rem;
        max-width: calc(100% - 2rem);
    }
    
    /* Ajustar lobby */
    #lobby-screen .w-full.p-3 {
        padding: 0.75rem;
    }
    
    #lobby-username {
        font-size: 0.875rem;
    }
    
    /* Ajustar área de jogo */
    #game-area {
        min-height: 0;
        flex: 1 1 auto;
    }
    
    /* Ajustar cartas */
    .card {
        width: 3.5rem;
        height: 4.5rem;
        font-size: 0.75rem;
    }
    
    .card .text-2xl {
        font-size: 1.5rem;
    }
    
    /* Ajustar deck container */
    #deck-container {
        gap: 0.5rem;
        padding: 0.5rem;
    }
    
    /* Ajustar botões */
    button {
        font-size: clamp(0.875rem, 4vw, 1rem);
        padding: 0.75rem 1rem;
    }
    
    /* Ajustar modais */
    .fixed.inset-0 {
        padding: 1rem;
    }
    
    /* Ajustar torres */
    .tower-princess {
        width: 40px;
        height: 48px;
    }
    
    .tower-king {
        width: 56px;
        height: 56px;
    }
    
    /* Ajustar unidades */
    .unit {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.875rem;
    }
    
    /* Ajustar health bars */
    .health-bar-container {
        width: 120%;
        height: 8px;
    }
    
    .hp-text {
        font-size: 7px;
        top: -24px;
    }
    
    /* Ajustar projéteis */
    .projectile {
        font-size: 16px;
        width: 16px;
        height: 16px;
    }
    
    /* Ajustar emotes */
    .emote-bubble {
        width: 60px;
        height: 60px;
        font-size: 35px;
    }
    
    /* Ajustar lista de salas */
    .lobby-item {
        padding: 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Ajustar tabs */
    .tab-content {
        padding: 1rem;
    }
    
    /* Ajustar inputs */
    input {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    /* Prevenir zoom em inputs no iOS */
    input, select, textarea {
        font-size: 16px;
    }
    
    /* Ajustar espaçamentos gerais */
    .gap-4 {
        gap: 1rem;
    }
    
    .p-4 {
        padding: 1rem;
    }
    
    .p-6 {
        padding: 1.5rem;
    }
    
    .p-8 {
        padding: 1.5rem;
    }
}

/* Ajustes específicos para telas muito pequenas */
@media screen and (max-width: 480px) {
    #auth-screen h1 {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    #auth-screen .bg-slate-800 {
        padding: 1rem;
    }
    
    .card {
        width: 3rem;
        height: 4rem;
    }
    
    button {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .tower-princess {
        width: 35px;
        height: 42px;
    }
    
    .tower-king {
        width: 50px;
        height: 50px;
    }
}

/* Ajustes para orientação landscape em mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    #auth-screen h1 {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
    
    #auth-screen .bg-slate-800 {
        padding: 1rem;
        max-width: 90%;
    }
    
    #game-area {
        min-height: 0;
    }
}

/* Melhorias adicionais para mobile */
@media screen and (max-width: 768px) {
    /* Ajustar área de jogo para mobile */
    #game-screen {
        padding: 0;
    }
    
    /* Ajustar barra de elixir */
    #elixir-fill {
        font-size: 0.625rem;
    }
    
    /* Ajustar deck container para mobile */
    #deck-container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }
    
    /* Ajustar cartas no deck para mobile */
    #deck-container .card {
        width: 3rem;
        height: 3.75rem;
        min-width: 3rem;
    }
    
    /* Ajustar preview de próxima carta */
    #next-card-preview {
        width: 2.5rem;
        height: 3rem;
        font-size: 1rem;
    }
    
    /* Ajustar área de baixo do jogo */
    #game-screen .h-52 {
        height: 8rem;
        padding: 0.5rem;
    }
    
    /* Ajustar botão de emote */
    #btn-toggle-emote {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.25rem;
        padding: 0.25rem;
    }
    
    /* Ajustar menu de emote */
    #ingame-emote-menu {
        width: 8rem;
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    /* Ajustar modais de recompensa */
    #reward-modal {
        padding: 1rem;
    }
    
    #chest-visual {
        font-size: 4rem;
    }
    
    /* Ajustar loja */
    .bg-slate-800.p-4 {
        padding: 1rem;
    }
    
    /* Ajustar grid de emotes */
    #shop-emotes-grid {
        grid-template-columns: repeat(auto-fill, minmax(4rem, 1fr));
        gap: 0.5rem;
    }
    
    /* Ajustar grid de cartas */
    #shop-cards-grid {
        gap: 0.5rem;
    }
    
    /* Ajustar lista de salas */
    .lobby-item {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Ajustar tabs */
    .tab-content {
        padding: 0.75rem;
    }
    
    /* Prevenir seleção de texto em mobile */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
    
    /* Ajustar inputs para não zoomar no iOS */
    input[type="text"],
    input[type="password"] {
        font-size: 16px !important;
    }
}

