/* ===== CSS VARIABLES ===== */
:root {
    --bg-dark: #0a0a0a;
    --bg-medium: #141414;
    --bg-light: #1e1e1e;
    --accent-yellow: #ef7c00;
    --accent-red: #d75743;
    --accent-green: #2ecc71;
    --accent-blue: #5592ce;
    --text-primary: #ecf0f1;
    --text-secondary: #95a5a6;
    --conveyor-dark: #2c3e50;
    --conveyor-light: #34495e;
    --steel: #7f8c8d;
    --money-green: #27ae60;
    --money-red: #c0392b;
}

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    user-select: none;
}

/* ===== SCREEN SYSTEM ===== */
.screen {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ===== BUTTONS ===== */
.btn {
    background: var(--accent-yellow);
    color: var(--bg-dark);
    border: none;
    padding: 14px 36px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: background 0.2s, transform 0.1s;
}

.btn:hover {
    background: #ff9020;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(1px);
}

/* ===== WELCOME SCREEN ===== */
#welcome-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #1a1200 0%, #000000 70%);
}

.welcome-container {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

/* Panther eyes image */
.panther-eyes {
    margin-bottom: 20px;
}

/* Real image version */
.panther-img {
    width: 280px;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(239, 124, 0, 0.4), 0 0 80px rgba(239, 124, 0, 0.15);
    animation: eyeGlow 3s ease-in-out infinite;
}

@keyframes eyeGlow {
    0% { box-shadow: 0 0 30px rgba(239, 124, 0, 0.3), 0 0 60px rgba(239, 124, 0, 0.1); }
    50% { box-shadow: 0 0 50px rgba(239, 124, 0, 0.6), 0 0 100px rgba(239, 124, 0, 0.2); }
    100% { box-shadow: 0 0 30px rgba(239, 124, 0, 0.3), 0 0 60px rgba(239, 124, 0, 0.1); }
}


.game-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 4px;
    color: var(--accent-yellow);
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.5);
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--conveyor-light);
    border-radius: 4px;
    background: var(--bg-medium);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent-yellow);
}

.btn-start {
    margin-top: 20px;
    width: 100%;
    padding: 16px;
    font-size: 20px;
}

/* ===== TUTORIAL SCREEN ===== */
#tutorial-screen {
    justify-content: flex-start;
    align-items: center;
    background: var(--bg-dark);
    overflow-y: auto;
}

.tutorial-container {
    max-width: 650px;
    width: 90%;
    padding: 30px 20px 40px;
}

.tutorial-header {
    text-align: center;
    margin-bottom: 24px;
}

.tutorial-eyes {
    width: 160px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 0 30px rgba(239, 124, 0, 0.3);
}

.tutorial-header h2 {
    font-size: 32px;
    color: var(--accent-yellow);
    letter-spacing: 4px;
}

.tutorial-section {
    margin-bottom: 20px;
    background: var(--bg-medium);
    border-radius: 6px;
    padding: 16px 20px;
    border-left: 3px solid var(--accent-yellow);
}

.tutorial-section h3 {
    font-size: 14px;
    color: var(--accent-yellow);
    letter-spacing: 2px;
    margin-bottom: 8px;
}

