:root {
    --primary: #39C5BB;
    /* Miku Teal */
    --primary-light: #a0e8e3;
    --secondary: #ff69b4;
    /* Hot Pink */
    --secondary-light: #ffb7d5;
    --accent: #ffd700;
    /* Gold */
    --bg-light: #f0f8ff;
    /* Alice Blue */
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #333333;
    --text-muted: #666666;
    --font-main: 'M PLUS Rounded 1c', 'Varela Round', sans-serif;
    --font-tech: 'Share Tech Mono', monospace;
}

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

body {
    font-family: var(--font-main);
    background-color: #e0f7fa;
    /* Darker base for contrast */
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    /* Vibrant Mesh Gradient */
    background-image:
        radial-gradient(at 0% 0%, hsla(178, 63%, 65%, 1) 0px, transparent 50%),
        radial-gradient(at 100% 0%, hsla(340, 82%, 76%, 1) 0px, transparent 50%),
        radial-gradient(at 100% 100%, hsla(178, 63%, 65%, 1) 0px, transparent 50%),
        radial-gradient(at 0% 100%, hsla(340, 82%, 76%, 1) 0px, transparent 50%);
}

/* Background Grid - Lighter & Softer */
.bg-grid {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: perspective(500px) rotateX(60deg);
    animation: grid-move 20s linear infinite;
    z-index: -1;
    pointer-events: none;
}

@keyframes grid-move {
    0% {
        transform: perspective(500px) rotateX(60deg) translateY(0);
    }

    100% {
        transform: perspective(500px) rotateX(60deg) translateY(50px);
    }
}

/* Card Scene */
.card-scene {
    width: 340px;
    height: 540px;
    perspective: 1200px;
    position: relative;
    z-index: 100;
    touch-action: none;
    /* Critical for mobile performance */
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: grab;
    will-change: transform;
}

.card.no-transition {
    transition: none !important;
}

.card:active {
    cursor: grabbing;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 30px;
    overflow: hidden;
    /* Glassmorphism 2.0 */
    background: rgba(255, 255, 255, 0.9);
    /* Higher opacity for contrast */
    backdrop-filter: blur(20px);
    /* Stronger blur */
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow:
        0 20px 40px rgba(0, 0, 0, 0.1),
        /* Deeper shadow */
        0 0 0 1px rgba(255, 255, 255, 0.5),
        /* Inner border ring */
        0 0 0 8px rgba(255, 255, 255, 0.2),
        /* Glass Halo - Transparent Outer Border */
        inset 0 0 30px rgba(255, 255, 255, 0.9);
    /* Inner glow */
    display: flex;
    flex-direction: column;
}

.card-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, #fff 0%, #f0f8ff 100%);
}

/* Advanced Holographic Effects (Pokémon Style) */
.holo-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    border-radius: 30px;
    pointer-events: none;
    mix-blend-mode: color-dodge;
    opacity: 0;
    transition: opacity 0.3s;
    overflow: hidden;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    pointer-events: none;
}

.card:hover .holo-layer,
.card.interacting .holo-layer {
    opacity: 1;
}

.foil-base {
    /* Metallic Sheen */
    background: linear-gradient(115deg,
            transparent 20%,
            rgba(255, 255, 255, 0.8) 50%,
            transparent 80%);
    background-size: 200% 200%;
    background-position: var(--holo-pos-x, 50%) var(--holo-pos-y, 50%);
    mix-blend-mode: overlay;
    opacity: 0.5;
    filter: blur(5px);
}

