:root {
    --bg-dark: #0a0a14;
    --bg-card: rgba(18, 18, 30, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-strong: rgba(22, 20, 40, 0.92);
    --border-glass: rgba(255, 255, 255, 0.08);
    --accent-purple: #8B5CF6;
    --accent-purple-light: #A78BFA;
    --accent-pink: #EC4899;
    --accent-cyan: #06B6D4;
    --neon-cyan: #22D3EE;
    --neon-purple: #C084FC;
    --neon-pink: #F472B6;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.75);
    --text-muted: rgba(255, 255, 255, 0.45);
    --gradient-primary: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    --gradient-vibrant: linear-gradient(135deg, #8B5CF6, #EC4899, #06B6D4);
    --gradient-glow: linear-gradient(135deg, rgba(139, 92, 246, 0.4), rgba(236, 72, 153, 0.4));
    --shadow-float: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(139, 92, 246, 0.15);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 40px rgba(139, 92, 246, 0.3), 0 0 80px rgba(236, 72, 153, 0.15);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(ellipse 80% 50% at 20% 10%, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 90%, rgba(236, 72, 153, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
    animation: aureolaFloat 15s ease-in-out infinite;
    pointer-events: none;
    z-index: -2;
}

@keyframes aureolaFloat {
    0%, 100% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    25% { 
        transform: scale(1.05) rotate(1deg);
        opacity: 0.9;
    }
    50% { 
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    75% { 
        transform: scale(1.03) rotate(-1deg);
        opacity: 0.95;
    }
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    background: 
        radial-gradient(circle at 30% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 25%),
        radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.06) 0%, transparent 25%);
    animation: orbFloat 20s ease-in-out infinite reverse;
    pointer-events: none;
    z-index: -1;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(20px, -20px); }
    50% { transform: translate(-10px, 10px); }
    75% { transform: translate(15px, 15px); }
}

.app-container {
    max-width: 1440px;
    height: 100vh;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header {
    flex-shrink: 0;
    margin-bottom: 20px;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 18px 28px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.header-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.5), rgba(236, 72, 153, 0.5), transparent);
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 30px rgba(236, 72, 153, 0.5); }
}

.logo-text {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-text .accent {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-glass);
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #EF4444;
    box-shadow: 0 0 10px #EF4444;
    animation: pulse 1.5s infinite;
}

.connection-status.connected .status-dot {
    background: #10B981;
    box-shadow: 0 0 15px #10B981;
}

.connection-status.connected {
    border-color: rgba(16, 185, 129, 0.3);
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.95); }
}

.main-content {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .main-content { grid-template-columns: 1fr; }
}

.video-section {
    display: flex;
    flex-direction: column;
    animation: fadeInLeft 0.7s ease-out 0.2s both;
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.video-container {
    position: relative;
    flex: 1;
    min-height: 0;
    background: var(--bg-dark);
    border-radius: 20px;
    overflow: hidden;
}


.video-container video,
.video-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.video-container canvas {
    pointer-events: none;
}

.ar-overlay {
    position: absolute;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
    transform: scale(0.8) translateY(-10px);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.ar-overlay.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.detected-letter {
    font-size: 90px;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.6));
    animation: letterGlow 1.5s ease-in-out infinite alternate;
    text-shadow: 0 0 60px rgba(139, 92, 246, 0.5);
}

@keyframes letterGlow {
    from { 
        filter: drop-shadow(0 0 20px rgba(139, 92, 246, 0.5));
        transform: scale(1);
    }
    to { 
        filter: drop-shadow(0 0 40px rgba(236, 72, 153, 0.7));
        transform: scale(1.05);
    }
}

.confidence-bar {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.confidence-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 4px;
    transition: width 0.25s ease, background 0.3s ease;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.hand-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 32px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 9999px;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: floatIndicator 3s ease-in-out infinite;
    opacity: 0;
    pointer-events: none;
}

.hand-indicator.visible {
    opacity: 1;
    pointer-events: auto;
}

@keyframes floatIndicator {
    0%, 100% { transform: translate(-50%, -50%) translateY(0); }
    50% { transform: translate(-50%, -50%) translateY(-8px); }
}

