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

:root {
    --primary-color: #4F46E5;
    --secondary-color: #10B981;
    --text-color: #1F2937;
    --border-color: #9CA3AF;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    overflow: hidden;
}

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

.bg-gradient {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(102, 126, 234, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 70%, rgba(118, 75, 162, 0.4) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(79, 70, 229, 0.2) 0%, transparent 60%),
        linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
    animation: gradientShift 15s ease-in-out infinite;
}

.bg-image {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: url('assets/background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.bg-mesh {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 10% 20%, rgba(255, 182, 193, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 90% 80%, rgba(147, 112, 219, 0.15) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 50%, rgba(100, 149, 237, 0.1) 0%, transparent 50%);
    animation: meshMove 25s ease-in-out infinite;
}

@keyframes meshMove {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    33% {
        transform: scale(1.05) rotate(2deg);
    }
    66% {
        transform: scale(0.98) rotate(-2deg);
    }
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
        opacity: 1;
    }
    25% {
        background-position: 100% 50%;
        opacity: 0.9;
    }
    50% {
        background-position: 100% 100%;
        opacity: 1;
    }
    75% {
        background-position: 50% 0%;
        opacity: 0.95;
    }
}

.particles {
    position: absolute;
    width: 100%;
    height: 100%;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: particleFloat 20s linear infinite;
}

.particle:nth-child(1) { left: 10%; animation-delay: 0s; animation-duration: 25s; }
.particle:nth-child(2) { left: 20%; animation-delay: 2s; animation-duration: 20s; }
.particle:nth-child(3) { left: 30%; animation-delay: 4s; animation-duration: 28s; }
.particle:nth-child(4) { left: 40%; animation-delay: 1s; animation-duration: 22s; }
.particle:nth-child(5) { left: 50%; animation-delay: 3s; animation-duration: 26s; }
.particle:nth-child(6) { left: 60%; animation-delay: 5s; animation-duration: 24s; }
.particle:nth-child(7) { left: 70%; animation-delay: 2.5s; animation-duration: 21s; }
.particle:nth-child(8) { left: 80%; animation-delay: 4.5s; animation-duration: 27s; }
.particle:nth-child(9) { left: 90%; animation-delay: 1.5s; animation-duration: 23s; }
.particle:nth-child(10) { left: 15%; animation-delay: 3.5s; animation-duration: 29s; }
.particle:nth-child(11) { left: 35%; animation-delay: 0.5s; animation-duration: 19s; }
.particle:nth-child(12) { left: 55%; animation-delay: 2.8s; animation-duration: 25s; }
.particle:nth-child(13) { left: 75%; animation-delay: 4.2s; animation-duration: 22s; }
.particle:nth-child(14) { left: 85%; animation-delay: 1.8s; animation-duration: 28s; }
.particle:nth-child(15) { left: 25%; animation-delay: 3.2s; animation-duration: 24s; }

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 0.8;
        transform: translateY(90vh) translateX(10px) scale(1);
    }
    90% {
        opacity: 0.6;
        transform: translateY(10vh) translateX(-10px) scale(1);
    }
    100% {
        transform: translateY(-10vh) translateX(0) scale(0);
        opacity: 0;
    }
}

.floating-shapes {
    position: absolute;
    width: 100%;
    height: 100%;
}

.floating-shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(5px);
    animation: shapeFloat 30s ease-in-out infinite;
}

.floating-shape:nth-child(1) {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 60%;
    animation-delay: 0s;
}
.floating-shape:nth-child(2) {
    width: 200px;
    height: 200px;
    top: 60%;
    left: 70%;
    animation-delay: -5s;
}
.floating-shape:nth-child(3) {
    width: 150px;
    height: 150px;
    top: 30%;
    left: 80%;
    animation-delay: -10s;
}
.floating-shape:nth-child(4) {
    width: 250px;
    height: 250px;
    top: 70%;
    left: 50%;
    animation-delay: -15s;
}
.floating-shape:nth-child(5) {
    width: 180px;
    height: 180px;
    top: 20%;
    left: 30%;
    animation-delay: -8s;
}
.floating-shape:nth-child(6) {
    width: 120px;
    height: 120px;
    top: 80%;
    left: 20%;
    animation-delay: -12s;
}

.bg-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: bubbleFloat 25s ease-in-out infinite;
}

@keyframes bubbleFloat {
    0%, 100% {
        transform: translateY(0) translateX(0) scale(1);
        opacity: 0.6;
    }
    25% {
        transform: translateY(-50px) translateX(30px) scale(1.1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-100px) translateX(-20px) scale(0.95);
        opacity: 0.5;
    }
    75% {
        transform: translateY(-50px) translateX(-30px) scale(1.05);
        opacity: 0.7;
    }
}

.bg-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    animation: starTwinkle 3s ease-in-out infinite;
    box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.3);
}

@keyframes starTwinkle {
    0%, 100% {
        opacity: 0.2;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.5);
    }
}

@keyframes shapeFloat {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate(30px, -40px) rotate(90deg) scale(1.1);
    }
    50% {
        transform: translate(-20px, -80px) rotate(180deg) scale(0.95);
    }
    75% {
        transform: translate(40px, -40px) rotate(270deg) scale(1.05);
    }
}

.background-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 1%;
    padding-top: 15%;
    z-index: 1;
}

.background-container.has-image {
    background-size: cover;
}

.signature-container {
    background: transparent;
    backdrop-filter: blur(0px);
    border: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.canvas-wrapper {
    position: relative;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 0;
}

#signatureCanvas {
    border: none;
    background: transparent;
    cursor: crosshair;
    touch-action: none;
    display: block;
    border-radius: 6px;
}

.button-group {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.btn {
    padding: 8px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-reset {
    background: linear-gradient(135deg, #93C5FD, #60A5FA);
    color: white;
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.3);
}

.btn-reset:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.4);
}

.btn-reset:active {
    transform: translateY(-1px);
}

.btn-confirm {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-confirm:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4);
}

.btn-confirm:active {
    transform: translateY(-1px);
}

.signature-bubble {
    position: absolute;
    border-radius: 50%;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.1),
        0 0 0 2px rgba(255, 255, 255, 0.06),
        inset 0 -3px 10px rgba(0, 0, 0, 0.05);
    overflow: hidden;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.signature-bubble:hover {
    transform: scale(1.1);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.25),
        0 0 0 3px rgba(255, 255, 255, 0.2),
        inset 0 -3px 10px rgba(0, 0, 0, 0.08);
}

.signature-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@keyframes bubbleAppear {
    from {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@media (max-width: 768px) {
    .background-container {
        padding-right: 0;
        padding-top: 20%;
        justify-content: center;
    }

    .signature-container {
        padding: 0;
        width: 85%;
        background: transparent;
    }

    .button-group {
        flex-direction: row;
        width: 100%;
        gap: 10px;
    }

    .btn {
        flex: 1;
        padding: 10px 16px;
        font-size: 13px;
    }

    .canvas-wrapper {
        border-width: 2px;
    }

    .floating-shape:nth-child(1) {
        width: 150px;
        height: 150px;
    }
    .floating-shape:nth-child(2) {
        width: 100px;
        height: 100px;
    }
    .floating-shape:nth-child(3) {
        width: 80px;
        height: 80px;
    }
    .floating-shape:nth-child(4) {
        width: 120px;
        height: 120px;
    }
    .floating-shape:nth-child(5) {
        width: 90px;
        height: 90px;
    }
    .floating-shape:nth-child(6) {
        width: 60px;
        height: 60px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bg-gradient,
    .particle,
    .floating-shape,
    .signature-bubble {
        animation: none;
    }
}
