/* ===== RESET ===== */
* {
  box-sizing: border-box;
  font-family: system-ui, sans-serif;
}

body {
  background: #000;
  color: #fff;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
}
/*----Test-----*/

#quiz-container{
    position: fixed;
    top: 0;
    left: 0;

    width: 100%;
    height: 100%;

    background: #6a6a6a;

    display: none;

    justify-content: center;
    align-items: center;
    flex-direction: column;

    z-index: 9999;

    color: white;
    text-align: center;
}

#quiz-container button{
    margin: 10px;
    padding: 12px 20px;
    font-size: 16px;
}

#quiz-feedback{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 220px;
    padding: 18px 28px;
    border-radius: 16px;
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    background: rgba(24, 24, 24, 0.72);
    backdrop-filter: blur(4px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.adblock-warning {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 10000;
}

.adblock-warning.is-visible {
  display: flex;
}

.adblock-warning__card {
  width: min(100%, 520px);
  padding: 28px 24px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  background: #161616;
  color: #fff;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.adblock-warning__card h2 {
  margin: 0 0 12px;
  font-size: 28px;
  line-height: 1.15;
}

.adblock-warning__card p {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.84);
}

.quiz-feedback--correcto{
    background: rgba(28, 140, 82, 0.78) !important;
}

.quiz-feedback--incorrecto{
    background: rgba(186, 48, 48, 0.78) !important;
}

.site-header {
  display: flex;
  justify-content: center;
  padding: 14px 16px 4px;
}

.site-title {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px;
  margin: 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.title-color {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0.72em;
  height: 1em;
  border-radius: 6px;
  color: #000;
  text-shadow: none;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.16);
}

.site-title .nonmetal {
  border: 1px solid rgba(0, 0, 0, 0.22);
}

/* ===== CONTROLES ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px 4px;
  min-height: 50px;
}

select,
button {
  background: #111;
  color: #fff;
  border: 1px solid #333;
  padding: 8px 14px;
  cursor: pointer;
}

button:hover,
select:hover {
  background: #222;
}

/* ===== VARIABLES (AJUSTE FINO DE TAMAÑO) ===== */
:root {
  --cell: clamp(44px, 4vw, 60px);
  --gap: 6px;
  --shell-max-width: 1800px;
  --rail-width: 160px;
  --rail-offset: 12px;
  --page-padding: 16px;
  --table-bottom-padding: 64px;
  --desktop-bottom-banner-height: 250px;
  --desktop-bottom-banner-width: 990px;
}

.page-shell {
  width: 100%;
  max-width: var(--shell-max-width);
  margin: 0 auto;
  padding: 0px var(--page-padding) 8px;
  position: relative;
}

.page-main {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  min-width: 0;
}

.support-mobile-top {
  display: none;
  margin: 0 auto 12px;
  max-width: 360px;
}

.support-bottom-wide {
  display: none;
}

.support-rail {
  display: none;
  width: var(--rail-width);
  margin-top: 0;
}

.support-rail-sticky {
  position: static;
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 858px;
}

.support-rail .support-label {
  display: none;
}

.support-label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.support-slot {
  width: 100%;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    rgba(16, 16, 16, 0.9);
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 8px;
}

.support-slot span {
  font-size: 11px;
  letter-spacing: 0.04em;
}

.support-slot--tower {
  height: 600px;
  min-height: 600px;
  flex: 0 0 600px;
}

.support-slot--compact {
  min-height: 250px;
  height: 250px;
  flex: 0 0 250px;
}

.support-slot--bottom {
  min-height: var(--desktop-bottom-banner-height);
}

.support-slot--mobile {
  min-height: 100px;
}

/* ===== CONTENEDOR TABLA ===== */
.table-wrapper {
  width: 100%;
  height: calc(100vh - 92px);
  max-height: calc(100vh - 92px);
  overflow-x: auto;
  overflow-y: hidden;
  -ms-overflow-style: auto;

  display: flex;
  justify-content: flex-start;
  align-items: flex-start;

  padding: 16px 0 var(--table-bottom-padding);
}

.table-wrapper::-webkit-scrollbar {
  width: 10px;
  height: 12px;
}

.table-wrapper::-webkit-scrollbar:vertical {
  width: 0;
}

