/* ========================================================
   DinoCraft 3D - Estilos Visuales Modernos y Amigables para Niños
   ======================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=VT323&display=swap');

:root {
    --primary: #4ade80;
    --primary-dark: #22c55e;
    --accent-orange: #fb923c;
    --accent-yellow: #facc15;
    --accent-blue: #38bdf8;
    --accent-purple: #c084fc;
    --bg-overlay: rgba(15, 23, 42, 0.75);
    --border-color: rgba(255, 255, 255, 0.25);
    --font-main: 'Fredoka', cursive, sans-serif;
    --font-pixel: 'VT323', monospace;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #5bb3ff;
    font-family: var(--font-main);
}

#game-canvas {
    width: 100vw;
    height: 100vh;
    display: block;
    cursor: crosshair;
}

/* ==========================================
   Mira Central Auténtica de Minecraft
   ========================================== */
#crosshair {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 100;
}

#crosshair::before,
#crosshair::after {
    content: '';
    position: absolute;
    background-color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.9);
}

#crosshair::before {
    top: 9px;
    left: 0;
    width: 20px;
    height: 2px;
}

#crosshair::after {
    top: 0;
    left: 9px;
    width: 2px;
    height: 20px;
}

/* ==========================================
   Barra Superior de Herramientas (Top Bar)
   ========================================== */
#top-bar {
    position: fixed;
    top: 14px;
    left: 14px;
    right: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 20;
}

.brand-badge {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border: 3px solid #4ade80;
    border-radius: 20px;
    padding: 8px 18px;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.brand-title {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #4ade80;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.top-buttons {
    display: flex;
    gap: 8px;
    pointer-events: auto;
}

.icon-btn {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn:hover {
    transform: translateY(-2px);
    border-color: #4ade80;
    background: rgba(30, 41, 59, 0.95);
}

.icon-btn:active {
    transform: translateY(1px);
}

.btn-spawn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-color: #fde68a;
    color: #ffffff;
}

/* ==========================================
   Notificación de Proximidad a Dinosaurio
   ========================================== */
#dino-prompt {
    position: fixed;
    top: 76px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border: 3px solid #fbbf24;
    border-radius: 30px;
    padding: 10px 24px;
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 25;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#dino-prompt.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================
   Barra de Modo de Acción (Laptop & Niños)
   ========================================== */
#action-mode-bar {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 20;
    pointer-events: auto;
}

.mode-pill {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 8px 16px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-pill:hover {
    transform: translateY(-2px);
    border-color: #4ade80;
    background: rgba(30, 41, 59, 0.95);
}

.mode-pill#btn-mode-mine.active {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border-color: #fca5a5;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
    transform: translateY(-2px) scale(1.05);
}

.mode-pill#btn-mode-build.active {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border-color: #93c5fd;
    box-shadow: 0 0 16px rgba(59, 130, 246, 0.6);
    transform: translateY(-2px) scale(1.05);
}

.mode-pill:active {
    transform: scale(0.96);
}

body.mode-free #game-canvas {
    cursor: crosshair;
}

/* ==========================================
   Barra Inferior de Bloques (Hotbar)
   ========================================== */
#hotbar-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 20;
}

#block-name {
    background: rgba(15, 23, 42, 0.85);
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#hotbar {
    display: flex;
    gap: 6px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(10px);
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-radius: 16px;
    padding: 6px 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}

.slot {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.15s ease;
}

.slot:hover {
    background: rgba(255, 255, 255, 0.18);
    transform: translateY(-3px);
}

.slot.active {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.25);
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.7);
    transform: translateY(-6px) scale(1.08);
}

.slot img {
    width: 34px;
    height: 34px;
    image-rendering: pixelated;
    pointer-events: none;
}

.slot-num {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #e2e8f0;
    text-shadow: 0 1px 2px #000;
}

/* ==========================================
   Controles Táctiles para Móviles / Tablets
   ========================================== */
#touch-controls {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 15;
}

/* Joystick virtual */
#joystick-zone {
    position: absolute;
    bottom: 90px;
    left: 20px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.12);
    border: 2px dashed rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

#joystick-knob {
    width: 56px;
    height: 56px;
    background: #4ade80;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
    position: absolute;
    transition: transform 0.05s linear;
}

/* Botones de acción táctil */
#action-buttons {
    position: absolute;
    bottom: 90px;
    right: 20px;
    display: grid;
    grid-template-columns: repeat(2, 68px);
    gap: 12px;
    pointer-events: auto;
}

