/* ==========================================================================
   PROTOCOLO ZERO — Tactical Neo-Industrial / Cyber-Hardware UI
   ========================================================================== */
:root {
  --bg: #0B0E14;
  --panel: #121721;
  --panel-2: #181F2D;
  --recessed: #080A0F;
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #E6EDF6;
  --muted: #8A96A8;
  --amber: #FFB000;
  --red: #FF2A4B;
  --green: #00E676;
  --cyan: #00E5FF;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --shadow-inset: inset 0 2px 6px rgba(0, 0, 0, 0.72), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-panel: 0 10px 28px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background-color: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: 15px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}

/* Textura sutil de aluminio anodizado / fibra técnica */
body {
  background-image:
    radial-gradient(circle at 50% 0%, rgba(0, 229, 255, 0.05), transparent 55%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 4px);
}

.hidden { display: none !important; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }

/* Animaciones de impacto, sacudida y chispas */
@keyframes screen-shake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-7px, 3px, 0); }
  30% { transform: translate3d(7px, -4px, 0); }
  45% { transform: translate3d(-5px, -2px, 0); }
  60% { transform: translate3d(5px, 3px, 0); }
  75% { transform: translate3d(-3px, 1px, 0); }
}
@keyframes flash-red { 0% { opacity: 0.9; } 100% { opacity: 0; } }
@keyframes led-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes spark-pop { 0% { transform: scale(0.4); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }

body.shake { animation: screen-shake 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); }
.strike-flash { position: fixed; inset: 0; pointer-events: none; z-index: 90; background: radial-gradient(circle, rgba(255, 42, 75, 0.12) 25%, rgba(255, 42, 75, 0.55) 100%); }
.strike-flash.active { animation: flash-red 0.55s ease-out forwards; }

/* Barra superior y contenedor */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: rgba(11, 14, 20, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { width: 28px; height: 28px; color: var(--amber); flex-shrink: 0; }
.brand-title { font-family: var(--font-mono); font-weight: 800; font-size: 1rem; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.68rem; letter-spacing: 0.12em; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.app-shell { width: 100%; max-width: 1220px; margin: 0 auto; padding: 14px 12px 36px; }
.view { display: flex; flex-direction: column; gap: 14px; }

/* Badges y botones táctiles */
.badge-mono, .badge-diff, .badge-cyan {
  font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700;
  padding: 4px 8px; border-radius: 6px; background: var(--recessed);
  border: 1px solid var(--border); color: var(--text); letter-spacing: 0.06em;
}
.badge-cyan { color: var(--cyan); border-color: rgba(0, 229, 255, 0.35); }
.badge-diff { color: var(--amber); border-color: rgba(255, 176, 0, 0.35); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--border-hi); color: var(--text);
  cursor: pointer; touch-action: manipulation;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 3px 8px rgba(0, 0, 0, 0.4);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.muted-state { color: var(--red); border-color: rgba(255, 42, 75, 0.35); }
.icon-btn:active, .btn-primary:active, .btn-ghost:active, .seg-btn:active, .diff-btn:active { transform: translateY(1px); }

/* Inicio y tarjetas de rol */
.hero-panel, .panel {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-panel);
}
.tag-amber {
  display: inline-block; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; color: var(--amber); background: rgba(255, 176, 0, 0.1);
  border: 1px solid rgba(255, 176, 0, 0.28); padding: 4px 9px; border-radius: 6px; margin-bottom: 10px;
}
.hero-panel h1 { margin: 0 0 8px; font-size: 1.45rem; line-height: 1.2; }
.hero-panel p { margin: 0; font-size: 0.94rem; }

.role-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .role-grid { grid-template-columns: 1fr 1fr; } }

