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

:root {
    --bg-dark: #0b0e14;
    --panel-bg: rgba(15, 23, 42, 0.78);
    --panel-border: rgba(255, 255, 255, 0.12);
    --accent-blue: #38bdf8;
    --accent-violet: #818cf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8, #818cf8);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --shadow-elevation: 0 8px 32px rgba(0, 0, 0, 0.45);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition-smooth: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

html, body {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #0b0e14;
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

#game-canvas {
    display: block;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    cursor: crosshair;
    touch-action: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

.hud {
    position: fixed;
    top: 16px;
    left: 16px;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
    display: flex;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hud-item {
    display: inline-flex;
    align-items: center;
}

.hud-label {
    color: #94a3b8;
    margin-right: 6px;
}

#mass-display,
#element-display,
#players-display {
    color: #38bdf8;
    font-weight: 600;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 14, 20, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    color: #f8fafc;
}

.overlay-content h1 {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.overlay-content p {
    font-size: 18px;
    color: #94a3b8;
}

/* ==== Sprint 12: Modal de muerte con opciones ==== */
.death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: rgba(120, 0, 0, 0.35);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    z-index: 50;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.death-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.death-modal-card {
    max-width: 560px;
    padding: 28px 32px;
    background: rgba(11, 14, 20, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.death-title {
    font-family: 'Cinzel', serif;
    font-size: 26px;
    font-weight: 900;
    color: #ef4444;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

/* Countdown con anillo pulsante */
.death-countdown-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    padding: 8px 20px;
}
.countdown-pulse-ring {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 20px;
    animation: pulse-ring 1.5s ease-in-out infinite;
}
@keyframes pulse-ring {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.08); opacity: 1; }
}
.death-countdown-text {
    position: relative;
    font-size: 16px;
    font-weight: 700;
    color: #f8fafc;
}
.death-countdown-text.urgent {
    color: #fbbf24;
    animation: pulse-text 0.8s ease-in-out infinite;
}
@keyframes pulse-text {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Contenedor del modal */
.revive-modal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* Botones de revivir */
.revive-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    font-family: inherit;
    text-align: left;
    border: 1px solid transparent;
}
.revive-btn:hover {
    transform: translateY(-2px);
}
.revive-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Boton gratis (secundario, discreto) */
.revive-btn-free {
    background: rgba(51, 65, 85, 0.6);
    border-color: rgba(148, 163, 184, 0.3);
    color: #f8fafc;
}
.revive-btn-free:hover {
    background: rgba(51, 65, 85, 0.8);
}
.revive-btn-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.revive-btn-icon {
    font-size: 24px;
}
.revive-btn-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.revive-btn-title {
    font-size: 14px;
    font-weight: 700;
}
.revive-btn-subtitle {
    font-size: 11px;
    color: #94a3b8;
}
.revive-btn-action {
    font-size: 12px;
    font-weight: 700;
    color: #38bdf8;
}

/* Separador */
.revive-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    color: #64748b;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.revive-divider::before,
.revive-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Contenedor de 2 tarjetas rewarded */
.rewarded-cards-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Boton rewarded (destacado, verde esmeralda) */
.revive-btn-ad {
    position: relative;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(5, 150, 105, 0.05));
    border-color: #10b981;
    color: #f8fafc;
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}
.revive-btn-ad:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(5, 150, 105, 0.15));
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}
.ad-tag {
    position: absolute;
    top: -8px;
    right: 12px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: #10b981;
    color: #0b0e14;
    padding: 3px 8px;
    border-radius: 10px;
}
.reward-icon {
    font-size: 28px;
    flex-shrink: 0;
}
.reward-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: left;
}
.reward-title {
    font-size: 14px;
    font-weight: 700;
    color: #34d399;
}
.reward-bonus {
    font-size: 11px;
    color: #94a3b8;
}

/* Badge de cooldown */
.rewarded-cooldown-badge {
    padding: 12px 16px;
    background: rgba(30, 41, 59, 0.6);
    border: 1px dashed rgba(148, 163, 184, 0.3);
    border-radius: 10px;
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
}
.rewarded-cooldown-badge strong {
    color: #fbbf24;
}
.rewarded-cooldown-badge.hidden {
    display: none;
}

/* ==== Sprint 8: HUD avanzado ==== */

/* Panel de counters elementales (esquina superior derecha) */
.element-counters {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 10px 16px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 140px;
}
.counter-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.counter-label {
    color: #94a3b8;
}
.counter-value {
    font-weight: 700;
    color: #38bdf8;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Panel de ranking (esquina derecha media) */
.ranking {
    position: fixed;
    top: 96px;
    right: 16px;
    width: 200px;
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    contain: content;
}
.ranking-title {
    font-weight: 700;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    text-align: center;
}
.ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.ranking-item {
    display: grid;
    grid-template-columns: 28px 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 3px 6px;
    border-radius: 4px;
    transition: background 0.2s ease;
}
.ranking-item.ranking-self {
    background: rgba(56, 189, 248, 0.15);
    box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4) inset;
}
.ranking-pos {
    color: #94a3b8;
    font-weight: 600;
    font-size: 11px;
}
.ranking-name {
    color: #f8fafc;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ranking-mass {
    color: #38bdf8;
    font-weight: 600;
    font-size: 11px;
    text-align: right;
}

