/* =========================
   GLOBAL / RESET
========================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", "Montserrat", sans-serif;
    min-height: 100vh;
    color: #e5e7eb;
    background:
        radial-gradient(circle at top left, #22c55e22, transparent 55%),
        radial-gradient(circle at bottom right, #0ea5e922, transparent 55%),
        radial-gradient(circle at top right, #f9731622, transparent 60%),
        #020617;
}

/* =========================
   LAYOUT
========================= */
#game-root {
    max-width: 1040px;
    margin: 0 auto;
    padding: 24px 16px 40px;
    position: relative; /* Necesario para posicionar elementos absolutos dentro */
}

.screen {
    display: none;
}

.screen-active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.panel {
    border-radius: 18px;
    padding: 20px 20px 22px;
}

/* Neon glass panel */
.neon-panel {
    background: radial-gradient(circle at top left, #1e293b, #020617);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow:
        0 0 0 1px rgba(15, 23, 42, 0.7),
        0 18px 40px rgba(0, 0, 0, 0.6);
}

/* =========================
   START SCREEN
========================= */
.start-card {
    text-align: center;
    max-width: 640px;
    margin: 40px auto 0;
    padding: 28px 20px 26px;
    border-radius: 22px;
    background: radial-gradient(circle at top, #111827, #020617);
    box-shadow:
        0 0 0 1px rgba(75, 85, 99, 0.4),
        0 22px 60px rgba(0, 0, 0, 0.8);
}

.logo-main {
    width: 220px;
    margin: 0 auto 12px;
    filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.8));
}

.game-title {
    font-size: 2.1rem;
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}

.game-subtitle {
    font-size: 1rem;
    color: #cbd5f5;
    max-width: 420px;
    margin: 0 auto 18px;
}

.highlight {
    color: #22d3ee;
    font-weight: 700;
}

.credits {
    margin-top: 12px;
    font-size: 0.85rem;
    color: #9ca3af;
}

/* =========================
   BUTTONS
========================= */
.btn {
    border: none;
    cursor: pointer;
    border-radius: 999px;
    padding: 11px 20px;
    font-size: 0.98rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition:
        transform 0.16s ease-out,
        box-shadow 0.16s ease-out,
        background 0.16s ease-out,
        opacity 0.12s ease-out;
}

.btn-primary {
    background: linear-gradient(135deg, #22c55e, #16a3ff);
    color: #0b1120;
    box-shadow:
        0 0 12px rgba(34, 197, 94, 0.8),
        0 0 24px rgba(56, 189, 248, 0.7);
}

.btn-primary:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow:
        0 0 16px rgba(52, 211, 153, 1),
        0 0 28px rgba(56, 189, 248, 0.9);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
    box-shadow: none;
}

.btn-big {
    padding: 13px 26px;
    font-size: 1.05rem;
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(148, 163, 184, 0.6);
    color: #e5e7eb;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.8);
    width: 64px;
    height: 64px;
    border-radius: 999px;
    font-size: 1.4rem;
}

.btn-ghost:hover {
    background: rgba(15, 23, 42, 0.9);
}

.btn-choice {
    width: 100%;
    justify-content: center;
    background: linear-gradient(135deg, #1d4ed8, #0f766e);
    color: #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.8);
}

.btn-choice:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.9);
}

.btn-choice.chosen {
    outline: 2px solid #fbbf24;
}

.btn.disabled,
.btn:disabled {
    opacity: 0.45;
    cursor: default;
    box-shadow: none;
    transform: none;
}

/* =========================
   INTRO
========================= */
.intro-layout {
    max-width: 720px;
    margin: 40px auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
}

.dialog-bubble {
    position: relative;
    background: radial-gradient(circle at top, #1f2937, #020617);
    border-radius: 18px;
    padding: 16px 18px 14px;
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.6),
        0 14px 32px rgba(0, 0, 0, 0.8);
    max-width: 100%;
}

