:root {
    --bg-void: #0b0b12;
    --bg-panel: #14141f;
    --line: #2a2a3a;
    --ink: #f2f0ea;
    --ink-dim: #8a8aa0;
    --magenta: #ff2e88;
    --cyan: #00e5ff;
    --lime: #c8ff3d;
    --amber: #ffb627;
    --violet: #8a5cff;
    --font-display: 'Bungee', system-ui, sans-serif;
    --font-mono: 'Space Mono', monospace;
    --font-mk-title: 'Press Start 2P', var(--font-display);

    /* ---- mk-frame: tocar estas dos variables para cambiar el tamaño del cuadro
     de selección de personaje del HOST. width/height aceptan cualquier unidad
     (px, %, vw/vh, min()...). height por defecto es "auto" (se ajusta solo al
     contenido); poné un valor fijo (ej. 600px) si querés forzar una altura. ---- */
    --mk-frame-width: min(900px, 92vw);
    --mk-frame-height: 800px;
    --mk-frame-max-height: 82vh;
    --mk-preview-width: 150px;
}

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

html,
body {
    height: 100%;
    background: var(--bg-void);
    color: var(--ink);
    font-family: var(--font-mono);
}

body {
    background-image:
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0px, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 3px);
}

.screen {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    animation: fadein .25s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: scale(.98)
    }

    to {
        opacity: 1;
        transform: scale(1)
    }
}

h1,
h2,
h3 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 14px;
    letter-spacing: 4px;
    color: var(--ink-dim);
    text-transform: uppercase;
}

/* ---------- MENU ---------- */
#screen-menu h1 {
    font-size: clamp(38px, 9vw, 72px);
    color: var(--ink);
    text-shadow: 3px 3px 0 var(--magenta), 6px 6px 0 rgba(0, 229, 255, .35);
    margin-bottom: 6px;
}

#screen-menu .tagline {
    color: var(--ink-dim);
    font-size: 13px;
    margin-bottom: 48px;
}

.role-picker {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    justify-content: center;
}

.role-card {
    width: 180px;
    background: var(--bg-panel);
    border: 2px solid var(--line);
    border-radius: 4px;
    padding: 20px 16px 16px;
    text-align: center;
    cursor: pointer;
    clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
    transition: border-color .15s, transform .15s;
}

.role-card:hover {
    transform: translateY(-4px);
}

.role-card.pc:hover {
    border-color: var(--cyan);
}

.role-card.phone:hover {
    border-color: var(--magenta);
}

.role-card .icon-slot {
    width: 100%;
    height: 120px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1c1c2a;
    border-radius: 3px;
    overflow: hidden;
}

.role-card .icon-slot img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.role-card .icon-fallback {
    font-size: 52px;
}

.role-card .label {
    font-family: var(--font-display);
    font-size: 18px;
}

.role-card .sub {
    font-size: 10px;
    color: var(--ink-dim);
    margin-top: 4px;
}

/* ---------- HOST LOBBY (estilo MK "Choose your fighter") ---------- */
#screen-host-lobby {
    text-align: center;
    padding-top: 16px;
    padding-bottom: 16px;
}

.room-code {
    font-family: var(--font-display);
    font-size: clamp(28px, 5vw, 48px);
    letter-spacing: 10px;
    color: var(--lime);
    text-shadow: 0 0 24px rgba(200, 255, 61, .35);
    margin: 0px 20px 10px 20px;
}

.host-footer {
    margin-top: 14px;
    font-size: 11px;
    color: var(--ink-dim);
}

/* ---------- PHONE: JOIN ---------- */
#screen-join {
    gap: 16px;
    width: 100%;
    max-width: 360px;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

.code-input-wrap {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.code-input-wrap input {
    width: clamp(40px, 15vw, 56px);
    height: clamp(50px, 18vw, 66px);
    text-align: center;
    font-family: var(--font-display);
    font-size: clamp(20px, 7vw, 28px);
    background: var(--bg-panel);
    border: 2px solid var(--line);
    color: var(--ink);
    border-radius: 4px;
    text-transform: uppercase;
}

.code-input-wrap input:focus {
    outline: none;
    border-color: var(--cyan);
}

.btn {
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-size: 13px;
    background: var(--magenta);
    color: #0b0b12;
    border: none;
    padding: 14px 28px;
    border-radius: 3px;
    cursor: pointer;
}

.btn:disabled {
    background: #3a3a48;
    color: var(--ink-dim);
    cursor: not-allowed;
}

.btn.ghost {
    background: transparent;
    border: 2px solid var(--line);
    color: var(--ink);
}

.status-line {
    font-size: 11px;
    color: var(--ink-dim);
    min-height: 16px;
}

/* ---------- PHONE: PROFILE + CHARACTER SELECT (simple, 100% responsive) ---------- */
#screen-profile {
    width: 100%;
    max-width: 520px;
    padding: 16px;
    gap: 16px;
    margin-left: auto;
    margin-right: auto;
}

