body {
    background-color: #0d0d0d;
    color: #f0f0f0;
    font-family: 'Segoe UI', sans-serif;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    background-image: url('https://images.unsplash.com/photo-1579952363873-27f3bade9f55?q=80&w=1920&auto=format&fit=crop');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
}
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 1;
}

.mode-section {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 70px;
    padding: 0 10px 60px;
    box-sizing: border-box;
}
.mode-section.hidden { display: none !important; }

h1 {
    margin: 10px 0 20px;
    text-align: center;
}

.mode-title {
    font-size: 2.5rem;
    font-weight: bold;
    letter-spacing: 0.5px;
}
.mode-title span {
    color: #2ed573;
    font-size: 1em;
    font-weight: bold;
}

/* ---------- Barra superior ---------- */
#top-bar {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 10;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#info-btn,
#stats-btn {
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid #333;
    color: #fff;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}
#info-btn:hover,
#stats-btn:hover {
    background: rgba(46, 213, 115, 0.15);
    border-color: #2ed573;
}

#lang-switcher {
    display: flex;
    gap: 6px;
    background: rgba(30, 30, 30, 0.8);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #333;
}
.lang-btn {
    background: transparent;
    border: 2px solid transparent;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.5;
    line-height: 1;
}
.lang-btn:hover { opacity: 0.85; }
.lang-btn.active {
    opacity: 1;
    border-color: #2ed573;
    background: rgba(46, 213, 115, 0.1);
}

/* ---------- Selector de Modo (Teams / Legends) ---------- */
#mode-switcher {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 10;
    display: flex;
    gap: 4px;
    background: rgba(30, 30, 30, 0.85);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid #333;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    width: auto;
}
.mode-btn {
    background: transparent;
    color: #aaa;
    border: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.mode-btn:hover { color: #fff; }
.mode-btn.active {
    background: #2ed573;
    color: #000;
    box-shadow: 0 4px 12px rgba(46, 213, 115, 0.3);
}

/* ---------- Cápsula de Racha ---------- */
#streak-capsule {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(30, 30, 30, 0.8);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 5px 12px 5px 5px;
    transition: all 0.3s;
}
#streak-capsule.tier-high {
    border-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.25);
}

#streak-ball-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#streak-aura {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.4s;
    pointer-events: none;
}

#streak-ball {
    position: relative;
    z-index: 2;
    font-size: 1.2rem;
    filter: grayscale(1) brightness(0.7);
    transition: filter 0.3s, transform 0.3s;
}

#streak-extra {
    position: absolute;
    font-size: 0.9rem;
    top: -4px;
    right: -6px;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
}

#streak-count {
    font-weight: bold;
    color: #fff;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

#streak-capsule.tier-1 #streak-ball { filter: none; }
#streak-capsule.tier-2 #streak-ball { filter: none; }
#streak-capsule.tier-2 #streak-aura {
    opacity: 0.7;
    background: radial-gradient(circle, #ffd93d 0%, transparent 70%);
    animation: pulseAura 2s ease-in-out infinite;
}
#streak-capsule.tier-3 #streak-ball { filter: none; }
#streak-capsule.tier-3 #streak-aura {
    opacity: 0.8;
    background: radial-gradient(circle, #ff9f1c 0%, transparent 70%);
    animation: pulseAura 1.8s ease-in-out infinite;
}
#streak-capsule.tier-3 #streak-extra { opacity: 1; }
#streak-capsule.tier-4 #streak-ball { filter: none; }
#streak-capsule.tier-4 #streak-aura {
    opacity: 0.95;
    background: radial-gradient(circle, #ff4d00 0%, #ff9f1c 40%, transparent 75%);
    animation: pulseAura 1.5s ease-in-out infinite;
}
#streak-capsule.tier-4 #streak-extra {
    opacity: 1;
    animation: bounceExtra 1s ease-in-out infinite;
}
#streak-capsule.tier-5 #streak-ball { filter: none; }
#streak-capsule.tier-5 #streak-aura {
    opacity: 1;
    background: radial-gradient(circle, #00d4ff 0%, #0080ff 50%, transparent 80%);
    animation: electricPulse 1.2s ease-in-out infinite;
}
#streak-capsule.tier-5 #streak-extra {
    opacity: 1;
    filter: drop-shadow(0 0 4px #00d4ff);
    animation: bounceExtra 0.8s ease-in-out infinite;
}
#streak-capsule.tier-6 #streak-ball { filter: none; }
#streak-capsule.tier-6 #streak-aura {
    opacity: 1;
    background: radial-gradient(circle, #c5f8ff 0%, #64dfdf 40%, #00c9a7 80%, transparent 90%);
    animation: electricPulse 1s ease-in-out infinite;
}
#streak-capsule.tier-6 #streak-extra {
    opacity: 1;
    filter: drop-shadow(0 0 6px #64dfdf);
    animation: rotateExtra 3s linear infinite;
}
#streak-capsule.tier-7 #streak-ball {
    filter: none;
    animation: floatBall 2s ease-in-out infinite;
}
#streak-capsule.tier-7 #streak-aura {
    opacity: 1;
    background: conic-gradient(from 0deg, #ff6b35, #ffd700, #ff1493, #00ffff, #8a2be2, #ff6b35);
    animation: rotateAura 4s linear infinite;
    filter: blur(3px);
}
#streak-capsule.tier-7 #streak-extra {
    opacity: 1;
    filter: drop-shadow(0 0 8px #ffd700);
    animation: rotateExtra 2s linear infinite;
}

