* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #000; color: #fff; font-family: -apple-system, sans-serif; overflow: hidden; height: 100dvh; }

#app { position: relative; width: 100%; height: 100dvh; display: flex; flex-direction: column; }

/* Loading */
#loading {
    position: fixed; inset: 0; background: #000; z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
}
.spinner {
    width: 40px; height: 40px; border: 3px solid #333; border-top-color: #3498db;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Camera */
#camera-wrap { flex: 1; position: relative; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; }
#overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: crosshair; }

/* HUD */
#hud {
    position: absolute; top: 12px; left: 12px; right: 12px;
    display: flex; justify-content: space-between; pointer-events: none;
}
#fps, #count {
    background: rgba(0,0,0,0.6); padding: 4px 10px; border-radius: 6px;
    font-size: 0.8rem; font-variant-numeric: tabular-nums;
}

/* Controls */
#controls {
    display: flex; gap: 8px; padding: 8px 12px; background: rgba(0,0,0,0.8); justify-content: center;
}
#controls button {
    padding: 8px 16px; border: none; border-radius: 8px; font-size: 0.85rem;
    background: #222; color: #fff; cursor: pointer;
}
#controls button:active { background: #444; }

/* Auto result overlay */
.auto-result {
    position: absolute; bottom: 60px; left: 12px; right: 12px;
    background: rgba(0,0,0,0.85); border-radius: 12px; padding: 12px 16px;
    z-index: 50; backdrop-filter: blur(8px); border: 1px solid rgba(255,255,255,0.1);
    max-height: 50vh; overflow-y: auto;
}
.auto-person {
    display: flex; gap: 10px; padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.auto-person:last-child { border-bottom: none; }
.auto-rank {
    font-size: 1.2rem; font-weight: 800; color: #e74c3c;
    min-width: 30px; padding-top: 2px;
}
.auto-detail { flex: 1; min-width: 0; }
.auto-name { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.auto-score { font-size: 0.75rem; color: #95a5a6; font-weight: 400; }
.auto-desc { font-size: 0.8rem; color: #ccc; line-height: 1.4; margin-bottom: 6px; }
.auto-links { display: flex; gap: 6px; }
.auto-links a {
    padding: 4px 10px; background: #3498db; color: #fff; border-radius: 6px;
    text-decoration: none; font-size: 0.75rem; font-weight: 600;
}
.auto-links a:nth-child(2) { background: #ff0000; }
.auto-links a:nth-child(3) { background: #00809d; }

/* Tap hint */
#tap-hint {
    position: absolute; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.7); padding: 8px 16px; border-radius: 8px;
    font-size: 0.9rem; animation: fadeOut 3s forwards;
}
@keyframes fadeOut { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

/* Modal */
.modal {
    position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 200;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal.hidden { display: none; }
.modal-content {
    background: #1a1a1a; border-radius: 16px; width: 100%; max-width: 420px;
    max-height: 85vh; overflow-y: auto; position: relative;
}
.close-btn {
    position: absolute; top: 8px; right: 12px; background: none; border: none;
    color: #fff; font-size: 1.8rem; cursor: pointer; z-index: 10;
}

#result-image-wrap { width: 100%; max-height: 240px; overflow: hidden; border-radius: 16px 16px 0 0; }
#result-image { width: 100%; display: block; object-fit: cover; }

#result-body { padding: 16px; }
#result-body .spinner { margin: 20px auto; }
#result-body p { text-align: center; }

#result-info h2 { font-size: 1.3rem; margin-bottom: 6px; }
#result-info .tag { display: inline-block; margin-bottom: 10px; }
#result-info p { color: #ccc; font-size: 0.9rem; line-height: 1.5; text-align: left; margin-bottom: 16px; }

#result-actions { display: flex; gap: 8px; }
.btn {
    display: inline-block; flex: 1; text-align: center;
    padding: 10px 16px; border-radius: 8px; text-decoration: none;
    font-size: 0.9rem; font-weight: 600;
    background: #3498db; color: #fff; border: none; cursor: pointer;
}
.btn:nth-child(2) { background: #e67e22; }

#result-loading { text-align: center; padding: 20px; }
#result-error { text-align: center; padding: 20px; color: #e74c3c; }

.hidden { display: none !important; }