.tutorial-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.tutorial-defects {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tutorial-defect {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.defect-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    border: 2px solid var(--conveyor-light);
    flex-shrink: 0;
    object-fit: cover;
}

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

.defect-name {
    font-size: 15px;
}

.defect-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Defect name colors match their marker colors */
.scratch-color { color: #e74c3c; }
.bubble-color { color: #3498db; }
.inclusion-color { color: #9b59b6; }
.coating-color { color: #f1c40f; }
.edge_chip-color { color: #e67e22; }

.tutorial-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tutorial-step {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.step-num {
    width: 28px;
    height: 28px;
    background: var(--accent-yellow);
    color: var(--bg-dark);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.tutorial-scoring {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    padding: 4px 0;
}

.score-row.gain { color: var(--money-green); }
.score-row.gain-partial { color: var(--accent-blue); }
.score-row.loss { color: var(--money-red); }

.tutorial-rules {
    list-style: none;
    padding: 0;
}

.tutorial-rules li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 3px 0;
    padding-left: 16px;
    position: relative;
}

.tutorial-rules li::before {
    content: ">";
    position: absolute;
    left: 0;
    color: var(--accent-yellow);
    font-weight: 700;
}

#tutorial-start-btn {
    margin-top: 24px;
    width: 100%;
}

/* ===== HUD ===== */
#hud {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: linear-gradient(180deg, #0d1117 0%, #161b22 100%);
    padding: 12px 20px;
    border-bottom: 3px solid var(--accent-yellow);
    z-index: 10;
    flex-shrink: 0;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-size: 11px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.hud-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

#hud-balance {
    color: var(--money-green);
}

.streak-value {
    color: var(--accent-yellow) !important;
}

.balance-up { animation: flashGreen 0.5s; }
.balance-down { animation: flashRed 0.5s; }

@keyframes flashGreen {
    0% { color: var(--money-green); transform: scale(1); }
    50% { color: #00ff88; transform: scale(1.3); }
    100% { color: var(--money-green); transform: scale(1); }
}

@keyframes flashRed {
    0% { color: var(--money-green); transform: scale(1); }
    50% { color: var(--money-red); transform: scale(1.3); }
    100% { color: var(--money-green); transform: scale(1); }
}

/* ===== MUTE BUTTON ===== */
.mute-btn {
    background: none;
    border: 1px solid var(--conveyor-light);
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: opacity 0.2s;
    touch-action: manipulation;
}

.mute-btn:hover { opacity: 0.7; }
.mute-btn.muted { opacity: 0.4; }

/* ===== CONVEYOR BELT ===== */
#conveyor {
    flex: 1;
    position: relative;
    overflow: hidden;
    margin-bottom: 75px;
    background: #1c2833;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 98px,
            rgba(255,255,255,0.03) 98px,
            rgba(255,255,255,0.03) 100px
        );
}

.conveyor-rollers {
    position: absolute;
    left: 0;
    right: 0;
    height: 20px;
    z-index: 5;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent 0px,
            transparent 58px,
            rgba(0,0,0,0.3) 58px,
            rgba(0,0,0,0.3) 62px
        ),
        linear-gradient(180deg, #5d6d7e 0%, #aab7b8 50%, #5d6d7e 100%);
}

.top-rollers { top: 0; }
.bottom-rollers { bottom: 0; }

/* ===== GLASS PANEL =====
   Positioned at bottom of conveyor, sitting on the bottom rollers.
   Size is set dynamically by game.js for random sizes. */
#glass-panel {
    position: absolute;
    bottom: 20px;          /* Sits right on top of bottom rollers */
    left: -500px;
    cursor: crosshair;
    z-index: 3;
    /* Default size — overridden by JS for random sizes */
    width: 450px;
    height: 320px;
}

#glass-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 20px rgba(52, 152, 219, 0.2));
}

/* ===== FLOATING TIMER =====
   Large visible timer that follows near the glass */
#floating-timer {
    position: absolute;
    bottom: 350px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    text-align: center;
    pointer-events: none;
}

#floating-timer-value {
    font-size: 64px;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow: 0 0 20px rgba(239, 124, 0, 0.5);
    display: block;
    line-height: 1;
}

#floating-timer-value.timer-danger {
    color: var(--accent-red);
    text-shadow: 0 0 20px rgba(215, 87, 67, 0.6);
    animation: timerPulse 0.5s ease-in-out infinite;
}

.floating-timer-label {
    font-size: 14px;
    color: var(--text-secondary);
    letter-spacing: 3px;
}

@keyframes timerPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ===== STOP LINE BUTTON ===== */
#stop-line-container {
    position: absolute;
    top: 10px;
    right: 30px;
    z-index: 15;
    text-align: center;
}

.stop-line-btn {
    background: var(--accent-red);
    color: white;
    border: 3px solid #ff6b5b;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.15s;
    box-shadow: 0 4px 15px rgba(215, 87, 67, 0.4);
}

.stop-line-btn:hover {
    background: #ff5040;
    transform: scale(1.05);
}

.stop-line-btn.line-stopped {
    background: var(--money-green);
    border-color: #50e080;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

#stop-penalty {
    margin-top: 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--money-red);
    animation: penaltyPulse 1s ease-in-out infinite;
}

@keyframes penaltyPulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ===== DONE INSPECTING BUTTON (Level 1) ===== */
#done-inspect-container {
    position: absolute;
    top: 10px;
    right: 30px;
    z-index: 15;
    text-align: center;
}

.done-inspect-btn {
    background: var(--money-green);
    color: white;
    border: 3px solid #50e080;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: all 0.15s;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
}

.done-inspect-btn:hover {
    background: #2ecc71;
    transform: scale(1.05);
}

#inspect-penalty {
    margin-top: 6px;
    font-size: 16px;
    font-weight: 700;
    color: var(--money-red);
    animation: penaltyPulse 1s ease-in-out infinite;
}

