body {
    margin: 0;
    overflow: hidden;
    background-color: #000;
    touch-action: none;
    font-family: "Microsoft JhengHei", sans-serif;
    user-select: none;
}

#camera-feed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    display: none;
    transform: scaleX(1);
}

#canvas-container {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 5;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a0505;
    z-index: 99999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #d4af37;
    pointer-events: auto;
}

.phone-icon {
    width: 50px;
    height: 90px;
    border: 4px solid #d4af37;
    border-radius: 8px;
    margin-bottom: 30px;
    position: relative;
    animation: rotate-phone 2s infinite ease-in-out;
}

.phone-icon::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 15px;
    height: 4px;
    background-color: #d4af37;
    border-radius: 2px;
}

@keyframes rotate-phone {
    0% {
        transform: rotate(-90deg);
        opacity: 0;
    }

    30% {
        transform: rotate(-90deg);
        opacity: 1;
    }

    70% {
        transform: rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: rotate(0deg);
        opacity: 0;
    }
}

.warning-text {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    text-align: center;
}

@media screen and (orientation: landscape) {
    #landscape-warning {
        display: flex;
    }
}

#streak-overlay {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    font-size: 88px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 20px #ff0000, 0 0 40px #ff0000;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    letter-spacing: 10px;
    white-space: nowrap;
}

#streak-overlay.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#streak-container {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 20;
    display: none;
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.streak-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #555;
    background-color: rgba(0, 0, 0, 0.5);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.streak-dot.active {
    background-color: #ff0000;
    border-color: #ffaaaa;
    box-shadow: 0 0 15px #ff0000, 0 0 30px #ff3333;
    transform: scale(1.2);
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out;
}

.loading-text {
    color: #d4af37;
    font-size: 24px;
    letter-spacing: 5px;
    font-weight: bold;
    margin-bottom: 20px;
    text-shadow: 0 0 10px #ffaa00;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #333;
    border-top: 4px solid #d4af37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

#injection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 80;
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    backdrop-filter: blur(4px);
    transition: opacity 1.0s ease-in-out;
}

.injection-text {
    color: #fff;
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    text-shadow: 0 0 20px #ffaa00, 0 0 40px #ff4400;
    animation: breathe 1.5s infinite alternate;
    text-align: center;
}

@keyframes breathe {
    0% {
        opacity: 0.6;
        transform: scale(0.98);
    }

    100% {
        opacity: 1;
        transform: scale(1.02);
    }
}

#custom-toast {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(50, 10, 10, 0.95);
    border: 2px solid #d94e41;
    padding: 20px 30px;
    border-radius: 12px;
    z-index: 100;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    width: 80%;
    max-width: 280px;
}

.toast-title {
    color: #d94e41;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
}

.toast-msg {
    color: #fff;
    font-size: 14px;
    line-height: 1.5;
}

.icon-btn {
    position: absolute;
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #ffd700;
    border-radius: 50%;
    color: #ffd700;
    font-size: 24px;
    backdrop-filter: blur(5px);
    cursor: pointer;
    pointer-events: auto;
    z-index: 20;
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 2px;
    transition: background 0.3s;
}

.icon-btn:active {
    background: rgba(255, 215, 0, 0.2);
}

#btn-settings {
    top: max(20px, env(safe-area-inset-top));
}

#btn-camera {
    top: calc(max(20px, env(safe-area-inset-top)) + 60px);
}

/* Result Display */
#result-display {
    position: absolute;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 100%;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.9);
    pointer-events: none;
}

.result-title {
    font-size: 60px;
    font-weight: 900;
    color: #ffd700;
    margin-bottom: 5px;
    letter-spacing: 8px;
}

.result-desc {
    font-size: 18px;
    color: #eee;
    letter-spacing: 2px;
    font-weight: 300;
}

#instruction {
    position: absolute;
    bottom: max(8%, env(safe-area-inset-bottom) + 20px);
    left: 0;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    letter-spacing: 2px;
    pointer-events: none;
    transition: opacity 0.5s;
    animation: pulse 3s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.8;
    }

    100% {
        opacity: 0.3;
    }
}

#settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 30;
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, #2a0a0a, #1a0505);
    border: 1px solid #d94e41;
    padding: 25px;
    border-radius: 15px;
    width: 85%;
    max-width: 320px;
    color: #d4af37;
    text-align: left;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    max-height: 80vh;
    overflow-y: auto;
}

#btn-close-settings {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    color: #aaa;
    cursor: pointer;
    z-index: 50;
    line-height: 1;
    font-weight: bold;
    padding: 5px;
}

#btn-close-settings:active {
    color: #fff;
    transform: scale(0.9);
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 5px;
}

input[type="tel"],
input[type="text"],
input[type="date"] {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid #555;
    color: white;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

input:focus {
    outline: none;
    border-color: #d94e41;
}

.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
}

.toggle-group label {
    margin: 0;
    color: #d4af37;
    font-size: 16px;
    font-weight: bold;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #d94e41;
    cursor: pointer;
}

.file-upload-btn {
    display: inline-block;
    width: 100%;
    padding: 12px 0;
    background: rgba(255, 215, 0, 0.1);
    border: 1px dashed #ffd700;
    color: #ffd700;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    box-sizing: border-box;
}

.file-upload-btn:hover {
    background: rgba(255, 215, 0, 0.2);
}

input[type="file"] {
    display: none;
}

.system-desc {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
    margin-bottom: 5px;
    line-height: 1.5;
    text-align: center;
}

button.confirm {
    background: #d94e41;
    color: white;
    border: none;
    padding: 12px 0;
    border-radius: 25px;
    margin-top: 10px;
    width: 100%;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(217, 78, 65, 0.6);
    position: relative;
    overflow: hidden;
    letter-spacing: 2px;
}

button.confirm:active {
    transform: scale(0.98);
}

button.confirm::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    20% {
        left: 100%;
    }

    100% {
        left: 100%;
    }
}