/* Tooltip de onboarding (centrado) */
.spawn-tooltip {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 90;
    pointer-events: none;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.spawn-tooltip.hidden {
    opacity: 0;
    visibility: hidden;
}
.spawn-tooltip-content {
    padding: 24px 36px;
    background: rgba(11, 14, 20, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    text-align: center;
    color: #f8fafc;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    max-width: 400px;
}
.spawn-tooltip-content h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}
.spawn-element-highlight {
    text-transform: uppercase;
}
.spawn-line {
    font-size: 15px;
    margin: 6px 0;
    color: #cbd5e1;
}
.spawn-target {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 14px;
    letter-spacing: 0.5px;
}
.spawn-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

/* ==== Sprint 9: Modal de alias + HUD premium ==== */

/* Modal de bienvenida */
.alias-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    /* Fondo casi 100% transparente con una viñeta muy ligera en los bordes */
    background: radial-gradient(circle at center, rgba(11, 14, 20, 0) 40%, rgba(5, 7, 11, 0.4) 100%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    z-index: 150;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Overlay oscuro sobre el modal */
.alias-modal::before {
    display: none;
}
.alias-modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.alias-modal-content {
    padding: 40px 48px;
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elevation);
    text-align: center;
    max-width: 480px;
    width: 90%;
    animation: fadeInScale 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.alias-modal-content-wide {
    max-width: 1100px;
    display: flex;
    flex-direction: row;
    gap: 32px;
    padding: 32px 40px;
    /* Fondo oscuro y sólido para el panel para máxima legibilidad sobre el fondo de juego */
    background: rgba(11, 14, 20, 0.94);
    /* Borde luminoso alquímico */
    border: 1px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.18);
    border-radius: var(--radius-lg);
}
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}
.alias-modal-header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 4px;
}
.alias-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}
.alias-modal-logo {
    font-family: 'Cinzel', serif;
    font-size: 42px;
    font-weight: 900;
    letter-spacing: -1px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}
.alias-modal-tagline {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 32px;
}
.alias-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
}
.alias-modal-input-wrap {
    position: relative;
    margin-bottom: 20px;
}
.alias-modal-input {
    width: 100%;
    padding: 14px 60px 14px 18px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--panel-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-smooth), box-shadow var(--transition-smooth);
    font-family: inherit;
    box-sizing: border-box;
}
.alias-modal-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.alias-modal-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}
.alias-modal-char-count {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    pointer-events: none;
}
#enter-arena-btn,
#alias-submit,
.alias-modal-button {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #0b0e14;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-smooth), box-shadow var(--transition-smooth);
    font-family: inherit;
}
.alias-modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.35);
}
.alias-modal-button:active {
    transform: translateY(0);
}
.alias-modal-hint {
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}
.alias-modal-hint-anon {
    color: var(--accent-blue);
    font-weight: 600;
}

/* Badge de audio en HUD */
.hud-item-audio {
    cursor: pointer;
    pointer-events: auto;
    padding: 2px 8px;
    border-radius: 4px;
    transition: background var(--transition-smooth);
}
.hud-item-audio:hover {
    background: rgba(255, 255, 255, 0.08);
}
.audio-icon {
    font-size: 14px;
    user-select: none;
}
.audio-icon.muted {
    opacity: 0.4;
}

/* ==== Sprint 10: Badge de racha ==== */
.hud-item-streak {
    background: rgba(245, 158, 11, 0.12);
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 2px 10px;
    border-radius: 4px;
    animation: pulse-streak 1.5s ease-in-out infinite;
}
.hud-item-streak.hidden {
    display: none;
}
.hud-item-streak .hud-label {
    color: #f59e0b;
}
#streak-value {
    color: #fbbf24;
    font-weight: 800;
    margin-left: 4px;
}
@keyframes pulse-streak {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.65; }
}

/* ==== Sprint 10: Banner del tutorial ==== */
.tutorial-banner {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
}
.tutorial-banner.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(10px);
}
.tutorial-banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevation);
    color: var(--text-main);
    font-size: 13px;
    max-width: 600px;
}
.tutorial-progress {
    display: flex;
    gap: 4px;
}
.tutorial-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.2s ease;
}
.tutorial-dot.active {
    background: var(--accent-blue);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}
.tutorial-dot.done {
    background: var(--accent-violet);
}
.tutorial-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.tutorial-step-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-blue);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.tutorial-message {
    font-size: 13px;
    color: var(--text-main);
}
.tutorial-skip {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    font-size: 11px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-smooth), color var(--transition-smooth);
    font-family: inherit;
    white-space: nowrap;
}
.tutorial-skip:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
}

/* ==== Sprint 10: Checkbox de tutorial en modal de alias ==== */
.alias-modal-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
}
.alias-modal-checkbox input {
    accent-color: var(--accent-blue);
    cursor: pointer;
    width: 14px;
    height: 14px;
}
.alias-modal-checkbox span {
    user-select: none;
}

/* ==== Sprint 10: Botones del HUD y Panel de atajos ==== */
.hud-item-btn {
    cursor: pointer;
    pointer-events: auto;
    padding: 4px 10px;
    border-radius: 4px;
    transition: background var(--transition-smooth);
    user-select: none;
}
.hud-item-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.hud-btn-icon {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.hud-item-btn:hover .hud-btn-icon {
    color: var(--text-main);
}
.hud-item-invite {
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.4);
}
.hud-item-invite .hud-btn-icon {
    color: #38bdf8;
}
.hud-item-account {
    background: rgba(129, 140, 248, 0.14);
    border: 1px solid rgba(129, 140, 248, 0.35);
}
.hud-item-account .hud-btn-icon {
    color: #a5b4fc;
}
.hud-item-account:hover .hud-btn-icon {
    color: #ffffff;
}
.help-panel {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 60;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    visibility: visible;
    opacity: 1;
}
.help-panel.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.help-panel-content {
    padding: 14px 18px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-elevation);
    color: var(--text-main);
    font-size: 12px;
    min-width: 220px;
}
.help-panel-content h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-blue);
    margin-bottom: 10px;
}
.help-panel-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.help-panel-content li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 0;
    color: var(--text-muted);
    align-items: center;
}
.help-panel-content kbd {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    font-family: monospace;
    font-size: 11px;
    color: var(--accent-blue);
}