@keyframes pulseAura {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0.95; }
}
@keyframes electricPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.25); opacity: 1; }
}
@keyframes rotateAura {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes rotateExtra {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
@keyframes bounceExtra {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.2) translateY(-2px); }
}
@keyframes floatBall {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

#attempts-counter,
#legends-attempts-counter {
    background-color: rgba(30, 30, 30, 0.8);
    padding: 12px 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    border: 1px solid #333;
    text-align: center;
}
.attempts-title { font-size: 0.85rem; color: #aaa; letter-spacing: 1px; text-transform: uppercase; }
#attempts-number,
#legends-attempts-number { font-size: 2.2rem; font-weight: bold; color: #2ed573; margin: 4px 0; }
#attempts-balls { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; max-width: 300px; }

.search-box { position: relative; width: 100%; max-width: 500px; margin-bottom: 30px; }
input {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid #3a3a3a;
    background: #1a1a1a;
    color: white;
    font-size: 1rem;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus {
    border-color: #2ed573;
    box-shadow: 0 0 0 3px rgba(46, 213, 115, 0.2);
}

.autocomplete-items {
    position: absolute;
    width: 100%;
    background: #252525;
    border-radius: 10px;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.autocomplete-items div {
    padding: 10px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #333;
    transition: background 0.15s;
    font-size: 0.95rem;
}
.autocomplete-items div:last-child { border-bottom: none; }
.autocomplete-items div:hover,
.autocomplete-items div.active { background: #333; }

/* ---------- Escudos ---------- */
.shield-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.shield-img {
    object-fit: contain;
    background: white;
    border-radius: 4px;
    padding: 2px;
    box-sizing: border-box;
}
.shield-fallback {
    display: none;
    align-items: center;
    justify-content: center;
    background: #2ed573;
    color: #000;
    font-weight: bold;
    border-radius: 4px;
    text-align: center;
    box-sizing: border-box;
}
.suggestion-shield .shield-img,
.suggestion-shield .shield-fallback {
    width: 26px; height: 26px;
    margin-right: 10px;
    font-size: 0.65rem;
}
.row-shield .shield-img,
.row-shield .shield-fallback {
    width: 36px; height: 36px;
    margin-right: 8px;
    font-size: 0.8rem;
}
.victory-shield .shield-img,
.victory-shield .shield-fallback {
    width: 46px; height: 46px;
    margin-right: 12px;
    padding: 4px;
    border-radius: 6px;
    font-size: 0.95rem;
}

/* ---------- TABLA DE INTENTOS ---------- */
:root {
    --square-size: 72px;
    --team-col-width: 170px;
    --grid-gap: 8px;
}

#results-table {
    width: 100%;
    overflow-x: auto;
}
.header-row, .guess-row {
    display: grid;
    grid-template-columns: var(--team-col-width) repeat(7, var(--square-size));
    gap: var(--grid-gap);
    align-items: center;
    margin-bottom: 10px;
    justify-content: center;
}
.hidden { display: none !important; }
.team-info-placeholder { width: var(--team-col-width); }

.team-cell-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    overflow: hidden;
}
.team-cell-info span {
    font-weight: bold;
    font-size: 0.92rem;
    color: #fff;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.cell-head {
    font-size: 0.7rem;
    color: #2ed573;
    text-transform: uppercase;
    font-weight: 800;
    text-align: center;
    letter-spacing: 0.5px;
}

.square {
    position: relative;
    width: var(--square-size);
    height: var(--square-size);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: #1e1e1e;
    font-size: 0.95rem;
    font-weight: 800;
    animation: popIn 0.4s ease-out forwards; opacity: 0;
    text-align: center;
    padding: 3px;
    box-sizing: border-box;
    overflow: hidden;
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.correct { background-color: #2ecc71 !important; color: #fff; }
.partial { background-color: #f1c40f !important; color: #222; }
.wrong   { background-color: #e74c3c !important; color: #fff; }

.square-bg-arrow {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    user-select: none;
}
.square-bg-arrow svg {
    width: 70%;
    height: 70%;
    opacity: 0.28;
}
.square.partial .square-bg-arrow svg { opacity: 0.32; }

.square-value {
    position: relative;
    z-index: 2;
    font-size: 0.95rem;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    letter-spacing: 0.2px;
    max-width: 100%;
    padding: 0 3px;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    line-height: 1.1;
}
.square.partial .square-value {
    color: #222;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ---------- MODO LEGENDS - Foto con blur ---------- */
#legend-photo-wrapper {
    position: relative;
    width: 280px;
    height: 280px;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 20px;
    border: 3px solid #2ed573;
    box-shadow: 0 10px 40px rgba(46, 213, 115, 0.3);
    background: #1a1a1a;
}

#legend-photo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: filter 0.8s ease-out;
    display: block;
    background: #0d0d0d;
}
#legend-photo.blur-10 { filter: blur(40px); }
#legend-photo.blur-9  { filter: blur(25px); }
#legend-photo.blur-8  { filter: blur(16px); }
#legend-photo.blur-7  { filter: blur(10px); }
#legend-photo.blur-6  { filter: blur(7px); }
#legend-photo.blur-5  { filter: blur(5px); }
#legend-photo.blur-4  { filter: blur(3.5px); }
#legend-photo.blur-3  { filter: blur(2px); }
#legend-photo.blur-2  { filter: blur(1px); }
#legend-photo.blur-1  { filter: blur(0.5px); }
#legend-photo.blur-0  { filter: blur(0); }

#legend-photo-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #2ed573, #1abc9c);
    color: #000;
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 2px;
}
#legend-photo-placeholder.hidden-placeholder { display: none; }

#legend-hint {
    background: rgba(46, 213, 115, 0.12);
    border: 1px solid rgba(46, 213, 115, 0.4);
    color: #2ed573;
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 0.95rem;
    margin-bottom: 18px;
    font-weight: bold;
    letter-spacing: 0.5px;
    animation: fadeIn 0.4s ease-out;
}
#legend-hint-year {
    font-size: 1.1rem;
    margin-left: 6px;
    color: #fff;
}

/* Lista de intentos fallidos en legends */
#legend-guesses-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}
.legend-guess-row {
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.4);
    padding: 10px 16px;
    border-radius: 10px;
    color: #fff;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popIn 0.3s ease-out;
}
/* ---------- Pantalla de Victoria ---------- */
#victory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.4s ease-out;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
    from { transform: translateY(30px) scale(0.9); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
#victory-card {
    background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
    border: 2px solid #2ed573;
    border-radius: 20px;
    padding: 30px 35px;
    text-align: center;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(46, 213, 115, 0.3);
    animation: slideUp 0.5s ease-out;
    box-sizing: border-box;
}
#victory-card.defeat {
    border-color: #e74c3c;
    box-shadow: 0 20px 60px rgba(231, 76, 60, 0.3);
}
#victory-card.defeat h2 { color: #e74c3c; }
.confetti-emoji {
    font-size: 3.5rem;
    margin-bottom: 8px;
    animation: bounce 1s ease-in-out infinite alternate;
}
@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}
#victory-card h2 {
    font-size: 2.2rem;
    margin: 0 0 8px;
    color: #2ed573;
    letter-spacing: 1px;
}
#victory-card p { color: #ccc; margin-bottom: 18px; font-size: 0.95rem; }
#victory-attempts { color: #2ed573; font-weight: bold; font-size: 1.2em; }