.dialog-bubble::after {
    content: "";
    position: absolute;
    bottom: -14px;
    left: 46px;
    border-width: 14px 12px 0 12px;
    border-style: solid;
    border-color: #111827 transparent transparent transparent;
}
.dialog-name {
    font-weight: bold;
    color: #00ffcc; 
    font-size: 1.1rem;
    text-transform: uppercase;
    margin-bottom: 8px; 
    border-bottom: 1px solid rgba(0, 255, 204, 0.3);
    padding-bottom: 4px;
    display: inline-block;
}
#intro-dialog-text {
    margin: 0;
    line-height: 1.4;
    color: #ffffff;
}

.intro-character img {
    width: 220px;
    filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.85));
    animation: floatChar 3s ease-in-out infinite alternate;
}

@keyframes floatChar {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

.intro-next {
    margin-top: 16px;
    text-align: center;
}

/* =========================
   RULES
========================= */
.panel-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.rules-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 18px;
}

.rules-list li {
    margin-bottom: 6px;
    color: #cbd5f5;
}

/* =========================
   GAME UI
========================= */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    font-size: 0.95rem;
    color: #cbd5f5;
}

.logo-mini {
    height: 32px;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 2.2fr) minmax(0, 1.3fr);
    gap: 16px;
}

@media (max-width: 800px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

.panel-news {
    display: flex;
    flex-direction: column;
    /* align-items: center;  <-- Quitamos esto para que el texto se alinee a la izquierda naturalmente */
    height: auto; 
    min-height: 400px;
}

#news-image {
    max-width: 100%;
    height: auto;
    max-height: 250px; /* Limite de altura para que no empuje todo */
    object-fit: contain;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 15px;
}

.news-title {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: #e5e7eb;
}

.news-body {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 10px;
    color: #d1d5db;
}

.news-source {
    font-size: 0.9rem;
    color: #9ca3af;
    margin-bottom: 14px;
    font-style: italic;
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Baba lateral */
.panel-baba {
    display: flex;
    align-items: center;
    justify-content: center;
}

.baba-side-wrapper {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at top, #0f172a, #020617);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.7),
        0 20px 36px rgba(0, 0, 0, 0.9);
}

.baba-side-wrapper img {
    width: 140px;
}

/* =========================
   FEEDBACK
========================= */
.panel-feedback {
    max-width: 720px;
    margin: 36px auto 0;
}

.feedback-text {
    margin-bottom: 16px;
    color: #e5e7eb;
    line-height: 1.5;
}

.reflection-question {
    margin-top: 10px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #a5b4fc;
}

.reflection-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.reflection-options .btn {
    background: linear-gradient(135deg, #334155, #0f172a);
    color: #e5e7eb;
    border-radius: 12px;
    text-align: left;
    justify-content: flex-start;
}

.reflection-options .btn.correct {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #0b1120;
}

.reflection-options .btn.wrong {
    background: linear-gradient(135deg, #ef4444, #b91c1c);
}

/* =========================
   END SCREEN
========================= */
.panel-end {
    max-width: 900px;
    margin: 50px auto 0;
    text-align: center;
}

.final-score-text {
    margin-top: 10px;
    margin-bottom: 4px;
}

.final-score {
    font-size: 1.6rem;
    font-weight: 700;
    color: #22c55e;
}

.final-message {
    margin-top: 4px;
    margin-bottom: 18px;
    color: #e5e7eb;
}

.final-actions {
    display: flex;
    justify-content: center;
    margin-top: 16px;
}

/* Tabla de resultados */
.results-wrapper {
    margin-top: 16px;
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 4px;
}

.results-table thead {
    background: rgba(15, 23, 42, 0.9);
}

.results-table th,
.results-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.results-table th {
    font-weight: 600;
    color: #e5e7eb;
}

.results-table td {
    color: #e5e7eb;
}

.results-table tr.correct-row td {
    color: #bbf7d0;
}

.results-table tr.wrong-row td {
    color: #fecaca;
}

/* =========================
   BABA OVERLAY
========================= */
.baba-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, rgba(15, 23, 42, 0.95), rgba(0, 0, 0, 0.95));
    z-index: 1000;
}

.baba-overlay.active {
    display: flex;
}

.baba-overlay-inner {
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle at top, #fee2e2, #fecaca, #7f1d1d);
    box-shadow:
        0 0 0 2px rgba(248, 250, 252, 0.6),
        0 28px 60px rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: overlayIn 0.4s ease-out;
}

@keyframes overlayIn {
    0% { transform: scale(0.4); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

#baba-overlay-img {
    width: 150px;
}

/* Animaciones baba */
.baba-hit { animation: hitPulse 0.6s ease-in-out; }
.baba-laugh { animation: laughPulse 0.7s ease-in-out; }

@keyframes hitPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.2); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes laughPulse {
    0% { transform: scale(1); }
    30% { transform: scale(1.15); }
    60% { transform: scale(0.95); }
    100% { transform: scale(1.1); }
}

.baba-overlay-text {
    position: absolute;
    bottom: 12px;
    font-weight: 800;
    font-size: 1.4rem;
    color: #111827;
    text-shadow:
        0 0 8px rgba(248, 250, 252, 0.9),
        0 0 24px rgba(248, 250, 252, 0.9);
}

/* =========================
   MOBILE & RESPONSIVE
========================= */
@media (max-width: 640px) {
    #game-root { padding: 16px 12px 32px; }
    .start-card { margin-top: 28px; padding-inline: 16px; }
    .intro-layout { margin-top: 28px; }
    .dialog-bubble::after { left: 30px; }
    .panel-news { order: 2; }
    .panel-baba { order: 1; }
    .combo-box { top: 15%; left: 0; right: 0; margin: auto; } /* Ajuste combo movil */
}

/* =========================
   HEALTH BARS
========================= */
.health-duel-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 20px;
    max-width: 800px;
    margin: 0 auto;
}