/* ==== Sprint 11: HUD de buffs activos ==== */
.buff-hud {
    position: fixed;
    bottom: 16px;
    left: 16px;
    display: flex;
    flex-direction: row;
    gap: 8px;
    z-index: 20;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.buff-hud.hidden {
    opacity: 0;
    visibility: hidden;
}
.buff-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #f8fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.buff-badge.expiring {
    animation: buff-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes buff-pulse {
    from { opacity: 1; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); }
    to { opacity: 0.6; box-shadow: 0 4px 20px currentColor; }
}
.buff-badge-icon {
    font-size: 16px;
}
.buff-badge-timer {
    font-size: 11px;
    font-weight: 800;
    opacity: 0.9;
}

.hud-label {
    font-size: 14px;
    margin-right: 4px;
    vertical-align: middle;
}

/* ==== Sprint 11: Consejos en el modal de alias ==== */
.alias-modal-content-wide {
    max-width: 900px;
    display: flex;
    flex-direction: row;
    gap: 32px;
    padding: 32px 40px;
}
.alias-modal-main {
    flex: 1;
    min-width: 320px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.alias-modal-tips-panel {
    flex: 1;
    min-width: 320px;
    border-left: 1px solid var(--panel-border);
    padding-left: 32px;
    display: flex;
    align-items: center;
}
.alias-tips {
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    text-align: left;
}
.alias-tips-section {
    margin-bottom: 14px;
}
.alias-tips-section:last-child {
    margin-bottom: 0;
}
.alias-tips-section h3 {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-blue);
    margin-bottom: 6px;
}
.alias-tips-section p {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.alias-tips-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.alias-tips-section li {
    font-size: 11px;
    color: var(--text-main);
    padding: 2px 0;
    line-height: 1.4;
}

/* Teclas (kbd) dentro de los consejos */
.alias-tips-keys li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    color: var(--text-main);
    padding: 3px 0;
    line-height: 1.4;
}
.alias-tips-keys kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-bottom-width: 2px;
    border-radius: 4px;
    font-family: "SF Mono", Consolas, Monaco, monospace;
    font-size: 10px;
    font-weight: 700;
    color: #38bdf8;
    text-align: center;
    flex-shrink: 0;
}

/* Scrollbar estilizada del panel de consejos */
.alias-tips::-webkit-scrollbar {
    width: 6px;
}
.alias-tips::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 3px;
}
.alias-tips::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.4);
    border-radius: 3px;
    transition: background 0.2s ease;
}
.alias-tips::-webkit-scrollbar-thumb:hover {
    background: rgba(56, 189, 248, 0.7);
}

/* Firefox (scrollbar-width y scrollbar-color) */
.alias-tips {
    scrollbar-width: thin;
    scrollbar-color: rgba(56, 189, 248, 0.4) rgba(255, 255, 255, 0.03);
}

@media (max-width: 800px) {
    .alias-modal-content-wide {
        flex-direction: column;
        max-width: 480px;
    }
    .alias-modal-tips-panel {
        border-left: none;
        border-top: 1px solid var(--panel-border);
        padding-left: 0;
        padding-top: 20px;
    }
}

/* ==== Sprint 11: Aviso movil ==== */
.mobile-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(11, 14, 20, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 20px;
}
.mobile-warning.hidden {
    display: none;
}
.mobile-warning-content {
    max-width: 400px;
    text-align: center;
    color: var(--text-main);
}
.mobile-warning-content h2 {
    font-size: 24px;
    margin-bottom: 16px;
    color: #fbbf24;
}
.mobile-warning-content p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}
.mobile-warning-hint {
    font-size: 12px !important;
    color: var(--accent-blue) !important;
    font-style: italic;
}