#victory-team {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 18px;
}
#victory-team-name { font-weight: bold; font-size: 1.2rem; }

#mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 18px;
}
.mini-stat {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid #333;
    border-radius: 10px;
    padding: 10px 4px;
    text-align: center;
}
.mini-stat-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: #2ed573;
    line-height: 1.1;
}
.mini-stat-label {
    font-size: 0.65rem;
    color: #aaa;
    text-transform: uppercase;
    margin-top: 3px;
    letter-spacing: 0.5px;
}

#countdown-box {
    background: rgba(46, 213, 115, 0.08);
    border: 1px solid rgba(46, 213, 115, 0.3);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 16px;
}
.countdown-label {
    font-size: 0.7rem;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 3px;
}
#countdown-timer {
    font-size: 1.6rem;
    font-weight: bold;
    color: #2ed573;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

#share-result-btn {
    background: #2ed573;
    color: #000;
    border: none;
    padding: 13px 32px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
    letter-spacing: 0.5px;
    width: 100%;
    margin-bottom: 10px;
}
#share-result-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(46, 213, 115, 0.4);
}
#share-result-btn.copied {
    background: #1abc9c;
}

#view-stats-btn {
    background: transparent;
    color: #2ed573;
    border: 2px solid #2ed573;
    padding: 13px 32px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.5px;
    width: 100%;
}
#view-stats-btn:hover {
    background: #2ed573;
    color: #000;
}

