:root {
    --deep-bg: #0b1120;
    --card-white: #f8fafc;
    --agency-red: #d50000;
    --agency-black: #0f172a;
    --text-gray: #64748b;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body {
    font-family: "Roboto Mono", "Noto Sans SC", "Microsoft YaHei", sans-serif;
    background-color: var(--deep-bg);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1200px;
    margin: 0;
}

#bg-canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
}

.badge-container {
    position: relative;
    z-index: 10;
    width: 280px;
    height: 460px;
    perspective: 1500px;
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1), height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: width, height;
}

.badge-container.email-mode { height: 650px; }

.badge-container.expanded {
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0;
    z-index: 9999;
    transform: none !important;
}

.badge-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-inner.flipped { transform: rotateY(180deg); }

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    transition: border-radius 0.4s ease;
}

.badge-container.expanded .card-face {
    border-radius: 0;
    box-shadow: none;
}

.card-face.front {
    background: var(--card-white);
    box-shadow: 0 25px 50px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.1) inset;
    display: flex;
    flex-direction: column;
    clip-path: polygon(0% 0%, 28% 0%, 28% 6%, 72% 6%, 72% 0%, 100% 0%, 100% 100%, 0% 100%);
}

.badge-container.expanded .card-face.front { clip-path: none; }

.card-face.back {
    background-color: #ffffff;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 30px 60px rgba(0,0,0,0.6);
    position: relative;
}

.card-face.back::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    z-index: 0;
}

.circuit-deco {
    position: absolute;
    top: 50%; left: 50%;
    width: 300px; height: 300px;
    transform: translate(-50%, -50%);
    border: 2px solid rgba(15, 23, 42, 0.05);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.5s ease 0.5s, transform 20s linear;
    pointer-events: none;
}
.circuit-deco::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 200px; height: 173px;
    background: transparent;
    border: 2px solid rgba(15, 23, 42, 0.08);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    transform: translate(-50%, -50%);
}
.badge-container.expanded .circuit-deco {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(360deg);
}

.loading-text {
    margin-top: 20px;
    font-family: "Noto Sans SC", sans-serif;
    color: var(--agency-black);
    font-weight: 900;
    z-index: 2;
    font-size: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.header-stripe {
    height: 8px;
    background: var(--agency-black);
    width: 100%;
    margin-top: 12px;
}

.lanyard-clip {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 110px;
    height: 24px;
    background: #1e293b;
    border-radius: 6px;
    z-index: 5;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    transition: opacity 0.3s;
    display: flex;
    justify-content: center;
    align-items: flex-end;
}
.lanyard-clip::before {
    content: '';
    position: absolute;
    top: -100vh;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 100vh;
    background: linear-gradient(90deg, #0f172a, #334155, #0f172a);
}
.lanyard-clip::after {
    content: '';
    width: 70px;
    height: 6px;
    background: rgba(0,0,0,0.4);
    margin-bottom: 6px;
    border-radius: 3px;
}

.watermark {
    position: absolute;
    top: 55%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 150px;
    color: rgba(0,0,0,0.04);
    pointer-events: none;
    z-index: 0;
}

.content-area {
    padding: 15px 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.content-area::-webkit-scrollbar { display: none; }

.triangle-frame {
    width: 90px;
    height: 78px;
    background: var(--agency-red);
    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
    margin-bottom: 12px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12px;
    box-shadow: 0 8px 15px rgba(213, 0, 0, 0.3);
    transition: transform 0.3s;
}
.triangle-frame i { font-size: 34px; color: white; transition: all 0.3s; }
.badge-container:hover .triangle-frame { transform: scale(1.05); }

.org-title {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    line-height: 0.85;
}
.org-title h1 {
    font-family: "Roboto Mono", sans-serif;
    font-size: 24px; font-weight: 900; color: var(--agency-black);
    letter-spacing: 2px; margin: 0; text-transform: uppercase;
    display: block;
}
.org-title span {
    font-family: "Roboto Mono", sans-serif;
    font-size: 24px; color: var(--agency-red); letter-spacing: 2px;
    text-transform: uppercase; font-weight: 900; display: block;
}
.org-title h2 {
    font-family: "Noto Sans SC", sans-serif;
    font-size: 10px; color: var(--text-gray); letter-spacing: 4px;
    text-transform: uppercase; font-weight: 700; display: block; margin-top: 8px;
}

.form-group { width: 100%; margin-bottom: 15px; }
.form-group label {
    font-family: "Noto Sans SC", sans-serif;
    font-size: 9px; color: var(--text-gray); font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; display: block; margin-bottom: 3px;
}
.form-group input {
    width: 100%; background: transparent; border: none;
    border-bottom: 2px solid #cbd5e1; padding: 5px 0;
    font-family: "Roboto Mono", monospace; font-size: 14px; font-weight: bold;
    color: var(--agency-black); outline: none; transition: all 0.3s;
}
.form-group input:focus { border-bottom-color: var(--agency-red); }
.form-group input::placeholder { font-family: "Noto Sans SC", sans-serif; font-weight: normal; opacity: 0.5; font-size: 12px; }

.btn-verify {
    margin-top: 8px; background: var(--agency-red); color: white;
    border: none; padding: 12px 0; font-size: 12px; font-weight: 900;
    letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
    transition: all 0.2s; width: 100%; border-radius: 4px;
    box-shadow: 0 4px 10px rgba(213, 0, 0, 0.2);
    font-family: "Noto Sans SC", sans-serif;
}
.btn-verify:hover { background: #b71c1c; transform: translateY(-1px); }

.footer-scan {
    margin-top: auto; width: 100%; padding: 12px;
    background: #f1f5f9; border-top: 1px solid #e2e8f0;
    position: relative; overflow: hidden;
}
.barcode {
    height: 25px; width: 100%;
    background: repeating-linear-gradient(90deg, #334155 0, #334155 2px, transparent 2px, transparent 4px);
    opacity: 0.6;
}
.laser-line {
    position: absolute; top: 0; left: 0; width: 100%; height: 2px;
    background: var(--agency-red); box-shadow: 0 0 8px var(--agency-red);
    animation: scan 2.5s infinite ease-in-out; opacity: 0.8;
}

.status-msg {
    font-size: 10px; color: var(--agency-red); margin-top: 10px;
    font-weight: bold; height: 12px; text-align: center; opacity: 0;
    font-family: "Noto Sans SC", sans-serif;
}
.status-msg.show { opacity: 1; }
.status-msg.success { color: #15803d; }

.code-row { display: flex; gap: 8px; align-items: flex-end; }
.code-row input { flex: 1; }
.btn-code {
    background: var(--agency-black);
    color: white;
    border: none;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 3px;
    white-space: nowrap;
    transition: all 0.2s;
}
.btn-code:hover { background: var(--agency-red); }
.btn-code:disabled { background: #94a3b8; cursor: not-allowed; }

.register-link, .login-link { margin-top: 8px; }
.register-link a, .login-link a {
    color: var(--text-gray);
    font-size: 11px;
    text-decoration: none;
}
.register-link a span, .login-link a span {
    color: var(--agency-red);
    font-weight: bold;
}

.email-section { display: none; }
.email-section.show { display: block; }

@keyframes scan {
    0% { top: 0; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { top: 100%; opacity: 0; }
}

@media (max-width: 400px) {
    .badge-container { width: 80vw; max-width: 280px; height: 460px; }
    .badge-container.email-mode { height: 650px; }
}

@media (max-height: 700px) {
    .badge-container.email-mode { height: 90vh; }
}
