:root {
    --azul-banner: #003399;
    --naranja-retro: #ff6600;
    --gris-fondo: #f0f0f0;
}

body {
    margin: 0;
    font-family: 'Press Start 2P', cursive;
    display: flex;
    height: 100vh;
    background-color: var(--gris-fondo);
    image-rendering: pixelated;
    /* Bloqueo total de scroll horizontal */
    overflow-x: hidden;
    width: 100vw;
}

/* SIDEBAR */
.sidebar {
    width: clamp(80px, 15vw, 130px); 
    background: var(--azul-banner);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    box-shadow: 4px 0 10px rgba(0,0,0,0.2);
    flex-shrink: 0; /* Evita que el sidebar se encoja */
    z-index: 10;
}

/* BOTÓN DE DADOS */
.dice-btn {
    width: 90%;
    height: clamp(50px, 8vh, 70px);
    margin: 8px 0;
    border: 3px solid #fff; 
    background: rgba(255,255,255,0.1);
    color: white; 
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(10px, 1.2vw, 14px);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 8px;
    box-sizing: border-box;
}

.dice-btn img {
    width: clamp(18px, 2.5vw, 25px);
    height: auto;
    margin-right: 8px;
    flex-shrink: 0;
}

.dice-btn.active { background: white; color: var(--azul-banner); }

/* CONTENIDO PRINCIPAL CORREGIDO */
.main-content {
    flex-grow: 1; 
    min-width: 0; /* VITAL: Evita que el contenido empuje el layout y cree scroll horizontal */
    display: flex; 
    flex-direction: column;
    align-items: center; 
    padding: 20px 10px; /* Reducido el padding lateral */
    overflow-y: auto;
    overflow-x: hidden; /* Seguridad extra */
}

/* Título que se ajusta */
.header-title {
    font-size: clamp(10px, 2.5vw, 18px);
    text-align: center;
    width: 90%;
    word-wrap: break-word;
}

#result-display {
    font-size: clamp(50px, 15vw, 100px); 
    color: var(--azul-banner);
    margin: 30px 0;
    text-align: center;
}

/* ZONA DE CONTROL MATEMÁTICO */
.math-controls {
    display: flex; 
    gap: 10px; 
    margin-bottom: 25px;
    background: #ddd; 
    padding: 10px; 
    border: 3px solid #000;
    width: 95%; /* Ajustado para móviles */
    max-width: 400px;
    box-sizing: border-box;
    justify-content: center;
}

.control-group { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 5px;
    flex: 1; /* Distribuye espacio equitativo */
}

.control-group label { font-size: 8px; }

select, input[type="number"] {
    font-family: 'Press Start 2P', cursive;
    padding: 5px 2px; 
    border: 2px solid #000;
    background: white; 
    text-align: center;
    width: 100%;
    font-size: 10px;
}

.roll-button {
    background: var(--naranja-retro); 
    color: white;
    border: 4px solid #000; 
    padding: 15px;
    font-family: 'Press Start 2P', cursive; 
    font-size: clamp(12px, 3vw, 18px);
    cursor: pointer;
    box-shadow: 4px 4px 0px #000; 
    width: 95%;
    max-width: 400px;
}

.roll-button:active { transform: translate(4px, 4px); box-shadow: 0 0; }

/* HISTORIAL */
.history-card {
    width: 95%; 
    max-width: 500px; 
    background: white;
    border: 3px solid #000; 
    margin-top: 30px; 
    padding: 10px;
    box-sizing: border-box;
}

.history-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    border-bottom: 3px solid #000; 
    padding-bottom: 10px; 
    margin-bottom: 10px;
}

.history-header h3 { font-size: 10px; margin: 0; }

.history-item {
    font-size: 9px; 
    display: flex; 
    justify-content: space-between;
    padding: 10px 0; 
    border-bottom: 1px solid #ddd;
}

.clear-btn {
    background: #ff4444; 
    color: white; 
    border: 2px solid #000;
    font-family: 'Press Start 2P', cursive; 
    font-size: 10px; 
    padding: 5px;
    cursor: pointer;
}