/* --- Config Type Toggle --- */
#mode-toggle {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 1rem 0 0.5rem;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 6px 16px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s;
}

.mode-btn:hover {
    border-color: #6153cc;
    color: #6153cc;
}

.mode-btn.active {
    background: #6153cc;
    border-color: #6153cc;
    color: white;
}

/* --- Input Mode Toggle --- */
#input-mode-toggle {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 0.25rem 0 0.5rem;
}

.input-mode-btn {
    padding: 5px 14px;
    border: 2px solid #dee2e6;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s;
}

.input-mode-btn:hover {
    border-color: #6153cc;
    color: #6153cc;
}

.input-mode-btn.active {
    background: #6153cc;
    border-color: #6153cc;
    color: white;
}

/* --- Element Display --- */
#element-display {
    text-align: center;
    margin: 2rem 0 1.5rem;
}

#element-symbol {
    font-size: 3.5rem;
    font-weight: 700;
    color: #6153cc;
    font-family: 'Georgia', serif;
}

#element-info {
    font-size: 1.1rem;
    color: #6c757d;
    margin-top: 4px;
}

/* --- Text Controls --- */
#primary-controls {
    display: flex;
    justify-content: center;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

#answer-input {
    width: 340px;
    padding: 10px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    font-size: 1.05rem;
    text-align: center;
    font-family: monospace;
}

#answer-input:focus {
    outline: none;
    border-color: #6153cc;
}

/* --- Tile Game Area --- */
#tile-game-area {
    width: 100%;
    max-width: 600px;
    margin: 0 auto 1rem;
}

/* Answer Zone */
#answer-zone {
    min-height: 56px;
    padding: 8px 12px;
    margin-bottom: 1rem;
    border: 2px dashed #ced4da;
    border-radius: 8px;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

#answer-slots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    min-height: 40px;
    align-items: center;
}

#answer-slots:empty::before {
    content: "Tap tiles below to build the configuration";
    color: #adb5bd;
    font-style: italic;
    font-size: 0.95rem;
}

/* Tile Tray */
#tile-tray {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 12px;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background-color: #f8f9fa;
    min-height: 50px;
}

/* Tile Base */
.tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    font-weight: 600;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition: transform 0.1s ease, box-shadow 0.1s ease, opacity 0.2s ease;
    border: 2px solid transparent;
}

.tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.tile:active {
    transform: translateY(0);
}

.tile.dragging {
    opacity: 0.3;
    cursor: grabbing;
}

.drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.85;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.tile.drop-before {
    border-left: 3px solid #362A8D;
}

#answer-slots.drop-at-end {
    border-right: 3px solid #362A8D;
}

#answer-slots .tile {
    padding: 6px 10px;
    font-size: 0.95rem;
}

/* --- Orbital Color Coding --- */
.tile[data-type="s-orbital"] {
    background-color: #dbeafe;
    border-color: #93c5fd;
    color: #1e40af;
}

.tile[data-type="p-orbital"] {
    background-color: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

.tile[data-type="d-orbital"] {
    background-color: #fef3c7;
    border-color: #fbbf24;
    color: #92400e;
}

.tile[data-type="f-orbital"] {
    background-color: #fce7f3;
    border-color: #f9a8d4;
    color: #9d174d;
}

.tile[data-type="core"] {
    background-color: #ede9fe;
    border-color: #a78bfa;
    color: #5b21b6;
}

/* --- Tile Controls --- */
#tile-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-bottom: 1rem;
}

#tile-primary-controls {
    display: flex;
    gap: 8px;
}

#tile-check-btn {
    background-color: #362A8D;
    min-width: 100px;
}

#tile-skip-btn {
    background-color: #bbc8ca;
    min-width: 100px;
}

#tile-skip-btn.next-ready {
    background-color: #333;
}

#tile-secondary-controls {
    display: flex;
    gap: 1rem;
}

#tile-secondary-controls .link-button:disabled {
    color: #adb5bd;
    text-decoration: none;
    cursor: default;
}

#tile-secondary-controls .link-button.hint-active {
    color: #51a3a3;
    font-weight: 600;
}

.link-button {
    background: none;
    border: none;
    color: #007bff;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-size: 0.9rem;
}

.link-button:hover {
    color: #0056b3;
}

/* --- Hint Message --- */
#tile-hint-message {
    text-align: center;
    font-size: 0.95rem;
    color: #495057;
    min-height: 1.4em;
    margin-bottom: 0.5rem;
}

/* --- Tricky Badge --- */
#tricky-badge {
    display: inline-block;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-right: 6px;
    vertical-align: middle;
}

#explanation-text {
    text-align: center;
    font-size: 0.95rem;
    color: #495057;
    margin: 0.5rem 0;
    min-height: 1.4em;
}

/* --- Animations --- */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

#answer-zone.shake {
    animation: shake 0.4s ease;
    border-color: #dc3545;
}

#answer-zone.correct-flash {
    animation: pop 0.3s ease;
    border-color: #28a745;
    background-color: #d4edda;
}

/* --- Utility --- */
.hidden {
    display: none !important;
}

/* --- Responsive --- */
@media (max-width: 480px) {
    #answer-input {
        width: 100%;
    }

    .tile {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    #answer-slots .tile {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    #tile-tray {
        gap: 6px;
        padding: 8px;
    }
}