.foil-sparkle {
    /* Glitter Effect */
    background-image:
        radial-gradient(circle at var(--holo-pos-x, 50%) var(--holo-pos-y, 50%),
            rgba(255, 255, 255, 0.8) 0%,
            transparent 20%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.5'/%3E%3C/svg%3E");
    mix-blend-mode: color-dodge;
    opacity: 0.4;
    filter: contrast(150%);
}

.foil-color {
    /* Prismatic Rainbow Bands */
    background: repeating-linear-gradient(115deg,
            rgba(255, 0, 0, 0.2) 0%,
            rgba(255, 154, 0, 0.2) 5%,
            rgba(208, 222, 33, 0.2) 10%,
            rgba(79, 220, 74, 0.2) 15%,
            rgba(63, 218, 216, 0.2) 20%,
            rgba(47, 201, 226, 0.2) 25%,
            rgba(28, 127, 238, 0.2) 30%,
            rgba(95, 21, 242, 0.2) 35%,
            rgba(186, 12, 248, 0.2) 40%,
            rgba(251, 7, 217, 0.2) 45%,
            rgba(255, 0, 0, 0.2) 50%);
    background-size: 300% 300%;
    background-position: var(--holo-pos-x, 50%) var(--holo-pos-y, 50%);
    mix-blend-mode: multiply;
    /* Visible on white */
    opacity: 0.4;
    filter: blur(5px);
    mask-image: radial-gradient(circle at var(--holo-pos-x, 50%) var(--holo-pos-y, 50%),
            black 0%,
            transparent 70%);
    -webkit-mask-image: radial-gradient(circle at var(--holo-pos-x, 50%) var(--holo-pos-y, 50%),
            black 0%,
            transparent 70%);
}

.glare {
    /* Sharp White Reflection */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: radial-gradient(circle at var(--holo-pos-x, 50%) var(--holo-pos-y, 50%),
            rgba(255, 255, 255, 0.9) 0%,
            rgba(255, 255, 255, 0.4) 20%,
            transparent 60%);
    pointer-events: none;
    opacity: 0.6;
    mix-blend-mode: overlay;
}

.card:hover .glare {
    opacity: 0.8;
}

/* Content Styling */
.card-content {
    position: relative;
    z-index: 20;
    padding: 25px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.header-tech {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-tech);
    color: var(--primary);
    font-size: 0.9rem;
    margin-bottom: 15px;
    border-bottom: 2px dashed var(--primary-light);
    padding-bottom: 8px;
}

.miku-mark {
    font-weight: 900;
    color: var(--secondary);
    font-size: 1.2rem;
    letter-spacing: -1px;
}

.avatar-section {
    position: relative;
    margin: 0 auto 15px;
    width: 140px;
    height: 140px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.avatar-circle {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    padding: 4px;
    background: linear-gradient(45deg, var(--primary), var(--secondary));
    position: relative;
    z-index: 2;
    box-shadow: 0 0 15px rgba(57, 197, 187, 0.3);
    animation: pulse-glow 4s ease-in-out infinite;
}

.avatar-circle img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    border: 3px solid #fff;
    background: #fff;
    display: block;
}

@keyframes rotate-ring {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

@keyframes rotate-ring-reverse {
    0% {
        transform: rotate(360deg);
    }

    100% {
        transform: rotate(0deg);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 15px rgba(57, 197, 187, 0.3);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 25px rgba(255, 105, 180, 0.4);
        transform: scale(1.02);
    }
}

.rank-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    background: var(--secondary);
    color: #fff;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transform: rotate(-5deg);
    border: 2px solid #fff;
    z-index: 10;
    /* Ensure it's above the rings */
}

.identity-section {
    text-align: center;
    margin-bottom: 15px;
}

.identity-section h1 {
    font-size: 1.8rem;
    /* Reduced for longer name */
    margin-bottom: 5px;
    color: var(--primary);
    text-shadow: 2px 2px 0px var(--primary-light);
    white-space: nowrap;
}

.role {
    font-family: var(--font-main);
    color: var(--secondary);
    font-weight: bold;
    font-size: 0.9rem;
    background: rgba(255, 105, 180, 0.1);
    display: inline-block;
    padding: 2px 10px;
    border-radius: 15px;
    margin-bottom: 8px;
}

.sub-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: bold;
    margin-bottom: 8px;
}

.affiliation {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 2;
}

.affiliation-line {
    margin-bottom: 8px;
    font-weight: 500;
}

.affiliation-line-en {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-bottom: 10px;
    font-weight: 500;
}

