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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    color: #fff; min-height: 100vh; overflow-x: hidden;
}

.container { max-width: 1280px; margin: 0 auto; padding: 20px; }

header { text-align: center; padding: 24px 0 16px; }
header h1 {
    font-size: 2.2rem;
    background: linear-gradient(90deg, #f7971e, #ffd200);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text; margin-bottom: 6px;
}
header p { color: #a0a0c0; font-size: 1.05rem; }

/* ── Level selector ── */
.level-select {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px; margin: 18px 0 24px;
}
.level-btn {
    padding: 12px 16px; border: 2px solid rgba(255,255,255,0.12);
    border-radius: 10px; background: rgba(255,255,255,0.05);
    color: #c0c0e0; font-size: 0.95rem; cursor: pointer;
    transition: all 0.25s; text-align: center;
}
.level-btn:hover { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.25); }
.level-btn.active {
    background: linear-gradient(135deg, rgba(247,151,30,0.2), rgba(255,210,0,0.15));
    border-color: #ffd200; color: #fff; font-weight: 600;
}

/* ── Game layout ── */
.game-layout {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 30px; margin-top: 8px;
}
@media (max-width: 768px) { .game-layout { grid-template-columns: 1fr; } }

.image-panel { display: flex; flex-direction: column; align-items: center; gap: 14px; }

.image-container {
    width: 100%; max-width: 540px; aspect-ratio: 1;
    border-radius: 16px; overflow: hidden;
    border: 3px solid rgba(255,255,255,0.1); background: #1a1a2e;
    position: relative;
}
.image-container canvas {
    width: 100%; height: 100%; display: block;
    image-rendering: pixelated;
}
.image-container.clear canvas { image-rendering: auto; }
.image-mystery {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 4rem; pointer-events: none;
    transition: opacity 0.5s;
}
.image-mystery.hidden { opacity: 0; }

.progress-bar-wrap {
    width: 100%; max-width: 540px; height: 26px;
    background: rgba(255,255,255,0.08); border-radius: 13px;
    overflow: hidden; position: relative;
}
.progress-bar {
    height: 100%; background: linear-gradient(90deg, #f7971e, #ffd200);
    border-radius: 13px; transition: width 0.6s cubic-bezier(0.22,1,0.36,1); width: 0%;
}
.progress-text {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%); font-size: 0.82rem;
    font-weight: 600; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ── Equations ── */
.equations-panel { display: flex; flex-direction: column; gap: 10px; }

.equation-card {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; padding: 14px 18px;
    display: flex; align-items: center; gap: 12px; transition: all 0.3s;
}
.equation-card:hover { background: rgba(255,255,255,0.09); }
.equation-card.solved { background: rgba(46,213,115,0.12); border-color: rgba(46,213,115,0.3); }
.equation-card.wrong { animation: shake 0.45s ease; }

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

.eq-num {
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(255,255,255,0.1); display: flex;
    align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.equation-card.solved .eq-num { background: rgba(46,213,115,0.3); }

.eq-text {
    font-size: 1.2rem; font-weight: 500; flex: 1;
    font-family: 'Cambria Math', 'Times New Roman', serif; letter-spacing: 0.5px;
}
.eq-input-group {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.eq-input-group label {
    font-size: 1.05rem; color: #a0a0c0;
    font-family: 'Cambria Math', 'Times New Roman', serif;
}
.eq-input {
    width: 80px; padding: 7px 10px;
    border: 2px solid rgba(255,255,255,0.15); border-radius: 8px;
    background: rgba(0,0,0,0.3); color: #fff; font-size: 1.05rem;
    text-align: center; outline: none; transition: border-color 0.3s;
    font-family: 'Cambria Math', 'Times New Roman', serif;
}
.eq-input:focus { border-color: #ffd200; }
.eq-input:disabled { opacity: 0.5; cursor: not-allowed; }

.eq-status { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }

/* ── Overlays ── */
.overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(8px);
    z-index: 100; align-items: center; justify-content: center;
    overflow-y: auto; padding: 20px;
}
.overlay.active { display: flex; }
.overlay-box {
    text-align: center; padding: 30px;
    max-width: 500px; width: 100%; margin: auto;
    animation: popIn 0.5s cubic-bezier(0.22,1,0.36,1);
}
@keyframes popIn { 0% { transform: scale(0.5); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.overlay-box h2 {
    font-size: 2.4rem; margin-bottom: 10px;
    background: linear-gradient(90deg, #f7971e, #ffd200);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.overlay-box p { font-size: 1.15rem; color: #c0c0e0; margin-bottom: 20px; }

.btn {
    padding: 11px 30px; border: none; border-radius: 10px;
    font-size: 1.05rem; font-weight: 600; cursor: pointer;
    background: linear-gradient(90deg, #f7971e, #ffd200);
    color: #1a1a2e; transition: transform 0.2s, box-shadow 0.2s;
    margin: 0 6px;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(247,151,30,0.3); }
.btn.secondary { background: rgba(255,255,255,0.12); color: #fff; }
.btn.secondary:hover { background: rgba(255,255,255,0.2); box-shadow: none; }

.confetti {
    position: fixed; top: -10px; z-index: 101; pointer-events: none;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

.game-area { display: none; }
.game-area.active { display: block; }

.completion-buttons {
    margin-top: 20px; display: flex; gap: 8px;
    justify-content: center; flex-wrap: wrap;
}
.completion-buttons .btn { margin: 0; }

/* ── Student name bar ── */
.student-bar {
    display: flex; align-items: center; justify-content: center;
    gap: 8px; margin: 10px 0 6px; flex-wrap: wrap;
}
.student-bar label { color: #a0a0c0; font-size: 0.85rem; }
.student-name-input {
    padding: 5px 10px; border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px; background: rgba(0,0,0,0.3); color: #fff;
    font-size: 0.9rem; width: 140px; outline: none;
    transition: border-color 0.2s;
}
.student-name-input:focus { border-color: #ffd200; }
.student-code { color: #606080; font-size: 0.75rem; font-family: monospace; }

/* ── Strategy picker (dev only) ── */
.strategy-picker {
    display: flex; gap: 8px; justify-content: center;
    margin-bottom: 12px; flex-wrap: wrap;
}
.strategy-btn {
    padding: 6px 14px; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px; background: rgba(255,255,255,0.04);
    color: #808090; font-size: 0.82rem; cursor: pointer;
    transition: all 0.2s;
}
.strategy-btn:hover { background: rgba(255,255,255,0.08); }
.strategy-btn.active { border-color: #ffd200; color: #ffd200; background: rgba(255,210,0,0.08); }