/* ===== DEFECT MARKERS ===== */
.defect-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 4;
    animation: markerPop 0.3s ease-out;
}

@keyframes markerPop {
    0% { transform: translate(-50%, -50%) scale(0); }
    70% { transform: translate(-50%, -50%) scale(1.3); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

.defect-marker.scratch { background: rgba(231, 76, 60, 0.7); }
.defect-marker.bubble { background: rgba(52, 152, 219, 0.7); }
.defect-marker.inclusion { background: rgba(155, 89, 182, 0.7); }
.defect-marker.coating { background: rgba(241, 196, 15, 0.7); }
.defect-marker.edge_chip { background: rgba(230, 126, 34, 0.7); }

/* ===== CLASSIFICATION POPUP ===== */
#classify-popup {
    position: absolute;
    z-index: 20;
    background: rgba(13, 17, 23, 0.95);
    border: 2px solid var(--accent-yellow);
    border-radius: 8px;
    padding: 10px;
    min-width: 160px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.classify-title {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-align: center;
}

.classify-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.classify-btn {
    background: var(--conveyor-dark);
    color: var(--text-primary);
    border: 1px solid var(--conveyor-light);
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
    text-align: left;
}

.classify-btn:hover {
    background: var(--bg-light);
    border-color: var(--accent-yellow);
}

.classify-btn[data-type="scratch"]::before { content: "\25CF "; color: #e74c3c; }
.classify-btn[data-type="bubble"]::before { content: "\25CF "; color: #3498db; }
.classify-btn[data-type="inclusion"]::before { content: "\25CF "; color: #9b59b6; }
.classify-btn[data-type="coating"]::before { content: "\25CF "; color: #f1c40f; }
.classify-btn[data-type="edge_chip"]::before { content: "\25CF "; color: #e67e22; }

/* ===== STREAK POPUP ===== */
#streak-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 25;
    font-size: 36px;
    font-weight: 900;
    color: var(--accent-yellow);
    text-shadow: 0 0 20px rgba(239, 124, 0, 0.8);
    pointer-events: none;
    animation: streakPop 1s ease-out forwards;
}

@keyframes streakPop {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    30% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0; transform: translate(-50%, -80%) scale(1); }
}

/* ===== FLOATING SCORE INDICATOR ===== */
#score-float {
    position: absolute;
    z-index: 25;
    font-size: 22px;
    font-weight: 700;
    pointer-events: none;
    animation: scoreFloat 1.2s ease-out forwards;
}

#score-float.gain { color: var(--money-green); }
#score-float.loss { color: var(--money-red); }

@keyframes scoreFloat {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-60px); }
}

/* ===== SCREEN SHAKE (on missed defects) ===== */
.screen-shake {
    animation: shake 0.4s ease-in-out;
}

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

/* ===== LEVEL OVERLAY ===== */
#level-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.level-overlay-content {
    text-align: center;
    padding: 40px;
}

.level-overlay-content h2 {
    font-size: 48px;
    color: var(--accent-yellow);
    margin-bottom: 12px;
}

.level-overlay-content p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* ===== RESULT SCREEN ===== */
#result-screen {
    justify-content: center;
    align-items: center;
    background: var(--bg-dark);
    overflow-y: auto;
}

.result-container {
    text-align: center;
    max-width: 700px;
    width: 90%;
    padding: 20px;
    animation: slideIn 0.4s ease-out;
}

.result-container h2 {
    font-size: 24px;
    color: var(--accent-yellow);
    margin-bottom: 10px;
    letter-spacing: 3px;
}

/* Perfect round banner */
.result-perfect {
    font-size: 22px;
    font-weight: 900;
    color: var(--accent-yellow);
    letter-spacing: 4px;
    padding: 8px;
    margin-bottom: 10px;
    border: 2px solid var(--accent-yellow);
    border-radius: 6px;
    background: rgba(239, 124, 0, 0.1);
    animation: perfectPulse 1.5s ease-in-out infinite;
}

@keyframes perfectPulse {
    0% { box-shadow: 0 0 10px rgba(239, 124, 0, 0.3); }
    50% { box-shadow: 0 0 30px rgba(239, 124, 0, 0.6); }
    100% { box-shadow: 0 0 10px rgba(239, 124, 0, 0.3); }
}

#result-glass-container {
    position: relative;
    display: inline-block;
    margin-bottom: 10px;
    border: 2px solid var(--conveyor-light);
    border-radius: 4px;
    overflow: hidden;
    max-width: 100%;
}

