body {
    font-family: 'Inter', sans-serif;
    touch-action: manipulation;
    background-color: #000;
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, minmax(0, 1fr));
    grid-template-rows: repeat(10, minmax(0, 1fr));
    gap: clamp(1px, 0.4vmin, 4px);
    width: 100%;
    height: 100%;
    margin: auto;
}

#app-container {
    aspect-ratio: 16 / 9;
    width: min(98vw, 177.778dvh);
    height: min(98dvh, 56.25vw);
    max-width: 100vw;
    max-height: 100dvh;
    position: relative;
    background-color: #111827;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    overflow: hidden;
}

@media (min-width: 1024px) {
    #app-container {
        border-radius: 8px;
    }
}

#spectrum-display {
    grid-column: 3 / 13;
    grid-row: 1 / 4; 
    margin: 0.5vmin;
    z-index: 5;
    background: radial-gradient(circle at center, #111 0%, #000 100%);
    box-shadow: inset 0 0 15px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.5);
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}

.element {
    position: relative;
    padding: 1px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.1s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    user-select: none;
}
.element:hover {
    transform: scale(1.1);
    z-index: 20;
    box-shadow: 0 0 15px rgba(0,0,0,0.8);
}
.element.active {
    transform: scale(1.15);
    filter: brightness(1.4);
    z-index: 20;
    box-shadow: 0 0 15px rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.8);
}
.element > * {
    pointer-events: none;
}
.element .number {
    position: absolute;
    top: 2px;
    left: 3px;
    font-size: clamp(0.3rem, 0.9vmin, 0.7rem);
    opacity: 0.8;
}
.element .symbol {
    font-size: clamp(0.5rem, 2.0vmin, 1.2rem);
    font-weight: 700;
    margin-top: auto;
    margin-bottom: auto;
}
.element .name {
    font-size: clamp(0.25rem, 0.7vmin, 0.5rem);
    text-align: center;
    display: none;
    margin-bottom: 2px;
}
.element .music-info {
    font-size: clamp(0.25rem, 0.8vmin, 0.5rem);
    width: 100%;
    text-align: center;
    opacity: 0.7;
    display: flex;
    justify-content: space-around;
    padding: 1px 0;
    background: rgba(0,0,0,0.2);
}

.diatomic-nonmetal { background-color: #2980b9; color: white; }
.noble-gas { background-color: #8e44ad; color: white; }
.alkali-metal { background-color: #d35400; color: white; }
.alkaline-earth-metal { background-color: #f39c12; color: #111; }
.metalloid { background-color: #16a085; color: white; }
.polyatomic-nonmetal { background-color: #27ae60; color: white; }
.post-transition-metal { background-color: #7f8c8d; color: white; }
.transition-metal { background-color: #c0392b; color: white; }
.lanthanide { background-color: #c51162; color: white; }
.actinide { background-color: #4a148c; color: white; }
.unknown { background-color: #555; color: #ccc; }

/* Controles refinados para Flexbox */
#controls {
    min-height: 40px;
}

@media (min-width: 768px) {
    .element .name { display: block; }
}
