/* Circuitos compactos: los hilos y las barras comparten la tinta del archivo. */
.quantum-game { min-width: 0; }
.quantum-game--circuit { -webkit-tap-highlight-color: transparent; }
.quantum-game p { margin: 0; }
.quantum-game .qg-help { color: var(--ink-2); font-size: 16px; line-height: 1.3; margin-bottom: 12px; }
.qg-button, .qg-bar-row, .qg-coordinates, .quantum-game .qg-label, .quantum-game .qg-instruction, .quantum-game .qg-history, .quantum-game .qg-status { font-family: var(--mono); }
.quantum-game .qg-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; color: var(--ink-3); }
.qg-states { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 0; }
.qg-state { min-width: 0; }
.qg-bar-row { display: flex; align-items: center; gap: 5px; min-height: 15px; font-size: 10.5px; border-left: 2px solid transparent; padding-left: 3px; }
/* Con dos qubits sobra alto: filas más holgadas. */
.qg-qubits-2 .qg-bar-row { min-height: 22px; }
.qg-bar-row--matched { background: var(--surface-2); border-left-color: var(--accent-ink); }
.qg-bar-row--empty { opacity: .48; background: transparent; border-left-color: transparent; }
.qg-row-match { flex: 0 0 10px; color: var(--accent-ink); font-weight: 700; }
.qg-basis { flex: 0 0 auto; }
.qg-bar-track { flex: 1 1 auto; height: 8px; min-width: 12px; background: var(--surface-2); }
.qg-bar-fill { display: block; height: 100%; background: var(--ink-2); transition: width 220ms ease-out; }
.qg-state--target .qg-bar-fill { background: var(--accent); }
.qg-percent { min-width: 29px; text-align: right; }
.qg-phase-dial { position: relative; flex: 0 0 14px; height: 14px; border: 1px solid var(--ink-3); border-radius: 50%; color: var(--ink); }
.qg-phase-needle { position: absolute; left: 50%; top: calc(50% - .5px); width: 6px; height: 1px; background: currentColor; transform-origin: 0 50%; }
.qg-phase-dial::after { content: ''; position: absolute; width: 3px; height: 3px; left: calc(50% - 1.5px); top: calc(50% - 1.5px); border-radius: 50%; background: currentColor; }
.qg-palette, .qg-actions { display: flex; flex-wrap: wrap; gap: 5px; }
/* Puertas y acciones en una sola fila; las acciones se van a la derecha. */
.qg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.quantum-game--circuit .qg-actions { margin: 0 0 0 auto; }
.quantum-game [hidden] { display: none !important; }
.qg-button { min-height: 34px; border: 1px solid var(--line); color: var(--ink); background: var(--surface); padding: 5px 10px; border-radius: 0; font-size: 11px; cursor: pointer; }
.qg-button:hover:not(:disabled), .qg-button[aria-pressed="true"] { color: var(--accent-ink); border-color: var(--accent); background: var(--surface-2); }
.qg-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qg-button:disabled { opacity: .5; cursor: default; }
.quantum-game .qg-instruction { margin: 5px 0; font-size: 11px; line-height: 1.5; color: var(--ink-2); }
/* Papel plano: las puertas son tipos enmarcados, sin relieve. */
.qg-circuit { max-width: 100%; min-width: 0; overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; border-block: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.qg-circuit-board { position: relative; min-width: 100%; font-family: var(--mono); }
.quantum-game .qg-wire { display: flex; position: absolute; align-items: center; width: 100%; height: 48px; padding: 0 12px 0 6px; border: 0; background: transparent; border-radius: 0; color: var(--ink); font: 10px var(--mono); text-align: left; touch-action: manipulation; }
.qg-wire-label { flex: 0 0 57px; }
.qg-wire-line { flex: 1; border-top: 1px solid var(--ink-3); }
.quantum-game .qg-wire:disabled { opacity: 1; }
.quantum-game button.qg-wire:hover:not(:disabled), .quantum-game .qg-wire--control { background: var(--surface-2); }
.qg-wire--control .qg-wire-label { color: var(--accent-ink); font-weight: 700; }
.quantum-game .qg-placed { position: absolute; display: grid; place-items: center; width: 44px; min-height: 44px; max-width: none; padding: 0; border: 0; background: transparent; color: var(--ink); z-index: 1; touch-action: none; user-select: none; cursor: grab; }
.qg-gate-stamp { display: grid; place-items: center; width: 34px; height: 34px; border: 1.5px solid currentColor; background: var(--surface); font: 16px var(--mono); }
.quantum-game .qg-placed:disabled { opacity: 1; cursor: default; touch-action: auto; }
.quantum-game .qg-placed[aria-pressed="true"] { background: transparent; color: var(--accent-ink); outline: 1px dashed var(--accent-ink); outline-offset: 1px; }
.qg-cnot-link { position: absolute; left: 21px; top: 22px; bottom: 22px; width: 1.5px; background: currentColor; }
.qg-cnot-control { position: absolute; left: 22px; width: 9px; height: 9px; transform: translate(-50%, -50%); border-radius: 50%; background: currentColor; }
.qg-cnot-target { position: absolute; left: 22px; width: 23px; height: 23px; transform: translate(-50%, -50%); border: 1.5px solid currentColor; border-radius: 50%; background: var(--surface); }
.qg-cnot-target::before, .qg-cnot-target::after { content: ''; position: absolute; background: currentColor; }
.qg-cnot-target::before { left: 50%; top: 0; width: 1.5px; height: 100%; transform: translateX(-50%); }
.qg-cnot-target::after { left: 0; top: 50%; width: 100%; height: 1.5px; transform: translateY(-50%); }
.qg-moment { position: absolute; left: 0; bottom: 7px; width: 24px; text-align: center; font: 9px var(--mono); color: var(--ink-3); }
.qg-drop-marker { position: absolute; z-index: 2; width: 34px; height: 34px; display: grid; place-items: center; border: 1px dashed var(--accent-ink); color: var(--accent-ink); background: var(--surface); font: 17px var(--mono); pointer-events: none; }
.qg-drop-marker[hidden], .qg-drag-ghost[hidden] { display: none; }
.quantum-game--circuit .qg-palette button { width: 38px; height: 38px; padding: 0; border-color: var(--ink-2); background: var(--surface); font-size: 15px; touch-action: none; user-select: none; cursor: grab; }
.quantum-game--circuit .qg-palette button[data-gate="CNOT"] { width: 52px; font-size: 11px; }
.quantum-game--circuit .qg-palette button:disabled { cursor: default; touch-action: auto; }
.quantum-game--circuit .qg-palette button[aria-pressed="true"] { border-bottom: 3px solid var(--accent-ink); color: var(--accent-ink); }
.qg-dragging, .qg-dragging button { cursor: grabbing; }
.qg-drag-ghost { position: fixed; z-index: 1000; width: 48px; height: 38px; display: grid; place-items: center; background: var(--surface); border: 1.5px solid var(--accent-ink); color: var(--accent-ink); font: 13px var(--mono); pointer-events: none; }
.quantum-game .qg-delete-hint { margin-top: 10px; min-height: 28px; padding: 5px 7px; border: 1px dashed var(--line); font: 10px/1.5 var(--mono); color: var(--ink-3); }
.quantum-game .qg-delete-hint[data-active="true"] { border-color: var(--accent-ink); color: var(--accent-ink); background: var(--surface-2); }
/* La línea de ayuda del arrastre solo aparece mientras se arrastra. */
.qg-finished .qg-delete-hint, .quantum-game:not(.qg-dragging) .qg-delete-hint { display: none; }
.quantum-game .qg-circuit--mini .qg-placed { cursor: default; touch-action: auto; }
.qg-circuit--mini { margin-bottom: 12px; }
.quantum-game .qg-history { font-size: 10.5px; color: var(--ink-3); margin: 8px 0; overflow-wrap: anywhere; }
.quantum-game .qg-status { font-size: 11px; line-height: 1.6; margin: 9px 0; }
/* Instrucción y contador en la misma línea, encima del circuito. */
.qg-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 14px; }
.quantum-game--circuit .qg-status { margin: 5px 0 5px auto; color: var(--ink-2); }
.qg-actions { margin-top: 10px; }
/* Un qubit: esfera a la izquierda y controles a la derecha, para que mida como los otros juegos. */
.quantum-game--sphere { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 0 20px; align-items: center; }
.quantum-game--sphere .qg-side { min-width: 0; }
.quantum-game--sphere .qg-history { font-size: 13px; color: var(--ink-2); margin: 14px 0 4px; }
.quantum-game--sphere .qg-solution { border-top: 0; margin-top: 14px; padding-top: 0; }
.qg-sphere { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; }
.qg-sphere svg { width: 100%; max-width: 340px; display: block; color: var(--ink); overflow: visible; }
.qg-sphere svg text { fill: currentColor; font-size: 14px; font-family: var(--mono); }
.qg-sphere-outline, .qg-sphere-grid, .qg-sphere-axis { fill: none; stroke: var(--line); stroke-width: 1; }
.qg-sphere-outline { stroke: var(--axis); }
.qg-sphere-axis { stroke: var(--ink-3); stroke-dasharray: 2 4; }
.qg-target-vector { stroke: var(--accent-ink); stroke-width: 2; stroke-dasharray: 4 3; }
.qg-target-dot { fill: var(--surface); stroke: var(--accent-ink); stroke-width: 3; }
.qg-current-vector { stroke: var(--ink); stroke-width: 1.5; }
.qg-current-dot { fill: var(--ink); stroke: var(--surface); stroke-width: 1.5; transition: transform 240ms ease-out; }
.qg-sphere-legend { display: flex; justify-content: center; gap: 18px; font: 11px/1.5 var(--mono); }
.qg-coordinates { min-width: 0; font-size: 10.5px; line-height: 1.7; text-align: center; color: var(--ink-3); }
.qg-coordinates summary { cursor: pointer; padding: 5px; }
.quantum-game .qg-coordinates p { font-family: var(--mono); }
.qg-target-key { color: var(--accent-ink); }
.qg-current-key { color: var(--ink); }
.qg-solution { margin-top: 12px; }
.quantum-game .qg-solution .qg-help { font: 12px/1.7 var(--mono); overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .qg-current-dot, .qg-bar-fill { transition: none; }
}
@media (max-width: 600px) {
  .qg-states { gap: 10px; }
  .qg-bar-row { font-size: 10px; gap: 3px; padding-left: 1px; }
  .qg-percent { min-width: 25px; }
  .qg-phase-dial { flex-basis: 14px; height: 14px; }
  .qg-phase-needle { width: 6px; }
  .quantum-game--circuit .qg-palette { gap: 4px; }
  .quantum-game--circuit .qg-palette button { width: 40px; }
  .quantum-game--circuit .qg-palette button[data-gate="CNOT"] { width: 53px; }
  .quantum-game--sphere { grid-template-columns: minmax(0, 1fr); }
  .qg-sphere svg { max-width: 280px; }
  .qg-coordinates { font-size: 10.5px; }
}