#screen-profile input[type=text] {
    width: 100%;
    background: var(--bg-panel);
    border: 2px solid var(--line);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 16px;
    padding: 12px 14px;
    border-radius: 4px;
}

#screen-profile input[type=text]:focus {
    outline: none;
    border-color: var(--magenta);
}

/* ---------- MK FRAME (usado solo en el HOST) ---------- */

.mk-frame {
    width: var(--mk-frame-width);
    height: var(--mk-frame-height);
    max-height: var(--mk-frame-max-height);
    margin: 0 auto;
    position: relative;
    padding: 14px 14px 16px;
    border-radius: 20px;
    overflow-y: auto;
    background:
        radial-gradient(circle at 15% 20%, rgba(255, 255, 255, .05), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(0, 0, 0, .35), transparent 45%),
        repeating-linear-gradient(115deg, #3a3a3e 0px, #333336 3px, #3d3d40 6px),
        #35353a;
    border: 3px solid #17171a;
    box-shadow: inset 0 0 0 2px #55555c, inset 0 0 30px rgba(0, 0, 0, .6), inset 0 0 60px rgba(0, 255, 140, .04), 0 10px 30px rgba(0, 0, 0, .6);
    /* ---- efecto CRT: leve inclinación 3D, como si mirases el tubo desde abajo ---- */
    transform: perspective(1000px) rotateX(2.5deg);
    transform-origin: center bottom;
}

/* ---- efecto CRT: curvatura óptica (esquinas oscurecidas + brillo de vidrio) + resplandor de fósforo + flicker ---- */
.mk-frame::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 6;
    pointer-events: none;
    border-radius: inherit;
    background:
        linear-gradient(105deg, rgba(255, 255, 255, .09) 0%, rgba(255, 255, 255, 0) 24%),
        radial-gradient(140px 100px at 0% 0%, rgba(0, 0, 0, .55), transparent 70%),
        radial-gradient(140px 100px at 100% 0%, rgba(0, 0, 0, .55), transparent 70%),
        radial-gradient(140px 100px at 0% 100%, rgba(0, 0, 0, .55), transparent 70%),
        radial-gradient(140px 100px at 100% 100%, rgba(0, 0, 0, .55), transparent 70%),
        radial-gradient(ellipse at center, rgba(180, 255, 210, .05) 0%, rgba(0, 0, 0, 0) 45%, rgba(0, 0, 0, .5) 100%);
    animation: crt-flicker 5s infinite;
}

@keyframes crt-flicker {

    0%,
    19%,
    22%,
    100% {
        opacity: 1;
    }

    20% {
        opacity: .82;
    }

    21% {
        opacity: .94;
    }

    46% {
        opacity: .9;
    }

    47% {
        opacity: 1;
    }

    74% {
        opacity: .88;
    }

    75% {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mk-frame::after {
        animation: none;
    }

    .mk-frame {
        transform: none;
    }
}

.mk-medal {
    position: absolute;
    top: 4px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #6b6b72, #1c1c1f 70%);
    box-shadow: inset 0 0 0 2px #17171a, inset 0 0 8px rgba(0, 0, 0, .7);
}

.mk-medal.left {
    left: 4px;
}

.mk-medal.right {
    right: 4px;
}

.mk-title {
    text-align: center;
    font-family: var(--font-mk-title);
    font-size: clamp(12px, 2.4vw, 19px);
    letter-spacing: 1px;
    line-height: 1.6;
    color: #F8F405;
    text-shadow: 2px 2px 0 #030200;
    margin-bottom: 10px;
    position: relative;
    z-index: 2;
}

.mk-body {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.mk-preview {
    flex: 0 0 var(--mk-preview-width);
    max-width: var(--mk-preview-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.mk-preview-img {
    width: 100%;
    background: transparent;
    border: none;
    overflow: visible;
}

.mk-preview-img img {
    width: 140%;
    height: 100%;
    object-fit: cover;
}

.mk-preview-img .fallback {
    font-size: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.mk-preview-name {
    font-family: var(--font-display);
    font-size: 11px;
    color: var(--lime);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    min-height: 14px;
}

.mk-preview input[type=text] {
    width: 100%;
    background: #1c1c20;
    border: 2px solid #55555c;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 8px 6px;
    border-radius: 3px;
    text-align: center;
    text-transform: uppercase;
}

.mk-preview input[type=text]:focus {
    outline: none;
    border-color: var(--lime);
}

/* las casillas tienen un tope de tamaño (minmax) para que no crezcan sin
   control si --mk-frame-width es grande: el frame gana aire, no las casillas */
.char-grid {
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(60px, 130px));
    justify-content: center;
    gap: 10px 8px;
    min-width: 0;
}

.char-grid.cols-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(70px, 140px));
    justify-content: center;
    gap: 12px 10px;
    width: 100%;
}

.char-tile {
    position: relative;
    cursor: pointer;
}

.char-tile .portrait-box {
    aspect-ratio: 1;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
    background: #20202a;
    border: 2px solid #6b6b72;
    box-shadow: inset 0 0 0 1px #17171a;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-tile .portrait-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.char-tile .fallback {
    font-size: 30px;
}

.char-tile .badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--lime);
    color: #0b0b12;
    font-family: var(--font-display);
    font-size: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 6px var(--lime);
}