/* ==== Sprint 11: Selector de skin en alias modal ==== */
.alias-skin-selector {
    margin-top: 16px;
    margin-bottom: 12px;
}
.alias-skin-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}
.alias-skin-options {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.alias-skin-option {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.alias-skin-preview {
    display: block;
    width: 40px;
    height: 40px;
}
.alias-skin-option:hover {
    transform: scale(1.1);
}
.alias-skin-option.selected {
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

/* ==== Sprint 19: Alchemy Identity - Modular Cosmetics Studio ==== */
.cosmetics-customizer-panel {
    margin-top: 10px;
    margin-bottom: 12px;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 12px;
    padding: 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.cosmetics-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.cosmetics-panel-header .alias-skin-label {
    margin-bottom: 0;
    font-size: 11px;
    font-weight: 700;
    color: #38bdf8;
    letter-spacing: 1.2px;
}

.cosmetics-preview-container {
    position: relative;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.95), rgba(11, 14, 20, 0.98));
    border: 2px solid rgba(56, 189, 248, 0.65);
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.4), inset 0 0 12px rgba(56, 189, 248, 0.25);
    overflow: hidden;
}

.cosmetics-preview-canvas {
    width: 72px;
    height: 72px;
    display: block;
}

.cosmetics-tabs {
    display: flex;
    gap: 4px;
    background: rgba(11, 14, 20, 0.7);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.cosmetics-tabs::-webkit-scrollbar {
    display: none;
}

.cosmetics-tab-btn {
    flex: 1;
    min-width: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 5px 3px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-muted, #94a3b8);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

.cosmetics-tab-btn .tab-emoji {
    font-size: 14px;
    line-height: 1;
}

.cosmetics-tab-btn .tab-label {
    font-size: 9px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.cosmetics-tab-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.06);
}

.cosmetics-tab-btn.active {
    background: rgba(56, 189, 248, 0.16);
    border-color: rgba(56, 189, 248, 0.6);
    color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.cosmetics-options-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 68px;
    align-items: flex-start;
}

.cosmetic-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 8px;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.cosmetic-option-btn:hover {
    transform: translateY(-2px);
}

.cosmetic-option-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9), rgba(11, 14, 20, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cosmetic-option-btn:hover .cosmetic-option-circle {
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.cosmetic-option-btn.selected .cosmetic-option-circle {
    border-color: #38bdf8;
    box-shadow: 0 0 14px rgba(56, 189, 248, 0.7), inset 0 0 8px rgba(56, 189, 248, 0.3);
    transform: scale(1.05);
}

.cosmetic-option-canvas {
    width: 44px;
    height: 44px;
    display: block;
    pointer-events: none;
}

.cosmetic-option-label {
    font-size: 10px;
    font-weight: 600;
    color: #cbd5e1;
    white-space: nowrap;
    text-align: center;
    letter-spacing: 0.3px;
    transition: color 0.2s ease;
}

.cosmetic-option-btn:hover .cosmetic-option-label {
    color: #ffffff;
}

.cosmetic-option-btn.selected .cosmetic-option-label {
    color: #38bdf8;
    font-weight: 700;
}

/* ==== Sprint 11: Cooldown de elemento en HUD ==== */
.element-cooldown {
    font-size: 11px;
    font-weight: 700;
    color: #fbbf24;
    display: none;
}
.element-cooldown.active {
    display: inline;
}

.alias-tips-hint {
    margin-top: 8px;
    font-size: 10px;
    font-style: italic;
    color: var(--accent-blue);
    line-height: 1.4;
}

/* ==== Sprint 13: Footer del modal de alias ==== */
.alias-modal-content-wide {
    flex-wrap: wrap;
}
.alias-modal-footer {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 11px;
    color: rgba(148, 163, 184, 0.6);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.alias-modal-footer .footer-separator {
    opacity: 0.6;
}

/* ==== Sprint 13: Botones de acciones del perfil ==== */
.profile-modal-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.profile-modal-change {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-smooth), color var(--transition-smooth);
    font-family: inherit;
}
.profile-modal-change:hover {
    background: rgba(56, 189, 248, 0.2);
    color: #7dd3fc;
}

/* ==== Sprint 14: Banner de eventos ==== */
.event-banner {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.event-banner.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
    pointer-events: none;
}
.event-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: rgba(11, 14, 20, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 2px solid rgba(251, 191, 36, 0.6);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(251, 191, 36, 0.3);
    animation: event-pulse 1.2s ease-in-out infinite;
}
@keyframes event-pulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 24px rgba(251, 191, 36, 0.3); }
    50% { box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 40px rgba(251, 191, 36, 0.6); }
}
.event-banner-icon {
    font-size: 32px;
    line-height: 1;
}
.event-banner-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.event-banner-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: #fbbf24;
    text-transform: uppercase;
}
.event-banner-subtitle {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
}

/* ==== Sprint 15 (Fase 1C): Pulido Visual Alquímico del Modal de Alias ==== */
.alias-modal-content-wide {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.88), rgba(11, 14, 20, 0.94));
    border: 1px solid rgba(56, 189, 248, 0.25);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 40px rgba(56, 189, 248, 0.12);
}

.alias-skin-option {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.9), rgba(11, 14, 20, 0.95));
    border: 2px solid rgba(148, 163, 184, 0.25);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.22s ease, box-shadow 0.22s ease;
}

.alias-skin-preview {
    width: 46px;
    height: 46px;
}

.alias-skin-option:hover {
    transform: translateY(-3px) scale(1.08);
    border-color: rgba(56, 189, 248, 0.6);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}

.alias-skin-option.selected {
    border-color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.65), inset 0 0 8px rgba(56, 189, 248, 0.25);
    transform: scale(1.06);
}

.alias-tips-section {
    padding: 10px 12px;
    background: rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin-bottom: 10px;
}

/* ==== Sprint 16: Soporte Multiplataforma, Controles Táctiles y UI Responsiva ==== */
html, body, #game-canvas {
    touch-action: none;
    -webkit-touch-callout: none;
    overscroll-behavior: none;
}

.mobile-controls {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 25;
}
.mobile-controls.hidden {
    display: none;
}

/* Zona del Joystick (esquina inferior izquierda) */
.joystick-zone {
    position: absolute;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: max(18px, env(safe-area-inset-left));
    width: 140px;
    height: 140px;
    pointer-events: auto;
    touch-action: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.joystick-base {
    position: relative;
    width: 112px;
    height: 112px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(15, 23, 42, 0.55) 0%, rgba(11, 14, 20, 0.78) 100%);
    border: 2px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45), inset 0 0 12px rgba(56, 189, 248, 0.15);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.joystick-base.active {
    border-color: rgba(56, 189, 248, 0.85);
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.45), inset 0 0 14px rgba(56, 189, 248, 0.3);
}

.joystick-stick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