#result-glass-image {
    width: 350px;
    max-width: 100%;
    height: auto;
    display: block;
}

.result-marker {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.result-marker.found {
    border-color: var(--accent-green);
    background: rgba(46, 204, 113, 0.3);
}
.result-marker.found::after { content: "\2713"; color: var(--accent-green); }

.result-marker.missed {
    border-color: var(--accent-red);
    background: rgba(231, 76, 60, 0.3);
}
.result-marker.missed::after { content: "\2715"; color: var(--accent-red); }

.result-marker.false-alarm-marker {
    border-color: var(--accent-yellow);
    background: rgba(241, 196, 15, 0.3);
}
.result-marker.false-alarm-marker::after { content: "?"; color: var(--accent-yellow); }

#result-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 12px;
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.result-stat {
    display: grid;
    grid-template-columns: 1fr 40px 70px;
    align-items: center;
    padding: 5px 10px;
    border-radius: 4px;
    background: var(--bg-medium);
}

.stat-label { font-size: 13px; color: var(--text-secondary); text-align: left; }
.stat-value { font-size: 15px; font-weight: 700; text-align: center; }
.stat-money { font-size: 13px; font-weight: 600; text-align: right; }

.result-stat.correct .stat-money { color: var(--money-green); }
.result-stat.partial .stat-money { color: var(--accent-blue); }
.result-stat.missed .stat-money { color: var(--money-red); }
.result-stat.false-alarm .stat-money { color: var(--accent-yellow); }
.result-stat.stop-cost .stat-money { color: var(--money-red); }
.result-stat.streak-bonus .stat-money { color: var(--accent-yellow); }

.result-stat.total {
    background: var(--bg-light);
    border: 1px solid var(--accent-yellow);
    margin-top: 4px;
    grid-template-columns: 1fr auto;
}

.result-stat.total .stat-value { font-size: 16px; text-align: right; }

.result-accuracy {
    font-size: 18px;
    font-weight: 700;
    margin: 8px 0 6px;
    color: var(--text-secondary);
}

.result-accuracy span:first-child { font-size: 28px; }

#result-accuracy-req {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

.result-fail {
    background: rgba(215, 87, 67, 0.15);
    border: 1px solid var(--accent-red);
    border-radius: 4px;
    padding: 12px 20px;
    margin: 10px 0;
    color: var(--accent-red);
    font-size: 15px;
    font-weight: 600;
}

.result-balance {
    font-size: 20px;
    margin: 16px 0 20px;
    color: var(--text-secondary);
}

.result-balance span {
    color: var(--money-green);
    font-weight: 700;
    font-size: 24px;
}

/* ===== GAME OVER SCREEN ===== */
#gameover-screen {
    justify-content: center;
    align-items: center;
    background: var(--bg-dark);
    overflow-y: auto;
}

.gameover-container {
    text-align: center;
    max-width: 700px;
    width: 90%;
    padding: 30px;
    animation: slideIn 0.4s ease-out;
}

.gameover-container h2 {
    font-size: 40px;
    color: var(--accent-yellow);
    letter-spacing: 4px;
    margin-bottom: 8px;
}

#gameover-message { color: var(--text-secondary); margin-bottom: 24px; }

.gameover-final {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
}

.final-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.final-value {
    font-size: 48px;
    font-weight: 900;
    color: var(--money-green);
}

#gameover-stats { color: var(--text-secondary); margin-bottom: 30px; }
#gameover-stats p { margin: 4px 0; }
#gameover-stats span { color: var(--text-primary); font-weight: 600; }

/* ===== LINESCANNER MARKETING MESSAGE ===== */
.linescanner-message {
    background: rgba(239, 124, 0, 0.08);
    border: 1px solid rgba(239, 124, 0, 0.3);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 30px;
    text-align: left;
}

.linescanner-message h3 {
    font-size: 16px;
    color: var(--accent-yellow);
    letter-spacing: 2px;
    margin-bottom: 12px;
    text-align: center;
}

.linescanner-message p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
}

