/* ============================================================
   KilkBit — Chasis virtual v4
   Referencia: hardware físico KilkBit K1
   Paleta: mauve/dusty-rose, pantalla OLED monocromática b/n
   ============================================================ */

/* ── GLOBALS ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    overflow-x: hidden;
    font-family: 'Nunito', sans-serif;
}

/* ── SUBTITLE ── */
.kb-sub {
    font-size: 11px;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,.2);
    margin-top: 16px;
    text-align: center;
}

/* ── CHASIS ──────────────────────────────────────────────── */
.chassis {
    --ch-main:   #c48aa6;
    --ch-light:  #dba8be;
    --ch-dark:   #8a5070;
    --ch-deep:   #5c2e48;
    --ch-stroke: #3a1428;

    /* Base size — works for any viewport. Responsive breakpoints refine it. */
    --chassis-w:  340px;
    --pad-v-top:  44px;
    --pad-v-bot:  52px;
    --pad-h:      24px;
    --chassis-gap: 22px;

    position: relative;
    width: min(var(--chassis-w), 94vw);
    padding: var(--pad-v-top) var(--pad-h) var(--pad-v-bot);

    background:
        radial-gradient(ellipse 110% 60% at 50% 0%,
            #daa8c0 0%, var(--ch-main) 40%, var(--ch-dark) 85%, var(--ch-deep) 100%);

    border: 1.5px solid var(--ch-stroke);
    border-radius: 50px 50px 108px 108px / 44px 44px 94px 94px;

    box-shadow:
        0 40px 80px -20px rgba(0,0,0,.75),
        0 14px 30px -10px rgba(0,0,0,.55),
        inset 0 2px 0 rgba(255,255,255,.25),
        inset 0 -16px 32px rgba(0,0,0,.35),
        inset 0 0 0 1.5px rgba(255,255,255,.06);

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--chassis-gap);

    isolation: isolate;
}

/* Brillo especular superior */
.chassis::before {
    content: "";
    position: absolute;
    inset: 8px 28px auto 28px;
    height: 24%;
    border-radius: 30px 30px 40% 40% / 26px 26px 40% 40%;
    background: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0) 90%);
    pointer-events: none;
    z-index: 0;
}

/* ── MARCA ── */
.kb-brand {
    position: absolute;
    top: 15px; left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 3px;
    color: rgba(255,255,255,.45);
    text-shadow: 0 1px 0 rgba(0,0,0,.3);
    white-space: nowrap;
    z-index: 2;
}
.kb-brand span { color: rgba(255,255,255,.7); margin-left: 3px; }

/* ── PANTALLA ────────────────────────────────────────────── */
.kb-screen-wrap {
    width: 100%;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow:
        inset 0 0 0 2px #0a0a0a,
        inset 0 4px 12px rgba(0,0,0,.9),
        0 2px 0 rgba(255,255,255,.18);
    position: relative;
    z-index: 1;
}

/* Scanlines cosmético */
.kb-screen-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0,0,0,.05) 3px,
        rgba(0,0,0,.05) 4px
    );
    pointer-events: none;
    z-index: 3;
}

/* Reflejo de cristal cosmético */
.kb-screen-wrap::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 10px;
    background: linear-gradient(155deg,
        rgba(255,255,255,.07) 0%, rgba(255,255,255,0) 45%);
    pointer-events: none;
    z-index: 2;
}

/*
 * OLED — fuente fija 18px, line-height 1.3 → cada fila = 23.4px
 * 8 filas = 187.2px + padding vertical 10px = ~198px total.
 * Se usa px fijo para que el height en em sea predecible.
 */
.kb-oled {
    display: block;
    width: 100%;
    /* 8 filas de texto monospace + padding */
    height: calc(8 * 1.3em + 12px);
    background: #000;
    color: #ffffff;
    font-family: 'VT323', monospace;
    font-size: 22px;
    line-height: 1.3;
    padding: 6px 8px;
    overflow: hidden;
    white-space: pre;
    user-select: none;
    text-shadow: 0 0 3px rgba(255,255,255,.5), 0 0 8px rgba(255,255,255,.12);
}

.kb-oled .row {
    display: block;
    min-height: 1.3em;
}

/* Fila con contenido centrado via flexbox */
.kb-oled .row-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 1.3em;
    white-space: normal;
}