/* Botón Táctil de Propulsión Alquímica (esquina inferior derecha) */
.mobile-boost-btn {
    position: absolute;
    bottom: max(28px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
    width: 84px;
    height: 84px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, rgba(56, 189, 248, 0.9), rgba(37, 99, 235, 0.92));
    border: 3px solid rgba(255, 255, 255, 0.75);
    box-shadow: 0 6px 24px rgba(56, 189, 248, 0.5), inset 0 0 12px rgba(255, 255, 255, 0.35);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: auto;
    touch-action: none;
    cursor: pointer;
    transition: transform 0.12s ease, opacity 0.2s ease, box-shadow 0.12s ease;
}
.mobile-boost-btn.active {
    transform: scale(0.92);
    box-shadow: 0 0 32px rgba(56, 189, 248, 0.95), inset 0 0 16px #ffffff;
}
.mobile-boost-btn.disabled {
    opacity: 0.4;
    filter: grayscale(0.6);
}
.mobile-boost-icon {
    font-size: 26px;
    line-height: 1;
}
.mobile-boost-label {
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.8px;
}

/* Barra Táctil de Elementos (inferior central) */
.mobile-element-bar {
    position: absolute;
    bottom: max(18px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    pointer-events: auto;
    touch-action: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}
.mobile-el-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(30, 41, 59, 0.85);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, border-color 0.15s ease, opacity 0.2s ease;
}
.mobile-el-btn.selected {
    border-color: #38bdf8;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.7);
    transform: scale(1.1);
}
.mobile-el-btn.cooldown {
    opacity: 0.38;
    filter: grayscale(0.7);
}

/* ============================================================================
   SISTEMA RESPONSIVO MULTI-DISPOSITIVO (TABLETS, MÓVIL PORTRAIT Y LANDSCAPE)
   ============================================================================ */

/* 1. TABLETS Y PANTALLAS MEDIANAS (<= 1024px) */
@media (max-width: 1024px) {
    .hud {
        top: 10px;
        left: 10px;
        padding: 7px 12px;
        gap: 10px;
        font-size: 12px;
    }
    .element-counters {
        top: 10px;
        right: 10px;
        padding: 7px 12px;
        font-size: 11px;
        min-width: 130px;
    }
    .ranking {
        top: 76px;
        right: 10px;
        width: 175px;
        padding: 8px 10px;
        pointer-events: auto;
        cursor: pointer;
    }
}

/* 2. MÓVILES Y TABLETS EN VERTICAL / PORTRAIT (<= 768px) */
@media (max-width: 768px) {
    /* HUD Superior Izquierdo: 1 sola fila limpia y sin redundancias */
    .hud {
        top: max(8px, env(safe-area-inset-top));
        left: 8px;
        height: 36px;
        padding: 0 10px;
        gap: 8px;
        font-size: 12px;
        flex-wrap: nowrap;
        align-items: center;
        border-radius: 999px;
        max-width: calc(100vw - 148px);
        overflow: hidden;
    }

    /* Ocultar en móvil lo que ya se ve abajo o es exclusivo de teclado PC */
    .hud-item-element,
    .hud-item-players,
    .hud-item-help {
        display: none !important;
    }

    .hud-label {
        margin-right: 3px;
        font-size: 12px;
    }

    /* Convertir botón "PERFIL" en icono compacto 👤 para ahorrar ancho */
    .hud-item-profile {
        padding: 4px 6px;
    }
    .hud-item-profile .hud-btn-icon {
        font-size: 0;
    }
    .hud-item-profile .hud-btn-icon::after {
        content: "👤";
        font-size: 13px;
    }

    .hud-item-invite {
        padding: 2px 6px;
    }
    .hud-item-invite .hud-btn-icon {
        font-size: 0;
    }
    .hud-item-invite .hud-btn-icon::after {
        content: "🔗";
        font-size: 13px;
    }

    .hud-item-audio {
        padding: 2px 4px;
    }

    /* Panel de Counters Superior Derecho: Compacto */
    .element-counters {
        top: max(8px, env(safe-area-inset-top));
        right: 8px;
        padding: 4px 10px;
        font-size: 10px;
        min-width: 118px;
        border-radius: 10px;
        gap: 2px;
    }
    .counter-value {
        font-size: 10px;
    }

    /* Ranking Top 5: Más compacto y colapsable a Top 3 con un toque */
    #ranking,
    .ranking {
        top: 56px; /* Alinear con el minimapa */
        right: 10px;
        width: 150px; /* Más estrecho para no chocar */
        font-size: 11px;
        padding: 6px 8px;
        border-radius: 10px;
        background: rgba(15, 23, 42, 0.65);
    }
    .ranking-title {
        font-size: 9px;
        margin-bottom: 4px;
        letter-spacing: 0.8px;
    }
    .ranking-title::after {
        content: " ▾";
        opacity: 0.7;
    }
    .ranking.ranking-collapsed .ranking-item:nth-child(n+4) {
        display: none;
    }
    .ranking-item {
        grid-template-columns: 20px 1fr auto;
        gap: 4px;
        padding: 2px 4px;
    }
    .ranking-pos,
    .ranking-mass {
        font-size: 10px;
    }

    /* Buffs Activos: Centrados arriba de la barra de elementos (lejos del Joystick) */
    .buff-hud {
        bottom: calc(max(12px, env(safe-area-inset-bottom)) + 52px);
        left: 50%;
        transform: translateX(-50%);
        justify-content: center;
        gap: 6px;
        width: max-content;
        max-width: 92vw;
    }
    .buff-badge {
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 999px;
    }
    .buff-badge-icon {
        font-size: 13px;
    }

    /* Banner de eventos adaptado a pantallas angostas */
    .event-banner {
        top: calc(max(8px, env(safe-area-inset-top)) + 46px);
        width: 90vw;
        max-width: 340px;
    }
    .event-banner-content {
        padding: 8px 14px;
        gap: 8px;
    }
    .event-banner-icon {
        font-size: 22px;
    }
    .event-banner-subtitle {
        font-size: 12px;
    }

    /* Modales adaptados a móvil */
    .alias-modal-content-wide {
        max-height: 92dvh;
        overflow-y: auto;
        padding: 20px 16px;
        gap: 16px;
    }
    .alias-modal-main,
    .alias-modal-tips-panel {
        min-width: 100%;
    }
    .alias-modal-logo {
        font-size: 28px;
    }
    .death-modal-card {
        width: 92%;
        max-height: 90dvh;
        overflow-y: auto;
        padding: 18px 16px;
    }
    .profile-modal-content {
        width: 94%;
        padding: 20px 16px;
    }
}