.touch-action-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    border: 3px solid #ffffff;
    color: #ffffff;
    font-size: 1.6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    font-family: var(--font-main);
    font-weight: 700;
    transition: transform 0.1s ease;
}

.touch-action-btn:active {
    transform: scale(0.9);
}

.touch-action-btn span {
    font-size: 0.65rem;
    margin-top: -2px;
    text-transform: uppercase;
}

.btn-jump { background: #22c55e; }
.btn-break { background: #ef4444; }
.btn-place { background: #3b82f6; }
.btn-ride { background: #f59e0b; }

/* ==========================================
   Modal de Invocar Dinosaurios (Spawner)
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 29, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #1e293b;
    border: 4px solid #4ade80;
    border-radius: 28px;
    padding: 28px;
    width: 90%;
    max-width: 650px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    color: #ffffff;
    position: relative;
}

.modal-title {
    font-size: 2rem;
    color: #4ade80;
    margin-bottom: 8px;
}

.modal-subtitle {
    color: #cbd5e1;
    font-size: 1.1rem;
    margin-bottom: 24px;
}

.dino-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.dino-card {
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 16px 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dino-card:hover {
    background: rgba(74, 222, 128, 0.2);
    border-color: #4ade80;
    transform: translateY(-4px);
}

.dino-emoji {
    font-size: 3rem;
}

.dino-name {
    font-weight: 700;
    font-size: 1rem;
    color: #f1f5f9;
}

.dino-desc {
    font-size: 0.75rem;
    color: #94a3b8;
}

.btn-close-modal {
    background: #ef4444;
    border: none;
    color: #ffffff;
    font-family: var(--font-main);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 10px 28px;
    border-radius: 14px;
    cursor: pointer;
}

/* ==========================================
   Pantalla de Inicio / Bienvenida (Start Screen)
   ========================================== */
#start-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: #ffffff;
    text-align: center;
    padding: 20px;
}

.start-title {
    font-size: 3.5rem;
    font-weight: 800;
    color: #4ade80;
    text-shadow: 0 4px 16px rgba(74, 222, 128, 0.5);
    margin-bottom: 6px;
}

.start-subtitle {
    font-size: 1.3rem;
    color: #e2e8f0;
    margin-bottom: 30px;
    max-width: 600px;
}

.instructions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    max-width: 780px;
    margin-bottom: 34px;
}

.instruction-item {
    background: rgba(255, 255, 255, 0.08);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 16px 12px;
    text-align: center;
}

.instruction-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.instruction-text {
    font-size: 0.95rem;
    color: #cbd5e1;
}

.btn-play {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 1.8rem;
    font-weight: 800;
    padding: 16px 48px;
    border: 4px solid #bbf7d0;
    border-radius: 28px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(34, 197, 94, 0.6);
    transition: all 0.2s ease;
    animation: pulse 2s infinite;
}

.btn-play:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 36px rgba(34, 197, 94, 0.8);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

/* ==========================================
   Overlay de Daño Rojo y Muerte en Lava
   ========================================== */
#damage-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(239, 68, 68, 0.45);
    pointer-events: none;
    z-index: 95;
    opacity: 0;
    transition: opacity 0.1s ease-out;
}

#damage-flash.active {
    opacity: 1;
}

#death-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, rgba(185, 28, 28, 0.85), rgba(127, 29, 29, 0.95));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 120;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out;
}

#death-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.death-box {
    background: rgba(15, 23, 42, 0.85);
    border: 3px solid #ef4444;
    border-radius: 20px;
    padding: 30px 40px;
    text-align: center;
    color: #ffffff;
    box-shadow: 0 10px 40px rgba(239, 68, 68, 0.6);
    animation: deathPop 0.3s ease-out;
}

.death-box h1 {
    font-size: 2.2rem;
    color: #f87171;
    margin-bottom: 10px;
}

.death-box p {
    font-size: 1.15rem;
    color: #fecaca;
}

@keyframes deathPop {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ==========================================
   Responsive Adaptations
   ========================================== */
@media (max-width: 768px) {
    #touch-controls {
        display: block;
    }
    .brand-title {
        font-size: 1rem;
    }
    .start-title {
        font-size: 2.4rem;
    }
    .start-subtitle {
        font-size: 1rem;
    }
    .slot {
        width: 42px;
        height: 42px;
    }
    .slot img {
        width: 26px;
        height: 26px;
    }
}