.hand-indicator.hidden {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
}

.pulse-ring {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
    border-radius: 50%;
    animation: pulseRing 2s infinite;
}

@keyframes pulseRing {
    0% { 
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 20px rgba(139, 92, 246, 0);
    }
    100% { 
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
    }
}

.indicator-text {
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 10;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(12px);
}

.btn-primary {
    background: rgba(139, 92, 246, 0.8);
    color: white;
}

.btn-primary:hover {
    background: rgba(139, 92, 246, 0.95);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

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

.btn.hidden {
    display: none;
}

.output-section {
    display: flex;
    flex-direction: column;
    gap: 18px;
    min-height: 0;
    overflow: hidden;
    animation: fadeInRight 0.7s ease-out 0.3s both;
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.output-card, .history-card, .reference-card {
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px);
    border: none;
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.output-card { flex: 1; display: flex; flex-direction: column; }

.output-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.output-text {
    flex: 1;
    min-height: 100px;
    padding: 22px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 14px;
    font-size: 26px;
    font-weight: 600;
    word-break: break-word;
    border: none;
}

.output-text .placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 16px;
    font-weight: 400;
}

.output-text .cursor {
    display: inline-block;
    width: 3px;
    height: 30px;
    background: linear-gradient(180deg, var(--accent-purple), var(--accent-pink));
    margin-left: 4px;
    animation: blink 1s step-end infinite;
    vertical-align: text-bottom;
    border-radius: 2px;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.output-actions {
    display: flex;
    gap: 12px;
    margin-top: 18px;
}

.btn-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-action:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
}

.btn-action-icon {
    font-size: 16px;
}

.btn-action-label {
    font-family: 'Manrope', sans-serif;
}

iconify-icon {
    display: inline-block;
    width: 1em;
    height: 1em;
}

.history-title, .reference-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.history-letters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.history-letter {
    min-width: 44px;
    height: 44px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.2);
    border-radius: 9999px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    animation: popIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.history-letter:first-child {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
}

@keyframes popIn {
    0% { transform: scale(0) rotate(-10deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.alphabet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 8px;
}

.alphabet-letter {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.05);
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alphabet-letter.active {
    background: var(--gradient-primary);
    color: white;
    transform: scale(1.2);
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
}

.footer {
    margin-top: 30px;
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.footer a {
    color: var(--neon-cyan);
    text-decoration: none;
    transition: color 0.3s;
}

.footer a:hover {
    color: var(--accent-pink);
    text-decoration: underline;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 18px;
}

.mode-toggle {
    display: flex;
    background: rgba(20, 18, 35, 0.9);
    border: 1px solid var(--border-glass);
    border-radius: 9999px;
    padding: 5px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mode-btn {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 700;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.5);
}

.game-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    flex: 1;
    min-height: 0;
    position: relative;
}

.game-panel.hidden {
    display: none;
}

.stage-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 14px 24px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
}

.stage-badge {
    padding: 10px 22px;
    background: var(--gradient-primary);
    color: white;
    font-size: 13px;
    font-weight: 800;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.stage-phrase {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-style: italic;
}

.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    width: 100%;
    position: relative;
}

.challenge-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex: 1;
    width: 100%;
    min-height: 140px;
    padding: 28px 36px;
    background: linear-gradient(145deg, rgba(25, 23, 45, 0.95), rgba(18, 16, 35, 0.95));
    backdrop-filter: blur(24px);
    border: 2px solid var(--border-glass);
    border-radius: 24px;
    box-shadow: var(--shadow-card), var(--shadow-glow);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.challenge-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    animation: rotateGradient 10s linear infinite;
    pointer-events: none;
}

@keyframes rotateGradient {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.challenge-card.success {
    border-color: #10B981;
    box-shadow: 0 0 60px rgba(16, 185, 129, 0.5), 0 0 100px rgba(16, 185, 129, 0.3);
    animation: successPulse 0.5s ease;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.challenge-label {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
}

.challenge-letter {
    font-size: clamp(70px, 12vw, 120px);
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    filter: drop-shadow(0 0 40px rgba(139, 92, 246, 0.6));
    animation: challengePulse 2s ease-in-out infinite;
}

@keyframes challengePulse {
    0%, 100% { 
        filter: drop-shadow(0 0 30px rgba(139, 92, 246, 0.5));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0 0 50px rgba(236, 72, 153, 0.6));
        transform: scale(1.03);
    }
}

.asl-image {
    width: clamp(110px, 18vw, 180px);
    height: clamp(110px, 18vw, 180px);
    object-fit: contain;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 20px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    transition: all 0.3s ease;
}

.asl-image:hover {
    border-color: rgba(139, 92, 246, 0.5);
    transform: scale(1.05);
}

.next-up {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    color: var(--text-muted);
}

.next-label {
    color: var(--text-muted);
    font-weight: 500;
}

.next-letter {
    color: var(--neon-purple);
    font-weight: 800;
    font-size: 22px;
}

.get-ready-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.92);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    z-index: 20;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.get-ready-overlay.hidden {
    display: none;
}

.get-ready-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.get-ready-icon {
    width: 90px;
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #10B981, #059669);
    border-radius: 50%;
    font-size: 44px;
    color: white;
    animation: scaleIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.5);
}

