/* RESET & VARIABLES */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --pk-red: #e3350d;
    --pk-blue: #3165b1;
    --pk-yellow: #ffcb05;
    --border-dark: #212121;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: #121212;
    color: white;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }
.full-screen {
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, #1a1a1a, #1a1a1a 10px, #222 10px, #222 20px);
}

.nes-container {
    background: white;
    color: black;
    border: 4px solid var(--border-dark);
    padding: 20px;
    box-shadow: 6px 6px 0 rgba(0, 0, 0, 0.5);
    text-align: center;
    border-radius: 4px;
}

.prof-intro-avatar {
    width: 120px;
    height: 120px;
    margin: 10px auto;
    background: url('https://play.pokemonshowdown.com/sprites/trainers/cheren-gen5bw2.png') no-repeat center;
    background-size: 150%;
    image-rendering: pixelated;
    border: 4px solid var(--border-dark);
    border-radius: 8px;
    background-color: #e0e0e0;
}

.intro-box { width: min(550px, calc(100vw - 40px)); }
.intro-box h1 { font-size: 16px; color: var(--pk-red); margin-bottom: 5px; }

.dialogue-box-intro {
    background: #f8f8f8;
    border: 3px solid #ccc;
    padding: 15px;
    text-align: left;
    line-height: 1.6;
    margin-bottom: 20px;
    min-height: 80px;
    font-family: 'VT323', monospace;
    font-size: 24px;
    border-radius: 4px;
}

input[type="text"] {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    padding: 10px;
    border: 3px solid var(--border-dark);
    width: 80%;
    text-align: center;
    margin-bottom: 15px;
    border-radius: 4px;
}

.nes-btn {
    font-family: 'Press Start 2P', cursive;
    background: white;
    border: 4px solid var(--border-dark);
    padding: 12px 15px;
    font-size: 10px;
    cursor: pointer;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.1s;
    border-radius: 4px;
}

.nes-btn:active { transform: scale(0.95); }
.nes-btn.primary { background: var(--pk-red); color: white; }
.nes-btn.primary:hover { background: #d32f2f; }

.selection-box { width: min(650px, calc(100vw - 40px)); }
.selection-box h2 { font-size: 14px; margin-bottom: 10px; color: var(--pk-blue); }
.pk-container { display: flex; gap: 15px; justify-content: center; margin-top: 15px; flex-wrap: wrap; }
.pk-card {
    border: 3px solid #ccc;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    background: #f9f9f9;
    width: 120px;
    transition: 0.2s;
}

.pk-card img { width: 80px; image-rendering: pixelated; transition: 0.3s; }
.pk-card p { font-size: 9px; margin-top: 10px; font-weight: bold; }
.pk-card:hover { border-color: var(--pk-red); background: #ffebee; transform: translateY(-5px); }

/* LAYOUT PRINCIPAL IDE */
#screen-main { flex-direction: column; }
.main-layout {
    display: flex;
    height: calc(100vh - 60px);
    background: #1e1e1e;
    flex-direction: row;
}

header {
    background: var(--border-dark);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid var(--pk-red);
    height: 60px;
    font-size: 10px;
    gap: 12px;
}

.header-info span { margin-right: 20px; }
.highlight { color: var(--pk-yellow); }

.header-level-select { display: flex; align-items: center; gap: 15px; }
select#level-selector {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    padding: 8px;
    background: #333;
    color: white;
    border: 2px solid #555;
    cursor: pointer;
    border-radius: 4px;
}

.btn-evaluator {
    font-family: 'Press Start 2P', cursive;
    background: #27c93f;
    color: white;
    border: 3px solid #156b20;
    padding: 10px 15px;
    font-size: 10px;
    cursor: pointer;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.2);
    transition: transform 0.1s, background 0.2s;
    animation: pulse 2s infinite;
    border-radius: 4px;
    margin-left: 10px;
}

.btn-evaluator:hover { background: #2ee649; }
.btn-evaluator:active { transform: scale(0.96); }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }

/* BLOQUEO DEL EDITOR */
#blockly-container {
    width: 55%;
    min-width: 520px;
    flex: none;
    border-right: 4px solid #000;
    position: relative;
    overflow: hidden;
    background: #d8d8d8;
}

#blocklyDiv { position: absolute; inset: 0; }
#right-panel {
    width: 45%;
    min-width: 360px;
    flex: none;
    display: flex;
    flex-direction: column;
    background: #eceff1;
}

