:root {
    --bg-dark: #1e293b;
    --panel-bg: rgba(30, 41, 59, 0.9);
    --primary-color: #2ecc71;
    --primary-dark: #27ae60;
    --accent-color: #f39c12;
    --accent-dark: #d35400;
    --text-light: #f8fafc;
    --text-dark: #334155;
    
    --font-title: 'Fredoka One', cursive;
    --font-text: 'Nunito', sans-serif;
}

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

body {
    background-color: #0f172a; /* Outer background */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: var(--font-text);
    overflow: hidden;
}

#game-wrapper {
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

/* Aspect ratio 16:9 container */
#game-container {
    width: 100%;
    height: 100%;
    max-width: calc(100vh * (16 / 9));
    max-height: calc(100vw * (9 / 16));
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    position: relative;
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    border: 4px solid #1e293b;
}

/* --- Estructura de Pantallas --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease;
    opacity: 1;
    z-index: 10;
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* --- Pantalla Inicio --- */
#screen-start {
    background-image: url('../img/Fondo_1.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.title-container {
    position: absolute;
    top: 5%;
    text-align: center;
    width: 100%;
    z-index: 10;
}

.title-container h1 {
    font-family: var(--font-title);
    font-size: 5.5rem;
    background: linear-gradient(180deg, #ffb347 0%, #ff7b00 40%, #cc2b5e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    letter-spacing: 3px;
    filter: drop-shadow(3px 3px 0 #1a1a1a) drop-shadow(-2px -2px 0 #1a1a1a) drop-shadow(2px -2px 0 #1a1a1a) drop-shadow(-2px 2px 0 #1a1a1a) drop-shadow(0px 8px 10px rgba(0,0,0,0.6));
    transform: rotate(-2deg);
}

.title-container .subtitle {
    font-size: 2.2rem;
    font-weight: 800;
    color: #fff;
    margin-top: 5px;
    text-shadow: 2px 2px 0 #1a1a1a, -1px -1px 0 #1a1a1a, 1px -1px 0 #1a1a1a, -1px 1px 0 #1a1a1a;
}

.hero-character {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    margin-top: 140px;
    padding-bottom: 120px;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 2;
}

.hero-character img {
    max-width: 100%;
    max-height: 70%;
    object-fit: contain;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.6));
    animation: float 3s ease-in-out infinite;
}

/* Botón Principal */
.btn-primary {
    position: absolute;
    bottom: 8%;
    z-index: 20;
    font-family: var(--font-title);
    font-size: 2rem;
    padding: 15px 40px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 15px;
    box-shadow: 0 8px 0 var(--primary-dark), 0 15px 20px rgba(0,0,0,0.3);
    cursor: pointer;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.3);
    transition: all 0.1s;
    letter-spacing: 1px;
}

.btn-primary:active {
    transform: translateY(8px);
    box-shadow: 0 0 0 var(--primary-dark), 0 5px 10px rgba(0,0,0,0.3);
}

/* --- Pantalla Narrativa --- */
#screen-narrative {
    background: rgba(0,0,0,0.7);
    justify-content: flex-end;
    padding-bottom: 5%;
}