@keyframes scaleIn {
    from { transform: scale(0) rotate(-180deg); }
    to { transform: scale(1) rotate(0deg); }
}

.get-ready-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress-section {
    flex-shrink: 0;
    padding: 14px 24px;
    background: var(--bg-glass-strong);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: var(--shadow-card);
}

.progress-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
    font-weight: 700;
}

.phrase-progress {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    font-family: 'Manrope', sans-serif;
}

.progress-letter {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(139, 92, 246, 0.08);
    border: 2px solid rgba(139, 92, 246, 0.15);
    border-radius: 10px;
    color: var(--text-muted);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-letter.current {
    border-color: var(--accent-purple);
    color: var(--accent-purple-light);
    background: rgba(139, 92, 246, 0.15);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    animation: currentPulse 1.5s ease-in-out infinite;
    transform: scale(1.1);
}

@keyframes currentPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(139, 92, 246, 0.4); }
    50% { box-shadow: 0 0 30px rgba(236, 72, 153, 0.6); }
}

.progress-letter.completed {
    background: var(--gradient-primary);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.progress-space {
    width: 16px;
}

.stage-complete-modal.hidden {
    display: none;
}

.output-card.hidden,
.history-card.hidden,
.reference-card.hidden {
    display: none;
}

@media (max-width: 1024px) {
    .game-panel {
        grid-column: 1;
    }
    
    .challenge-card {
        padding: 30px 40px;
    }
    
    .challenge-letter {
        font-size: 80px;
    }
    
    .asl-image {
        width: 150px;
        height: 150px;
    }
    
    .header-right {
        flex-direction: column;
        gap: 10px;
    }
    
    .mode-toggle {
        order: 1;
    }
}

@media (max-width: 600px) {
    .mode-btn {
        padding: 8px 14px;
        font-size: 12px;
    }
    
    .challenge-letter {
        font-size: 60px;
    }
    
    .asl-image {
        width: 120px;
        height: 120px;
    }
    
    .progress-letter {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

.stage-timer {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: rgba(20, 18, 35, 0.95);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 9999px;
    font-size: 18px;
    font-weight: 800;
    font-family: 'Manrope', sans-serif;
    color: var(--accent-purple-light);
    letter-spacing: 0.5px;
}

.stage-timer .stage-timer-icon {
    font-size: 20px;
    color: var(--accent-purple-light);
}

.confetti-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    opacity: 0;
    animation: confetti-fall linear forwards;
}

.confetti:nth-child(odd) {
    width: 8px;
    height: 16px;
    border-radius: 2px;
}

.confetti:nth-child(even) {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.confetti:nth-child(3n) {
    width: 6px;
    height: 6px;
    border-radius: 0;
    transform: rotate(45deg);
}

@keyframes confetti-fall {
    0% {
        opacity: 1;
        top: -10%;
        transform: translateX(0) rotateZ(0deg);
    }
    100% {
        opacity: 0.7;
        top: 100%;
        transform: translateX(calc(var(--drift, 20px) - 40px)) rotateZ(720deg);
    }
}

.confetti:nth-child(1n) { --drift: 10px; }
.confetti:nth-child(2n) { --drift: 30px; }
.confetti:nth-child(3n) { --drift: 50px; }
.confetti:nth-child(4n) { --drift: 70px; }
.confetti:nth-child(5n) { --drift: 90px; }

.stage-complete-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 20, 0.92);
    backdrop-filter: blur(20px);
    z-index: 100;
    animation: modalFadeIn 0.5s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.stage-complete-modal .modal-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    padding: 70px 90px;
    background: linear-gradient(145deg, rgba(30, 28, 50, 0.98), rgba(20, 18, 40, 0.98));
    border: 2px solid var(--accent-purple);
    border-radius: 36px;
    box-shadow: 
        0 0 80px rgba(139, 92, 246, 0.4),
        0 0 150px rgba(236, 72, 153, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: modalScaleIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleIn {
    from { 
        transform: scale(0.6) translateY(30px); 
        opacity: 0; 
    }
    to { 
        transform: scale(1) translateY(0); 
        opacity: 1; 
    }
}

.stage-complete-modal .modal-icon {
    font-size: 110px;
    animation: celebrateIcon 0.7s ease infinite alternate;
    filter: drop-shadow(0 0 30px rgba(255, 200, 0, 0.6));
}

@keyframes celebrateIcon {
    from { transform: scale(1) rotate(-8deg); }
    to { transform: scale(1.15) rotate(8deg); }
}

.stage-complete-modal .modal-title {
    font-size: 38px;
    font-weight: 900;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
}

.stage-complete-modal .modal-message {
    font-size: 18px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.6;
}

.completion-phrase {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.completion-time {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: 9999px;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.time-label {
    font-size: 16px;
    color: var(--text-secondary);
}

.time-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent-purple-light);
}

.stage-complete-modal .modal-btn {
    padding: 18px 50px;
    font-size: 18px;
    font-weight: 800;
    background: var(--gradient-primary);
    border: none;
    border-radius: 9999px;
    color: white;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
}

.stage-complete-modal .modal-btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.6), 0 0 60px rgba(236, 72, 153, 0.3);
}

.inspiring-tagline {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    font-size: 18px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    z-index: 5;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    animation: fadeIn 1s ease-out 0.8s both;
}

.inspiring-tagline.wipe-reveal {
    color: transparent;
}

.inspiring-tagline.wipe-reveal span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.inspiring-tagline.wipe-reveal .white-part {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    -webkit-text-fill-color: rgba(255, 255, 255, 0.7);
    animation: wipeRevealWhite 0.8s ease-out forwards;
}

@keyframes wipeRevealWhite {
    0% { 
        clip-path: inset(0 100% 0 0);
    }
    100% { 
        clip-path: inset(0 0 0 0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-15px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.inspiring-tagline span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    body::before,
    body::after {
        animation: none !important;
    }
    
    .logo-img {
        animation: none !important;
    }
    
    .hand-indicator {
        animation: none !important;
    }
    
    .pulse-ring {
        animation: none !important;
    }
    
    .detected-letter {
        animation: none !important;
    }
    
    .challenge-letter {
        animation: none !important;
    }
    
    .confetti {
        animation: none !important;
    }
    
    .stage-complete-modal .modal-icon {
        animation: none !important;
    }
}

/* Hand Match Indicator */
.hand-match-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    padding: 16px 32px;
    border-radius: 16px;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    text-align: center;
    z-index: 100;
    animation: handMatchPop 1.5s ease-out forwards;
    border: 2px solid var(--hand-color, #00f5ff);
    box-shadow: 0 0 30px var(--hand-color, rgba(0, 245, 255, 0.5));
}

@keyframes handMatchPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) translateY(-20px);
    }
}

/* Glassmorphic effect when camera is active */
body.camera-active .output-card,
body.camera-active .history-card,
body.camera-active .reference-card,
body.camera-active .game-panel {
    background: rgba(22, 20, 40, 0.65);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body.camera-active .output-card:hover,
body.camera-active .history-card:hover,
body.camera-active .reference-card:hover {
    background: rgba(22, 20, 40, 0.75);
    border-color: rgba(139, 92, 246, 0.3);
}
