:root {
    /* Paleta Oficial Scratch 3.0 */
    --scratch-motion: #4C97FF;
    --scratch-motion-dark: #3373CC;
    --scratch-looks: #9966FF;
    --scratch-looks-dark: #774DCB;
    --scratch-sound: #CF63CF;
    --scratch-sound-dark: #BD42BD;
    --scratch-events: #FFBF00;
    --scratch-events-dark: #CC9900;
    --scratch-control: #FFAB19;
    --scratch-control-dark: #CF8B17;
    --scratch-sensing: #5CB1D6;
    --scratch-sensing-dark: #2E8EB8;
    --scratch-operators: #59C059;
    --scratch-operators-dark: #389438;
    --scratch-variables: #FF8C1A;
    --scratch-variables-dark: #DB6E00;
    --scratch-custom: #FF6680;
    --scratch-custom-dark: #FF3355;

    --bg-color: #f0f4f8;
    --text-color: #333;
    --card-bg: #ffffff;
    --locked-gray: #e0e0e0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    background: linear-gradient(135deg, var(--scratch-motion), #2d5eb8);
    color: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

h1 {
    margin: 0;
    font-size: 2.2em;
}

h2 {
    color: var(--scratch-motion);
    border-bottom: 2px solid var(--scratch-motion);
    padding-bottom: 10px;
    margin-top: 0;
}

h3 {
    color: #444;
    margin-top: 0;
}

.concept-card {
    background: var(--card-bg);
    border-left: 5px solid var(--scratch-looks);
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.level-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.level {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-top: 5px solid var(--scratch-variables);
    transition: all 0.3s ease;
    opacity: 1;
}

.level.locked {
    filter: grayscale(1);
    opacity: 0.5;
    pointer-events: none;
    display: none;
}

.level.completed {
    border-top-color: var(--scratch-operators);
    background-color: #f9fff9;
}

.level-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Checkbox Styles */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    color: var(--scratch-motion);
    background: #eef5ff;
    padding: 8px 15px;
    border-radius: 20px;
    transition: background 0.2s;
}

.checkbox-wrapper:hover {
    background: #dceaff;
}

.checkbox-wrapper.teacher-checked {
    background-color: #e8f5e9;
    /* Verde claro */
    color: #2e7d32;
    cursor: default;
    border: 1px solid #c8e6c9;
}

.checkbox-wrapper.teacher-only {
    color: #d32f2f;
    background: #ffebee;
    border: 1px solid #ffcdd2;
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: var(--scratch-operators);
    cursor: pointer;
}

/* --- BLOQUES SCRATCH 3.0 --- */
.sb3-block {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    margin: 2px 0;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-weight: bold;
    font-size: 0.85rem;
    color: white;
    cursor: default;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
    vertical-align: middle;
}

/* Tipos de Bloques */
.sb3-stack {
    border-radius: 4px;
    /* Muesca simulada simple con pseudoelemento si se desea, 
       pero por simplicidad y robustez CSS puro, usaremos borde. */
}

.sb3-hat {
    border-radius: 15px 15px 4px 4px;
    margin-top: 10px;
    /* Espacio para la "gorra" */
    padding-top: 8px;
}

.sb3-c-block {
    display: flex;
    flex-direction: column;
    background: transparent !important;
    /* El color lo llevan las partes */
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    align-items: flex-start;
}

.sb3-c-head {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px 4px 0 0;
    /* Forma de C parte sup */
    width: 100%;
    box-sizing: border-box;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-bottom: none;
    position: relative;
}

/* Interior de la C */
.sb3-c-mouth {
    border-left: 12px solid;
    /* Color dinámico */
    min-height: 15px;
    padding-left: 8px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    /* Borde interior oscuro simulado */
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.sb3-c-foot {
    height: 12px;
    border-radius: 0 0 4px 4px;
    width: 100%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-top: none;
    /* Muesca inferior simulada */
}

.sb3-reporter {
    border-radius: 20px;
    padding: 4px 10px;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.sb3-boolean {
    padding: 4px 15px;
    clip-path: polygon(10px 0,
            /* Top Left start */
            calc(100% - 10px) 0,
            /* Top Right end */
            100% 50%,
            /* Right Point (Outwards) */
            calc(100% - 10px) 100%,
            /* Bottom Right start */
            10px 100%,
            /* Bottom Left end */
            0 50%
            /* Left Point (Outwards) */
        );
    margin: 0 5px;
}

/* Inputs */
.sb3-input {
    background-color: white;
    color: black;
    border-radius: 10px;
    padding: 0 6px;
    margin: 0 4px;
    font-weight: normal;
    display: inline-block;
    min-width: 15px;
    text-align: center;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.sb3-input-text {
    border-radius: 4px;
    min-width: 25px;
}

/* Colores por Categoría */
/* Motion */
.motion {
    background-color: var(--scratch-motion);
    border-color: var(--scratch-motion-dark);
}

.sb3-c-mouth.motion {
    border-left-color: var(--scratch-motion);
}

/* Lado C interior */

/* Events */
.events {
    background-color: var(--scratch-events);
    border-color: var(--scratch-events-dark);
}

/* Control */
.control {
    background-color: var(--scratch-control);
    border-color: var(--scratch-control-dark);
}

.sb3-c-mouth.control {
    border-left-color: var(--scratch-control);
}

/* Looks */
.looks {
    background-color: var(--scratch-looks);
    border-color: var(--scratch-looks-dark);
}

/* Sensing */
.sensing {
    background-color: var(--scratch-sensing);
    border-color: var(--scratch-sensing-dark);
}

/* Operators */
.operators {
    background-color: var(--scratch-operators);
    border-color: var(--scratch-operators-dark);
}

/* Variables */
.variables {
    background-color: var(--scratch-variables);
    border-color: var(--scratch-variables-dark);
}

/* Sound */
.sound {
    background-color: var(--scratch-sound);
    border-color: var(--scratch-sound-dark);
}



.btn {
    background-color: var(--scratch-motion);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 4px 0 #3a7bd5;
}

.btn.secondary {
    background-color: #666;
    box-shadow: 0 4px 0 #444;
}

.controls {
    margin-top: 20px;
}

.viz-controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.viz-btn {
    padding: 8px 16px;
    border: none;
    background: #ddd;
    border-radius: 20px;
    cursor: pointer;
}

.viz-btn.active {
    background: var(--scratch-motion);
    color: white;
}

/* --- MERGED: styles_viz.css --- */
.sim-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.sim-tab {
    background: #e0e0e0;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    color: #666;
    transition: all 0.3s;
}

.sim-tab.active {
    background: var(--scratch-motion, #4C97FF);
    color: white;
    box-shadow: 0 4px 10px rgba(76, 151, 255, 0.3);
}

.sim-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #eee;
}

/* GRID 10x10 */
.number-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 450px;
    margin: 0 auto;
}

.grid-cell {
    aspect-ratio: 1;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #333;
    cursor: default;
    transition: all 0.2s ease;
}

/* Estados de celda */
.grid-cell.discarded {
    background-color: #eee;
    color: #ccc;
    transform: scale(0.9);
    border-color: transparent;
}

.grid-cell.active-range {
    background-color: #fff;
    border-color: var(--scratch-motion-dark, #3373CC);
    font-weight: bold;
}

.grid-cell.guess {
    background-color: var(--scratch-events, #FFBF00) !important;
    color: white;
    transform: scale(1.15);
    z-index: 10;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.grid-cell.winner {
    background-color: var(--scratch-operators, #59C059) !important;
    color: white;
    animation: bounce 0.5s infinite alternate;
}

@keyframes bounce {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.1);
    }
}

/* Controles */
.sim-controls {
    text-align: center;
    width: 100%;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.control-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.big-input {
    font-size: 1.2rem;
    padding: 10px;
    width: 80px;
    text-align: center;
    border: 2px solid var(--scratch-motion);
    border-radius: 8px;
}

.msg-box {
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--scratch-looks-dark, #774DCB);
    padding: 10px;
    background: #f0ebff;
    border-radius: 8px;
    width: 100%;
    text-align: center;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.explanation-text {
    text-align: left;
    background: #e8f5e9;
    padding: 15px;
    border-radius: 8px;
    border-left: 5px solid var(--scratch-operators);
    font-size: 0.95rem;
}

/* --- MERGED: styles_hints.css --- */
.hint-container {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint-btn {
    background: #eef5ff;
    border: 1px solid var(--scratch-motion);
    color: var(--scratch-motion-dark);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    width: fit-content;
    transition: all 0.2s;
}

.hint-btn:hover {
    background: #e3f2fd;
    transform: translateX(5px);
}

.hint-btn::before {
    content: "💡";
    margin-right: 8px;
}

.hint-btn.hint-2 {
    border-color: var(--scratch-events);
    color: #bfa004;
    /* Darker yellow */
}

.hint-box {
    display: none;
    background-color: #fffde7;
    border-left: 4px solid var(--scratch-events);
    border-radius: 4px;
    padding: 15px;
    margin-top: 15px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.instructions {
    background: #fdfdfe;
    border-left: 4px solid #ddd;
    padding: 15px;
    color: #555;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.instructions strong {
    color: #333;
}