/* ---------- Modales Estadísticas y Cómo jugar ---------- */
#stats-overlay,
#info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1001;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.3s ease-out;
    padding: 30px 15px;
    box-sizing: border-box;
    overflow-y: auto;
}
#stats-card,
#info-card {
    background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
    border: 2px solid #2ed573;
    border-radius: 20px;
    padding: 30px 30px;
    text-align: center;
    max-width: 460px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(46, 213, 115, 0.3);
    animation: slideUp 0.4s ease-out;
    box-sizing: border-box;
}
#stats-card h2,
#info-card h2 {
    font-size: 1.8rem;
    margin: 0 0 22px;
    color: #2ed573;
    letter-spacing: 1px;
}

/* ---------- ESTADÍSTICAS (grid arreglado) ---------- */
#stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 22px;
}

/* Título de sección ocupa TODAS las columnas */
.stats-section-title {
    grid-column: 1 / -1;
    color: #2ed573;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 10px 0 4px;
    text-align: left;
    padding: 8px 4px;
    border-bottom: 2px solid rgba(46, 213, 115, 0.3);
    font-weight: 800;
}
.stats-section-title:first-child { margin-top: 0; }

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #333;
    border-radius: 12px;
    padding: 14px 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 75px;
}
.stat-box-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2ed573;
    line-height: 1;
}
.stat-box-label {
    font-size: 0.65rem;
    color: #aaa;
    text-transform: uppercase;
    margin-top: 6px;
    letter-spacing: 0.5px;
    text-align: center;
}
#close-stats-btn,
#close-info-btn {
    background: transparent;
    color: #2ed573;
    border: 2px solid #2ed573;
    padding: 11px 30px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.5px;
}
#close-stats-btn:hover,
#close-info-btn:hover {
    background: #2ed573;
    color: #000;
}