.location {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: bold;
    margin-top: 8px;
    padding: 3px 8px;
    background: rgba(57, 197, 187, 0.1);
    border-radius: 10px;
    border: 1px solid var(--primary);
}

.location i {
    font-size: 0.7rem;
}

.stats-preview {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.domain-tag {
    background: rgba(57, 197, 187, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-family: var(--font-tech);
    font-weight: bold;
}

.footer-hint {
    text-align: center;
    font-size: 0.8rem;
    color: var(--primary);
    margin-top: 15px;
    animation: bounce 2s infinite;
}

/* Back Face Styling */
.data-grid {
    background: rgba(255, 255, 255, 0.6);
    padding: 15px;
    border-radius: 20px;
    margin-bottom: 20px;
    border: 2px solid var(--primary-light);
}

.data-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-family: var(--font-main);
    font-size: 0.9rem;
}

.data-row .label {
    color: var(--text-muted);
}

.data-row .value {
    color: var(--primary);
    font-weight: bold;
}

.data-row .value.active {
    color: var(--secondary);
}

.bio-terminal {
    background: #1a1b26;
    /* Dark Terminal Background */
    padding: 15px;
    border-radius: 10px;
    font-family: 'Share Tech Mono', monospace;
    /* Tech Font */
    font-size: 0.85rem;
    color: #a9b1d6;
    /* Terminal Text Color */
    margin-bottom: 20px;
    height: 110px;
    /* Slightly taller for code */
    overflow: hidden;
    border: 1px solid #414868;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
}

/* Terminal Header (Fake Buttons) */
.bio-terminal::before {
    content: '● ● ●';
    position: absolute;
    top: 8px;
    left: 10px;
    font-size: 10px;
    color: #414868;
    letter-spacing: 2px;
}

.typing-text {
    display: block;
    margin-top: 10px;
    /* Reduced space */
    line-height: 1.3;
    /* Tighter line height */
    white-space: pre-wrap;
}

/* Syntax Highlighting Colors (Simulated) */
.keyword {
    color: #bb9af7;
}

/* Purple */
.string {
    color: #9ece6a;
}

/* Green */
.variable {
    color: #7dcfff;
}

/* Blue */
.comment {
    color: #565f89;
    font-style: italic;
}

/* Grey */
.operator {
    color: #89ddff;
}

/* Cyan */

.social-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: auto;
}

.social-tile {
    background: #fff;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
    border-radius: 15px;
    font-size: 0.85rem;
    transition: all 0.2s;
    border: 2px solid transparent;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-weight: bold;
}

.social-tile:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-3px);
}

.qr-placeholder {
    height: 60px;
    background: #fff;
    margin-top: 10px;
    padding: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    border: 1px solid #eee;
}

.qr-pattern {
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(45deg, var(--primary) 25%, transparent 25%),
        linear-gradient(-45deg, var(--primary) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--primary) 75%),
        linear-gradient(-45deg, transparent 75%, var(--primary) 75%);
    background-size: 10px 10px;
    opacity: 0.2;
}

/* Animations */
@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes grid-move {
    0% {
        transform: perspective(500px) rotateX(60deg) translateY(0);
    }

    100% {
        transform: perspective(500px) rotateX(60deg) translateY(40px);
    }
}

/* Glitch Effect (Modified for Cute) */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.glitch::before {
    left: 2px;
    text-shadow: -1px 0 var(--secondary);
    clip: rect(24px, 550px, 90px, 0);
    animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -1px 0 var(--primary);
    clip: rect(85px, 550px, 140px, 0);
    animation: glitch-anim 2.5s infinite linear alternate-reverse;
}

/* Floating Decorations */
.floating-icon {
    position: absolute;
    font-size: 1.5rem;
    animation: float-up 4s ease-in-out infinite;
    opacity: 0.6;
    z-index: 5;
    pointer-events: none;
}

@keyframes float-up {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }

    20% {
        opacity: 0.8;
    }

    80% {
        opacity: 0.8;
    }

    100% {
        transform: translateY(-50px) rotate(20deg);
        opacity: 0;
    }
}