body {
  background: #0d0d1a;
  color: #e0e0ff;
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
}

header {
  text-align: center;
  margin-bottom: 50px;
}

h1 {
  font-size: 3em;
  text-shadow: 0 0 30px #6e00ff;
  margin: 0;
}

header p {
  font-size: 1.2em;
  opacity: 0.9;
}

/* Tabla */
#periodic-table {
  display: grid;
  grid-template-columns: repeat(18, 80px);
  grid-template-rows: repeat(10, 90px);
  gap: 12px;
  max-width: 1700px;
  margin: 0 auto;
  justify-content: center;
}

.element-cube {
  perspective: 1000px;
}

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s, filter 0.4s;
  cursor: pointer;
  tabindex: 0; /* Navegación teclado */
  border-radius: 12px;
  background: rgba(30, 30, 60, 0.4);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glow-color, #6e00ff);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-color);
}

.cube:hover, .cube:focus {
  transform: rotateY(20deg) rotateX(15deg);
  filter: brightness(1.5);
  outline: 3px solid var(--glow-color);
}

.face {
  position: absolute;
  width: 100%;
  height: 100%;
  backdrop-filter: blur(10px);
  background: rgba(20, 20, 40, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  border-radius: 12px;
}

.front { transform: translateZ(45px); }

.atomic-number { font-size: 1.3em; font-weight: bold; }
.symbol { font-size: 1.8em; font-weight: bold; margin: 6px 0; }
.mass { font-size: 0.8em; opacity: 0.9; }

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.95);
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: rgba(20, 20, 40, 0.6);
  backdrop-filter: blur(20px);
  width: 90%;
  max-width: 1200px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8), 0 0 40px var(--glow-color);
  position: relative;
  border: 1px solid var(--glow-color);
}

.close {
  position: absolute;
  top: 20px; right: 30px;
  font-size: 3em;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 10;
}

.modal-body {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 40px;
  padding: 40px;
}

.info-panel {
  font-size: 1.1em;
}

.info-panel h2 {
  margin-top: 0;
  font-size: 2em;
  text-shadow: 0 0 15px var(--glow-color);
}

.viewer-panel {
  display: flex;
  align-items: center;
  justify-content: center;
}

.glass-card {
  width: 100%;
  height: 500px;
  background: rgba(30, 30, 60, 0.3);
  backdrop-filter: blur(15px);
  border-radius: 20px;
  border: 1px solid var(--glow-color);
  box-shadow: 0 15px 40px rgba(0,0,0,0.7), inset 0 0 30px rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 1.4em;
  color: #fff;
  padding: 20px;
  box-sizing: border-box;
}

.glass-card small {
  margin-top: 20px;
  opacity: 0.8;
  font-size: 0.9em;
}

/* Responsive */
@media (max-width: 900px) {
  .modal-body {
    grid-template-columns: 1fr;
  }
  #periodic-table {
    grid-template-columns: repeat(18, 60px);
    grid-template-rows: repeat(10, 70px);
    gap: 8px;
  }
}