.role-card {
  text-align: left; display: flex; flex-direction: column; gap: 10px; padding: 20px 18px;
  border-radius: var(--radius); background: linear-gradient(180deg, #171E2C 0%, #10151E 100%);
  border: 1px solid var(--border-hi); color: var(--text); cursor: pointer;
  box-shadow: var(--shadow-panel); touch-action: manipulation;
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.role-card h2 { margin: 0; font-family: var(--font-mono); font-size: 1.15rem; letter-spacing: 0.05em; }
.role-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }
.role-defuser { border-left: 3px solid var(--red); }
.role-expert { border-left: 3px solid var(--cyan); }
.role-header { display: flex; align-items: center; justify-content: space-between; }
.role-svg { width: 26px; height: 26px; opacity: 0.85; }
.role-defuser .role-svg { color: var(--red); }
.role-expert .role-svg { color: var(--cyan); }
.role-pill { font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700; padding: 3px 7px; border-radius: 5px; letter-spacing: 0.08em; }
.pill-red { color: var(--red); background: rgba(255, 42, 75, 0.12); border: 1px solid rgba(255, 42, 75, 0.35); }
.pill-cyan { color: var(--cyan); background: rgba(0, 229, 255, 0.1); border: 1px solid rgba(0, 229, 255, 0.32); }
.role-cta { margin-top: auto; font-family: var(--font-mono); font-size: 0.82rem; font-weight: 700; letter-spacing: 0.05em; }
.role-defuser .role-cta { color: var(--amber); }
.role-expert .role-cta { color: var(--cyan); }

.info-strip {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--recessed);
  border: 1px solid var(--border); font-size: 0.82rem; color: var(--muted);
}
.info-item { display: flex; align-items: center; gap: 8px; }

.led { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: #2A3242; box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.8); }
.led-amber { background: var(--amber); box-shadow: 0 0 8px rgba(255, 176, 0, 0.75); }
.led-cyan { background: var(--cyan); box-shadow: 0 0 8px rgba(0, 229, 255, 0.75); }
.led-green { background: var(--green); box-shadow: 0 0 8px rgba(0, 230, 118, 0.8); }
.led-red { background: var(--red); box-shadow: 0 0 8px rgba(255, 42, 75, 0.8); }

/* Formularios de configuración */
.view-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.view-label { font-family: var(--font-mono); font-size: 0.76rem; color: var(--muted); letter-spacing: 0.08em; }
.btn-back, .btn-ghost, .btn-hud {
  min-height: 44px; padding: 8px 14px; border-radius: 9px;
  background: var(--panel-2); border: 1px solid var(--border-hi); color: var(--text);
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.btn-small { min-height: 36px; padding: 6px 10px; font-size: 0.74rem; }

.code-box {
  text-align: center; padding: 16px; border-radius: 10px;
  background: var(--recessed); box-shadow: var(--shadow-inset); margin-bottom: 18px;
}
.code-label { display: block; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); letter-spacing: 0.08em; }
.code-value {
  font-family: var(--font-mono); font-size: 2.35rem; font-weight: 800; letter-spacing: 0.22em;
  color: var(--amber); text-shadow: 0 0 14px rgba(255, 176, 0, 0.35); margin: 8px 0 12px;
}
.code-actions { display: flex; justify-content: center; gap: 10px; }

.form-group { margin-bottom: 18px; }
.group-label { display: block; font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; color: var(--muted); letter-spacing: 0.07em; margin-bottom: 8px; }
.field-hint { margin: 6px 0 0; font-size: 0.82rem; color: var(--muted); }
.field-hint.ok { color: var(--green); }
.field-hint.err { color: var(--red); }

.seg-group { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.seg-btn {
  min-height: 46px; border-radius: 9px; background: var(--recessed); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font-mono); font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow-inset); touch-action: manipulation;
}
.seg-btn.active { background: rgba(0, 229, 255, 0.14); border-color: var(--cyan); color: var(--cyan); box-shadow: 0 0 12px rgba(0, 229, 255, 0.2); }

.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.diff-btn {
  display: flex; flex-direction: column; gap: 3px; text-align: left; min-height: 58px; padding: 10px 12px;
  border-radius: 9px; background: var(--recessed); border: 1px solid var(--border);
  color: var(--text); cursor: pointer; box-shadow: var(--shadow-inset); touch-action: manipulation;
}
.diff-btn strong { font-family: var(--font-mono); font-size: 0.92rem; }
.diff-btn span { font-size: 0.75rem; color: var(--muted); }
.diff-btn.active { background: rgba(255, 176, 0, 0.12); border-color: var(--amber); }
.diff-btn.active strong { color: var(--amber); }

.code-input {
  width: 100%; min-height: 56px; padding: 10px 14px; border-radius: 10px;
  background: var(--recessed); border: 1px solid var(--border-hi); color: var(--amber);
  font-family: var(--font-mono); font-size: 1.65rem; font-weight: 800; letter-spacing: 0.24em;
  text-align: center; text-transform: uppercase; box-shadow: var(--shadow-inset);
}
.code-input:focus, .manual-search:focus { outline: none; border-color: var(--cyan); }

