/* API World — estilos pixel art */
:root {
  --black: #181425; --night: #262b44; --ink: #3a4466; --slate: #5a6988; --steel: #8b9bb4; --silver: #c0cbdc;
  --white: #ffffff; --paper: #f4ead8; --paper2: #e7d8bd; --sand: #ead4aa;
  --red: #e43b44; --wine: #a22633; --orange: #f77622; --gold: #feae34; --yellow: #fee761;
  --green: #63c74d; --greenD: #3e8948; --blue: #0099db; --navy: #124e89; --cyan: #2ce8f5; --pink: #f6757a; --plum: #68386c;
  --a0: #e43b44; --a1: #0099db; --a2: #e8a100; --a3: #3e8948;
  --px: 4px;
  --font-title: 'Press Start 2P', monospace;
  --font: 'Pixelify Sans', 'Trebuchet MS', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--black); color: var(--white); font-family: var(--font); overflow: hidden; -webkit-tap-highlight-color: transparent; }
body { overscroll-behavior: none; }
button { font-family: inherit; }
#app { position: fixed; inset: 0; }
#stage { position: absolute; inset: 0; overflow: hidden; }
#stage canvas { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
.pe-none { pointer-events: none !important; }

/* ---------- Paneles y botones pixel ---------- */
.px {
  position: relative; background: var(--paper); color: var(--black);
  box-shadow: 0 calc(var(--px) * -1) 0 0 var(--black), 0 var(--px) 0 0 var(--black), calc(var(--px) * -1) 0 0 0 var(--black), var(--px) 0 0 0 var(--black),
    inset calc(var(--px) * -1) calc(var(--px) * -1) 0 0 var(--paper2), inset var(--px) var(--px) 0 0 #fff;
}
.px.dark { background: var(--night); color: var(--white); box-shadow: 0 -4px 0 0 var(--black), 0 4px 0 0 var(--black), -4px 0 0 0 var(--black), 4px 0 0 0 var(--black), inset -4px -4px 0 0 #1d2138, inset 4px 4px 0 0 var(--ink); }
.btn {
  font-family: var(--font-title); font-size: clamp(10px, 1.1vw, 14px); line-height: 1.4; color: var(--black); background: var(--gold); border: 0; cursor: pointer;
  padding: 14px 20px 16px; position: relative; text-transform: uppercase; letter-spacing: 0.5px;
  box-shadow: 0 -4px 0 0 var(--black), 0 4px 0 0 var(--black), -4px 0 0 0 var(--black), 4px 0 0 0 var(--black), inset 0 -6px 0 0 rgba(0,0,0,0.22), inset 0 4px 0 0 rgba(255,255,255,0.4);
  transition: transform 0.05s; user-select: none;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(3px); box-shadow: 0 -4px 0 0 var(--black), 0 4px 0 0 var(--black), -4px 0 0 0 var(--black), 4px 0 0 0 var(--black), inset 0 -2px 0 0 rgba(0,0,0,0.22), inset 0 4px 0 0 rgba(0,0,0,0.12); }
.btn:disabled { filter: grayscale(1) brightness(0.8); cursor: not-allowed; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.green { background: var(--green); }
.btn.red { background: var(--red); color: #fff; }
.btn.ghost { background: var(--silver); }
.btn.small { font-size: 10px; padding: 9px 12px 11px; }
.btn.big { font-size: clamp(12px, 1.5vw, 18px); padding: 18px 26px 20px; }
.btn kbd { font-family: var(--font-title); font-size: 0.8em; background: rgba(0,0,0,0.2); padding: 2px 5px; margin-left: 6px; }
.icon-btn { font-family: var(--font-title); font-size: 14px; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
kbd.key { font-family: var(--font-title); font-size: 0.75em; background: var(--white); color: var(--black); padding: 3px 6px 4px; box-shadow: 0 2px 0 var(--steel); border-radius: 2px; }

input.px-input {
  font-family: var(--font-title); font-size: 16px; padding: 14px 12px; width: 100%; border: 0; outline: 0; background: #fff; color: var(--black);
  box-shadow: 0 -4px 0 0 var(--black), 0 4px 0 0 var(--black), -4px 0 0 0 var(--black), 4px 0 0 0 var(--black), inset 4px 4px 0 0 var(--silver);
}
input.px-input:focus { box-shadow: 0 -4px 0 0 var(--blue), 0 4px 0 0 var(--blue), -4px 0 0 0 var(--blue), 4px 0 0 0 var(--blue), inset 4px 4px 0 0 var(--silver); }
input.code-input { font-size: clamp(22px, 5vw, 34px); text-align: center; letter-spacing: 8px; }

/* ---------- Pantallas (home, unirse...) ---------- */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; overflow-y: auto; }
.screen.dim { background: rgba(24, 20, 37, 0.35); }
.home { flex-direction: column; gap: 28px; text-align: center; }
.title-block { background: rgba(24, 20, 37, 0.62); padding: 26px 36px 22px; display: flex; flex-direction: column; gap: 22px; box-shadow: 0 -6px 0 rgba(24,20,37,0.62), 0 6px 0 rgba(24,20,37,0.62), -6px 0 0 rgba(24,20,37,0.62), 6px 0 0 rgba(24,20,37,0.62); }
.logo { font-family: var(--font-title); font-size: clamp(30px, 7vw, 84px); color: var(--yellow); text-shadow: 0 6px 0 var(--orange), 0 12px 0 var(--black), 6px 6px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black), 0 -4px 0 var(--black); letter-spacing: 4px; cursor: default; user-select: none; line-height: 1.2; }
.logo span { color: var(--cyan); text-shadow: 0 6px 0 var(--navy), 0 12px 0 var(--black), 6px 6px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black), 0 -4px 0 var(--black); }
.subtitle { font-family: var(--font-title); font-size: clamp(10px, 1.6vw, 16px); color: #fff; text-shadow: 3px 3px 0 var(--black); line-height: 1.8; }
.home .tagline { display: inline-block; padding: 10px 16px; font-size: clamp(14px, 2vw, 20px); }
.home-buttons { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.home-foot { position: absolute; bottom: 12px; left: 0; right: 0; text-align: center; font-size: 13px; color: var(--silver); text-shadow: 2px 2px 0 var(--black); }

.panel { padding: 26px; width: min(560px, 94vw); }
.panel h2 { font-family: var(--font-title); font-size: clamp(14px, 2vw, 20px); margin: 0 0 18px; line-height: 1.5; }
.panel p { font-size: 18px; line-height: 1.35; margin: 8px 0; }
.panel .row { display: flex; gap: 14px; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.panel .row.end { justify-content: flex-end; }
.field { margin-top: 16px; }
.field label { display: block; font-family: var(--font-title); font-size: 11px; margin-bottom: 10px; }
.err { color: var(--wine); font-weight: 600; min-height: 1.2em; }
.hint { color: var(--ink); font-size: 15px; }

/* Editor de avatar */
.avatar-editor { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; margin-top: 14px; }
.avatar-preview { width: 120px; height: 150px; background: linear-gradient(#9fd8f5, #d8f0ff 70%, #cdb38a 70%); box-shadow: 0 -4px 0 var(--black), 0 4px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black); display: grid; place-items: end center; }
.avatar-preview canvas { image-rendering: pixelated; width: 108px; height: 135px; }
.avatar-opts { display: grid; gap: 6px; }
.aopt { display: grid; grid-template-columns: 92px 34px 1fr 34px; align-items: center; gap: 6px; font-size: 16px; }
.aopt b { font-weight: 600; }
.aopt span { text-align: center; font-family: var(--font-title); font-size: 9px; }
.aopt button { font-family: var(--font-title); font-size: 10px; height: 30px; background: var(--silver); border: 0; cursor: pointer; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black), inset 0 -3px 0 rgba(0,0,0,0.2); }
.aopt button:active { transform: translateY(2px); }
@media (max-width: 520px) {
  .avatar-editor { grid-template-columns: 1fr; justify-items: center; }
  .avatar-opts { width: 100%; }
}

/* ---------- HUD ---------- */
.hud { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 12px 14px; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud .chip { font-family: var(--font-title); font-size: clamp(9px, 0.9vw, 12px); padding: 9px 12px; display: inline-flex; align-items: center; gap: 8px; line-height: 1.3; }
.hud-left, .hud-right { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.hud-right { justify-content: flex-end; }
.hud .code-chip b { color: var(--yellow); font-size: 1.25em; letter-spacing: 2px; }
.pieces { display: flex; gap: 6px; padding: 6px 8px; align-items: center; }
.pieces .lbl { font-family: var(--font-title); font-size: 9px; margin-right: 4px; color: var(--yellow); }
.slot { width: 36px; height: 36px; background: #1d2138; display: grid; place-items: center; box-shadow: inset 2px 2px 0 #11131f; position: relative; }
.slot img { width: 24px; height: 24px; image-rendering: pixelated; opacity: 0.18; filter: grayscale(1); transition: all 0.4s; }
.slot.got img { opacity: 1; filter: none; }
.slot.got { background: #2b3b62; animation: slotpop 0.6s; }
.slot .tip { position: absolute; top: 40px; left: 50%; transform: translateX(-50%); font-size: 12px; white-space: nowrap; background: var(--black); padding: 2px 6px; display: none; }
.slot:hover .tip { display: block; }
@keyframes slotpop { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
.progress { flex: 1; max-width: 520px; padding: 8px 12px 10px; }
.progress .ptitle { font-family: var(--font-title); font-size: clamp(8px, 0.8vw, 11px); color: var(--yellow); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbar { position: relative; height: 10px; background: #1d2138; display: flex; gap: 2px; }
.pbar .seg { flex: 1; background: var(--ink); position: relative; }
.pbar .seg.cur { background: var(--slate); }
.pbar .dot { position: absolute; top: 2px; width: 6px; height: 6px; background: var(--gold); transform: translateX(-3px); }
.pbar .dot.done { background: var(--green); }
.pbar .me { position: absolute; top: -6px; width: 4px; height: 22px; background: #fff; box-shadow: 0 0 0 2px var(--black); transform: translateX(-2px); transition: left 0.2s; }
.score-chip b { color: var(--yellow); font-size: 1.2em; }
.dialog:not(.hidden) ~ .controls-hint, #ui:has(.quiz) .controls-hint, #ui:has(.board) .controls-hint { display: none; }
.controls-hint { position: absolute; right: 14px; bottom: 12px; font-size: 14px; color: #fff; text-shadow: 2px 2px 0 var(--black); text-align: right; line-height: 1.7; pointer-events: none; opacity: 0.85; }

/* ---------- Diálogo ---------- */
.dialog { position: absolute; left: 50%; bottom: clamp(10px, 2.5vh, 26px); transform: translateX(-50%); width: min(1180px, 94vw); display: grid; grid-template-columns: auto 1fr; gap: 18px; padding: 16px 22px 18px 16px; align-items: start; }
.dialog .portrait { width: clamp(64px, 7.5vw, 112px); height: clamp(64px, 7.5vw, 112px); background: #9fd8f5; box-shadow: 0 -4px 0 var(--black), 0 4px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black); overflow: hidden; }
.dialog .portrait canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.dialog .who { font-family: var(--font-title); font-size: clamp(10px, 1vw, 14px); color: var(--wine); margin-bottom: 10px; }
.dialog .txt { font-size: clamp(18px, 1.85vw, 30px); line-height: 1.32; min-height: 2.6em; font-weight: 500; }
.dialog .txt strong { color: var(--navy); background: rgba(254, 231, 97, 0.55); padding: 0 3px; font-weight: 700; }
.dialog .txt code, .q-text code { font-family: monospace; font-size: 0.82em; background: var(--night); color: var(--cyan); padding: 1px 5px; }
.dialog .next { position: absolute; right: 14px; bottom: 8px; font-family: var(--font-title); font-size: 10px; color: var(--ink); animation: blink 0.9s steps(2) infinite; }
.dialog .counter { position: absolute; right: 16px; top: 10px; font-family: var(--font-title); font-size: 9px; color: var(--steel); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- Fichas ---------- */
.card { position: absolute; right: clamp(10px, 1.5vw, 24px); top: clamp(70px, 9vh, 96px); width: min(560px, 44vw); padding: 16px 18px 18px; max-height: 52vh; overflow: auto; animation: cardin 0.25s ease-out; }
.card h3 { font-family: var(--font-title); font-size: clamp(9px, 0.85vw, 12px); line-height: 1.5; margin: 0 0 12px; color: var(--wine); }
.card.left { right: auto; left: clamp(10px, 1.5vw, 24px); }
@keyframes cardin { from { transform: translateY(-12px); opacity: 0; } to { transform: none; opacity: 1; } }
.cbox { padding: 8px 8px; text-align: center; color: #fff; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); transition: all 0.3s; }
.cbox b { font-family: var(--font-title); font-size: clamp(8px, 0.75vw, 11px); line-height: 1.4; }
.cbox small { font-size: clamp(12px, 1vw, 15px); opacity: 0.95; }
.cbox.dim { opacity: 0.3; transform: scale(0.95); }
.c-green { background: #2f9e4a; } .c-red { background: #d65a52; } .c-yellow { background: #e0a100; } .c-blue { background: #0b7dc0; } .c-gray { background: var(--slate); }
.chain { display: flex; align-items: stretch; gap: 6px; }
.chain .cbox { flex: 1; }
.carrow { display: grid; place-items: center; font-family: var(--font-title); font-size: 12px; color: var(--ink); }
.cnote { font-size: clamp(14px, 1.1vw, 17px); margin: 12px 0 0; text-align: center; }
.equation { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
.equation .eq { display: flex; flex-direction: column; align-items: center; background: #fff; padding: 8px 8px; min-width: 80px; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.equation .eq.hl { background: var(--yellow); }
.equation .eq b { font-size: 15px; } .equation .eq small { font-size: 13px; color: var(--wine); font-weight: 600; }
.equation .op { font-family: var(--font-title); font-size: 16px; }
.emo { font-size: 26px; line-height: 1.2; }
.fcols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fcol h4 { font-family: var(--font-title); font-size: 10px; margin: 0 0 8px; color: var(--navy); }
.feat { display: flex; flex-direction: column; padding: 4px 0; border-bottom: 2px dotted var(--paper2); }
.feat b { font-size: 15px; } .feat small { font-size: 13px; color: var(--ink); }
.bridge-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; margin: 6px 0; }
.bridge-row .node { background: #fff; padding: 8px; text-align: center; font-size: 16px; font-weight: 600; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.bridge-row .link { font-family: var(--font-title); font-size: 14px; color: var(--red); text-align: center; }
.bridge-row .link small { display: block; font-size: 8px; color: var(--ink); }
.steps { display: flex; gap: 4px; align-items: stretch; }
.step { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 8px 4px; background: #fff; opacity: 0.45; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.step b { font-size: 14px; } .step small { font-size: 12px; color: var(--ink); }
.step.on { opacity: 1; background: var(--yellow); transform: scale(1.04); }
.step.done { opacity: 0.85; }
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dodont h4 { font-family: var(--font-title); font-size: 10px; margin: 0 0 8px; }
.dodont p { margin: 4px 0; font-size: 16px; }
.dodont .dont { background: #ffd9d6; padding: 10px; } .dodont .dont h4 { color: var(--wine); }
.dodont .do { background: #d9f7e6; padding: 10px; } .dodont .do h4 { color: var(--greenD); }
pre.code { font-family: Consolas, monospace; font-size: clamp(13px, 1.05vw, 16px); background: var(--black); color: #e8eef7; padding: 12px 14px; margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
pre.code .k { color: var(--gold); } pre.code .s { color: var(--green); } pre.code .f { color: var(--cyan); } pre.code .n { color: var(--pink); } pre.code .ok { color: var(--green); font-weight: bold; }
pre.code .hlk { color: var(--black); background: var(--yellow); }
.codes .coderow { display: flex; gap: 12px; align-items: center; font-size: 17px; padding: 4px 0; }
.badge { font-family: var(--font-title); font-size: 11px; padding: 6px 8px; color: #fff; min-width: 52px; text-align: center; }
.badge.ok { background: var(--greenD); } .badge.warn { background: var(--orange); } .badge.bad { background: var(--red); }
.url { font-family: Consolas, monospace; font-size: clamp(12px, 1vw, 15px); background: var(--black); color: var(--steel); padding: 12px; word-break: break-all; line-height: 1.7; }
.url span { padding: 1px 2px; transition: all 0.3s; }
.url .u-end.on { background: #0b7dc0; color: #fff; } .url .u-par.on { background: var(--greenD); color: #fff; } .url .u-key.on { background: var(--orange); color: #fff; }
.url .u-q { color: var(--yellow); }
.legend { margin-top: 10px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.legend .lg { font-family: var(--font-title); font-size: 8px; padding: 4px 6px; }
.legend .lg.u-end { background: #0b7dc0; color: #fff; } .legend .lg.u-par { background: var(--greenD); color: #fff; } .legend .lg.u-key { background: var(--orange); color: #fff; }
.chain.small .cbox b { font-size: 8px; } .chain.small .cbox small { font-size: 12px; }
.prov { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pcol { background: #fff; padding: 10px; transition: all 0.3s; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.pcol h4 { margin: 0 0 6px; font-size: 16px; } .pcol p { margin: 0 0 6px; font-size: 14px; line-height: 1.3; } .pcol small { font-size: 13px; color: var(--wine); font-weight: 600; }
.pcol.dim { opacity: 0.3; } .pcol.cur { background: var(--yellow); }
.loop { display: flex; align-items: center; gap: 6px; justify-content: center; }
.lnode { display: flex; flex-direction: column; align-items: center; background: #fff; padding: 10px; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.lnode b { font-family: var(--font-title); font-size: 10px; margin-top: 4px; } .lnode small { font-size: 13px; }
.math { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: center; }
.mcol { padding: 12px; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.mcol h4 { font-family: var(--font-title); font-size: 10px; margin: 0 0 8px; }
.mcol .big { font-family: var(--font-title); font-size: clamp(16px, 1.8vw, 26px); margin: 6px 0; }
.mcol.bad { background: #ffd9d6; } .mcol.good { background: #d9f7e6; } .mcol.dim { background: #eee; opacity: 0.5; }
.mcp3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.m3 { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 6px; color: #fff; transition: all 0.3s; box-shadow: 0 -3px 0 var(--black), 0 3px 0 var(--black), -3px 0 0 var(--black), 3px 0 0 var(--black); }
.m3 b { font-family: var(--font-title); font-size: 9px; margin: 4px 0; } .m3 small { font-size: 14px; font-weight: 600; } .m3 em { font-size: 13px; opacity: 0.9; margin-top: 4px; }
.m3-0 { background: #d0661f; } .m3-1 { background: #0b7dc0; } .m3-2 { background: #8a3d8f; }
.m3.dim { opacity: 0.25; }
.summary .srow { display: grid; grid-template-columns: 32px 110px 1fr; gap: 4px 10px; align-items: center; padding: 5px 0; border-bottom: 2px dotted var(--paper2); }
.summary .srow img { width: 24px; height: 24px; image-rendering: pixelated; grid-row: span 2; }
.summary .srow b { font-size: 16px; } .summary .srow span { font-size: 16px; font-weight: 600; color: var(--wine); }
.summary .srow small { grid-column: 2 / 4; font-size: 13px; color: var(--ink); }
.exercise { margin: 0; padding-left: 22px; } .exercise li { font-size: 16px; margin: 5px 0; line-height: 1.3; }
.pieces-row { display: flex; gap: 10px; justify-content: space-between; }
.piece-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; background: var(--night); color: #fff; padding: 10px 6px; flex: 1; font-size: 15px; font-weight: 600; }
.px-icon { image-rendering: pixelated; }

/* ---------- Pregunta lista / banners ---------- */
.banner { position: absolute; left: 50%; top: clamp(70px, 10vh, 110px); transform: translateX(-50%); padding: 14px 18px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; animation: cardin 0.25s; max-width: 94vw; }
.banner .t { font-family: var(--font-title); font-size: clamp(10px, 1vw, 13px); line-height: 1.5; }
.toast { position: absolute; left: 50%; top: clamp(74px, 11vh, 110px); transform: translateX(-50%); padding: 12px 18px; font-family: var(--font-title); font-size: 11px; animation: cardin 0.25s; z-index: 50; max-width: 92vw; line-height: 1.6; text-align: center; }

/* ---------- Pregunta (pantalla grande) ---------- */
.quiz { position: absolute; inset: 0; background: rgba(24, 20, 37, 0.72); display: grid; grid-template-rows: auto 1fr auto; gap: clamp(10px, 2vh, 22px); padding: clamp(12px, 2.5vh, 30px) clamp(12px, 3vw, 44px); animation: fadein 0.2s; }
@keyframes fadein { from { opacity: 0; } }
.q-head { padding: clamp(14px, 2.2vh, 26px) clamp(16px, 2vw, 30px); text-align: center; }
.q-meta { font-family: var(--font-title); font-size: clamp(9px, 0.8vw, 11px); color: var(--wine); margin-bottom: 10px; }
.q-text { font-size: clamp(22px, 2.6vw, 44px); font-weight: 600; line-height: 1.22; }
.q-mid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; min-height: 0; }
.timer { width: clamp(90px, 10vw, 150px); height: clamp(90px, 10vw, 150px); border-radius: 50%; background: var(--night); display: grid; place-items: center; font-family: var(--font-title); font-size: clamp(24px, 3vw, 44px); color: #fff; box-shadow: 0 0 0 6px var(--black), inset 0 0 0 8px var(--ink); position: relative; }
.timer.warn { color: var(--red); animation: pulse 0.5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }
.timer svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.answered-box { justify-self: end; text-align: center; padding: 14px 18px; }
.answered-box .n { font-family: var(--font-title); font-size: clamp(22px, 2.6vw, 40px); }
.answered-box .l { font-size: 18px; }
.q-side { display: flex; flex-wrap: wrap; gap: 6px; align-content: center; max-height: 100%; overflow: hidden; }
.q-side .mini { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.12); padding: 3px 7px 3px 3px; font-size: 14px; animation: cardin 0.3s; }
.q-side .mini canvas { width: 22px; height: 28px; image-rendering: pixelated; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(8px, 1.5vh, 16px); }
.opt { position: relative; display: flex; align-items: center; gap: 16px; padding: clamp(12px, 2vh, 22px) clamp(14px, 1.6vw, 24px); font-size: clamp(17px, 1.7vw, 28px); font-weight: 600; color: #fff; border: 0; text-align: left; cursor: default; line-height: 1.2; min-height: clamp(64px, 11vh, 120px);
  box-shadow: 0 -4px 0 var(--black), 0 4px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black), inset 0 -8px 0 rgba(0,0,0,0.25); transition: opacity 0.3s, transform 0.2s; }
.opt.o0 { background: var(--a0); } .opt.o1 { background: var(--a1); } .opt.o2 { background: var(--a2); } .opt.o3 { background: var(--a3); }
.opt .shape { flex: none; width: clamp(28px, 2.6vw, 44px); height: clamp(28px, 2.6vw, 44px); }
.opt.clickable { cursor: pointer; }
.opt.clickable:hover { transform: translateY(-2px); filter: brightness(1.08); }
.opt.wrong { opacity: 0.28; }
.opt.right { transform: scale(1.02); animation: glow 0.8s infinite alternate; }
.opt.mine::after { content: 'TU RESPUESTA'; position: absolute; top: -12px; right: 10px; font-family: var(--font-title); font-size: 9px; background: #fff; color: var(--black); padding: 4px 6px; box-shadow: 0 0 0 3px var(--black); }
@keyframes glow { to { box-shadow: 0 -4px 0 var(--yellow), 0 4px 0 var(--yellow), -4px 0 0 var(--yellow), 4px 0 0 var(--yellow), inset 0 -8px 0 rgba(0,0,0,0.25), 0 0 30px var(--yellow); } }
.opt .count { margin-left: auto; font-family: var(--font-title); font-size: clamp(14px, 1.4vw, 22px); display: flex; align-items: center; gap: 10px; }
.opt .bar { position: absolute; left: 0; bottom: 0; height: 6px; background: rgba(255,255,255,0.75); transition: width 0.8s; }
.opt .tick { font-family: var(--font-title); font-size: 18px; }
.explain { padding: 14px 20px; font-size: clamp(16px, 1.5vw, 24px); line-height: 1.3; display: flex; gap: 14px; align-items: center; }
.explain .lamp { font-size: 30px; }
.q-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.reading { font-family: var(--font-title); color: var(--yellow); font-size: clamp(12px, 1.4vw, 20px); text-align: center; text-shadow: 3px 3px 0 var(--black); }
.result-flash { font-family: var(--font-title); font-size: clamp(18px, 2.2vw, 30px); text-shadow: 3px 3px 0 var(--black); }
.result-flash.ok { color: var(--green); } .result-flash.ko { color: var(--red); }

/* ---------- Clasificación ---------- */
.board { position: absolute; inset: 0; background: rgba(24, 20, 37, 0.78); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px; animation: fadein 0.2s; }
.board h2 { font-family: var(--font-title); font-size: clamp(18px, 2.4vw, 34px); color: var(--yellow); text-shadow: 4px 4px 0 var(--black); margin: 0; }
.ranks { width: min(900px, 94vw); display: grid; gap: 12px; }
.rank { display: grid; grid-template-columns: 56px 52px 1fr auto auto; gap: 14px; align-items: center; padding: 10px 18px; font-size: clamp(18px, 1.8vw, 28px); font-weight: 600; animation: slidein 0.4s backwards; }
.rank .pos { font-family: var(--font-title); font-size: clamp(14px, 1.4vw, 22px); }
.rank canvas { width: 40px; height: 50px; image-rendering: pixelated; }
.rank .pts { font-family: var(--font-title); font-size: clamp(12px, 1.2vw, 18px); }
.rank .delta { font-family: var(--font-title); font-size: 11px; color: var(--greenD); }
.rank.r1 { background: var(--yellow); } .rank.r2 { background: #e2e8f2; } .rank.r3 { background: #f2c9a0; }
@keyframes slidein { from { transform: translateX(-40px); opacity: 0; } }
.board .foot { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

/* ---------- Lobby profesor ---------- */
.lobby { position: absolute; left: 50%; top: clamp(12px, 3vh, 34px); transform: translateX(-50%); width: min(1100px, 94vw); padding: 18px 22px; display: grid; grid-template-columns: 1fr auto; gap: 18px; align-items: center; }
.lobby .join-how { font-size: clamp(16px, 1.6vw, 24px); line-height: 1.35; }
.lobby .url { display: inline-block; font-family: var(--font-title); font-size: clamp(10px, 1.1vw, 16px); background: var(--night); color: var(--cyan); padding: 8px 10px; margin: 6px 0; word-break: break-all; }
.lobby .bigcode { font-family: var(--font-title); font-size: clamp(30px, 5vw, 72px); letter-spacing: 6px; color: var(--black); }
.lobby .qr { background: #fff; padding: 6px; box-shadow: 0 0 0 4px var(--black); }
.lobby .qr img, .lobby .qr canvas { display: block; width: clamp(90px, 9vw, 140px); height: auto; image-rendering: pixelated; }
.lobby .players-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; max-height: 18vh; overflow: auto; }
.pchip { display: inline-flex; align-items: center; gap: 6px; background: var(--night); color: #fff; padding: 4px 10px 4px 4px; font-size: 16px; cursor: pointer; animation: cardin 0.3s; }
.pchip canvas { width: 24px; height: 30px; image-rendering: pixelated; background: #9fd8f5; }
.pchip:hover { background: var(--wine); }
.lobby-bottom { position: absolute; left: 50%; bottom: clamp(14px, 3vh, 34px); transform: translateX(-50%); display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; }
.lobby-bottom .count { font-family: var(--font-title); font-size: clamp(12px, 1.4vw, 18px); color: #fff; text-shadow: 3px 3px 0 var(--black); }

/* ---------- Menú / mapa ---------- */
.modal { position: absolute; inset: 0; background: rgba(24, 20, 37, 0.7); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 30; }
.modal .panel { max-height: 90vh; overflow: auto; width: min(760px, 96vw); }
.map-list { display: grid; gap: 4px; margin-top: 8px; }
.map-ch { font-family: var(--font-title); font-size: 10px; color: var(--wine); margin: 14px 0 4px; }
.map-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: #fff; border: 0; text-align: left; font-size: 17px; cursor: pointer; font-family: var(--font); box-shadow: 0 2px 0 var(--paper2); }
.map-item:hover { background: var(--yellow); }
.map-item:disabled { opacity: 0.4; cursor: not-allowed; }
.map-item .st { font-family: var(--font-title); font-size: 10px; width: 26px; text-align: center; }
.map-item .qb { margin-left: auto; font-size: 13px; color: var(--ink); }
.menu-grid { display: grid; gap: 12px; margin-top: 10px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 16px; align-items: center; margin-top: 10px; }

/* ---------- Controles táctiles (modo solo) ---------- */
.touch { position: absolute; bottom: 14px; left: 14px; right: 14px; display: none; justify-content: space-between; align-items: flex-end; pointer-events: none; }
.touch > div { display: flex; gap: 14px; pointer-events: auto; }
.touch button { width: 64px; height: 64px; font-family: var(--font-title); font-size: 18px; background: rgba(255,255,255,0.85); border: 0; box-shadow: 0 -4px 0 var(--black), 0 4px 0 var(--black), -4px 0 0 var(--black), 4px 0 0 var(--black); user-select: none; -webkit-user-select: none; touch-action: none; }
.touch button.act { background: var(--gold); width: 74px; height: 74px; }
.touch button.nxt { background: var(--cyan); font-size: 11px; }
@media (pointer: coarse) { .touch.on { display: flex; } .controls-hint { display: none; } }

/* ---------- Vista del alumno (móvil) ---------- */
.student { position: absolute; inset: 0; display: grid; grid-template-rows: auto auto 1fr; background: var(--black); }
.st-top { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--night); border-bottom: 4px solid var(--black); }
.st-top canvas { width: 32px; height: 40px; image-rendering: pixelated; background: #9fd8f5; }
.st-top .nm { font-weight: 700; font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-top .sc { font-family: var(--font-title); font-size: 11px; color: var(--yellow); text-align: right; line-height: 1.6; }
.st-scene { position: relative; height: 30vh; min-height: 150px; max-height: 300px; overflow: hidden; border-bottom: 4px solid var(--black); }
.st-scene canvas { display: block; image-rendering: pixelated; }
.st-scene .zone-tag { position: absolute; left: 8px; top: 8px; font-family: var(--font-title); font-size: 9px; background: rgba(24,20,37,0.8); color: var(--yellow); padding: 6px 8px; }
.st-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 14px; }
.st-body .msg { padding: 16px; font-size: 19px; line-height: 1.35; }
.st-body .msg h3 { font-family: var(--font-title); font-size: 12px; margin: 0 0 10px; line-height: 1.5; }
.st-dialog { display: grid; grid-template-columns: 64px 1fr; gap: 12px; padding: 12px; }
.st-dialog .portrait { width: 64px; height: 64px; background: #9fd8f5; overflow: hidden; }
.st-dialog .portrait canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.st-dialog .who { font-family: var(--font-title); font-size: 10px; color: var(--wine); margin-bottom: 6px; }
.st-dialog .txt { font-size: 18px; line-height: 1.32; }
.st-dialog .txt strong { color: var(--navy); background: rgba(254, 231, 97, 0.55); padding: 0 2px; }
.st-card { padding: 12px; }
.st-card h3 { font-family: var(--font-title); font-size: 9px; color: var(--wine); margin: 0 0 10px; line-height: 1.5; }
.st-card .chain, .st-card .steps, .st-card .loop { flex-wrap: wrap; }
.st-card .prov, .st-card .mcp3, .st-card .fcols, .st-card .dodont, .st-card .math { grid-template-columns: 1fr; }
.st-q { display: flex; flex-direction: column; gap: 10px; }
.st-q .q-text { font-size: 21px; padding: 14px; line-height: 1.3; }
.st-q .tbar { height: 14px; background: var(--ink); position: relative; box-shadow: 0 0 0 3px var(--black); }
.st-q .tbar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); }
.st-opts { display: grid; gap: 10px; }
.st-opts .opt { min-height: 60px; font-size: 18px; cursor: pointer; }
.st-opts .opt:disabled { cursor: default; }
.st-opts .opt.picked { outline: 6px solid #fff; outline-offset: -10px; }
.st-result { text-align: center; padding: 20px 16px; }
.st-result .big { font-family: var(--font-title); font-size: 22px; margin: 6px 0 12px; }
.st-result .pts { font-family: var(--font-title); font-size: 16px; color: var(--greenD); }
.st-result.ok { background: #d9f7e6; } .st-result.ko { background: #ffd9d6; } .st-result.none { background: #e8eef7; }
.review { display: grid; gap: 10px; }
.rv { padding: 12px; font-size: 16px; line-height: 1.3; }
.rv .rq { font-weight: 700; margin-bottom: 6px; }
.rv .ra { font-size: 15px; } .rv .ra.ok { color: var(--greenD); } .rv .ra.ko { color: var(--wine); }
.rv .rx { font-size: 14px; color: var(--ink); margin-top: 6px; }
.rv .tag { font-family: var(--font-title); font-size: 9px; float: right; }

/* ---------- Resultados finales ---------- */
.results { position: absolute; inset: 0; overflow-y: auto; background: rgba(24, 20, 37, 0.82); display: flex; justify-content: center; padding: 30px 14px; }
.results .panel { width: min(820px, 96vw); height: fit-content; }
.results .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.results .stat { background: var(--night); color: #fff; padding: 14px; text-align: center; }
.results .stat b { display: block; font-family: var(--font-title); font-size: clamp(16px, 2.4vw, 26px); color: var(--yellow); margin-bottom: 6px; }
.results .title-rank { font-family: var(--font-title); font-size: clamp(12px, 1.6vw, 18px); color: var(--plum); text-align: center; margin: 10px 0 4px; line-height: 1.6; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-title); font-size: 14px; color: var(--yellow); background: var(--black); z-index: 100; }
.fade-black { position: absolute; inset: 0; background: var(--black); pointer-events: none; transition: opacity 0.4s; z-index: 40; }

@media (max-width: 760px) {
  .hud { padding: 8px; gap: 6px; }
  .progress { display: none; }
  .slot { width: 28px; height: 28px; } .slot img { width: 20px; height: 20px; }
  .card { width: auto; left: 10px; right: 10px; top: 64px; max-height: 38vh; }
  .dialog { grid-template-columns: 56px 1fr; gap: 10px; padding: 12px; }
  .dialog .portrait { width: 56px; height: 56px; }
  .quiz { grid-template-rows: auto auto 1fr; }
  .q-mid { grid-template-columns: auto 1fr; }
  .q-side { display: none; }
  .opts { grid-template-columns: 1fr; }
  .opt { min-height: 54px; }
  .lobby { grid-template-columns: 1fr; }
  .rank { grid-template-columns: 40px 44px 1fr auto; }
  .rank .delta { display: none; }
}

/* ---------- Mis partidas (historial local) ---------- */
.hist-panel { width: min(900px, 96vw) !important; }
.tabs { display: flex; gap: 12px; margin: 12px 0 16px; }
.hist-body { display: grid; gap: 14px; }
.hist-item { padding: 14px; display: grid; gap: 10px; }
.hist-head { display: flex; gap: 12px; align-items: center; font-size: 17px; line-height: 1.3; }
.hist-head canvas { width: 32px; height: 40px; image-rendering: pixelated; background: #9fd8f5; }
.hist-head small { color: var(--ink); font-size: 14px; }
.best { font-family: var(--font-title); font-size: 9px; background: var(--yellow); padding: 3px 6px; }
.hist-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 16px; }
.hist-bar { height: 10px; background: var(--paper2); box-shadow: 0 0 0 2px var(--black); }
.hist-bar i { display: block; height: 100%; background: var(--green); }
.hist-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.cmp-wrap { overflow-x: auto; }
.cmp { border-collapse: collapse; width: 100%; font-size: 14px; background: #fff; }
.cmp th, .cmp td { border: 2px solid var(--paper2); padding: 6px 8px; text-align: center; }
.cmp th { background: var(--night); color: #fff; font-weight: 600; font-size: 13px; }
.cmp th small { color: var(--silver); font-weight: 400; }
.cmp .qcol { text-align: left; min-width: 220px; }
.cmp td.c-ok { background: #d9f7e6; color: var(--greenD); font-weight: 700; }
.cmp td.c-ko { background: #ffd9d6; color: var(--wine); font-weight: 700; }
.cmp td.c-none { color: var(--steel); }
.cmp tfoot td { background: var(--paper); }
.hardtag { font-family: var(--font-title); font-size: 7px; background: var(--plum); color: #fff; padding: 2px 4px; vertical-align: middle; }
.st-top .icon-btn { width: 34px; height: 34px; font-size: 14px; }