.table-wrapper::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.28);
  border-radius: 999px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.table-viewport {
  position: relative;
  width: max-content;
  min-width: max-content;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  transform-origin: center top;
}

/* ===== TABLA ===== */
.periodic-table {
  display: grid;
  grid-template-columns: repeat(18, var(--cell));
  grid-template-rows: repeat(9, var(--cell));
  gap: var(--gap);
  transform-origin: center top;
}


/* ===== ELEMENTOS ===== */
.element {
  position: relative;
  height: 100%;
  padding: 6px;
  line-height: 1.1;
  border-radius: 8px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  text-align: center;
  color: #000;
  text-decoration: none;
  transition: transform .25s ease, box-shadow .25s ease;
  z-index: 1;
}

.element .number {
  font-size: 11px;
  align-self: flex-start;
}

.element .symbol {
  font-size: 22px;
  line-height: 1;
}

.element .name {
  font-size: 10px;
  text-align: center;
}

/* HOVER */
.element:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 0 16px rgba(255, 255, 255, .35);
  z-index: 10;
}

/* ===== TEXTO INTERNO ===== */
.element span {
  font-size: 9px;
  text-align: left;
}

.element .masa {
  position: absolute;
  top: 4px;
  right: 4px;

  font-size: 7px;
  font-weight: 500;
  opacity: 0.85;

  pointer-events: none;
}

.element strong {
  font-size: clamp(15px, 1.5vw, 20px);
  line-height: 1;
}

.element em {
  font-size: 8px;
  font-style: normal;
  opacity: 0.85;
}

/* ===== COLORES ===== */
.alkali {
  background: #ff6b6b;
}

.alkaline {
  background: #feca57;
}

.transition {
  background: #48dbfb;
}

.post {
  background: #1dd1a1;
}

.metalloid {
  background: #a29bfe;
}

.nonmetal {
  background: #ffffff;
}

.halogen {
  background: #54a0ff;
}

.noble {
  background: #00d2d3;
}

.lanthanoid {
  background: #ff9ff3;
}

.actinoid {
  background: #c8d6e5;
}

/* ===== LABELS ===== */
.label {
  grid-column: span 3;
  align-self: center;
  text-align: right;
  padding-right: 8px;
  font-size: 11px;
  opacity: 0.75;
}

/* ===== ESPACIADO SERIES ===== */

/* Grupo 3 – posiciones clásicas */

[data-number="57"] {
  grid-column: 3;
  grid-row: 6;
}

[data-number="89"] {
  grid-column: 3;
  grid-row: 7;
}

[data-number="58"] { grid-column: 3; grid-row: 8; }
[data-number="59"] { grid-column: 4; grid-row: 8; }
[data-number="60"] { grid-column: 5; grid-row: 8; }
[data-number="61"] { grid-column: 6; grid-row: 8; }
[data-number="62"] { grid-column: 7; grid-row: 8; }
[data-number="63"] { grid-column: 8; grid-row: 8; }
[data-number="64"] { grid-column: 9; grid-row: 8; }
[data-number="65"] { grid-column: 10; grid-row: 8; }
[data-number="66"] { grid-column: 11; grid-row: 8; }
[data-number="67"] { grid-column: 12; grid-row: 8; }
[data-number="68"] { grid-column: 13; grid-row: 8; }
[data-number="69"] { grid-column: 14; grid-row: 8; }
[data-number="70"] { grid-column: 15; grid-row: 8; }
[data-number="71"] { grid-column: 16; grid-row: 8; }

[data-number="90"]  { grid-column: 3;  grid-row: 9; }
[data-number="91"]  { grid-column: 4;  grid-row: 9; }
[data-number="92"]  { grid-column: 5;  grid-row: 9; }
[data-number="93"]  { grid-column: 6;  grid-row: 9; }
[data-number="94"]  { grid-column: 7;  grid-row: 9; }
[data-number="95"]  { grid-column: 8;  grid-row: 9; }
[data-number="96"]  { grid-column: 9;  grid-row: 9; }
[data-number="97"]  { grid-column: 10; grid-row: 9; }
[data-number="98"]  { grid-column: 11; grid-row: 9; }
[data-number="99"]  { grid-column: 12; grid-row: 9; }
[data-number="100"] { grid-column: 13; grid-row: 9; }
[data-number="101"] { grid-column: 14; grid-row: 9; }
[data-number="102"] { grid-column: 15; grid-row: 9; }
[data-number="103"] { grid-column: 16; grid-row: 9; }

