:root {
    --primary: #00f2ff;
    --secondary: #7000ff;
    --bg-dark: #0a0a12;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
}

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

body {
    font-family: 'Inter', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

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

.container {
    position: relative;
    z-index: 1;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px;
    max-width: 520px;
    width: 90%;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5), inset 0 0 0 1px var(--border);
    transform: translateY(20px);
    opacity: 0;
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.container::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 24px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(0, 242, 255, 0.3), rgba(112, 0, 255, 0.3));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude; 
    pointer-events: none;
}

@keyframes fadeInUp {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header {
    text-align: center;
    margin-bottom: 35px;
}

.title {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.form-group {
    margin-bottom: 25px;
    position: relative;
}

.label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.input-wrapper {
    position: relative;
    transition: all 0.3s ease;
}

.input {
    width: 100%;
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-family: 'JetBrains Mono', monospace;
    transition: all 0.3s ease;
    appearance: none;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

/* Slider Styling */
.slider-container {
    padding: 10px 0;
}

.slider-value-display {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-main);
    background: rgba(0, 242, 255, 0.1);
    border: 1px solid rgba(0, 242, 255, 0.3);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-value-number {
    font-family: 'JetBrains Mono', monospace;
    color: var(--primary);
    font-weight: 700;
}

input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    margin: 10px 0;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

input[type=range]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -8px;
    box-shadow: 0 0 10px var(--primary);
    transition: transform 0.2s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 10px;
    margin-top: 5px;
    font-family: 'JetBrains Mono', monospace;
}

.button {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(112, 0, 255, 0.4);
}

.button:hover::before {
    left: 100%;
}

.button:active {
    transform: scale(0.98);
}

.button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    filter: grayscale(1);
}

.result-container {
    margin-top: 30px;
    height: 0;
    overflow: hidden;
    transition: height 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.result-container.show {
    height: 180px;
}

.result-box {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    position: relative;
}

.result-box::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    opacity: 0.5;
}

.result-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.activation-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    word-break: break-all;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.3s;
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.3);
    position: relative;
}

.activation-code:hover {
    background: rgba(0, 242, 255, 0.1);
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.6);
}

.copy-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.algorithm-info {
    margin-top: 30px;
    padding: 20px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

.algorithm-title {
    color: white;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-block {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 5px;
    border-left: 2px solid var(--secondary);
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(10, 10, 18, 0.9);
    border: 1px solid var(--primary);
    color: white;
    padding: 15px 25px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    transform: translateX(150%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    z-index: 1000;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateX(0);
}

/* Glitch Effect Keyframes */
@keyframes glitch {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 2px) }
    40% { transform: translate(-2px, -2px) }
    60% { transform: translate(2px, 2px) }
    80% { transform: translate(2px, -2px) }
    100% { transform: translate(0) }
}

.glitch-active {
    animation: glitch 0.2s cubic-bezier(.25, .46, .45, .94) both infinite;
    color: #ff00ff;
}

/* Responsive Design for Mobile */
@media screen and (max-width: 600px) {
    .container {
        padding: 25px 20px;
        width: 95%;
        margin: 20px 0;
        /* Allow scrolling if content is tall */
        max-height: 90vh;
        overflow-y: auto;
        /* Custom scrollbar for container */
        scrollbar-width: thin;
        scrollbar-color: var(--primary) transparent;
    }

    body {
        /* Allow body scroll on mobile */
        overflow-y: auto;
        height: auto;
        min-height: 100vh;
        padding: 20px 0;
        align-items: flex-start; /* Align top to avoid cutting off on small screens */
    }

    .title {
        font-size: 24px;
    }

    .subtitle {
        font-size: 12px;
    }

    .input, .select, .button {
        padding: 14px;
        font-size: 14px;
    }

    .activation-code {
        font-size: 18px;
        word-break: break-all;
    }

    .result-container.show {
        height: auto;
        min-height: 160px;
    }

    .toast {
        width: 90%;
        left: 5%;
        right: 5%;
        text-align: center;
        justify-content: center;
    }
}
