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

:root {
    --primary-color: #00d2ff;
    --secondary-color: #3a7bd5;
    --background-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #facc15;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Prompt', sans-serif;
}

body {
    background: linear-gradient(135deg, var(--background-dark) 0%, #1e1e2f 100%);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.8s ease-out;
}

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

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
    margin-bottom: 10px;
}

.header p {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-light);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 210, 255, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 10px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 210, 255, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

/* AR Game Specific */
.game-container {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.game-header {
    padding: 15px 20px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
}

.player-info {
    font-weight: 600;
    color: var(--accent);
}

.instructions {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-light);
    flex-grow: 1;
}

.video-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.input_video {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1);
    /* Mirror */
    opacity: 0.8;
}

.output_canvas {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scaleX(-1);
    /* Mirror */
    z-index: 10;
}

.overlay-ui {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    text-align: center;
    width: 90%;
    max-width: 600px;
}

/* ===== Timer HUD ===== */
.timer-hud {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.timer-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid #00d2ff;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 20px rgba(0, 210, 255, 0.3);
    transition: border-color 0.5s, box-shadow 0.5s;
    will-change: transform;
}

.timer-circle span {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    font-family: 'Prompt', sans-serif;
}

.timer-circle.warning {
    border-color: #facc15;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.4);
}

.timer-circle.danger {
    border-color: #ef4444;
    box-shadow: 0 0 25px rgba(239, 68, 68, 0.5);
}

.timer-circle.danger span {
    color: #ef4444;
}

.timer-circle.warning span {
    color: #facc15;
}

.score-hud.animate {
    transform: scale(1.3);
    color: #facc15;
}

/* ===== Mini Leaderboard ===== */
.mini-leaderboard {
    position: absolute;
    top: 220px;
    /* Below the timerHUD */
    right: 20px;
    z-index: 30;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px 15px;
    width: 160px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.mini-leaderboard h4 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    text-align: center;
    color: #facc15;
    text-shadow: 0 0 5px rgba(250, 204, 21, 0.5);
    letter-spacing: 0.5px;
}

.mini-leaderboard ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-leaderboard li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
    padding: 5px 8px;
    border-radius: 6px;
}

.mini-leaderboard li .name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80px;
}

.mini-leaderboard li .score {
    color: #38bdf8;
    font-family: 'Courier New', Courier, monospace;
}

/* SweetAlert2 Glassmorphism */
div:where(.swal2-container) div:where(.swal2-popup).glass-alert {
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    color: white;
}

div:where(.swal2-container) div:where(.swal2-html-container) {
    color: #e2e8f0;
}

/* --- Cyber Modal (System Broadcast) --- */
div:where(.swal2-container) div:where(.swal2-popup).cyber-modal {
    background: #050505 !important;
    border: 1px solid rgba(250, 204, 21, 0.5);
    /* Gold border */
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.1);
    border-radius: 12px;
    color: #e2e8f0;
    font-family: 'Courier New', Courier, monospace;
    width: 600px;
    max-width: 95vw;
}

.sb-container {
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sb-header {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.sb-icon {
    font-size: 2.5rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

.sb-titles {
    display: flex;
    flex-direction: column;
}

.sb-title {
    color: #facc15;
    /* Gold */
    font-size: 1.4rem;
    font-weight: bold;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
    margin: 0;
}

.sb-subtitle {
    color: #64748b;
    font-size: 0.8rem;
    letter-spacing: 1px;
    margin: 0;
}

.sb-content-box {
    background: #0f0f0f;
    border: 1px solid rgba(250, 204, 21, 0.2);
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    min-height: 120px;
    max-height: 50vh;
    overflow-y: auto;
}

.sb-text {
    margin: 0;
    line-height: 1.6;
    color: #cbd5e1;
    font-size: 0.95rem;
}

.sb-hr {
    border: none;
    border-top: 1px solid #333;
    margin: 15px 0;
}

.sb-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    border-top: 1px solid #1f2937;
    padding-top: 20px;
}

.sb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    letter-spacing: 1px;
}

.sb-checkbox-label input {
    display: none;
}

.sb-custom-checkbox {
    width: 18px;
    height: 18px;
    border: 1px solid #64748b;
    border-radius: 4px;
    display: inline-block;
    position: relative;
    background: #000;
}

.sb-checkbox-label input:checked+.sb-custom-checkbox::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid #facc15;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.sb-btn {
    background: #eab308;
    color: #000;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: bold;
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    letter-spacing: 1px;
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.3);
    transition: all 0.2s;
}

.sb-btn:hover {
    background: #facc15;
    box-shadow: 0 0 20px rgba(250, 204, 21, 0.6);
    transform: translateY(-1px);
}


.score-hud {
    font-size: 1.4rem;
    font-weight: 700;
    color: #22c55e;
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.5);
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 16px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
}