/* 3. TELÉFONOS PEQUEÑOS EN VERTICAL (<= 480px) */
@media (max-width: 480px) {
    .joystick-zone {
        width: 112px;
        height: 112px;
        bottom: calc(max(10px, env(safe-area-inset-bottom)) + 54px);
        left: 10px;
    }
    .joystick-base {
        width: 92px;
        height: 92px;
    }
    .joystick-stick {
        width: 38px;
        height: 38px;
    }
    .mobile-boost-btn {
        width: 70px;
        height: 70px;
        bottom: calc(max(10px, env(safe-area-inset-bottom)) + 62px);
        right: 12px;
    }
    .mobile-boost-icon {
        font-size: 22px;
    }
    .mobile-boost-label {
        font-size: 8px;
    }
    .mobile-element-bar {
        bottom: max(10px, env(safe-area-inset-bottom));
        gap: 6px;
        padding: 5px 10px;
    }
    .mobile-el-btn {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }
    .buff-hud {
        bottom: calc(max(10px, env(safe-area-inset-bottom)) + 52px);
    }
}

/* 4. MÓVILES EN HORIZONTAL / LANDSCAPE (Altura reducida <= 560px, ej. 915x412) */
@media (max-height: 560px) {
    /* HUD Superior Izquierdo en una sola píldora compacta */
    .hud {
        top: max(6px, env(safe-area-inset-top));
        left: max(8px, env(safe-area-inset-left));
        height: 32px;
        padding: 0 10px;
        gap: 8px;
        font-size: 11px;
        flex-wrap: nowrap;
        align-items: center;
        border-radius: 999px;
        max-width: calc(100vw - 260px);
    }
    .hud-item-element,
    .hud-item-players,
    .hud-item-help {
        display: none !important;
    }
    .hud-item-profile {
        padding: 2px 6px;
    }
    .hud-item-profile .hud-btn-icon {
        font-size: 0;
    }
    .hud-item-profile .hud-btn-icon::after {
        content: "👤";
        font-size: 13px;
    }

    .hud-item-invite {
        padding: 2px 6px;
    }
    .hud-item-invite .hud-btn-icon {
        font-size: 0;
    }
    .hud-item-invite .hud-btn-icon::after {
        content: "🔗";
        font-size: 13px;
    }

    /* Counters en 1 sola fila horizontal arriba a la derecha */
    .element-counters {
        top: max(6px, env(safe-area-inset-top));
        right: max(8px, env(safe-area-inset-right));
        padding: 4px 10px;
        font-size: 10px;
        flex-direction: row;
        gap: 10px;
        min-width: auto;
        border-radius: 999px;
    }
}

/* ==== Sprint 18: AAA Visual Polish & CrazyGames Quality Upgrade ==== */

/* 1. Sello Alquímico Giratorio en pantalla de carga */
.alchemy-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 30px;
}

.alchemy-loader-ring {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 3px solid rgba(56, 189, 248, 0.2);
    border-top: 3px solid #38bdf8;
    border-right: 3px solid #818cf8;
    box-shadow: 0 0 24px rgba(56, 189, 248, 0.35);
    animation: alchemySpin 1.6s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
    position: relative;
    margin-bottom: 20px;
}

.alchemy-loader-core {
    position: absolute;
    top: 38px;
    font-size: 32px;
    animation: alchemyPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 12px rgba(56, 189, 248, 0.6));
}

@keyframes alchemySpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes alchemyPulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.15); opacity: 1; filter: drop-shadow(0 0 18px rgba(129, 140, 248, 0.9)); }
}

.loader-title {
    font-family: 'Cinzel', serif;
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 2px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

/* 2. Borde luminoso animado en modal de alias */
.alias-modal-content-wide {
    position: relative;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(11, 14, 20, 0.95));
    border: 1px solid rgba(56, 189, 248, 0.35);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.18);
    animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 3. Tarjetas visuales de consejos y elementos en modal de alias */
