/* Modern Dark Theme & Glassmorphism */
:root {
    --bg-color: #050505;
    --text-color: #ffffff;
    --text-secondary: #a1a1aa;
    --accent-color: #3b82f6;
    --card-bg: rgba(22, 22, 24, 0.6);
    --card-border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(0, 0, 0, 0.4);
    --input-border: rgba(255, 255, 255, 0.1);
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --hover-gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* Pure Black Background */
    background-color: #000000;
    background-image: none;
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wrap {
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Spacing Fixed */
.logo-area {
    margin-bottom: 20px !important;
}

.logo-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto !important;
    /* 위아래 마진 0, 좌우 자동 */
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: none;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 20px 0 !important;
    /* 아래쪽 마진 20px 강제 */
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
    margin-left: 0.25rem;
}

input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: all 0.2s ease;
    outline: none;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background: rgba(0, 0, 0, 0.6);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    margin-top: 1rem;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.login-btn:active {
    transform: translateY(1px);
}

.helper-links {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.helper-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.helper-links a:hover {
    color: white;
    text-decoration: underline;
}

#msg {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    display: none;
    /* Hide when empty */
}

#msg.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    white-space: pre-wrap;
    word-break: break-word;
}

#msg.progress {
    display: block;
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.hint {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: left;
}

/* Mobile responsive font scaling (System requirement) */
@media (max-width: 480px) {
    html {
        font-size: 18px;
        /* Slightly increased base */
    }

    .card {
        padding: 1.5rem;
    }

    /* Mobile keyboard active: Natural scroll, no fixed positioning */
    body.keyboard-open {
        /* Allow the page to scroll naturally */
    }

    body.keyboard-open .wrap {
        align-items: flex-start;
        padding-top: 0.5rem;
        min-height: auto;
    }

    /* Modal keyboard active */
    body.keyboard-open .modal-overlay {
        align-items: flex-start;
        padding-top: 0.5rem;
        overflow-y: auto;
    }

    body.keyboard-open .modal-card {
        margin-top: 0;
    }
}

/* Modal Overlay & Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-card {
    background: #111;
    border: 1px solid var(--card-border);
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 360px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
    animation: slideUp 0.3s ease-out;
}

.modal-card h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    color: white;
}

.modal-card .subtitle {
    margin-bottom: 1.5rem;
}

.modal-card input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 1.5rem;
}

.cancel-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.8rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.cancel-btn:hover {
    color: white;
    text-decoration: underline;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Error Shake Animation */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-5px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
    border-color: #ef4444 !important;
    /* Red border */
    color: #ef4444 !important;
}