.status-badge {
    display: inline-block;
    padding: 15px 30px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid var(--primary-color);
    border-radius: 30px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.status-badge.success {
    border-color: #22c55e;
    color: #22c55e;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.loader {
    display: none;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateX(150%);
    transition: transform 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.toast.show {
    transform: translateX(0);
}

/* ===== Premium Glassmorphism Debug Overlay ===== */
.debug-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 20px;
}

.debug-overlay-content {
    position: relative;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    border-radius: 24px;
    padding: 35px 40px;
    max-width: 550px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.debug-overlay-content::-webkit-scrollbar {
    width: 6px;
}

.debug-overlay-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.debug-overlay-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.debug-overlay-content h2 {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #facc15 0%, #fb923c 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 15px rgba(250, 204, 21, 0.2);
    letter-spacing: -0.5px;
}

.debug-report h3 {
    font-size: 1.2rem;
    color: #38bdf8;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.debug-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 30px;
}

.debug-stat {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s;
    box-shadow: inset 0 2px 10px rgba(255, 255, 255, 0.02);
}

.debug-stat:hover {
    background: rgba(0, 0, 0, 0.35);
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.08);
}

.debug-label {
    font-size: 0.75rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}

.debug-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #f8fafc;
}

.debug-value.good {
    color: #4ade80;
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.2);
}

.debug-value.bad {
    color: #f87171;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.2);
}

.debug-problems {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.debug-problem {
    padding: 16px 20px;
    border-radius: 14px;
    border-left: 4px solid;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(255, 255, 255, 0.02);
    border-right: 1px solid rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.debug-buttons {
    display: flex;
    gap: 16px;
    margin-top: 35px;
    width: 100%;
}

.glass-btn {
    flex: 1;
    height: 56px;
    padding: 0 20px;
    border-radius: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.glass-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    border-radius: 16px;
}

.glass-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.4);
    pointer-events: none;
}

.glass-btn:hover {
    transform: translateY(-3px);
}

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

.glass-btn-primary {
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.8) 0%, rgba(58, 123, 213, 0.9) 100%);
    box-shadow: 0 10px 20px rgba(0, 210, 255, 0.2);
}

.glass-btn-primary:hover {
    box-shadow: 0 15px 25px rgba(0, 210, 255, 0.4);
    background: linear-gradient(135deg, rgba(0, 210, 255, 0.9) 0%, rgba(58, 123, 213, 1) 100%);
}

.glass-btn-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.8) 0%, rgba(220, 38, 38, 0.9) 100%);
    box-shadow: 0 10px 20px rgba(239, 68, 68, 0.2);
}

.glass-btn-danger:hover {
    box-shadow: 0 15px 25px rgba(239, 68, 68, 0.4);
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(185, 28, 28, 1) 100%);
}

.btn-icon {
    font-size: 1.25rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.debug-problem.error {
    background: rgba(239, 68, 68, 0.1);
    border-left-color: #ef4444;
}

.debug-problem.warning {
    background: rgba(250, 204, 21, 0.1);
    border-left-color: #facc15;
}

.debug-problem.info {
    background: rgba(59, 130, 246, 0.1);
    border-left-color: #3b82f6;
}

.debug-problem strong {
    display: block;
    margin-bottom: 4px;
}

.debug-problem small {
    color: #94a3b8;
}

.debug-problem em {
    font-style: normal;
    color: #00d2ff;
    font-size: 0.85rem;
}

.debug-ok {
    text-align: center;
    padding: 20px;
    font-size: 1.2rem;
    color: #22c55e;
}

.debug-play-again {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    background: linear-gradient(to right, #00d2ff, #3a7bd5);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Prompt', sans-serif;
    transition: transform 0.2s, box-shadow 0.2s;
}

.debug-play-again:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 210, 255, 0.3);
}

/* ===== FPS Counter ===== */
.fps-counter {
    position: absolute;
    top: 430px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #22c55e;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: none;
}

.fps-counter.lagging {
    color: #ef4444;
    border-color: #ef4444;
}

/* ===== Portrait Warning (Force Landscape) ===== */
#portrait-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #0f172a;
    z-index: 999999;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
    backdrop-filter: blur(10px);
}

#portrait-warning .warning-content {
    padding: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border: 1px solid rgba(0, 210, 255, 0.3);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-width: 80%;
}

#portrait-warning .rotate-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    display: inline-block;
    animation: rotatePhone 2.5s infinite ease-in-out;
}

#portrait-warning h2 {
    color: #00d2ff;
    margin-bottom: 10px;
}

#portrait-warning p {
    color: #94a3b8;
    font-size: 1.1rem;
}

@keyframes rotatePhone {
    0% {
        transform: rotate(0deg);
    }

    30% {
        transform: rotate(-90deg);
    }

    70% {
        transform: rotate(-90deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

@media screen and (orientation: portrait) {
    #portrait-warning {
        display: flex;
    }
}

/* ===== Countdown Overlay ===== */
#countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 50;
    pointer-events: none;
}

#countdown-overlay span {
    font-size: 15rem;
    font-weight: 700;
    color: #facc15;
    text-shadow: 0 0 50px rgba(250, 204, 21, 0.8), 0 0 20px rgba(0, 0, 0, 0.5);
    /* animation: countdownPing 1s cubic-bezier(0, 0, 0.2, 1) infinite; */
}

@keyframes countdownPing {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    20% {
        transform: scale(1.1);
        opacity: 1;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* ── Announcement Modal Override ── */
div:where(.swal2-container) div:where(.swal2-popup).ann-swal-popup {
    border-radius: 18px !important;
    border: 1px solid rgba(0, 210, 255, 0.15) !important;
    overflow: hidden !important;
    padding: 0 !important;
    box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 0 1px rgba(0,210,255,0.08) !important;
}