.tip-card-cycle,
.tip-card-rules,
.tip-card-relics {
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 12px;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.tip-card-cycle:hover,
.tip-card-rules:hover,
.tip-card-relics:hover {
    border-color: rgba(56, 189, 248, 0.35);
    transform: translateY(-1px);
}

.tip-card-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.element-cycle-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.el-chip {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
}

.el-chip.el-water { border-color: rgba(56, 189, 248, 0.4); color: #38bdf8; background: rgba(56, 189, 248, 0.1); }
.el-chip.el-fire { border-color: rgba(239, 68, 68, 0.4); color: #f87171; background: rgba(239, 68, 68, 0.1); }
.el-chip.el-plant { border-color: rgba(34, 197, 94, 0.4); color: #4ade80; background: rgba(34, 197, 94, 0.1); }
.el-chip.el-earth { border-color: rgba(217, 119, 6, 0.4); color: #fbbf24; background: rgba(217, 119, 6, 0.1); }
.el-chip.el-electric { border-color: rgba(234, 179, 8, 0.4); color: #fde047; background: rgba(234, 179, 8, 0.1); }

.tip-card-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.tip-card-list li strong {
    color: #f8fafc;
}

.powerup-mini-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.pw-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    text-align: center;
    color: var(--text-main);
}

/* 4. Viñeta atmosférica periférica sobre el juego */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.65);
    z-index: 5;
}

    /* Ranking compacto debajo de Counters */
    .ranking {
        top: calc(max(6px, env(safe-area-inset-top)) + 34px);
        right: max(8px, env(safe-area-inset-right));
        width: 155px;
        padding: 4px 8px;
        font-size: 10px;
        border-radius: 8px;
        background: rgba(15, 23, 42, 0.68);
        pointer-events: auto;
        cursor: pointer;
    }
    .ranking-title {
        font-size: 9px;
        margin-bottom: 2px;
    }
    .ranking-title::after {
        content: " ▾";
        opacity: 0.7;
    }
    .ranking.ranking-collapsed .ranking-item:nth-child(n+3) {
        display: none;
    }
    .ranking-item {
        padding: 1px 4px;
    }

    /* Controles táctiles en pantalla horizontal */
    .joystick-zone {
        width: 110px;
        height: 110px;
        bottom: max(10px, env(safe-area-inset-bottom));
        left: max(16px, env(safe-area-inset-left));
    }
    .joystick-base {
        width: 90px;
        height: 90px;
    }
    .joystick-stick {
        width: 38px;
        height: 38px;
    }
    .mobile-boost-btn {
        width: 72px;
        height: 72px;
        bottom: max(14px, env(safe-area-inset-bottom));
        right: max(18px, env(safe-area-inset-right));
    }
    .mobile-boost-icon {
        font-size: 22px;
    }
    .mobile-boost-label {
        font-size: 8px;
    }
    .mobile-element-bar {
        bottom: max(8px, env(safe-area-inset-bottom));
        gap: 6px;
        padding: 4px 8px;
    }
    .mobile-el-btn {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }
    .buff-hud {
        bottom: calc(max(8px, env(safe-area-inset-bottom)) + 46px);
        left: 50%;
        transform: translateX(-50%);
        gap: 6px;
    }
    .buff-badge {
        padding: 3px 8px;
        font-size: 10px;
    }

    /* MODAL DE ALIAS EN HORIZONTAL (Evita que se corte arriba y abajo en 915x412) */
    .alias-modal,
    .death-overlay,
    .profile-modal {
        padding: 8px 12px;
        overflow-y: auto;
        align-items: center;
    }
    .alias-modal-content-wide {
        max-width: 860px;
        width: 96%;
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
        padding: 14px 20px;
        gap: 18px;
        flex-direction: row;
        align-items: stretch;
    }
    .alias-modal-main {
        min-width: 260px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    .alias-modal-header-row {
        margin-bottom: 2px;
    }
    .alias-modal-icon {
        width: 30px;
        height: 30px;
    }
    .alias-modal-logo {
        font-size: 24px;
        margin-bottom: 0;
    }
    .alias-modal-tagline {
        font-size: 10px;
        margin-bottom: 8px;
        letter-spacing: 1.2px;
    }
    .alias-modal-title {
        font-size: 14px;
        margin-bottom: 8px;
    }
    .alias-modal-input-wrap {
        margin-bottom: 8px;
    }
    .alias-modal-input {
        padding: 8px 48px 8px 12px;
        font-size: 13px;
    }
    .alias-skin-selector {
        margin-top: 4px;
        margin-bottom: 8px;
    }
    .alias-skin-label {
        font-size: 10px;
        margin-bottom: 4px;
    }
    .alias-skin-options {
        gap: 6px;
        flex-wrap: nowrap;
    }
    .cosmetics-customizer-panel {
        padding: 6px;
        margin-top: 4px;
        margin-bottom: 6px;
    }
    .cosmetics-preview-container {
        width: 48px;
        height: 48px;
    }
    .cosmetics-preview-canvas {
        width: 44px;
        height: 44px;
    }
    .cosmetic-option-btn {
        width: 40px;
        height: 40px;
    }
    .cosmetic-option-canvas {
        width: 36px;
        height: 36px;
    }
    .cosmetics-tab-btn {
        padding: 3px 2px;
        min-width: 42px;
    }
    .alias-skin-option {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }
    .alias-skin-preview {
        width: 34px;
        height: 34px;
    }
    .alias-modal-button {
        padding: 9px 16px;
        font-size: 13px;
    }
    .alias-modal-checkbox {
        margin-top: 6px;
        margin-bottom: 2px;
        font-size: 11px;
    }
    .alias-modal-hint {
        margin-top: 4px;
        font-size: 10px;
    }
    .alias-modal-tips-panel {
        min-width: 260px;
        flex: 1;
        padding-left: 18px;
        border-left: 1px solid var(--panel-border);
        border-top: none;
        padding-top: 0;
    }
    .alias-tips {
        max-height: calc(100dvh - 80px);
    }
    .alias-modal-footer {
        margin-top: 8px;
        padding-top: 6px;
        font-size: 10px;
    }
    .death-modal-card,
    .profile-modal-content {
        max-height: calc(100dvh - 16px);
        overflow-y: auto;
        padding: 14px 18px;
    }
}

/* ==== Sprint 17 & 18: Estilos del Modo Espectador ==== */
.alias-secondary-btn,
.alias-spectate-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 320px; /* Mismo ancho que el botón principal */
    margin: 12px auto 0 auto; /* Centrado horizontal y separación */
    padding: 12px 16px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #e2e8f0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.alias-secondary-btn:hover,
.alias-spectate-button:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
    color: #ffffff;
}

.alias-secondary-btn .spectator-icon,
.alias-spectate-button .spectator-icon {
    font-size: 18px;
    line-height: 1;
}

/* Si el botón principal tiene un ancho específico, igualarlo */
#enter-arena-btn {
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
}

.revive-btn-spectate {
    background: rgba(147, 51, 234, 0.12);
    border-color: rgba(168, 85, 247, 0.4);
    color: #f8fafc;
}
.revive-btn-spectate:hover {
    background: rgba(147, 51, 234, 0.22);
    border-color: rgba(168, 85, 247, 0.7);
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.35);
}
.revive-btn-spectate .revive-btn-action {
    color: #c084fc;
}

