* { box-sizing: border-box; margin: 0; padding: 0; }

.skip-link {
    position: absolute;
    top: -999px;
    left: 0;
    background: #e8d44d;
    color: #1a1a2e;
    padding: 8px 16px;
    z-index: 9999;
    font-weight: 700;
    text-decoration: none;
    font-size: 0.85rem;
}
.skip-link:focus { top: 0; outline: 2px solid #fff; }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #1a1a2e;
    color: #e0e0e0;
    padding: 20px;
    min-height: 100vh;
}

#app {
    max-width: 1300px;
    margin: 0 auto;
    position: relative;
}

#top-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #aaa;
}

#high-score { color: #e8d44d; font-weight: bold; }

#sound-toggle {
    cursor: pointer;
    font-size: 1.2rem;
    user-select: none;
    transition: transform 0.15s;
}
#sound-toggle:hover { transform: scale(1.2); }
#sound-toggle.muted { opacity: 0.5; }

#timer-display {
    font-weight: bold;
    color: #e0e0e0;
    transition: color 0.3s;
}
#timer-display.hidden { visibility: hidden; }

#help-btn {
    cursor: pointer;
    font-size: 1.1rem;
    user-select: none;
    transition: transform 0.15s;
}
#help-btn:hover { transform: scale(1.2); }

h1 {
    text-align: center;
    color: #e8d44d;
    font-size: 1.8rem;
    margin-bottom: 4px;
}

.subtitle {
    text-align: center;
    color: #bbb;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.header-top {
    text-align: center;
    margin-bottom: 20px;
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.nav-links a {
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 4px;
    transition: color 0.15s;
    white-space: nowrap;
    opacity: 0.85;
}
.nav-links a:hover {
    color: #e8d44d;
    opacity: 1;
}
.nav-links a.nav-home {
    font-size: 12px;
    opacity: 0.6;
}
.nav-links a.nav-home:hover {
    opacity: 1;
}

/* Layout */
#layout {
    display: grid;
    grid-template-areas:
        "temp  disc  cont  rocks";
    grid-template-columns: 80px 1fr 1fr 200px;
    gap: 12px;
    align-items: start;
}

#temp-col  { grid-area: temp; }
#layout > div:nth-child(2) { grid-area: disc; }
#layout > div:nth-child(3) { grid-area: cont; }
#rock-col  { grid-area: rocks; }

#layout > div {
    background: #16213e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    min-height: 300px;
}

/* Temperature column */
#temp-col {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px !important;
}

.temp-label {
    font-size: 0.7rem;
    color: #999;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.temp-bar {
    flex: 1;
    width: 20px;
    border-radius: 10px;
    margin: 8px 0;
    min-height: 200px;
    background: linear-gradient(to bottom, #e74c3c, #e67e22, #f1c40f, #3498db);
}

.temp-values {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    font-size: 0.65rem;
    color: #bbb;
    gap: 4px;
}

/* Series columns */
.series-title {
    text-align: center;
    font-size: 0.9rem;
    color: #e8d44d;
    font-weight: bold;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid #333;
}

.mineral-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 100px;
}

/* Mineral boxes */
.mineral-box {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: grab;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    transition: all 0.2s;
    position: relative;
}

.mineral-box:hover {
    border-color: #e8d44d88;
    transform: translateX(4px);
}

.mineral-box.selected {
    border-color: #e8d44d;
    box-shadow: 0 0 12px rgba(232,212,77,0.3);
    transform: translateX(6px);
}

.mineral-box.dragging {
    opacity: 0.5;
}

.mineral-box.correct {
    border-color: #2ecc71 !important;
    background: rgba(46,204,113,0.15) !important;
}

.mineral-box.incorrect {
    border-color: #e74c3c !important;
    background: rgba(231,76,60,0.15) !important;
}

.mineral-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mineral-info strong {
    font-size: 0.85rem;
    color: #fff;
}

.mineral-formula {
    font-size: 0.65rem;
    color: #aaa;
    font-family: 'Consolas', monospace;
}

