:root {
    /* Paleta de Día (Colores Pastel Dulces) */
    --bg-day: #fff4f4;
    --text-day: #7a757e;
    --player-day: #a2d2ff;
    --obs-day: #ffc8dd;
    
    /* Paleta de Noche (Colores Oscuros Relajantes) */
    --bg-night: #2b2d42;
    --text-night: #edf2f4;
    --player-night: #ffca3a;
    --obs-night: #8d99ae;
}

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

body {
    /* Fondo exterior de la página web */
    background-color: #f7ecec; 
    color: var(--text-day);
    font-family: 'Nunito', sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

/* El Wrapper contiene todo. No se voltea, solo cambia de color */
#game-wrapper {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 100%;
    max-height: 600px;
    background-color: var(--bg-day);
    border-radius: 30px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.05);
    overflow: hidden;
    transition: background-color 1.5s ease, color 1.5s ease;
}

#game-wrapper.night-mode {
    background-color: var(--bg-night);
    color: var(--text-night);
}

/* El Game Container contiene el Canvas, y ES EL QUE ROTA */
#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 2s cubic-bezier(0.4, 0, 0.2, 1);
}

.canvas-rotated {
    transform: rotate(180deg);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* INTERFAZ DE TEXTOS (Siempre derecha) */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 40px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 5;
}

.score-container {
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
}

.score-value {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 5px;
    color: inherit;
}

.high-score-label {
    font-size: 1rem;
    opacity: 0.6;
    font-weight: 700;
}

.gravity-indicator {
    background: rgba(255, 255, 255, 0.6);
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1.1rem;
    backdrop-filter: blur(10px);
    transition: background 1.5s, color 1.5s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
}

#game-wrapper.night-mode .gravity-indicator {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-night);
}

#glitch-warning {
    position: absolute;
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 15px 35px;
    border-radius: 50px;
    font-size: 1.4rem;
    font-weight: 800;
    opacity: 1;
    transition: opacity 1s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}

#game-wrapper.night-mode #glitch-warning {
    background: rgba(0, 0, 0, 0.6);
}

#glitch-warning.hidden {
    opacity: 0;
}

/* Pantallas modales */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 244, 244, 0.7);
    backdrop-filter: blur(10px);
    z-index: 10;
    transition: opacity 0.5s;
}

#game-wrapper.night-mode .overlay {
    background: rgba(43, 45, 66, 0.7);
}

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

.modal {
    background: white;
    padding: 50px 60px;
    border-radius: 40px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.08);
    transform: translateY(0) scale(1);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background 1.5s;
}

#game-wrapper.night-mode .modal {
    background: #1e1e2d;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
}

.overlay.hidden .modal {
    transform: translateY(30px) scale(0.95);
}

h1, h2 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.6;
    margin-bottom: 30px;
    font-weight: 800;
}

.instructions p {
    font-size: 1.1rem;
    margin-bottom: 12px;
    font-weight: 600;
    opacity: 0.8;
}

.score-summary p {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 25px;
}

button {
    background: var(--player-day);
    color: white;
    border: none;
    padding: 16px 45px;
    font-size: 1.3rem;
    font-family: inherit;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 15px;
    transition: transform 0.2s, filter 0.2s, background 1.5s;
    box-shadow: 0 8px 20px rgba(162, 210, 255, 0.4);
}

button:hover {
    transform: scale(1.05) translateY(-2px);
    filter: brightness(1.1);
}

#game-wrapper.night-mode button {
    background: var(--player-night);
    color: #2b2d42;
    box-shadow: 0 8px 20px rgba(255, 202, 58, 0.2);
}

/* Floating Sound Toggle Button */
#sound-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border: none;
    cursor: pointer;
    z-index: 15;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.3rem;
    padding: 0;
    margin: 0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: transform 0.2s, background 1.5s, box-shadow 0.2s;
}

#sound-toggle:hover {
    transform: scale(1.1) translateY(0);
}

#game-wrapper.night-mode #sound-toggle {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-night);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