/* Oganesón (118) debajo del 86 */
[data-number="118"] {
  grid-column: 18;
}

.bottom-spacer {
  grid-column: 1 / -1;
  height: 24px;
  /* margen inferior real */
}

.element::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .75);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  z-index: 20;
}

.element:target {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%) scale(1);
  z-index: 30;
  box-shadow: 0 25px 60px rgba(0, 0, 0, .8);
  pointer-events: auto;
}

.element:target::before {
  opacity: 1;
  pointer-events: auto;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 18px;
  color: #fff;
  opacity: 0;
  pointer-events: none;
}

.element:target .close-btn {
  opacity: 1;
  pointer-events: auto;
}

.element {
  transition:
    transform .35s cubic-bezier(.2, .8, .2, 1),
    box-shadow .35s ease;
}

.element-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  z-index: 50;
}

.element-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.element-modal:target {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: absolute;
  top: 50%;
  left: 50%;

  width: 80vw;
  height: 80vh;
  max-width: 900px;
  max-height: 600px;

  transform: translate(-50%, -50%) scale(.7);
  animation: modalOpen .4s forwards;

  background: #ffffff;
  color: #111;

  border-radius: 18px;
  padding: 32px;

  display: flex;
  flex-direction: column;
  justify-content: left;
  align-items: left;

  box-shadow: 0 40px 80px rgba(0, 0, 0, .45);
}

.modal-card h2 {
  margin: 0 0 12px;
  font-size: 32px;
}

.modal-card p {
  margin: 6px 0;
  font-size: 16px;
}

.modal-header{
   display: flex;
  flex-direction: row;
    gap: 20px;
}

@keyframes modalOpen {
  to {
    transform: translate(-50%, -50%) scale(1);
  }
}

.close {
  position: absolute;
  top: 18px;
  right: 22px;
  font-size: 22px;
  color: #111;
  text-decoration: none;
}

.element-modal:target~body {
  overflow: hidden;
}


.element.disabled {
  opacity: 0.2;
  pointer-events: none;
  filter: grayscale(100%);
}

@media (max-width: 1699px) {
  .support-rail {
    display: none;
  }
}

@media (min-width: 1280px) {
  #quiz-container {
    left: calc(max((100vw - var(--shell-max-width)) / 2, 0px) + var(--page-padding) + var(--rail-width) + 24px);
    width: calc(100vw - ((max((100vw - var(--shell-max-width)) / 2, 0px) + var(--page-padding) + var(--rail-width) + 24px) * 2));
  }

  .page-shell {
    display: grid;
    grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--rail-width);
    gap: 12px;
    align-items: start;
    margin-bottom: 48px;
  }

  .support-rail {
    display: block;
    margin-top: -118px;
  }

  .page-main {
    margin-top: 8px;
  }

  .table-wrapper {
    height: auto;
    max-height: none;
    padding-top: 8px;
  }
}

@media (max-width: 767px) {
  .site-header {
    padding: 12px 10px 6px;
  }

  .site-title {
    flex-wrap: nowrap;
    gap: 2px;
    font-size: clamp(26px, 7.8vw, 34px);
  }

  .title-color {
    min-width: 0.62em;
    border-radius: 5px;
  }

  .page-shell {
    padding-left: 10px;
    padding-right: 10px;
  }

  .controls {
    gap: 8px;
  }

  .controls select,
  .controls button {
    width: 100%;
    text-align: center;
  }

  .controls select {
    text-align-last: center;
  }

  .support-mobile-top {
    display: block;
  }

  .support-bottom-wide {
    display: none;
  }

  .table-wrapper {
    position: relative;
    overflow-x: auto;
    overflow-y: hidden;
    min-height: 72vh;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    background:
      radial-gradient(circle at top, rgba(255, 255, 255, 0.05), transparent 40%),
      rgba(8, 8, 8, 0.92);
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
  }

  .table-viewport {
    min-height: calc(72vh - 24px);
    justify-content: flex-start;
    align-items: flex-start;
    transform: none !important;
  }

  .periodic-table {
    flex: 0 0 auto;
  }
}