.health-wrapper {
    position: relative;
}

.health-label {
    font-size: 0.6rem;
    color: #fff;
    margin-bottom: 3px;
    display: block;
    letter-spacing: 1px;
}

.health-bar-bg {
    position: relative;
    width: 100%;
    height: 30px;
    background: #1a1a1a;
    border-radius: 15px;
    border: 2px solid #00ffcc; /* Default Enemy Color */
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.3);
    overflow: hidden;
}

/* Barra Enemigo */
.health-bar-fill.enemy {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00ffcc, #00e6b8);
    transition: width 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.5);
}

/* Barra Jugador (Azul) */
.health-bar-bg.player {
    border-color: #00d2ff;
}

.health-bar-fill.player {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #00d2ff, #3a7bd5);
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
    transition: width 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* =========================
   ADMIN PANEL
========================= */
.admin-card {
    background: rgba(20, 20, 30, 0.95);
    border: 2px solid #00ffcc;
    border-radius: 20px;
    padding: 30px;
    max-width: 800px;
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.2);
}

.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 700px) {
    .admin-grid { grid-template-columns: 1fr; }
}

.input-group {
    margin-bottom: 15px;
    text-align: left;
}

.input-group label {
    display: block;
    color: #00ffcc;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.input-group input, .input-group textarea, .neon-select {
    width: 100%;
    background: #0a0a0f;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    color: white;
    transition: 0.3s;
}

.input-group input:focus {
    border-color: #00ffcc;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.3);
    outline: none;
}

.admin-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
}

/* =========================
   ARCADE COMBO SYSTEM
========================= */
.hidden { display: none !important; }