.blocklySvg { background: linear-gradient(180deg, #d7d7d7 0%, #cecece 100%); }
.blocklyToolboxDiv {
    background-color: #f5f5f5 !important;
    border-right: 2px solid #ccc;
    box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.08);
}

.blocklyTreeRow {
    height: 42px !important;
    line-height: 42px !important;
    margin-bottom: 4px;
}

.blocklyTreeLabel {
    font-family: 'Press Start 2P', cursive !important;
    font-size: 10px !important;
}

.blocklyFlyout,
.blocklyFlyoutBackground {
    filter: drop-shadow(4px 0 6px rgba(0, 0, 0, 0.12));
}

/* ESCENARIO POKEMON */
#escenario {
    height: 220px;
    background: linear-gradient(to bottom, #4facfe 0%, #00f2fe 70%);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    border-bottom: 4px solid #000;
    isolation: isolate;
}

#escenario::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255,255,255,0.16), transparent 30%);
    pointer-events: none;
    z-index: 0;
}

.scenario-bg {
    position: absolute;
    width: 100%;
    height: 38%;
    bottom: 0;
    left: 0;
    background: linear-gradient(180deg, #86d654 0%, #63b73a 100%);
    border-top: 4px solid #5a9c32;
    z-index: 1;
}

.scenario-bg::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 8px;
    background: rgba(0, 0, 0, 0.18);
}

#pk-shadow {
    position: absolute;
    left: 50%;
    bottom: 82px;
    width: 78px;
    height: 18px;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.25);
    border-radius: 50%;
    filter: blur(2px);
    z-index: 2;
    animation: shadow-breathe 2s infinite ease-in-out;
}

#pk-sprite {
    position: absolute;
    left: 50%;
    bottom: 92px;
    width: 108px;
    image-rendering: pixelated;
    transform: translateX(-50%);
    transform-origin: center bottom;
    z-index: 3;
    animation: breathe 2s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-6px); }
}

@keyframes shadow-breathe {
    0%, 100% { transform: translateX(-50%) scaleX(1); opacity: 0.24; }
    50% { transform: translateX(-50%) scaleX(0.92); opacity: 0.18; }
}

#dialogo-box {
    position: absolute;
    bottom: 6px;
    left: 6px;
    right: 6px;
    background: #fff;
    border: 4px solid #2a2a2a;
    border-radius: 8px;
    padding: 8px;
    z-index: 10;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: inset 0 0 0 2px #e0e0e0, 2px 2px 0 rgba(0, 0, 0, 0.3);
}

.dialogue-avatar-mini {
    width: 65px;
    height: 65px;
    flex-shrink: 0;
    background: url('https://play.pokemonshowdown.com/sprites/trainers/cheren-gen5bw2.png') no-repeat center top;
    background-size: 160%;
    image-rendering: pixelated;
    border: 3px solid var(--border-dark);
    background-color: #ddd;
    border-radius: 4px;
}

.dialogue-content { flex: 1; display: flex; flex-direction: column; justify-content: flex-start; height: 100%; }
.dialogue-header {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: var(--pk-red);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.dialogue-text {
    font-family: 'VT323', monospace;
    font-size: 20px;
    line-height: 1.1;
    color: #111;
}

.cursor { animation: blink 1s infinite; margin-left: 5px; color: var(--pk-red); }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0.2; } }

/* NAVEGADOR */
#browser-window {
    flex: 1;
    margin: 10px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 2px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    min-height: 0;
}

.browser-header {
    background: #e0e0e0;
    padding: 8px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #ccc;
    gap: 12px;
}

.dots { display: flex; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }

.browser-url {
    background: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: Arial, sans-serif;
    font-size: 12px;
    color: #666;
    flex: 1;
    text-align: left;
    border: 1px solid #ccc;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#web-preview {
    flex: 1;
    width: 100%;
    height: 100%;
    background: #ffffff;
    border: none;
}

@media (max-width: 1120px) {
    header {
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
    }

    .main-layout {
        flex-direction: column;
        height: calc(100vh - 96px);
    }

    #blockly-container,
    #right-panel {
        width: 100%;
        min-width: 0;
    }

    #blockly-container {
        min-height: 48vh;
        border-right: none;
        border-bottom: 4px solid #000;
    }

    #right-panel {
        min-height: 0;
    }
}