/* ---------- Modal "Cómo jugar" ---------- */
#info-content {
    text-align: left;
    color: #ddd;
    font-size: 0.95rem;
    line-height: 1.55;
    margin-bottom: 22px;
}
#info-content p { margin: 0 0 14px; }
#info-content h3 {
    color: #2ed573;
    font-size: 1rem;
    margin: 20px 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(46, 213, 115, 0.3);
    padding-bottom: 6px;
}
.info-legend {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.info-legend-swatch {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    font-size: 0.8rem;
}
.info-legend-swatch.correct { background: #2ecc71; }
.info-legend-swatch.partial { background: #f1c40f; color: #222; }
.info-legend-swatch.wrong   { background: #e74c3c; }
.info-legend-text {
    flex: 1;
    font-size: 0.9rem;
}
.info-legend-swatch svg {
    width: 60%;
    height: 60%;
    opacity: 0.55;
}

/* ---------- Modal LEVEL UP ---------- */
#levelup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    animation: fadeIn 0.3s ease-out;
    padding: 15px;
    box-sizing: border-box;
}
#levelup-card {
    background: linear-gradient(145deg, #1e1e1e, #2a2a2a);
    border: 2px solid gold;
    border-radius: 24px;
    padding: 35px 30px;
    text-align: center;
    max-width: 380px;
    width: 100%;
    box-shadow: 0 20px 80px rgba(255, 215, 0, 0.4);
    animation: levelUpIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
}
@keyframes levelUpIn {
    0% { transform: scale(0.3) rotate(-15deg); opacity: 0; }
    60% { transform: scale(1.1) rotate(3deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
.levelup-title {
    font-size: 1.7rem;
    font-weight: 900;
    color: gold;
    letter-spacing: 3px;
    margin-bottom: 18px;
    text-shadow: 0 0 20px gold;
    animation: titleGlow 1.5s ease-in-out infinite alternate;
}
@keyframes titleGlow {
    from { text-shadow: 0 0 10px gold; }
    to { text-shadow: 0 0 30px gold, 0 0 50px orange; }
}
#levelup-ball-wrapper {
    position: relative;
    width: 110px;
    height: 110px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#levelup-aura {
    position: absolute;
    inset: -18px;
    border-radius: 50%;
    pointer-events: none;
}
#levelup-ball {
    position: relative;
    z-index: 2;
    font-size: 4rem;
    animation: spinBall 1.5s ease-out;
}
#levelup-extra {
    position: absolute;
    font-size: 2.2rem;
    top: -8px;
    right: -8px;
    z-index: 3;
}
@keyframes spinBall {
    from { transform: rotate(-360deg) scale(0.5); }
    to { transform: rotate(0) scale(1); }
}
#levelup-tier-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 6px;
    letter-spacing: 1px;
}
#levelup-streak-number {
    font-size: 0.95rem;
    color: #aaa;
    margin-bottom: 22px;
}
#levelup-close-btn {
    background: gold;
    color: #000;
    border: none;
    padding: 11px 35px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.2s;
    letter-spacing: 0.5px;
}
#levelup-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.5);
}

/* ==========================================================
   RESPONSIVE - Móvil (pantallas <= 700px)
   ========================================================== */