@media (hover: none) and (pointer: coarse) {
  .element:hover {
    transform: none;
    box-shadow: none;
  }
}

@page {
  size: landscape;
  margin: 8mm;
}

@media print {
  :root {
    --cell: 1.18cm;
    --gap: 0.06cm;
    --table-bottom-padding: 0;
  }

  html,
  body {
    width: auto;
    height: 100%;
    min-height: 100%;
    overflow: visible !important;
    background: #fff !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    forced-color-adjust: none;
  }

  body * {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    forced-color-adjust: none;
  }

  .controls,
  #quiz-container,
  .support-mobile-top,
  .support-bottom-wide,
  .support-rail,
  .element-modal,
  .overlay,
  .close {
    display: none !important;
  }

  .page-shell,
  .page-main {
    display: block !important;
    min-height: 100vh !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
  }

  .table-wrapper {
    width: 100% !important;
    min-height: calc(100vh - 16mm) !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #fff !important;
  }

  .table-wrapper::-webkit-scrollbar {
    display: none !important;
    position: relative; 
  }

  .table-viewport {
    width: auto !important;
    min-width: 0 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: flex-start !important;
    transform: none !important;
    background: #fff !important;
  }

  .periodic-table {
    display: grid !important;
    margin: 0 auto !important;
    background: #fff !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .element {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none !important;
    transform: none !important;
    border: 0.02cm solid rgba(0, 0, 0, 0.18);
  }

  .element span {
    font-size: 0.20cm;
  }

  .element strong {
    font-size: 0.46cm;
  }

  .element em {
    font-size: 0.16cm;
    opacity: 1;
  }
}

@media print {
  .element .masa {
    font-size: 6px;
  }
}

.controls {
  position: relative;

  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;

  margin: 6px 0 6px; /* separación con la tabla */
  z-index: 10; /* por si algo se encimaba */
}

.legend-box {
  position: absolute;
  top: 18px;
  right: 24px;
  width: 200px;
  z-index: 5;
  background: rgba(25, 25, 35, 0.9);
  border: 1px solid #c0c0c0;
  border-radius: 12px;
  padding: 12px;
}

.legend-title {
  text-align: center;
  font-size: 12px;
  margin-bottom: 8px;
  color: #ccc;
} 

.legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}


.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;

  font-size: 11px;
  color: white;
}

