/* ====================================================== */
/* VARIABLES GLOBALES (MISMA PALETA QUE styles.css)       */
/* ====================================================== */
:root {
    --bg-main: #1a1a1a;
    --bg-panel: #2a2a2a;
    --bg-glass: rgba(42, 42, 42, 0.95);
    --accent: #e63946;
    --accent-soft: rgba(230, 57, 70, 0.25);
    --text-main: #e0e0e0;
    --text-muted: #b0b0b0;
    --border-soft: rgba(255, 255, 255, 0.15);
}

/* ====================================================== */
/* RESET BÁSICO                                           */
/* ====================================================== */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    touch-action: manipulation;
}

/* ====================================================== */
/* BOTÓN REGRESAR                                         */
/* ====================================================== */
.back-button {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    color: var(--accent);
    border: 1px solid var(--accent);
    background: transparent;
    transition: background 0.2s, color 0.2s;
}

.back-button:hover {
    background: var(--accent);
    color: white;
}

/* ====================================================== */
/* CONTENEDOR DEL JUEGO                                   */
/* ====================================================== */
.game-container {
    width: 95%;
    max-width: 900px;
    background: var(--bg-glass);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    position: relative;
}

/* ====================================================== */
/* HEADER                                                 */
/* ====================================================== */
.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-header h1 {
    margin: 0;
    color: var(--accent);
    font-size: clamp(1.6em, 4vw, 2.6em);
}

.game-header p {
    margin-top: 5px;
    color: var(--text-muted);
}

/* ====================================================== */
/* SCORE BOARD                                            */
/* ====================================================== */
.score-board {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.score-item {
    background: rgba(0,0,0,0.4);
    padding: 10px;
    border-radius: 12px;
    text-align: center;
    min-width: 90px;
    font-weight: bold;
    font-size: 0.9em;
}

/* ====================================================== */
/* CANVAS                                                 */
/* ====================================================== */
.game-canvas {
    display: block;
    margin: 0 auto;
    background: #000;
    border-radius: 15px;
    border: 3px solid var(--accent-soft);
    max-width: 100%;
    height: auto;
}

/* ====================================================== */
/* INDICADOR DE CONGELACIÓN                                */
/* ====================================================== */
.freeze-indicator {
    margin: 15px auto;
    padding: 10px;
    text-align: center;
    border-radius: 12px;
    background: var(--accent-soft);
    color: white;
    font-weight: bold;
}

/* ====================================================== */
/* LEYENDA                                                */
/* ====================================================== */
.legend {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 15px;
    font-size: 0.8em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.coin-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.gold {
    background: linear-gradient(45deg, #c9a227, #f0c94d);
}

.silver {
    background: linear-gradient(45deg, #9e9e9e, #cfcfcf);
}

/* ====================================================== */
/* CONTROLES                                              */
/* ====================================================== */
.controls {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.controls p {
    margin: 6px 0;
}

/* ====================================================== */
/* BOTONES                                                */
/* ====================================================== */
.pause-btn,
.start-btn,
.restart-btn {
    margin: 6px;
    padding: 10px 22px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-weight: bold;
    color: white;
    background: linear-gradient(135deg, #b72c36, var(--accent));
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.2s;
}

.pause-btn:hover,
.start-btn:hover,
.restart-btn:hover {
    transform: translateY(-2px);
}

/* ====================================================== */
/* PANEL DE MENSAJES                                      */
/* ====================================================== */
.message-panel {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-panel);
    border-radius: 12px;
    border-left: 4px solid var(--accent);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.message-title {
    color: var(--accent);
    font-weight: bold;
    margin-bottom: 10px;
}

.message-content {
    color: var(--text-main);
    line-height: 1.5;
}

/* ====================================================== */
/* PANELES MODALES                                        */
/* ====================================================== */
.start-panel,
.game-over-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-main);
    padding: 25px;
    border-radius: 20px;
    border: 1px solid var(--border-soft);
    box-shadow: 0 12px 50px rgba(0,0,0,0.7);
    text-align: center;
    z-index: 1000;
    max-width: 90vw;
}

.start-title,
.game-over-title {
    color: var(--accent);
    font-size: clamp(1.6em, 4vw, 2.4em);
    margin-bottom: 15px;
}

.start-message,
.game-over-message {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 15px;
}

.close-modal {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s, transform 0.2s;
}

.close-modal:hover {
    color: var(--accent);
    transform: scale(1.1);
}


/* ====================================================== */
/* CONTROLES MÓVILES                                      */
/* ====================================================== */
.mobile-controls {
    display: none;
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 50;
    background: rgba(0,0,0,0.85);
    padding: 15px;
    border-radius: 20px;
}

.joystick-base {
    width: 140px;
    height: 140px;
    background: rgba(255,255,255,0.08);
    border: 2px solid var(--border-soft);
    border-radius: 50%;
    position: relative;
    touch-action: none;
}

.joystick-stick {
    width: 60px;
    height: 60px;
    background: var(--accent);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}


/* ====================================================== */
/* RESPONSIVE                                             */
/* ====================================================== */
@media (hover: none) and (pointer: coarse) {
    .mobile-controls {
        position: fixed;
        bottom: 20px;
        left: 20px;
        z-index: 999;
        display: none;
    }
}


@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .game-container {
        padding: 15px;
    }
}