.linescanner-message ul {
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.linescanner-message li {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
    padding: 6px 0 6px 20px;
    position: relative;
}

.linescanner-message li::before {
    content: "\26A0";
    position: absolute;
    left: 0;
    color: var(--accent-yellow);
}

.linescanner-cta {
    color: var(--text-primary) !important;
    font-size: 15px !important;
    margin-top: 12px;
}

.btn-linescanner {
    display: inline-block;
    margin-top: 12px;
    background: var(--accent-yellow);
    color: var(--bg-dark) !important;
    font-weight: 700;
    letter-spacing: 1px;
    text-decoration: none;
}

.btn-linescanner:hover {
    background: #ff9520;
}

.gameover-container h3 {
    font-size: 22px;
    color: var(--accent-yellow);
    letter-spacing: 3px;
    margin-bottom: 16px;
}

/* ===== LEADERBOARD TABLE (shared by welcome + game-over screens) ===== */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.leaderboard-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    padding: 8px 12px;
    border-bottom: 2px solid var(--conveyor-light);
    text-align: left;
}

.leaderboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--conveyor-dark);
    font-size: 14px;
    text-align: left;
}

.leaderboard-table tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }

.leaderboard-table tr.current-player {
    background: rgba(239, 124, 0, 0.1);
    border-left: 3px solid var(--accent-yellow);
}

/* Welcome screen leaderboard — compact, scrollable */
.welcome-leaderboard {
    margin-top: 30px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.welcome-leaderboard h3 {
    font-size: 16px;
    color: var(--accent-yellow);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.company-cell { display: flex; align-items: center; gap: 8px; }
.company-logo { width: 24px; height: 24px; border-radius: 4px; background: var(--conveyor-dark); }

/* ===== TOUCH OPTIMIZATION ===== */
/* Prevents the 300ms delay on mobile tap. "manipulation" tells the browser
   this element handles taps directly, so don't wait to see if it's a double-tap. */
.btn, .classify-btn, .stop-line-btn, .done-inspect-btn {
    touch-action: manipulation;
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE: TABLET (768px and below) ===== */
@media (max-width: 768px) {
    .game-title { font-size: 32px; letter-spacing: 2px; }
    .panther-img { width: 200px; }
    #hud { padding: 8px 10px; flex-wrap: wrap; gap: 4px; }
    .hud-label { font-size: 9px; }
    .hud-value { font-size: 18px; }
    .result-container, .gameover-container { padding: 20px 15px; }
    .level-overlay-content h2 { font-size: 36px; }
    .stop-line-btn, .done-inspect-btn { padding: 10px 18px; font-size: 12px; }
    #floating-timer-value { font-size: 48px; }
    .result-container h2 { font-size: 26px; }
    .gameover-container h2 { font-size: 32px; }
    .final-value { font-size: 36px; }
}

/* ===== RESPONSIVE: PHONE (480px and below) ===== */
@media (max-width: 480px) {
    .game-title { font-size: 24px; }
    .game-subtitle { font-size: 14px; margin-bottom: 24px; }
    .welcome-container { padding: 20px; }
    .panther-img { width: 160px; }
    .tutorial-eyes { width: 120px; }

    /* Buttons: large enough for finger taps (44px minimum) */
    .btn { padding: 12px 24px; font-size: 16px; min-height: 44px; }
    .btn-start { padding: 14px; font-size: 18px; }

    /* HUD wraps to 2 rows on small screens */
    #hud {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 8px;
    }
    .hud-value { font-size: 16px; }

    /* Glass fits the screen */
    #glass-panel { max-width: 90vw !important; }

    /* Classification popup centers on mobile */
    #classify-popup {
        min-width: 140px;
    }
    .classify-btn {
        padding: 12px 14px;
        font-size: 14px;
        min-height: 44px;
    }

    /* Stop + Done buttons */
    .stop-line-btn, .done-inspect-btn {
        padding: 14px 20px;
        font-size: 13px;
        min-height: 44px;
    }
    #stop-line-container, #done-inspect-container { right: 10px; top: 10px; }

    /* Timer */
    #floating-timer-value { font-size: 40px; }

    /* Leaderboard table */
    .leaderboard-table td,
    .leaderboard-table th {
        padding: 6px 8px;
        font-size: 12px;
    }
    .company-logo { width: 18px; height: 18px; }

    /* Tutorial */
    .tutorial-container { padding: 20px 15px; }
    .tutorial-section { padding: 12px 14px; }
    .tutorial-section h3 { font-size: 13px; }
    .tutorial-section p { font-size: 13px; }
    .defect-thumbnail { width: 48px; height: 48px; }

    /* Result screen */
    #result-stats { max-width: 100%; }
    .stat-label { font-size: 12px; }
    .stat-value { font-size: 14px; }
    .stat-money { font-size: 12px; }
    .result-accuracy { font-size: 16px; }
    .result-accuracy span:first-child { font-size: 20px; }

    /* Game over */
    .final-value { font-size: 32px; }
    .gameover-container h2 { font-size: 28px; }
}