/* Selección OLED: fondo blanco, texto negro */
.kb-oled .inv {
    background: #fff;
    color: #000;
    padding: 0 2px;
    margin: 0 -2px;
}

/* Letra en círculo (respuesta seleccionada) */
.kb-oled .char-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    border-radius: 50%;
    background: #fff;
    color: #000;
    text-shadow: none;
    vertical-align: middle;
}

/* ── Primitivas CSS — independientes de COLS ── */

/* Fila de texto centrado via CSS (no necesita COLS) */
.kb-oled .row-c {
    display: block;
    min-height: 1.3em;
    text-align: center;
    white-space: pre;
}

/* Línea divisora full-width simétrica via CSS */
.kb-oled .row-hr {
    display: block;
    height: 1.3em;
    position: relative;
}
.kb-oled .row-hr::before {
    content: "";
    position: absolute;
    left: 0; right: 0;
    top: 50%;
    height: 1px;
    background: rgba(255,255,255,.62);
    transform: translateY(-50%);
}

/* Barra de opciones A-E centrada con flexbox */
.kb-oled .row-opts {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 1.3em;
    gap: 1.8em;
    white-space: normal;
}
/* Todos los slots de opción tienen el mismo ancho para alineación uniforme */
.kb-oled .row-opts span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3em;
}

/* ── ZONA DE CONTROLES ───────────────────────────────────── */
.kb-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0 4px;
    position: relative;
    z-index: 1;
}

/* ── BOTONES LATERALES (back / ok) ── */
.kb-side-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--ch-stroke);
    cursor: pointer;
    transition: transform 70ms ease, box-shadow 70ms ease, filter 70ms ease;
    user-select: none;
    position: relative;
    flex-shrink: 0;
}

.kb-back {
    color: rgba(60,20,36,.85);
    background:
        radial-gradient(circle at 32% 28%, #e0b4c4 0%, #c8889e 50%, #8a4a66 100%);
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.28),
        inset 0 -3px 6px rgba(0,0,0,.3),
        0 4px 10px rgba(0,0,0,.4);
}

.kb-ok {
    color: #05391a;
    background:
        radial-gradient(circle at 32% 28%, #aaffc8 0%, #34d870 48%, #158a3c 100%);
    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.35),
        inset 0 -3px 6px rgba(0,0,0,.25),
        0 4px 10px rgba(0,0,0,.4),
        0 0 0 2px rgba(52,216,112,.35);
}

.kb-side-btn.pressed,
.kb-side-btn:active {
    transform: translateY(2px) scale(.94);
    filter: brightness(1.1);
    box-shadow: inset 0 3px 8px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.25) !important;
}

/* ── D-PAD CIRCULAR ── */
.kb-dpad {
    --dp-size: 108px;
    position: relative;
    width: var(--dp-size);
    height: var(--dp-size);
    border-radius: 50%;
    background:
        radial-gradient(circle at 38% 32%, #c698ae 0%, #a8607c 55%, #7a3858 100%);
    box-shadow:
        inset 0 3px 0 rgba(255,255,255,.22),
        inset 0 -4px 8px rgba(0,0,0,.5),
        0 6px 14px rgba(0,0,0,.45),
        0 2px 4px rgba(0,0,0,.3);
    flex-shrink: 0;
}

/* Centro del D-pad */
.kb-dpad-center {
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: 32%;
    height: 32%;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 30%, #9a6880, #5c2e48 80%);
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,.15),
        inset 0 -2px 6px rgba(0,0,0,.55);
    pointer-events: none;
    z-index: 2;
}

/* Zonas de click del D-pad */
.kb-dpad-zone {
    position: absolute;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.75);
    font-size: 13px;
    transition: filter 80ms ease;
    user-select: none;
    z-index: 1;
}

.kb-dpad-up    { top: 0;     left: 25%; width: 50%; height: 45%; align-items: flex-start; padding-top: 7px; }
.kb-dpad-down  { bottom: 0;  left: 25%; width: 50%; height: 45%; align-items: flex-end;   padding-bottom: 7px; }
.kb-dpad-left  { left: 0;    top: 25%;  width: 45%; height: 50%; justify-content: flex-start; padding-left: 7px; }
.kb-dpad-right { right: 0;   top: 25%;  width: 45%; height: 50%; justify-content: flex-end;   padding-right: 7px; }