.color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.color.alkali { background: #ff6b6b; }
.color.alkaline { background: #feca57; }
.color.transition { background: #48dbfb; }
.color.post { background: #1dd1a1; }
.color.metalloid { background: #a29bfe; }
.color.nonmetal { background: #ffffff; }
.color.halogen { background: #54a0ff; }
.color.noble { background: #00d2d3; }
.color.lanthanoid { background: #ff9ff3; }
.color.actinoid { background: #c8d6e5; }

@media print {
  .legend-box {
    background: white !important;
    border: 1px solid black !important;
    color: black !important; 

    backdrop-filter: none !important;
    box-shadow: none !important;
  }

  .legend-title {
    color:#535353
     }

  .legend-item {
    color: black !important;
  }
}


/* ===== GUÍA ELEMENTO ===== */
.element-guide {
  position: absolute;
  top: 18px;
  left: 24px;
  z-index: 5;
}

body.quiz-open .element-guide,
body.quiz-open .legend-box,
body.modal-open .element-guide,
body.modal-open .legend-box {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Tarjeta */
.guide-card {
  position: relative;
  width: 100px;
  height: 100px;
  border: 2px solid #000;
  border-radius: 16px;
  background: #fff;
  text-align: center;
  font-family: sans-serif;
  color: #000;
}

/* Contenido */
.guide-number {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 14px;
}

.guide-mass {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 12px;
}

.guide-symbol {
  font-size: 50px;
  font-weight: bold;
  line-height: 100px;
}

.guide-name {
  position: absolute;
  bottom: 6px;
  width: 100%;
  font-size: 14px;
}

/* Labels */
.guide-label {
  position: absolute;
  font-size: 10px;
  white-space: nowrap;
  color: inherit;
}

/* Posiciones */
.guide-label.number {
  top: 10px;
  left: -110px;
}

.guide-label.mass {
  top: 10px;
  right: -110px;
}

.guide-label.symbol {
  top: 60px;
  left: -80px;
}

.guide-label.name {
  bottom: 10px;
  right: -80px;
}

/* ===== LÍNEAS ===== */
.line {
  position: absolute;
  height: 1px;
  background: currentColor;
}

/* cada línea apunta a su parte */
.number-line {
  top: 18px;
  left: -60px;
  width: 60px;
}

.mass-line {
  top: 18px;
  right: -60px;
  width: 60px;
}

.symbol-line {
  top: 70px;
  left: -40px;
  width: 40px;
}

.name-line {
  bottom: 18px;
  right: -40px;
  width: 40px;
}

/* ===== MODO OSCURO (APP) ===== */
@media (prefers-color-scheme: dark) {
  .guide-card {
    background: #ffffff;
    border: 2px solid #000000;
    color: #000000;
  }

  .element-guide {
    color: #fff;
  }
}

/* ===== IMPRESIÓN ===== */
@media print {
  .guide-card {
    background: white !important;
    color: black !important;
    border: 2px solid black;
  }

  .line {
    background: black;
  }
}

@media print {
  .guide-label {
    color: black !important;
  }
}

.line {
  z-index: 1;
}

.guide-label {
  z-index: 2;
  background: white; /* 👈 esto evita que la línea atraviese el texto */
  padding: 0 2px;
}

@media (prefers-color-scheme: dark) {
  .guide-label {
    background: #111;
    color: white;
  }
}

@media print {
  .line {
    opacity: 0.6;
  }
}

@media print {
  .guide-label {
    color: black !important;
    background: transparent !important; 
    padding: 0; 
  }
}

.number-line,
.mass-line {
  top: 24px;
}

.guide-label.number,
.guide-label.mass {
  top: 6px;
}

@media print {

   /* ===== LÍNEAS (solo posición) ===== */
  .number-line {
    top: 18px;
    left: -25px;
    width: 30px;
  }

  .mass-line {
    top: 19px;
    right: -110px;
    width: 30px;
  }

  .symbol-line {
    top: 48px;
    left: -22px;
    width: 22px;
  }

  .name-line {
    bottom: 5px;
    right: -105px;
    width: 22px;
  }

  /* 👉 más a la derecha todavía */
  .element-guide {
  left: 255px;
  }

  /* 👉 cuadro más pequeño */
  .guide-card {
    width: 85px;
    height: 85px;
  }

  /* 👉 contenido proporcional */
  .guide-symbol {
    font-size: 28px;
    line-height: 85px;
  }

  .guide-number {
    font-size: 9px;
  }

  .guide-mass {
    font-size: 6px;
  }

  .guide-name {
    font-size: 9px;
  }

 /* ===== LABELS (solo posición) ===== */
  .guide-label.number {
    top: 4px;
    left: -91px;
  }

  .guide-label.mass {
    top: 4px;
    right: -148px;
  }

  .guide-label.symbol {
    top: 29px;
    left: -50px;
  }

  .guide-label.name {
    bottom: 9px;
    right: -130px;
  }


  
  
 /* 👉 ajustar líneas para que conecten bien */
  .number-line,
  .mass-line {
    width: 26px; /* antes 38px → muy largo */
  }

  .symbol-line {
    top: 45px;
    width: 24px;
  }

  .name-line {
    bottom: 10px;
    width: 24px;
  }

  
}

/* ===== AJUSTE FINAL GUÍA/LEYENDA ===== */
.table-viewport .element-guide {
  top: calc(var(--cell) * 0.2);
  left: calc((var(--cell) * 5.6) - 50px);
  right: auto;
  transform: none;
  z-index: 5;
}

.table-viewport .legend-box {
  top: calc(var(--cell) * 0.2);
  left: calc((var(--cell) * 10.3) - 50px);
  right: auto;
  transform: none;
  z-index: 5;
}

body.quiz-open .element-guide,
body.quiz-open .legend-box,
body.modal-open .element-guide,
body.modal-open .legend-box {
  display: none !important;
}

@media print {
  :root {
    --cell: 0.98cm;
    --gap: 0.04cm;
  }

  .element-guide,
  .legend-box {
    display: none !important;
  }

  .table-viewport {
    padding-top: 0 !important;
  }
}

@media print {

  /* ❌ Oculta TODO */
  body * {
    visibility: hidden !important;
  }

  /* ✅ Solo muestra tu tabla */
  .print-area,
  .print-area * {
    visibility: visible !important;
  }

  /* Ajusta posición */
  .print-area {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }

  /* Por si quedan restos raros */
  iframe,
  ins,
  aside,
  [class*="ad"],
  [id*="ad"] {
    display: none !important;
  }
}

@media print {
  .table-wrapper {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
  }
}

@media screen {
  .table-viewport {
    --guide-row-height: 124px;
  }

  .table-viewport .periodic-table {
    margin-top: var(--guide-row-height);
  }

  .table-viewport .element-guide,
  .table-viewport .legend-box {
    top: 8px;
  }

  .table-viewport .element-guide {
    left: calc((var(--cell) * 5.6) - 50px);
    color: #f7f7f7;
  }

  .table-viewport .legend-box {
    left: calc((var(--cell) * 10.3) - 50px);
    width: 210px;
    max-width: 210px;
    background: rgba(18, 18, 28, 0.96);
    border-color: rgba(255, 255, 255, 0.72);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
  }

  .guide-card {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
    forced-color-adjust: none;
  }

  .guide-label {
    color: #ffffff;
    background: #050505;
    border-radius: 2px;
    forced-color-adjust: none;
  }

  .guide-label.number {
    left: -82px;
  }

  .guide-label.mass {
    right: -82px;
  }

  .guide-label.symbol {
    left: -58px;
  }

  .guide-label.name {
    right: -58px;
  }

  .number-line,
  .mass-line {
    width: 42px;
  }

  .symbol-line,
  .name-line {
    width: 28px;
  }

  .line {
    color: #ffffff;
  }
}

@media screen and (max-width: 767px) {
  .table-viewport {
    --guide-row-height: 156px;
  }

  .table-viewport .legend-box {
    width: 206px;
    max-width: 206px;
    padding: 10px;
  }

  .legend {
    gap: 4px 6px;
  }

  .legend-item {
    font-size: 10px;
    gap: 5px;
  }

  .color {
    width: 11px;
    height: 11px;
    flex: 0 0 11px;
  }
}

.learning-section {
  width: 100%;
  padding: 36px 16px 8px;
  background: #050505;
  color: #f7f7f7;
}

.learning-section__inner {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.learning-section h2,
.legal-page h1 {
  margin: 0 0 14px;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.1;
}

.learning-section p,
.legal-page p {
  margin: 0 0 16px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.65;
}

.learning-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.learning-grid article {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #101010;
}

.learning-grid h2,
.legal-page h2 {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.25;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 22px 16px 34px;
  color: rgba(255, 255, 255, 0.72);
}

.site-footer p {
  margin: 0;
  font-weight: 700;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
}

.site-footer a,
.legal-page a {
  color: #66ccff;
}

.legal-page {
  width: min(100% - 32px, 840px);
  margin: 0 auto;
  padding: 56px 0;
  color: #fff;
}

.legal-page h2 {
  margin-top: 28px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 28px;
  text-decoration: none;
}

.updated-note {
  margin-top: 28px;
  font-size: 14px;
}

@media (max-width: 767px) {
  .learning-grid {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-footer nav {
    justify-content: flex-start;
  }
}

@media (min-width: 1280px) and (max-height: 900px) {
  .support-rail-sticky {
    height: 850px;
  }

  .support-slot--tower {
    height: 592px;
    min-height: 592px;
    flex-basis: 592px;
  }
}

@media (min-width: 1280px) and (max-height: 760px) {
  .support-rail-sticky {
    height: calc(100vh + 128px);
  }

  .support-slot--tower {
    height: calc(100vh - 132px);
    min-height: 430px;
    flex: 1 1 auto;
  }

  .support-slot--compact {
    flex: 0 0 250px;
  }
}

@page {
  size: A4 landscape;
  margin: 6mm;
}

@media print {
  :root {
    --cell: 8.7mm;
    --gap: 0.45mm;
    --table-bottom-padding: 0;
  }

  html,
  body {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
    color: #000 !important;
  }

  body * {
    visibility: hidden !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    forced-color-adjust: none !important;
  }

  .print-area,
  .print-area * {
    visibility: visible !important;
  }

  .site-header,
  .controls,
  #quiz-container,
  .support-mobile-top,
  .support-bottom-wide,
  .support-rail,
  .element-modal,
  .learning-section,
  .site-footer {
    display: none !important;
  }

  .page-shell,
  .page-main,
  .print-area,
  .table-wrapper,
  .table-viewport {
    display: block !important;
    position: static !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
    border: 0 !important;
    transform: none !important;
    page-break-before: avoid !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .table-viewport {
    position: relative !important;
    width: max-content !important;
    margin: 0 auto !important;
    padding-top: 39mm !important;
  }

  .periodic-table {
    display: grid !important;
    margin: 0 !important;
    background: #fff !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  .element-guide,
  .legend-box {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: absolute !important;
    top: 2mm !important;
    transform: none !important;
    z-index: 5 !important;
  }

  .element-guide {
    left: 48mm !important;
    color: #000 !important;
  }

  .legend-box {
    left: 108mm !important;
    width: 54mm !important;
    padding: 2.2mm !important;
    background: #fff !important;
    border: 0.35mm solid #000 !important;
    border-radius: 2mm !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  .legend-title {
    margin-bottom: 1.5mm !important;
    color: #000 !important;
    font-size: 3mm !important;
  }

  .legend {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.9mm 1.5mm !important;
  }

  .legend-item {
    color: #000 !important;
    font-size: 2.35mm !important;
    gap: 1.1mm !important;
  }

  .color {
    width: 3mm !important;
    height: 3mm !important;
    flex: 0 0 3mm !important;
  }

  .guide-card {
    width: 22mm !important;
    height: 22mm !important;
    border: 0.45mm solid #000 !important;
    border-radius: 3mm !important;
    background: #fff !important;
    color: #000 !important;
  }

  .guide-number {
    top: 1.6mm !important;
    left: 2mm !important;
    font-size: 3.2mm !important;
  }

  .guide-mass {
    top: 1.7mm !important;
    right: 2mm !important;
    font-size: 2.6mm !important;
  }

  .guide-symbol {
    font-size: 11mm !important;
    line-height: 22mm !important;
  }

  .guide-name {
    bottom: 1.7mm !important;
    font-size: 3mm !important;
  }

  .guide-label {
    color: #000 !important;
    background: #fff !important;
    padding: 0 0.6mm !important;
    font-size: 2.6mm !important;
    white-space: nowrap !important;
  }

  .guide-label.number {
    top: 1mm !important;
    left: -24mm !important;
  }

  .guide-label.mass {
    top: 1mm !important;
    right: -27mm !important;
  }

  .guide-label.symbol {
    top: 10mm !important;
    left: -18mm !important;
  }

  .guide-label.name {
    bottom: 2.5mm !important;
    right: -19mm !important;
  }

  .line {
    display: block !important;
    background: #000 !important;
    color: #000 !important;
    height: 0.25mm !important;
    opacity: 1 !important;
  }

  .number-line,
  .mass-line {
    top: 4.5mm !important;
    width: 13mm !important;
  }

  .number-line {
    left: -13mm !important;
  }

  .mass-line {
    right: -13mm !important;
  }

  .symbol-line,
  .name-line {
    width: 9mm !important;
  }

  .symbol-line {
    top: 12.5mm !important;
    left: -9mm !important;
  }

  .name-line {
    bottom: 4.5mm !important;
    right: -9mm !important;
  }

  .element {
    border-radius: 1.5mm !important;
    padding: 0.9mm !important;
    color: #000 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    transform: none !important;
  }

  .element span {
    font-size: 1.75mm !important;
  }

  .element .masa {
    top: 0.7mm !important;
    right: 0.7mm !important;
    font-size: 1.25mm !important;
  }

  .element strong {
    font-size: 4.2mm !important;
  }

  .element em {
    font-size: 1.45mm !important;
    opacity: 1 !important;
  }
}
