@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
    --bg-dark: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-danger: #ef4444;
    --accent-danger-hover: #dc2626;
    --accent-success: #10b981;
    --accent-success-hover: #059669;
    --accent-warning: #f59e0b;
    
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --font-ui: 'Space Grotesk', 'Inter', sans-serif;
    --font-clock: 'Orbitron', monospace;
}

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

body {
    background: linear-gradient(135deg, #0f172a, #1e1b4b, #172554);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app-container {
    width: 100%;
    height: 100%;
    position: relative;
    /* Glassmorphism full-container on mobile, max-width on desktop to keep it pretty but wide */
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    justify-content: center;
    align-items: center;
}

@media (min-width: 768px) {
    #app-container {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        border: none;
    }
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px) scale(0.95);
}

.screen.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    z-index: 10;
}

/* Typography */
.title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: center;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 2px;
}

.subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    text-align: center;
}

.clock-display {
    font-family: var(--font-clock);
    font-size: clamp(4rem, 10vw, 7rem);
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 2rem;
    text-shadow: 0 0 30px rgba(59, 130, 246, 0.5);
    letter-spacing: 4px;
}

.clock-display.giant {
    font-size: clamp(5rem, 15vw, 9rem);
    color: var(--accent-primary);
}

.highlight {
    color: var(--accent-warning);
    font-weight: bold;
    text-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

/* Forms */
.form-group {
    width: 100%;
    max-width: 400px;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
}

label {
    font-size: 1.1rem;
    margin-bottom: 0.8rem;
    color: var(--text-muted);
}

input[type="time"] {
    width: 100%;
    padding: 1.2rem;
    font-size: 1.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-main);
    font-family: var(--font-ui);
    transition: all 0.3s ease;
    text-align: center;
}

input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

input[type="time"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

/* Buttons */
.btn {
    width: 100%;
    max-width: 400px;
    padding: 1.2rem;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-ui);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
    letter-spacing: 1px;
}

.btn:active {
    transform: scale(0.96);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #6366f1);
    color: white;
    box-shadow: 0 10px 20px -10px var(--accent-primary);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 15px 25px -10px var(--accent-primary);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-success), #14b8a6);
    color: white;
    box-shadow: 0 10px 20px -10px var(--accent-success);
}

.btn-success:hover {
    box-shadow: 0 15px 25px -10px var(--accent-success);
    transform: translateY(-2px);
}

/* Waiting Screen */
.target-info {
    text-align: center;
    background: rgba(0,0,0,0.4);
    padding: 2rem;
    border-radius: 24px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 2rem;
    line-height: 1.8;
    font-size: 1.2rem;
    border: 1px solid var(--glass-border);
}

.sub-info {
    display: inline-block;
    margin-top: 1rem;
    color: var(--accent-primary);
    font-size: 0.95rem;
    background: rgba(59, 130, 246, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

/* Alarm Screen */
#screen-alarm {
    background: radial-gradient(circle at center, #450a0a, #000);
}

#screen-alarm.shake {
    animation: shake 0.6s infinite;
}

.alarm-header {
    text-align: center;
    margin-bottom: 2rem;
    z-index: 2;
}

.alarm-header h2 {
    color: var(--accent-danger);
    font-size: clamp(3rem, 6vw, 4rem);
    margin-bottom: 1rem;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8);
    animation: pulseAlarm 1s infinite alternate;
}

.alarm-header p {
    font-size: clamp(1.2rem, 3vw, 1.5rem);
}

.pulse-text {
    animation: pulseText 1s infinite alternate;
    font-size: 1.6rem;
    display: inline-block;
    padding: 0.2rem 0.5rem;
    background: rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    margin: 0 0.5rem;
}

.camera-container {
    width: 100%;
    max-width: 600px;
    aspect-ratio: 16/9;
    border-radius: 24px;
    overflow: hidden;
    position: relative;
    border: 4px solid var(--accent-danger);
    box-shadow: 0 0 40px rgba(239, 68, 68, 0.5);
    background-color: #000;
}

@media (max-width: 768px) {
    .camera-container {
        aspect-ratio: 1; /* Square on mobile */
    }
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: var(--accent-danger);
    box-shadow: 0 0 15px var(--accent-danger), 0 0 30px var(--accent-danger);
    animation: scanPulse 2.5s ease-in-out infinite alternate;
    z-index: 5;
}

.scan-overlay::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to bottom, rgba(239,68,68,0.4), transparent);
}

.detection-panel {
    width: 100%;
    max-width: 600px;
    background: rgba(0,0,0,0.8);
    padding: 2rem;
    border-radius: 24px;
    margin-top: 2rem;
    text-align: center;
    border: 1px solid var(--glass-border);
}

#detection-status {
    margin-bottom: 1.5rem;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.confidence-bar-container {
    width: 100%;
    height: 30px;
    background-color: rgba(255,255,255,0.1);
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
}

.confidence-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-warning), var(--accent-success));
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 15px;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.confidence-val {
    font-family: var(--font-clock);
    font-size: 1.5rem;
    font-weight: 700;
}

/* Success Screen */
.success-icon {
    font-size: 6rem;
    margin-bottom: 1rem;
    animation: bounceObj 2s ease-in-out infinite alternate;
    filter: drop-shadow(0 0 20px rgba(255,255,255,0.2));
}

.success-text {
    color: var(--accent-success);
    text-shadow: 0 0 25px rgba(16, 185, 129, 0.6);
    background: none;
    -webkit-text-fill-color: initial;
}

.stats-box {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 2rem;
    border-radius: 24px;
    margin: 2rem 0;
    width: 100%;
    max-width: 400px;
    text-align: center;
    font-size: 1.2rem;
}

#success-time {
    font-family: var(--font-clock);
    color: var(--accent-success);
    font-size: 1.5rem;
    margin-left: 0.5rem;
}

.error-msg {
    color: var(--accent-danger);
    margin-top: 1rem;
    font-size: 0.95rem;
    text-align: center;
    min-height: 24px;
}

#camera-error {
    margin-top: 1rem;
    color: var(--accent-warning);
    text-align: center;
}

/* Animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px) rotate(-1deg); }
    20%, 40%, 60%, 80% { transform: translateX(4px) rotate(1deg); }
}

@keyframes pulseText {
    from { color: var(--accent-warning); transform: scale(0.95); opacity: 0.8; }
    to { color: #fff; transform: scale(1.05); opacity: 1; text-shadow: 0 0 10px #fff; }
}

@keyframes pulseAlarm {
    from { text-shadow: 0 0 10px rgba(239, 68, 68, 0.4); transform: scale(0.98); }
    to { text-shadow: 0 0 30px rgba(239, 68, 68, 1); transform: scale(1.02); }
}

@keyframes scanPulse {
    from { top: 0; }
    to { top: calc(100% - 4px); }
}

@keyframes bounceObj {
    from { transform: translateY(0) scale(1); }
    to { transform: translateY(-30px) scale(1.1); }
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