.kb-dpad-zone.pressed,
.kb-dpad-zone:active {
    filter: brightness(1.6);
    color: #fff;
}

/* ── NUMPAD ── */
.kb-numpad {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.kb-numrow {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.kb-num {
    --ring: #67e8f9;
    --btn-size: 60px;
    width: var(--btn-size);
    height: var(--btn-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    font-size: 22px;
    color: var(--ch-deep);
    cursor: pointer;
    user-select: none;
    position: relative;
    border: 1.5px solid rgba(0,0,0,.25);

    background:
        radial-gradient(circle at 30% 28%, #f0e8ec 0%, #dbbec8 40%, #b888a0 100%);

    box-shadow:
        inset 0 2px 0 rgba(255,255,255,.7),
        inset 0 -3px 6px rgba(0,0,0,.2),
        0 4px 10px rgba(0,0,0,.4),
        0 0 0 3px var(--ring),
        0 0 10px 2px var(--ring),
        0 0 20px 4px color-mix(in srgb, var(--ring) 40%, transparent);

    transition: transform 70ms ease, box-shadow 80ms ease;
}

.kb-num.pressed,
.kb-num:active {
    transform: translateY(2px) scale(.94);
    box-shadow:
        inset 0 3px 8px rgba(0,0,0,.3),
        0 1px 2px rgba(0,0,0,.25),
        0 0 0 3px var(--ring),
        0 0 16px 4px var(--ring),
        0 0 32px 8px color-mix(in srgb, var(--ring) 55%, transparent) !important;
}

/* ── FOOTER DETAILS ── */
.kb-footer-details {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
    opacity: .45;
}

.kb-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--ch-stroke);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
}
.kb-dot--mid {
    width: 24px;
    border-radius: 3px;
    height: 3px;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */

/* Pantallas medianas (tabletas pequeñas, monitores normales) */
@media (min-width: 600px) {
    .chassis {
        --chassis-w:   400px;
        --pad-v-top:   48px;
        --pad-v-bot:   60px;
        --pad-h:       28px;
        --chassis-gap: 26px;
    }
    .kb-oled      { font-size: 24px; height: calc(8 * 1.3em + 14px); padding: 7px 10px; }
    .kb-dpad      { --dp-size: 126px; }
    .kb-side-btn  { width: 60px; height: 60px; }
    .kb-num       { --btn-size: 64px; font-size: 24px; }
}

/* Pantallas grandes (1080p, monitores anchos) */
@media (min-width: 900px) {
    .chassis {
        --chassis-w:   440px;
        --pad-v-top:   52px;
        --pad-v-bot:   66px;
        --pad-h:       32px;
        --chassis-gap: 28px;
    }
    .kb-oled      { font-size: 26px; height: calc(8 * 1.3em + 16px); padding: 8px 12px; }
    .kb-dpad      { --dp-size: 140px; }
    .kb-side-btn  { width: 64px; height: 64px; }
    .kb-side-btn svg { width: 28px; height: 28px; }
    .kb-num       { --btn-size: 70px; font-size: 26px; }
}

/* Pantallas muy grandes (1440p, 4K) */
@media (min-width: 1400px) {
    .chassis {
        --chassis-w:   480px;
        --pad-v-top:   56px;
        --pad-v-bot:   72px;
        --pad-h:       36px;
        --chassis-gap: 30px;
    }
    .kb-oled      { font-size: 28px; height: calc(8 * 1.3em + 18px); padding: 9px 14px; }
    .kb-dpad      { --dp-size: 154px; }
    .kb-side-btn  { width: 68px; height: 68px; }
    .kb-side-btn svg { width: 30px; height: 30px; }
    .kb-num       { --btn-size: 76px; font-size: 28px; }
    .kb-brand     { font-size: 11px; top: 17px; }
}

/* Pantallas pequeñas (móvil) */
@media (max-width: 380px) {
    .chassis {
        --chassis-w:   310px;
        --pad-v-top:   38px;
        --pad-v-bot:   44px;
        --pad-h:       18px;
        --chassis-gap: 18px;
    }
    .kb-oled      { font-size: 16px; height: calc(8 * 1.3em + 10px); padding: 5px 7px; }
    .kb-dpad      { --dp-size: 96px; }
    .kb-side-btn  { width: 44px; height: 44px; }
    .kb-num       { --btn-size: 46px; font-size: 18px; }
}