.btn-primary {
  width: 100%; min-height: 54px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.18);
  font-family: var(--font-mono); font-size: 0.98rem; font-weight: 800; letter-spacing: 0.08em;
  cursor: pointer; color: #090B10; background: var(--amber); touch-action: manipulation;
  box-shadow: 0 6px 18px rgba(255, 176, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn-danger-cta { background: linear-gradient(180deg, #FF4764 0%, #E01637 100%); color: #FFF; box-shadow: 0 6px 20px rgba(255, 42, 75, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn-cyan-cta { background: linear-gradient(180deg, #2EEBFF 0%, #00B8D4 100%); color: #061018; box-shadow: 0 6px 20px rgba(0, 229, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.45); }
.btn-primary:disabled { opacity: 0.38; cursor: not-allowed; box-shadow: none; }

/* HUD de bomba activa y chasis */
.bomb-hud {
  position: sticky; top: 8px; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius);
  background: rgba(14, 19, 28, 0.95); backdrop-filter: blur(8px);
  border: 1px solid var(--border-hi); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
}
.hud-timer-wrap { display: flex; flex-direction: column; gap: 2px; }
.hud-timer {
  font-family: var(--font-mono); font-size: 1.75rem; font-weight: 800; line-height: 1;
  letter-spacing: 0.06em; color: var(--red); text-shadow: 0 0 12px rgba(255, 42, 75, 0.55);
  background: var(--recessed); padding: 6px 10px; border-radius: 8px; box-shadow: var(--shadow-inset);
}
.hud-timer.urgent { animation: led-pulse 0.6s infinite; }
.hud-timer-meta { display: flex; gap: 6px; font-family: var(--font-mono); font-size: 0.68rem; }
.speed-badge { color: var(--amber); }
.progress-badge { color: var(--green); }

.hud-strikes { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.strikes-label { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.08em; color: var(--muted); }
.strikes-leds { display: flex; gap: 6px; padding: 5px 8px; border-radius: 7px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.strike-led { width: 14px; height: 14px; border-radius: 3px; background: #232A38; border: 1px solid rgba(255, 255, 255, 0.06); }
.strike-led.on { background: var(--red); box-shadow: 0 0 10px rgba(255, 42, 75, 0.9); }
.hud-controls { display: flex; align-items: center; gap: 6px; }
.btn-hud[aria-expanded="true"] { border-color: var(--cyan); color: var(--cyan); }

.chassis-drawer {
  background: linear-gradient(180deg, #161C28 0%, #10151F 100%);
  border: 1px solid var(--border-hi); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow-panel);
}
.chassis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.chassis-cell { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 8px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.chassis-key { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.08em; }
.chassis-val { font-size: 1.08rem; color: var(--amber); letter-spacing: 0.08em; }
.chassis-batteries, .chassis-leds { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.bat-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 5px;
  background: #1B2332; border: 1px solid var(--border-hi); font-family: var(--font-mono); font-size: 0.74rem;
}
.bat-chip svg { width: 14px; height: 14px; color: var(--amber); }
.ind-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 5px;
  background: #161D2B; border: 1px solid var(--border); font-family: var(--font-mono); font-size: 0.78rem; font-weight: 700;
}
.chassis-cell-actions { justify-content: space-between; }

/* Rejilla de módulos */
.modules-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 720px) { .modules-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .modules-grid { grid-template-columns: repeat(3, 1fr); } }

.module-card {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 14px;
  border-radius: var(--radius); background: linear-gradient(180deg, #18202F 0%, #111622 100%);
  border: 1px solid var(--border-hi); box-shadow: var(--shadow-panel); transition: border-color 0.2s ease;
}
.module-card.defused { border-color: rgba(0, 230, 118, 0.5); }
.module-card.error-flash { border-color: var(--red); box-shadow: 0 0 18px rgba(255, 42, 75, 0.35); }
.module-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.module-title { font-family: var(--font-mono); font-size: 0.82rem; font-weight: 800; letter-spacing: 0.08em; }
.module-status-led { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.module-status-led .led { width: 11px; height: 11px; }
.module-card.defused .module-status-led { color: var(--green); }
.module-body { display: flex; flex-direction: column; gap: 10px; flex: 1; justify-content: center; }

/* 1. Cables */
.wires-bay { background: var(--recessed); border-radius: 9px; padding: 10px 8px; box-shadow: var(--shadow-inset); }
.wire-row { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; touch-action: manipulation; border-radius: 6px; padding: 2px 4px; }
.wire-row:active:not(.is-cut) { background: rgba(255, 255, 255, 0.04); }
.wire-row.is-cut { cursor: default; }
.wire-idx { font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); width: 16px; text-align: center; }
.wire-svg { flex: 1; height: 32px; overflow: visible; }
.wire-path { fill: none; stroke-width: 7; stroke-linecap: round; }
.wire-copper { fill: none; stroke: #D98B48; stroke-width: 4; stroke-linecap: round; }
.wire-spark { fill: var(--amber); transform-origin: center; animation: spark-pop 0.35s ease-out forwards; }
.wire-red { stroke: #FF2A4B; }
.wire-blue { stroke: #1E88FF; }
.wire-yellow { stroke: #FFB800; }
.wire-white { stroke: #E9EFF7; }
.wire-black { stroke: #364152; }

/* 2. Botón táctico */
.button-bay { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px; background: var(--recessed); border-radius: 10px; box-shadow: var(--shadow-inset); }
.tactile-btn {
  flex: 1; min-height: 92px; border-radius: 14px; border: 2px solid rgba(255, 255, 255, 0.22);
  font-family: var(--font-mono); font-size: 1.05rem; font-weight: 900; letter-spacing: 0.1em;
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: none;
  box-shadow: 0 7px 0 rgba(0, 0, 0, 0.65), inset 0 2px 3px rgba(255, 255, 255, 0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tactile-btn.holding, .tactile-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), inset 0 2px 4px rgba(0, 0, 0, 0.35); }
.tbtn-red { background: linear-gradient(180deg, #FF3B5C 0%, #C81031 100%); color: #FFF; }
.tbtn-blue { background: linear-gradient(180deg, #2D96FF 0%, #0D5BB8 100%); color: #FFF; }
.tbtn-yellow { background: linear-gradient(180deg, #FFC928 0%, #D99200 100%); color: #141414; }
.tbtn-white { background: linear-gradient(180deg, #F1F5FA 0%, #BAC5D4 100%); color: #10151F; }
.led-strip { width: 24px; height: 92px; border-radius: 8px; background: #141923; border: 1px solid var(--border-hi); box-shadow: var(--shadow-inset); transition: background-color 0.15s ease, box-shadow 0.15s ease; }
.strip-blue { background: #1E88FF; box-shadow: 0 0 18px #1E88FF; }
.strip-yellow { background: #FFB800; box-shadow: 0 0 18px #FFB800; }
.strip-red { background: #FF2A4B; box-shadow: 0 0 18px #FF2A4B; }
.strip-white { background: #F1F5FA; box-shadow: 0 0 18px rgba(241, 245, 250, 0.9); }
.module-hint { font-size: 0.74rem; color: var(--muted); text-align: center; font-family: var(--font-mono); }

/* 3. Teclado de glifos */
.glyphs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.glyph-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  min-height: 76px; padding: 8px; border-radius: 10px;
  background: linear-gradient(180deg, #20283A 0%, #151B27 100%);
  border: 1px solid var(--border-hi); color: var(--text); cursor: pointer;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08); touch-action: manipulation;
}
.glyph-btn svg { width: 34px; height: 34px; }
.glyph-btn.pressed { background: rgba(0, 230, 118, 0.14); border-color: var(--green); color: var(--green); transform: translateY(2px); box-shadow: var(--shadow-inset); }
.glyph-led { width: 24px; height: 4px; border-radius: 2px; background: #2C3546; }
.glyph-btn.pressed .glyph-led { background: var(--green); box-shadow: 0 0 8px var(--green); }

/* 4. Secuencia de memoria */
.memory-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.memory-screen {
  flex: 1; height: 64px; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; background: var(--recessed); box-shadow: var(--shadow-inset);
  font-family: var(--font-mono); font-size: 2.1rem; font-weight: 900; color: var(--cyan); text-shadow: 0 0 12px rgba(0, 229, 255, 0.45);
}
.memory-stages { display: flex; flex-direction: column; gap: 5px; padding: 6px; background: var(--recessed); border-radius: 8px; }
.stage-pip { width: 10px; height: 10px; border-radius: 50%; background: #262E3D; }
.stage-pip.done { background: var(--green); box-shadow: 0 0 7px var(--green); }
.stage-pip.current { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.memory-keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mem-btn {
  min-height: 54px; border-radius: 9px; background: linear-gradient(180deg, #222B3E 0%, #161C29 100%);
  border: 1px solid var(--border-hi); color: var(--text); font-family: var(--font-mono);
  font-size: 1.25rem; font-weight: 800; cursor: pointer; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.55); touch-action: manipulation;
}
.mem-btn:active { transform: translateY(2px); }

/* 5. Matriz de interruptores */
.switches-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.switch-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; border-radius: 9px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.switch-tag { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.switch-toggle { position: relative; width: 44px; height: 62px; border-radius: 8px; background: #1A2130; border: 1px solid var(--border-hi); cursor: pointer; padding: 0; touch-action: manipulation; }
.switch-lever {
  position: absolute; left: 5px; right: 5px; height: 26px; bottom: 5px; border-radius: 5px;
  background: linear-gradient(180deg, #525E74 0%, #2F384A 100%); border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.16s ease, background 0.16s ease;
}
.switch-toggle.on .switch-lever { transform: translateY(-24px); background: linear-gradient(180deg, #2EFF9B 0%, #00B85C 100%); }
.switch-state-txt { font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.switch-slot.is-on .switch-state-txt { color: var(--green); }
.btn-module-confirm {
  min-height: 46px; border-radius: 9px; border: 1px solid rgba(255, 176, 0, 0.45);
  background: rgba(255, 176, 0, 0.14); color: var(--amber); font-family: var(--font-mono);
  font-size: 0.86rem; font-weight: 800; letter-spacing: 0.08em; cursor: pointer; touch-action: manipulation;
}
.btn-module-confirm:active { background: rgba(255, 176, 0, 0.28); }

/* 6. Sintonizador de frecuencia */
.freq-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.freq-readout { font-family: var(--font-mono); font-size: 1.45rem; font-weight: 800; color: var(--cyan); }
.freq-beacon-wrap { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.freq-beacon { width: 22px; height: 22px; border-radius: 50%; background: #232A38; border: 2px solid #3A4458; transition: background-color 0.06s linear, box-shadow 0.06s linear; }
.freq-beacon.lit { background: var(--amber); border-color: #FFE082; box-shadow: 0 0 18px var(--amber); }
.freq-controls { display: flex; align-items: center; gap: 8px; }
.freq-step-btn {
  min-width: 44px; min-height: 44px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--border-hi); color: var(--text); font-family: var(--font-mono);
  font-size: 1.15rem; font-weight: 800; cursor: pointer; touch-action: manipulation;
}
.freq-slider { flex: 1; accent-color: var(--cyan); height: 36px; cursor: pointer; }

/* Manual táctico de expertos */
.manual-topbar {
  position: sticky; top: 0; z-index: 25;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: var(--radius);
  background: rgba(14, 19, 28, 0.96); backdrop-filter: blur(8px); border: 1px solid var(--border-hi);
}
.manual-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.manual-tools { display: flex; flex-direction: column; gap: 8px; }
.manual-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.manual-tab {
  flex-shrink: 0; min-height: 40px; padding: 6px 12px; border-radius: 8px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  font-family: var(--font-mono); font-size: 0.76rem; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.manual-tab.active { background: rgba(0, 229, 255, 0.14); border-color: var(--cyan); color: var(--cyan); }
.manual-search { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 9px; background: var(--recessed); border: 1px solid var(--border-hi); color: var(--text); font-size: 0.92rem; }
.manual-content { display: flex; flex-direction: column; gap: 14px; }
.manual-card { background: linear-gradient(180deg, #171E2C 0%, #111622 100%); border: 1px solid var(--border-hi); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-panel); }
.manual-card h3 { margin: 0 0 6px; font-family: var(--font-mono); font-size: 1.05rem; color: var(--cyan); letter-spacing: 0.05em; }
.manual-card .manual-intro { margin: 0 0 12px; font-size: 0.88rem; color: var(--muted); }
.rule-block { margin-bottom: 12px; padding: 10px 12px; border-radius: 9px; background: var(--recessed); border: 1px solid var(--border); }
.rule-block h4 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 0.84rem; color: var(--amber); }
.rule-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }

.cbadge { display: inline-block; font-family: var(--font-mono); font-size: 0.76rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; }
.cbadge-red { background: rgba(255, 42, 75, 0.22); color: #FF7A90; border: 1px solid rgba(255, 42, 75, 0.5); }
.cbadge-blue { background: rgba(30, 136, 255, 0.22); color: #74B9FF; border: 1px solid rgba(30, 136, 255, 0.5); }
.cbadge-green { background: rgba(0, 230, 118, 0.2); color: #5BFFAC; border: 1px solid rgba(0, 230, 118, 0.5); }
.cbadge-yellow { background: rgba(255, 184, 0, 0.22); color: #FFD257; border: 1px solid rgba(255, 184, 0, 0.5); }
.cbadge-white { background: rgba(241, 245, 250, 0.18); color: #FFF; border: 1px solid rgba(241, 245, 250, 0.45); }
.cbadge-black { background: rgba(66, 79, 100, 0.45); color: #C8D2E2; border: 1px solid rgba(138, 150, 168, 0.45); }

.manual-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.manual-table th, .manual-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.manual-table th { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }

.glyph-columns-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .glyph-columns-grid { grid-template-columns: repeat(4, 1fr); } }
.glyph-col-box { background: var(--recessed); border: 1px solid var(--border); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.glyph-col-title { font-family: var(--font-mono); font-size: 0.72rem; color: var(--amber); text-align: center; }
.glyph-col-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; background: rgba(255, 255, 255, 0.03); font-size: 0.78rem; }
.glyph-col-item svg { width: 24px; height: 24px; flex-shrink: 0; color: var(--cyan); }
.pulse-code { font-family: var(--font-mono); font-size: 1rem; letter-spacing: 0.14em; color: var(--amber); }

/* Pantalla final de victoria / detonación */
.endgame-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(6, 8, 12, 0.9); backdrop-filter: blur(8px); }
.endgame-card {
  width: 100%; max-width: 460px; padding: 24px 20px; border-radius: 16px;
  background: linear-gradient(180deg, #192130 0%, #10151F 100%);
  border: 2px solid var(--border-hi); text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}
.endgame-card.victory { border-color: var(--green); }
.endgame-card.defeat { border-color: var(--red); }
.endgame-badge { display: inline-block; font-family: var(--font-mono); font-size: 0.74rem; font-weight: 800; padding: 4px 10px; border-radius: 6px; margin-bottom: 10px; letter-spacing: 0.1em; }
.endgame-card.victory .endgame-badge { color: var(--green); background: rgba(0, 230, 118, 0.14); }
.endgame-card.defeat .endgame-badge { color: var(--red); background: rgba(255, 42, 75, 0.16); }
.endgame-card h2 { margin: 0 0 8px; font-family: var(--font-mono); font-size: 1.55rem; }
.endgame-sub { margin: 0 0 18px; color: var(--muted); font-size: 0.92rem; }
.endgame-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.stat-box { padding: 10px; border-radius: 8px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.stat-box span { display: block; font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); }
.stat-box strong { font-family: var(--font-mono); font-size: 1.05rem; color: var(--text); }
.endgame-actions { display: flex; flex-direction: column; gap: 10px; }

/* 7. Simón Desfasado */
.simon-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.simon-pips { display: flex; gap: 6px; padding: 6px 8px; border-radius: 7px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.simon-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.simon-pad {
  min-height: 68px; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer; touch-action: manipulation; opacity: 0.72;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: opacity 0.1s ease, transform 0.08s ease, box-shadow 0.1s ease;
}
.simon-pad:active { transform: translateY(2px); }
.simon-red { background: #B81834; }
.simon-blue { background: #1464C4; }
.simon-green { background: #0C8A4B; }
.simon-yellow { background: #B88000; }
.simon-pad.lit { opacity: 1; }
.simon-red.lit { background: #FF3355; box-shadow: 0 0 22px #FF2A4B; }
.simon-blue.lit { background: #369CFF; box-shadow: 0 0 22px #1E88FF; }
.simon-green.lit { background: #00E676; box-shadow: 0 0 22px #00E676; }
.simon-yellow.lit { background: #FFD028; box-shadow: 0 0 22px #FFB800; }

/* 8. Laberinto Ciego */
.maze-screen { display: flex; justify-content: center; padding: 8px; border-radius: 9px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.maze-svg { width: 100%; max-width: 176px; height: auto; display: block; }
.maze-dpad { display: grid; grid-template-columns: repeat(3, 48px); grid-template-rows: repeat(2, 44px); gap: 6px; justify-content: center; }
.maze-btn {
  border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border-hi); color: var(--text);
  font-size: 1rem; font-weight: 800; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
.maze-btn:active { transform: translateY(2px); }
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.maze-manual-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.maze-manual-card { padding: 8px; border-radius: 8px; background: var(--recessed); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 6px; }

/* 9. Candado de Rodillos */
.pw-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.pw-col { display: flex; flex-direction: column; align-items: stretch; gap: 4px; background: var(--recessed); padding: 6px 4px; border-radius: 8px; box-shadow: var(--shadow-inset); }
.pw-arrow { min-height: 40px; border-radius: 6px; background: var(--panel-2); border: 1px solid var(--border-hi); color: var(--text); font-size: 0.85rem; cursor: pointer; touch-action: manipulation; }
.pw-letter { text-align: center; font-family: var(--font-mono); font-size: 1.35rem; font-weight: 900; color: var(--amber); padding: 4px 0; }
.pw-word-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; font-size: 0.92rem; }
@media (min-width: 560px) { .pw-word-grid { grid-template-columns: repeat(4, 1fr); } }

/* 10. Pantalla Trampa */
.wof-top { display: flex; align-items: center; gap: 8px; }
.wof-screen {
  flex: 1; min-height: 48px; display: flex; align-items: center; justify-content: center;
  border-radius: 8px; background: var(--recessed); box-shadow: var(--shadow-inset);
  font-family: var(--font-mono); font-size: 1.25rem; font-weight: 900; color: var(--cyan); letter-spacing: 0.08em;
}
.wof-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wof-btn {
  min-height: 46px; border-radius: 8px; background: linear-gradient(180deg, #212A3C 0%, #151B28 100%);
  border: 1px solid var(--border-hi); color: var(--text); font-family: var(--font-mono);
  font-size: 0.9rem; font-weight: 800; cursor: pointer; touch-action: manipulation;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
.wof-btn:active { transform: translateY(2px); }

/* 11. Caja de Fusibles */
.fuses-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.fuse-slot {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 70px; padding: 8px 6px; border-radius: 9px;
  background: var(--recessed); border: 1px solid var(--border-hi); color: var(--text);
  cursor: pointer; touch-action: manipulation; box-shadow: var(--shadow-inset);
  transition: transform 0.16s ease, opacity 0.16s ease, border-color 0.16s ease;
}
.fuse-slot.extracted { transform: translateY(-6px); opacity: 0.55; border-color: var(--amber); border-style: dashed; }
.fuse-svg { width: 100%; max-width: 68px; height: auto; }
.fuse-cap { fill: #7E8A9E; }
.fuse-glass { fill: rgba(255, 255, 255, 0.1); stroke: rgba(255, 255, 255, 0.3); stroke-width: 1.2; }
.fuse-wire { stroke: #FFB000; stroke-width: 1.8; }
.fband-red { fill: #FF2A4B; }
.fband-blue { fill: #1E88FF; }
.fband-yellow { fill: #FFB800; }
.fband-white { fill: #F1F5FA; }
.fuse-amp { font-family: var(--font-mono); font-size: 0.78rem; font-weight: 800; }

/* 12. Manómetro de Presión */
.pressure-wrap { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px; border-radius: 9px; background: var(--recessed); box-shadow: var(--shadow-inset); }
.pressure-svg { width: 100%; max-width: 190px; height: auto; }
.gauge-lbl { fill: var(--muted); font-family: var(--font-mono); font-size: 11px; font-weight: 700; }
.pressure-needle { transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1); }
.pressure-readout { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 900; color: var(--amber); }
.pressure-valves { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.valve-btn {
  min-height: 46px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--border-hi);
  color: var(--cyan); font-family: var(--font-mono); font-size: 1rem; font-weight: 800;
  cursor: pointer; touch-action: manipulation; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
.valve-btn:active { transform: translateY(2px); }
