.periodic-container {
  max-width: 1400px;
  margin: 20px auto;
  padding: 20px;
  font-family: Arial, sans-serif;
}

.periodic-table {
  display: grid;
  grid-template-columns: repeat(32, 40px); /* Extended for f-block placement */
  grid-template-rows: repeat(10, 55px);
  gap: 3px;
  background: #fff;
  padding: 10px;
  border: 2px solid #333;
  margin-bottom: 20px;
}

.element {
  background: #f0f0f0;
  border: 1px solid #999;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.element:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  z-index: 10;
}

.element.selected {
  border: 3px solid #ff0000;
  z-index: 11;
}

.atomic-number {
  font-size: 9px;
  align-self: flex-start;
  margin: 2px 0 0 3px;
}

.symbol {
  font-size: 15px;
  font-weight: bold;
}

.mass {
  font-size: 7px;
}

.name {
  font-size: 7px;
  text-align: center;
}

/* Category colors matching ACS style approximately */
.s { background: #ffd700; } /* Alkali */
.p { background: #ffca80; } /* Alkaline earth ~ orange */
.d { background: #add8e6; } /* Transition */
.f { background: #ff8080; } /* Lanthanide/Actinide red-ish */
.nonmetal { background: #ffc0cb; } /* Nonmetals pink */
.metalloid { background: #cccccc; }
.halogen { background: #ffff99; }
.noble-gas { background: #c0ffff; }
.unknown { background: #e8e8e8; }

#element-details {
  width: 100%;
  min-height: 200px;
  padding: 15px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  margin-bottom: 15px;
  overflow-y: auto;
}

#element-details h2 { margin-top: 0; color: #333; }
#element-details h3 { color: #555; margin: 15px 0 5px; }

.buttons {
  text-align: center;
}

button {
  margin: 5px;
  padding: 10px 15px;
  font-size: 14px;
  cursor: pointer;
}

@media (max-width: 1200px) {
  .periodic-table {
    grid-template-columns: repeat(32, 35px);
    grid-template-rows: repeat(10, 48px);
  }
}

@media (max-width: 768px) {
  .periodic-table {
    grid-template-columns: repeat(18, 30px);
    grid-template-rows: repeat(10, 45px);
    gap: 2px;
  }
  .element { font-size: 9px; }
  .symbol { font-size: 14px; }
}