@media (max-width: 700px) {
    :root {
        --square-size: 40px;
        --team-col-width: 78px;
        --grid-gap: 3px;
    }

    .mode-section {
        margin-top: 60px;
        padding: 0 2px 40px;
        max-width: 100%;
    }

    h1 { font-size: 1.6rem; margin: 5px 0 12px; }
    .mode-title { font-size: 1.6rem; }

    #top-bar {
        top: 10px;
        right: 8px;
        left: auto;
        gap: 6px;
        justify-content: flex-end;
        flex-wrap: wrap;
        max-width: calc(100% - 170px);
    }

    #info-btn, #stats-btn {
        padding: 6px 9px;
        font-size: 1rem;
    }

    #streak-capsule { padding: 3px 9px 3px 3px; }
    #streak-ball-wrapper { width: 26px; height: 26px; }
    #streak-ball { font-size: 1rem; }
    #streak-extra { font-size: 0.75rem; top: -3px; right: -5px; }
    #streak-count { font-size: 0.85rem; }

    #lang-switcher { padding: 3px; gap: 4px; }
    .lang-btn { font-size: 1.05rem; padding: 3px 6px; }

    #mode-switcher {
        top: 10px;
        left: 8px;
        padding: 3px;
        z-index: 11;
    }
    .mode-btn {
        padding: 5px 9px;
        font-size: 0.72rem;
    }

    #attempts-counter,
    #legends-attempts-counter {
        padding: 10px 25px;
        margin-bottom: 15px;
    }
    #attempts-number,
    #legends-attempts-number { font-size: 1.8rem; }
    .attempts-title { font-size: 0.7rem; }

    input {
        padding: 13px;
        font-size: 0.9rem;
    }
    .search-box { margin-bottom: 22px; }

    .autocomplete-items div { padding: 9px 10px; font-size: 0.85rem; }
    .suggestion-shield .shield-img,
    .suggestion-shield .shield-fallback {
        width: 22px; height: 22px;
        margin-right: 8px;
    }

    .row-shield .shield-img,
    .row-shield .shield-fallback {
        width: 22px; height: 22px;
        margin-right: 5px;
        font-size: 0.55rem;
    }
    .team-cell-info { padding-right: 4px; }
    .team-cell-info span { font-size: 0.65rem; }
    .cell-head { font-size: 0.5rem; letter-spacing: 0; }

    .square {
        border-radius: 6px;
        padding: 1px;
    }
    .square-value {
        font-size: 0.6rem;
        padding: 0 1px;
        letter-spacing: -0.2px;
    }

    #legend-photo-wrapper {
        width: 240px;
        height: 240px;
    }
    #legend-photo-placeholder { font-size: 3rem; }

    #mini-stats { gap: 6px; }
    .mini-stat { padding: 8px 3px; }
    .mini-stat-value { font-size: 1.15rem; }
    .mini-stat-label { font-size: 0.55rem; }

    #victory-card { padding: 22px 18px; }
    .confetti-emoji { font-size: 2.8rem; }
    #victory-card h2 { font-size: 1.7rem; }
    #victory-card p { font-size: 0.85rem; }
    #victory-team { padding: 10px 14px; }
    #victory-team-name { font-size: 1rem; }
    #countdown-timer { font-size: 1.3rem; }
    #view-stats-btn,
    #share-result-btn { padding: 11px 25px; font-size: 0.95rem; }

    #stats-card,
    #info-card { padding: 22px 18px; }
    #stats-grid { gap: 6px; }
    .stat-box { padding: 10px 4px; min-height: 65px; }
    .stat-box-value { font-size: 1.5rem; }
    .stat-box-label { font-size: 0.55rem; }
    .stats-section-title {
        font-size: 0.8rem;
        margin: 8px 0 2px;
        padding: 6px 4px;
    }

    #info-content { font-size: 0.85rem; }
    #info-content h3 { font-size: 0.85rem; }
    .info-legend-swatch { width: 32px; height: 32px; font-size: 0.7rem; }
    .info-legend-text { font-size: 0.8rem; }

    #levelup-card { padding: 25px 20px; }
    .levelup-title { font-size: 1.3rem; letter-spacing: 2px; }
    #levelup-ball-wrapper { width: 90px; height: 90px; }
    #levelup-ball { font-size: 3.2rem; }
    #levelup-extra { font-size: 1.7rem; }
    #levelup-tier-name { font-size: 1.1rem; }
}

@media (max-width: 380px) {
    :root {
        --square-size: 34px;
        --team-col-width: 65px;
        --grid-gap: 2px;
    }
    .team-cell-info span { font-size: 0.6rem; }
    .cell-head { font-size: 0.45rem; }
    .square-value { font-size: 0.52rem; }
    .row-shield .shield-img,
    .row-shield .shield-fallback {
        width: 18px; height: 18px;
        margin-right: 3px;
    }
    #legend-photo-wrapper {
        width: 200px;
        height: 200px;
    }
}
/* ---------- Footer con botón Buy me a coffee ---------- */
#page-footer {
    position: relative;
    z-index: 2;
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 20px 15px 30px;
    box-sizing: border-box;
    margin-top: auto;
}

.coffee-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #ffdd00 0%, #ffa500 100%);
    color: #000;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 0.95rem;
    box-shadow: 0 4px 16px rgba(255, 165, 0, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    border: 2px solid rgba(0, 0, 0, 0.1);
}

.coffee-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(255, 165, 0, 0.5);
}

.coffee-icon {
    font-size: 1.2rem;
    animation: coffeeSteam 2s ease-in-out infinite;
}

@keyframes coffeeSteam {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-2px) rotate(5deg); }
}

/* Asegurar que body/html son flex para que el footer se vaya al fondo */
body {
    flex-direction: column;
    align-items: center;
}

/* Responsive - más pequeño en móvil */
@media (max-width: 700px) {
    #page-footer {
        padding: 15px 10px 20px;
    }
    .coffee-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    .coffee-icon {
        font-size: 1rem;
    }
}