.mineral-tags {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.tag {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: bold;
}

.temp-tag {
    background: rgba(0,0,0,0.4);
    color: #ffb;
}

.silica-tag {
    background: rgba(0,0,0,0.4);
    color: #aaf;
}

.icon-ok { color: #2ecc71; font-weight: bold; font-size: 1rem; }
.icon-fail { color: #e74c3c; font-weight: bold; font-size: 1rem; }
.correct-hint { color: #f1c40f; font-size: 0.7rem; }

/* Rock column */
#rock-col { padding: 12px !important; }

.rock-title {
    text-align: center;
    font-size: 0.85rem;
    color: #e8d44d;
    font-weight: bold;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #333;
}

#rock-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rock-item {
    padding: 8px 10px;
    background: #0a0a1a;
    border-radius: 4px;
    font-size: 0.72rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: all 0.2s;
}

.rock-item strong { color: #ddd; font-size: 0.78rem; }
.rock-item small { color: #bbb; }
.rock-item span { color: #999; font-size: 0.65rem; }
.rock-subtitle { color: #999; font-weight: normal; }

/* Controls */
#controls {
    text-align: center;
    margin-top: 14px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 24px;
    border: 1px solid #444;
    border-radius: 6px;
    background: #0f3460;
    color: #e0e0e0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    min-height: 40px;
}

.btn:hover { background: #1a4a7a; border-color: #e8d44d; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled:hover { background: #0f3460; border-color: #444; }

.btn-primary { background: #2d6a2d; border-color: #4a8; }
.btn-primary:hover { background: #3a8a3a; }

.btn-sm {
    background: #0f3460;
    border: 1px solid #e8d44d;
    color: #e8d44d;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    margin-left: 6px;
}
.btn-sm:hover { background: #1a4a7a; }

#score {
    text-align: center;
    font-size: 1rem;
    color: #e8d44d;
    font-weight: bold;
    margin-top: 10px;
}

#confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.hidden { display: none !important; }

.result-msg {
    text-align: center;
    margin-top: 10px;
    font-size: 0.9rem;
    line-height: 1.6;
}

.result-success { color: #2ecc71; }
.result-fail { color: #e74c3c; }

/* Instructions modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: #16213e;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    position: relative;
}
.modal h2 { color: #e8d44d; margin-bottom: 12px; }
.modal p, .modal li { color: #ccc; font-size: 0.85rem; line-height: 1.5; }
.modal ol { padding-left: 20px; margin: 10px 0; }
label input[type="checkbox"] { accent-color: #e8d44d; }

.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    font-size: 1.4rem;
    cursor: pointer;
    color: #666;
    background: none;
    border: none;
}
.modal-close:hover { color: #fff; }

/* Responsive */
@media (max-width: 1100px) {
    #layout {
        grid-template-areas:
            "temp  disc  cont"
            "rocks rocks rocks";
        grid-template-columns: 60px 1fr 1fr;
    }
    .rock-item {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
        padding: 6px 10px;
    }
    .rock-item strong { min-width: 80px; }
}

@media (max-width: 768px) {
    .nav-links { display: none; }
    #layout {
        grid-template-areas:
            "temp  temp"
            "disc  cont"
            "rocks rocks";
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    #temp-col {
        flex-direction: row;
        gap: 8px;
        padding: 8px !important;
        align-items: center;
    }
    .temp-bar {
        width: 100%;
        height: 10px;
        min-height: 30px;
        background: linear-gradient(to right, #e74c3c, #e67e22, #f1c40f, #3498db);
    }
    .temp-values {
        flex-direction: row;
        font-size: 0.6rem;
        gap: 4px;
        justify-content: space-around;
        width: 100%;
    }
    .temp-label {
        font-size: 0.6rem;
        letter-spacing: 0;
        writing-mode: unset;
    }
    #rock-col { margin-top: 0; }
    .modal { max-width: 90%; margin: 10px; }
}

@media (max-width: 480px) {
    body { padding: 6px; }
    h1 { font-size: 1.1rem; margin-bottom: 2px; }
    .subtitle { font-size: 0.7rem; margin-bottom: 10px; }
    #top-bar { flex-wrap: wrap; gap: 4px; font-size: 0.65rem; padding: 0 2px; }
    #top-bar > * { min-height: 32px; display: flex; align-items: center; }
    #layout {
        grid-template-areas:
            "temp"
            "disc"
            "cont"
            "rocks";
        grid-template-columns: 1fr;
        gap: 6px;
    }
    #layout > div { padding: 6px; border-radius: 6px; }
    #temp-col {
        flex-direction: row;
        gap: 6px;
        padding: 6px !important;
    }
    .temp-bar { height: 8px; min-height: 24px; }
    .temp-values { font-size: 0.5rem; gap: 2px; justify-content: space-around; width: 100%; }
    .temp-label { display: none; }
    .series-title { font-size: 0.78rem; margin-bottom: 5px; padding-bottom: 4px; }
    .mineral-box {
        padding: 6px 8px;
        min-height: 40px;
        cursor: pointer;
    }
    .mineral-info strong { font-size: 0.72rem; }
    .mineral-formula { display: none; }
    .mineral-tags { gap: 2px; }
    .tag { font-size: 0.5rem; padding: 1px 4px; }
    #controls { gap: 4px; margin-top: 8px; }
    .btn {
        font-size: 0.72rem;
        padding: 6px 10px;
        min-height: 32px;
        flex: 1 1 auto;
    }
    .btn-primary { flex: 1 1 100%; }
    #score { font-size: 0.85rem; }
    .result-msg { font-size: 0.8rem; }
    .rock-item {
        padding: 5px 8px;
        font-size: 0.65rem;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }
    .rock-item strong { font-size: 0.7rem; min-width: 60px; }
    .modal { padding: 14px; }
    .modal h2 { font-size: 1rem; margin-bottom: 8px; }
    .modal p, .modal li { font-size: 0.75rem; }
    .modal ol { padding-left: 14px; }
}

@media (max-width: 360px) {
    h1 { font-size: 0.9rem; }
    .subtitle { font-size: 0.6rem; }
    #top-bar { font-size: 0.55rem; gap: 3px; }
    .mineral-box { padding: 4px 6px; min-height: 34px; }
    .mineral-info strong { font-size: 0.65rem; }
    .mineral-tags { flex-direction: column; gap: 1px; }
    .btn { font-size: 0.62rem; padding: 4px 8px; min-height: 28px; }
    .rock-item { font-size: 0.58rem; }
}