.rpg-dialog-box {
    width: 80%;
    height: 25%;
    background: var(--panel-bg);
    border: 4px solid var(--accent-color);
    border-radius: 20px;
    display: flex;
    padding: 20px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.character-portrait {
    width: 150px;
    height: 150px;
    background: #64748b;
    border-radius: 50%;
    border: 4px solid #fff;
    overflow: hidden;
    position: absolute;
    top: -50px;
    left: -20px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.character-portrait img {
    height: 150%;
    margin-top: -10px;
}

.dialog-content {
    margin-left: 140px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.character-name {
    font-family: var(--font-title);
    color: var(--accent-color);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.dialog-text {
    font-size: 1.3rem;
    color: var(--text-light);
    line-height: 1.5;
    flex: 1;
}

.btn-next {
    align-self: flex-end;
    background: none;
    border: none;
    color: var(--primary-color);
    font-family: var(--font-title);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-next:hover {
    transform: translateX(5px);
}

/* --- Opciones de Diálogo (Karma) --- */
.dialog-choices {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.btn-choice {
    background: #334155;
    border: 2px solid var(--accent-color);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: var(--font-text);
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    flex: 1;
    min-width: 150px;
}

.btn-choice:hover {
    background: var(--accent-color);
    color: var(--panel-bg);
    transform: translateY(-2px);
}

/* --- Minijuego --- */
#screen-minigame {
    background: #e2e8f0;
}

.top-hud {
    position: absolute;
    top: 5%;
    width: 90%;
    display: flex;
    justify-content: space-between;
}

.timer-box, .objective-box {
    background: var(--panel-bg);
    color: var(--text-light);
    padding: 15px 25px;
    border-radius: 15px;
    font-family: var(--font-title);
    font-size: 1.5rem;
    border: 3px solid #334155;
}

.timer-box {
    color: #ef4444;
}

.minigame-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

#dirty-plate {
    width: 300px;
    height: 300px;
    background: #fff;
    border-radius: 50%;
    border: 15px solid #cbd5e1;
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.1), 0 20px 40px rgba(0,0,0,0.2);
    position: relative;
    cursor: pointer;
    transition: transform 0.1s;
}

#dirty-plate:active {
    transform: scale(0.95);
}

.stains {
    position: absolute;
    width: 80px;
    height: 60px;
    background: #78350f;
    border-radius: 50%;
    opacity: 0.8;
    filter: blur(2px);
    top: 30%;
    left: 20%;
    transition: opacity 0.2s;
    pointer-events: none;
}

.stains.s2 { top: 50%; left: 50%; width: 100px; height: 80px; background: #5c2705;}
.stains.s3 { top: 20%; left: 60%; width: 50px; height: 50px; background: #3f1902;}

/* Overlay */
.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.overlay h2 {
    font-family: var(--font-title);
    font-size: 4rem;
    color: var(--accent-color);
    margin-bottom: 20px;
}

.overlay p {
    font-size: 1.5rem;
    color: white;
    margin-bottom: 40px;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

/* --- Nuevos estilos Minijuego Lavado --- */
.item-container {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 20px;
    background: radial-gradient(circle, #fff, #cbd5e1);
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.1), 0 20px 40px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: transform 0.1s, opacity 0.5s;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.item-container img {
    max-width: 80%;
    max-height: 80%;
    object-fit: contain;
    z-index: 1;
}

.dirt-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="40" fill="%235c2705" opacity="0.6" filter="blur(5px)"/></svg>');
    background-size: cover;
    z-index: 2;
    pointer-events: none;
    transition: opacity 0.1s;
}

.item-container.glass { background: radial-gradient(circle, #f8fafc, #e2e8f0); }
.item-container.pot { background: #334155; border: 10px solid #0f172a; border-radius: 50%; }

.slide-out {
    transform: translateX(-200%);
    opacity: 0;
}

/* --- Estilos Minijuego Inspección --- */
.inspection-container {
    position: relative;
    width: 80%;
    max-width: 800px;
    border: 4px solid var(--accent-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.inspection-bg {
    width: 100%;
    display: block;
}

.hitbox {
    position: absolute;
    cursor: crosshair;
    /* border: 1px solid rgba(255,0,0,0.5); // Descomentar para depurar */
    border-radius: 50%;
}

.hitbox.found {
    border: 3px solid #ef4444;
    background: rgba(239, 68, 68, 0.4);
    pointer-events: none;
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* --- Estilos Minijuego Plagas --- */
.pest-entity {
    position: absolute;
    width: 60px;
    height: 60px;
    object-fit: contain;
    cursor: crosshair;
    transition: transform 0.2s;
    filter: drop-shadow(0 5px 5px rgba(0,0,0,0.8));
    animation: scurry 0.2s infinite alternate;
}

.pest-entity.whacked {
    transform: scale(0.1) rotate(180deg);
    opacity: 0;
}

@keyframes scurry {
    0% { transform: translateX(-3px) rotate(-10deg); }
    100% { transform: translateX(3px) rotate(10deg); }
}

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

.supply-entity {
    position: absolute;
    cursor: crosshair;
    transition: transform 0.2s;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

/* --- Estilos Minijuego Mercado --- */
.market-card {
    background: var(--panel-bg);
    border: 3px solid #64748b;
    border-radius: 15px;
    width: 200px;
    padding: 15px;
    color: white;
    text-align: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.market-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
}

.market-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 10px;
    border: 2px solid #1e293b;
}

.market-card h4 {
    font-family: var(--font-title);
    margin-bottom: 5px;
    color: var(--accent-color);
}

.market-desc {
    font-size: 0.8rem;
    color: #cbd5e1;
    margin-top: 10px;
}

.market-card.bought {
    border-color: var(--primary-color);
    background: rgba(46, 204, 113, 0.2);
    pointer-events: none;
    opacity: 0.7;
}

.market-card.bought::after {
    content: '✓ COMPRADO';
    display: block;
    color: var(--primary-color);
    font-family: var(--font-title);
    margin-top: 10px;
}

.market-card.error {
    animation: shake 0.5s;
    border-color: #ef4444;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