.char-tile.selected .portrait-box {
    border-color: var(--lime);
    box-shadow: 0 0 12px var(--lime), inset 0 0 0 1px #17171a;
}

.char-tile.selected .badge {
    display: flex;
}

.char-tile .slot-name {
    font-family: var(--font-mk-title);
    margin-top: 4px;
    font-size: 12px;
    text-align: center;
    letter-spacing: .5px;
    color: var(--ink-dim);
    min-height: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.char-tile.taken .portrait-box {
    opacity: .35;
    cursor: not-allowed;
    filter: grayscale(1);
}

.char-tile.taken .slot-name {
    color: var(--magenta);
}

.char-tile.taken {
    cursor: not-allowed;
}

.mk-confirm {
    display: block;
    margin: 20px auto 0;
}

/* ---------- WAITING ---------- */
.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--lime);
    animation: pulse 1.2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1
    }

    50% {
        opacity: .2
    }
}

.waiting-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---------- ESCRITURA DE FRASES ---------- */
.write-input-row {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 14px;
}

.write-input-row input {
    flex: 1;
    background: var(--bg-panel);
    border: 2px solid var(--line);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 14px;
    padding: 12px;
    border-radius: 4px;
}

.write-input-row input:focus {
    outline: none;
    border-color: var(--magenta);
}

.write-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
    width: 100%;
}

.write-list-item {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 9px 12px;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.write-count {
    font-size: 11px;
    color: var(--ink-dim);
    margin-bottom: 10px;
}

/* ---------- RONDA: prompt / respuestas / voto ---------- */
.prompt-card {
    width: 100%;
    background: var(--bg-panel);
    border: 2px solid var(--line);
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    margin-bottom: 18px;
}

.prompt-card .prompt-text {
    font-size: 18px;
    line-height: 1.4;
}

.prompt-card.hidden-prompt {
    color: var(--ink-dim);
    font-style: italic;
}

.answer-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.answer-option {
    background: var(--bg-panel);
    border: 2px solid var(--line);
    border-radius: 6px;
    padding: 14px 16px;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.answer-option .answer-key {
    font-family: var(--font-display);
    color: var(--cyan);
    flex: 0 0 auto;
}

.answer-option:hover {
    border-color: var(--cyan);
}

.answer-option.voted {
    border-color: var(--lime);
    box-shadow: 0 0 10px var(--lime);
}

.answer-option.winner {
    border-color: var(--amber);
    box-shadow: 0 0 14px var(--amber);
}

.answer-option .answer-author {
    font-size: 10px;
    color: var(--ink-dim);
    margin-top: 4px;
}

.answer-option .answer-votes {
    margin-left: auto;
    font-family: var(--font-mono);
    color: var(--amber);
    flex: 0 0 auto;
}

.answer-option .vote-taps {
    font-size: 11px;
    color: var(--lime);
    flex: 0 0 auto;
}

.round-label {
    font-family: var(--font-display);
    font-size: 13px;
    color: var(--amber);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

/* ---------- MARCADOR ---------- */
.scoreboard {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.scoreboard-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 10px 14px;
}

.scoreboard-row .sb-portrait {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    overflow: hidden;
    flex: 0 0 auto;
    background: #1c1c2a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.scoreboard-row .sb-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scoreboard-row .sb-name {
    flex: 1;
    font-size: 13px;
}

.scoreboard-row .sb-points {
    font-family: var(--font-display);
    color: var(--lime);
    font-size: 15px;
}

.scoreboard-row.leader {
    border-color: var(--amber);
    box-shadow: 0 0 10px rgba(255, 182, 39, .3);
}

/* ---------- MOBILE ---------- */
@media (max-width: 480px) {
    #screen-profile {
        padding: 12px;
        gap: 12px;
    }

    #screen-profile input[type=text] {
        font-size: 14px;
        padding: 10px 12px;
    }

    .char-grid.cols-3 {
        grid-template-columns: repeat(3, minmax(60px, 110px));
        gap: 8px 6px;
    }

    .char-tile .fallback {
        font-size: 22px;
    }

    .char-tile .slot-name {
        font-size: 10px;
        margin-top: 3px;
    }

    .char-tile .badge {
        width: 15px;
        height: 15px;
        font-size: 9px;
    }

    .role-card {
        width: 140px;
        padding: 16px 10px 12px;
    }

    .role-card .icon-slot {
        height: 90px;
    }

    .prompt-card {
        padding: 14px;
    }

    .prompt-card .prompt-text {
        font-size: 15px;
    }
}

/* misc */
.hidden {
    display: none !important;
}