.spectator-bar {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(56, 189, 248, 0.35);
    border-radius: 999px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 0 20px rgba(56, 189, 248, 0.2);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.spectator-bar.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%) translateY(20px);
}
.spectator-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #f8fafc;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.spectator-nav-btn:hover {
    background: rgba(56, 189, 248, 0.25);
    border-color: #38bdf8;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
    transform: scale(1.08);
}
.spectator-nav-btn:active {
    transform: scale(0.95);
}
.spectator-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 180px;
    padding: 0 6px;
    user-select: none;
}
.spectator-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    color: #38bdf8;
    text-transform: uppercase;
}
.spectator-target-name {
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}
.spectator-join-btn {
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: #0b0e14;
    background: linear-gradient(135deg, #38bdf8, #a855f7);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.spectator-join-btn:hover {
    transform: translateY(-1px) scale(1.04);
    box-shadow: 0 4px 16px rgba(168, 85, 247, 0.45);
}
.spectator-join-btn:active {
    transform: translateY(0) scale(0.98);
}

@media (max-width: 640px) {
    .spectator-bar {
        padding: 8px 12px;
        gap: 8px;
        max-width: 92vw;
    }
    .spectator-info {
        min-width: 120px;
    }
    .spectator-target-name {
        font-size: 11px;
        max-width: 130px;
    }
    .spectator-nav-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }
    .spectator-join-btn {
        padding: 7px 12px;
        font-size: 11px;
    }
}

/* ============================================================================
   HOTFIX SPRINT 18: ESTILO BOTÓN ESPECTADOR Y SEPARACIÓN HUD / RANKING
   ============================================================================ */

/* 1. Botón "Entrar como Espectador" en el Modal de Alias */
#alias-spectate-btn,
.alias-spectate-button,
#spectator-btn,
.alias-secondary-btn {
    width: 100%;
    margin-top: 10px;
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.78);
    border: 1px solid rgba(56, 189, 248, 0.42);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 0 10px rgba(56, 189, 248, 0.08);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#alias-spectate-btn:hover,
.alias-spectate-button:hover,
#spectator-btn:hover,
.alias-secondary-btn:hover {
    background: rgba(30, 41, 59, 0.92);
    border-color: #38bdf8;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 189, 248, 0.28), inset 0 0 12px rgba(56, 189, 248, 0.18);
}

#alias-spectate-btn:active,
.alias-spectate-button:active,
#spectator-btn:active,
.alias-secondary-btn:active {
    transform: translateY(0);
}

/* 2. Separación garantizada entre #element-counters y #ranking (Desktop y General) */
.element-counters {
    top: 14px !important;
    right: 16px !important;
    padding: 8px 14px !important;
    gap: 4px !important;
    min-width: 170px;
    z-index: 12;
}

.ranking {
    top: 86px !important;
    right: 16px !important;
    width: 220px !important;
    padding: 10px 12px !important;
    z-index: 11;
}

/* 3. Ajuste para Tablets (ej. iPad Air 820x1180) */
@media (max-width: 1024px) {
    .element-counters {
        top: 12px !important;
        right: 12px !important;
        padding: 7px 12px !important;
        min-width: 165px;
    }
    .ranking {
        top: 80px !important;
        right: 12px !important;
        width: 205px !important;
    }
}

/* 4. Ajuste para Móviles en Vertical (<= 768px) */
@media (max-width: 768px) {
    .element-counters {
        top: max(8px, env(safe-area-inset-top)) !important;
        right: 8px !important;
        padding: 5px 10px !important;
        min-width: 135px;
        gap: 2px !important;
    }
    .ranking {
        top: calc(max(8px, env(safe-area-inset-top)) + 56px) !important;
        right: 8px !important;
        width: 168px !important;
        padding: 6px 8px !important;
    }
}

/* 5. Ajuste para Móviles en Horizontal / Landscape (max-height: 560px) */
@media (max-height: 560px) {
    .element-counters {
        top: max(6px, env(safe-area-inset-top)) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        padding: 4px 10px !important;
        flex-direction: row !important;
        gap: 12px !important;
        min-width: auto !important;
    }
    .ranking {
        top: calc(max(6px, env(safe-area-inset-top)) + 36px) !important;
        right: max(8px, env(safe-area-inset-right)) !important;
        width: 175px !important;
        padding: 4px 8px !important;
    }
    #alias-spectate-btn,
    .alias-spectate-button,
    #spectator-btn,
    .alias-secondary-btn {
        margin-top: 6px;
        padding: 8px 14px;
        font-size: 11px;
    }
}

/* Ocultar HUD durante el menú de entrada */
body.in-menu #hud,
body.in-menu #element-counters,
body.in-menu #ranking,
body.in-menu #buff-hud,
body.in-menu .spectator-bar {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}













