/* ===========================================
   Home Page — Black Minimal Landing
   =========================================== */

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

body {
    background: #050505;
    color: #fff;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    opacity: 0;
    transition: opacity 0.35s ease;
}

body.loaded { opacity: 1; }

html[lang="ja"] body,
html[lang="zh"] body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans CJK SC', 'Noto Sans CJK JP',
        'Hiragino Sans', 'Microsoft YaHei', 'Yu Gothic', sans-serif;
}

/* === CANVAS === */
#smokeCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* === APP CONTAINER === */
#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    pointer-events: none;
}

#app * {
    pointer-events: auto;
}

/* === LOGO MARK === */
.logo-mark {
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
    opacity: 0;
    transition: opacity 1s ease;
}

.logo-mark.visible {
    opacity: 1;
}

.open-wrap {
    position: relative;
    width: 65px;
    height: 72px;
}

.frame-back {
    position: absolute;
    top: 0;
    left: 8px;
    width: 50px;
    height: 70px;
    border: 2.5px solid rgba(201, 162, 78, 0.25);
    border-radius: 5px 5px 0 0;
    background: linear-gradient(150deg, rgba(14, 14, 32, 0.3), rgba(24, 24, 56, 0.3));
}

.inner-light {
    position: absolute;
    top: 4px;
    left: 20px;
    width: 36px;
    height: 64px;
    background: linear-gradient(135deg, rgba(226, 179, 90, 0.04), rgba(226, 179, 90, 0.1));
    border-radius: 3px 3px 0 0;
}

.door-open {
    position: absolute;
    top: 2px;
    left: 0;
    width: 32px;
    height: 66px;
    border: 2.5px solid rgba(201, 162, 78, 0.7);
    border-radius: 4px 4px 0 0;
    transform: perspective(200px) rotateY(-35deg);
    transform-origin: left center;
    background: linear-gradient(150deg, rgba(14, 14, 32, 0.15), rgba(24, 24, 56, 0.15));
}

.door-open::after {
    content: '';
    position: absolute;
    right: 5px;
    top: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #e2b35a;
}

/* === TITLE === */
.landing-title {
    font-size: clamp(2.5rem, 6vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    text-align: center;
    opacity: 0;
    transition: opacity 1.2s ease;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff 0%, rgba(255,255,255,0.7) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.landing-title.visible {
    opacity: 1;
}

/* === GREETING === */
.greeting {
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: rgba(255,255,255,0.5);
    text-align: center;
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    margin-bottom: 8px;
    font-weight: 300;
    letter-spacing: 0.02em;
}

.greeting.visible {
    opacity: 1;
    transform: translateX(0);
}

/* === HINT === */
.hint {
    font-size: clamp(0.8rem, 1.5vw, 0.95rem);
    color: rgba(255,255,255,0.3);
    text-align: center;
    opacity: 0;
    transition: opacity 0.8s ease;
    margin-bottom: 32px;
}

.hint.visible {
    opacity: 1;
}

/* === AUTH CONTAINER === */
.auth-container {
    width: 100%;
    max-width: 380px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.auth-container.visible {
    opacity: 1;
}

/* === FORM INPUTS === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 14px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease, background 0.3s ease;
    outline: none;
}

.form-input:focus {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.09);
}

.form-input::placeholder {
    color: rgba(255,255,255,0.2);
}

/* === PASSWORD TOGGLE === */
.password-wrap {
    position: relative;
}
.password-wrap .form-input {
    padding-right: 44px;
}
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255,255,255,0.25);
    cursor: pointer;
    padding: 4px;
    font-size: 0;
    line-height: 1;
    transition: color 0.2s ease;
}
.password-toggle:hover {
    color: rgba(255,255,255,0.5);
}
.password-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* === BUTTONS === */
.btn-primary {
    width: 100%;
    padding: 14px 24px;
    background: #fff;
    color: #050505;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.3s ease, transform 0.15s ease;
    margin-top: 8px;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-link {
    background: none;
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
    margin-top: 16px;
    display: block;
    text-align: center;
    width: 100%;
}

.btn-link:hover {
    color: rgba(255,255,255,0.7);
}

/* === OTP === */
.otp-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 24px 0;
}

.otp-digit, .forgot-otp-digit {
    width: 50px;
    height: 60px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    outline: none;
    transition: border-color 0.3s ease, background 0.3s ease;
    caret-color: transparent;
}

.otp-digit:focus, .forgot-otp-digit:focus {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
}

.otp-digit.filled, .forgot-otp-digit.filled {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
}

.otp-info {
    text-align: center;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.35);
    margin-bottom: 20px;
    line-height: 1.5;
}

.otp-info strong {
    color: rgba(255,255,255,0.6);
    font-weight: 500;
}

/* === ERROR / SUCCESS MESSAGES === */
.msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
    text-align: center;
    line-height: 1.4;
}

.msg.error {
    display: block;
    background: rgba(239, 68, 68, 0.12);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.msg.success {
    display: block;
    background: rgba(16, 185, 129, 0.12);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* === USER VIEW (Authenticated) === */
.user-view {
    text-align: center;
    max-width: 380px;
    width: 100%;
}

.user-email {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.5);
    margin-bottom: 24px;
}

.user-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-left: 8px;
}

.user-badge.tester {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.user-badge.stable {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* === DOWNLOAD BUTTON === */
.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 32px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.4s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn-download::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(99,102,241,0.3), rgba(236,72,153,0.3), rgba(16,185,129,0.3));
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: blur(8px);
}

.btn-download:hover {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99,102,241,0.15);
}

.btn-download:hover::before {
    opacity: 1;
}

.btn-download svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.25);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    margin-top: 32px;
    padding: 8px 16px;
    transition: color 0.3s ease;
}