.combo-box {
    position: absolute;
    top: 25%;
    left: 5%;
    transform: rotate(-10deg);
    text-align: center;
    pointer-events: none;
    z-index: 100;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-count {
    font-weight: 900;
    font-size: 3rem; /* Base size */
    line-height: 1;
    transition: all 0.2s ease;
    text-shadow: 3px 3px 0px rgba(0,0,0,0.5);
    font-family: 'Montserrat', sans-serif, system-ui;
}

.combo-text {
    font-size: 1.2rem;
    color: white;
    font-style: italic;
    letter-spacing: 2px;
    margin-top: -5px;
    text-shadow: 0 0 5px rgba(0,0,0,0.8);
}

.combo-bonus {
    font-size: 1.2rem;
    color: #00ffcc;
    opacity: 0;
    font-weight: bold;
}

/* Animaciones Arcade */
.punch-anim {
    animation: punch 0.15s ease-out forwards;
}

@keyframes punch {
    0% { transform: scale(1) rotate(-10deg); }
    50% { transform: scale(1.4) rotate(-15deg); }
    100% { transform: scale(1) rotate(-10deg); }
}

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

/* --- NIVELES DE COMBO Y COLORIMETRÍA --- */

/* Nivel 1: Frío (Azul/Cyan) */
.combo-level-1 .combo-count {
    color: #00f2ff;
    text-shadow: 0 0 10px #00f2ff, 3px 3px 0 #005555;
}

/* Nivel 2: Calentando (Amarillo/Oro) */
.combo-level-2 .combo-count {
    color: #ffcc00;
    text-shadow: 0 0 15px #ffcc00, 3px 3px 0 #b35900;
}

/* Nivel 3: Fuego (Naranja/Rojo) */
.combo-level-3 .combo-count {
    color: #ff4d4d;
    text-shadow: 0 0 20px #ff0000, 4px 4px 0 #660000;
}

/* Nivel 4: MODO FASTCHECKER (Identidad de Marca) */
.combo-level-4 .combo-count {
    color: #ffffff; /* Blanco puro */
    /* El Cyan corporativo #00f2ff como aura potente */
    text-shadow: 0 0 10px #00f2ff, 0 0 30px #00f2ff, 0 0 50px #00f2ff; 
    animation: shake 0.2s infinite; /* Vibra de energía */
}

.combo-level-4 .combo-text {
    color: #00f2ff; /* Texto FASTCHECKER en Cyan */
    font-weight: 900;
    font-size: 1.5rem;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.8);
}

@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

/* Estilos extra para leaderboard input */
.arcade-input:focus {
    outline: none;
    box-shadow: 0 0 15px #00f2ff;
}

.arcade-table th, .arcade-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* =========================
   ESTILOS PANTALLA FINAL MEJORADA
========================= */

/* Layout de dos columnas para pantallas grandes */
.end-grid-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 10px;
    text-align: left;
}

@media (max-width: 700px) {
    .end-grid-layout {
        grid-template-columns: 1fr; /* Una columna en móvil */
    }
}

/* --- LEADERBOARD COMPACTO --- */
.leaderboard-scroll {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid rgba(0, 242, 255, 0.3);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
}

.arcade-table.compact {
    width: 100%;
    font-size: 0.85rem; /* Letra más pequeña */
}

.arcade-table.compact th, 
.arcade-table.compact td {
    padding: 6px 8px; /* Menos relleno */
    text-align: center;
}

.arcade-table.compact th {
    color: #00f2ff;
    font-weight: bold;
    font-size: 0.7rem;
}

/* --- HISTORIAL DE RESPUESTAS (SCROLL) --- */
.results-scroll {
    max-height: 200px; /* Altura fija con scroll */
    overflow-y: auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(0,0,0,0.3);
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.results-table th, .results-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Scrollbars personalizadas para que se vean modernas */
.leaderboard-scroll::-webkit-scrollbar,
.results-scroll::-webkit-scrollbar {
    width: 6px;
}
.leaderboard-scroll::-webkit-scrollbar-track,
.results-scroll::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
}
.leaderboard-scroll::-webkit-scrollbar-thumb {
    background: #00f2ff;
    border-radius: 3px;
}
.results-scroll::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 3px;
}