.btn-logout:hover {
    color: rgba(255,255,255,0.5);
}

/* === RESEND LINK === */
.resend-row {
    text-align: center;
    margin-top: 12px;
}

.resend-link {
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.3s ease;
    padding: 0;
}

.resend-link:hover {
    color: rgba(255,255,255,0.6);
}

.resend-link:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

/* === DOWNLOAD SECTION === */
.download-section {
    width: 100%;
    max-width: 420px;
    margin-top: 48px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.download-section.visible {
    opacity: 1;
}

.section-title {
    font-size: clamp(1rem, 2vw, 1.2rem);
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    text-align: center;
    margin-bottom: 20px;
    letter-spacing: 0.02em;
}

.platform-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 12px;
}

.platform-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
}

.platform-header svg {
    flex-shrink: 0;
}

.channel-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-top: 1px solid rgba(255,255,255,0.04);
}

.channel-row:first-of-type {
    border-top: none;
}

.channel-label {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.45);
}

.channel-status {
    font-size: 0.8rem;
    font-weight: 500;
}

.channel-status.unavailable {
    color: rgba(255,255,255,0.25);
}

.channel-status.available a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #34d399;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.3s ease;
}

.channel-status.available a:hover {
    opacity: 0.8;
}

.channel-status.available a svg {
    width: 16px;
    height: 16px;
}

.channel-status.login-required {
    color: rgba(255,255,255,0.3);
    font-style: italic;
}

.coming-soon {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.25);
    text-align: center;
    padding: 8px 0;
}

.download-guest-msg {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.35);
    text-align: center;
    padding: 24px 0;
    line-height: 1.5;
}

/* === LOADING SPINNER === */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(5,5,5,0.2);
    border-top-color: #050505;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.spinner.light {
    border-color: rgba(255,255,255,0.2);
    border-top-color: #fff;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === FOOTER TAGLINE === */
.footer-tagline {
    margin-top: 48px;
    font-size: 12px;
    color: rgba(255,255,255,0.3);
    text-align: center;
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 1s ease;
}

.footer-tagline.visible {
    opacity: 1;
}

.footer-legal-links {
    margin-top: 8px;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.footer-legal-links.visible {
    opacity: 1;
    transform: translateY(0);
}

.footer-legal-links a {
    color: rgba(255,255,255,0.25);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-legal-links a:hover {
    color: rgba(255,255,255,0.6);
}

/* === NAV MENU === */
.nav-menu {
    position: fixed;
    top: 20px;
    right: 24px;
    z-index: 100;
}

.nav-menu-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.5);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.nav-menu-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.8);
}

.nav-dropdown {
    position: absolute;
    top: 48px;
    right: 0;
    background: rgba(20,20,20,0.95);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 8px 0;
    min-width: 160px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.nav-dropdown a,
.nav-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 18px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.88rem;
    font-family: inherit;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-dropdown a:hover,
.nav-dropdown button:hover {
    background: rgba(255,255,255,0.06);
    color: #a78bfa;
}

/* === HIDDEN STATE === */
.hidden {
    display: none !important;
}

/* === RESPONSIVE === */
@media (max-width: 480px) {
    .nav-menu {
        top: 12px;
        right: 12px;
    }

    #app {
        padding: 32px 16px;
    }

    .otp-digit, .forgot-otp-digit {
        width: 42px;
        height: 52px;
        font-size: 1.3rem;
    }

    .otp-container {
        gap: 7px;
    }

    .btn-download {
        padding: 14px 24px;
        font-size: 0.9rem;
    }

    .download-section {
        margin-top: 32px;
    }

    .platform-card {
        padding: 16px;
    }
}

@media (max-height: 700px) {
    #app {
        padding: 20px 24px;
    }

    .landing-title {
        margin-bottom: 8px;
    }

    .greeting {
        margin-bottom: 4px;
    }

    .hint {
        margin-bottom: 20px;
    }
}

/* ═══ FLIP PAGE CONTAINER ═══ */
.flip-page-container {
    max-width: 860px;
    margin: 48px auto 0;
    padding: 0 20px 60px;
    perspective: 1800px;
    visibility: hidden;
}
.flip-page-container.visible { visibility: visible; }

.flip-page {
    transform-origin: left center;
    transform: rotateY(-90deg);
    will-change: transform;
}
.flip-page.flipped {
    transform: rotateY(0deg);
    transition: transform 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.flip-page-inner {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    padding: 32px 24px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    backface-visibility: hidden;
}

/* ═══ LEADERBOARD ═══ */
.leaderboard-section {
    max-width: 800px;
    margin: 0 auto;
}

.leaderboard-subtitle {
    text-align: center;
    color: rgba(255,255,255,0.35);
    font-size: 0.85rem;
    margin: -8px 0 24px;
}

.leaderboard-table-wrap {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.leaderboard-table th {
    padding: 10px 12px;
    text-align: left;
    color: rgba(255,255,255,0.4);
    font-weight: 500;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.leaderboard-table td {
    padding: 10px 12px;
    color: rgba(255,255,255,0.7);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}
.leaderboard-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}
.lb-rank {
    font-weight: 700;
    color: rgba(255,255,255,0.3);
    font-size: 0.75rem;
}
.lb-rank-1 { color: #fbbf24; }
.lb-rank-2 { color: #d1d5db; }
.lb-rank-3 { color: #cd7f32; }
.lb-model {
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}
.lb-score {
    font-weight: 700;
    color: #a78bfa;
    font-size: 0.9rem;
}
.lb-dim { color: rgba(255,255,255,0.35); }

@media (max-width: 600px) {
    .leaderboard-table { font-size: 0.75rem; }
    .leaderboard-table th, .leaderboard-table td { padding: 8px 6px; }
    .hide-mobile { display: none; }
}
