* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    --secondary-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --success-gradient: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    --danger-gradient: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    --info-gradient: linear-gradient(135deg, #30cfd0 0%, #330867 100%);
    --dark-bg: #0a0a1a;
    --dark-surface: rgba(20, 20, 40, 0.8);
    --dark-surface-light: rgba(30, 30, 60, 0.6);
    --dark-border: rgba(100, 100, 200, 0.3);
    --text-primary: #ffffff;
    --text-secondary: #b8b8d4;
    --text-muted: #8888aa;
    --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 15px 35px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Animated Background */
body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

.animated-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(-45deg, #0a0a1a, #1a0a2e, #16213e, #0f3460);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    opacity: 0.9;
}

.animated-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(240, 147, 251, 0.2) 0%, transparent 50%);
    animation: pulse 8s ease-in-out infinite;
}

.animated-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 4px);
    animation: drift 20s linear infinite;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

@keyframes drift {
    0% { transform: translateY(0); }
    100% { transform: translateY(50px); }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    animation: fadeInUp 0.8s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    padding: 50px 30px;
    background: var(--dark-surface);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--dark-border);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

h1 {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 15px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -2px;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.5);
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.3rem;
    font-weight: 300;
    letter-spacing: 1px;
}

/* Tab Navigation */
.tab-container {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
}

.tab-button {
    padding: 18px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--dark-surface);
    color: var(--text-primary);
    border: 2px solid var(--dark-border);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.tab-button:hover::before {
    width: 300px;
    height: 300px;
}

.tab-button:hover {
    transform: translateY(-3px);
    border-color: #667eea;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
}

.tab-button.active {
    background: var(--primary-gradient);
    border-color: transparent;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
    transform: translateY(-2px);
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Input Section */
.input-section {
    background: var(--dark-surface);
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--dark-border);
    transition: transform 0.3s, box-shadow 0.3s;
}

.input-section:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.input-group {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.input-group-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.input-group-vertical label {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 1.1rem;
}

.input-group-vertical textarea {
    width: 100%;
    padding: 20px;
    font-size: 1rem;
    border: 2px solid var(--dark-border);
    border-radius: 15px;
    background: var(--dark-surface-light);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: all 0.3s;
}

.input-group-vertical textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: rgba(10, 10, 26, 0.8);
}

input[type="text"] {
    flex: 1;
    padding: 20px 25px;
    font-size: 1.2rem;
    border: 2px solid var(--dark-border);
    border-radius: 15px;
    background: var(--dark-surface-light);
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
    background: rgba(10, 10, 26, 0.8);
    transform: translateY(-2px);
}

.hint {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 10px;
    font-style: italic;
}

/* Buttons */
.btn-primary, .btn-success, .btn-danger, .btn-info {
    padding: 20px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-success {
    background: var(--success-gradient);
    color: white;
}

.btn-danger {
    background: var(--danger-gradient);
    color: white;
}

.btn-info {
    background: var(--info-gradient);
    color: white;
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-primary:hover .btn-shine,
.btn-success:hover .btn-shine,
.btn-danger:hover .btn-shine,
.btn-info:hover .btn-shine {
    left: 100%;
}

.btn-primary:hover, .btn-success:hover, .btn-danger:hover, .btn-info:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
}

.btn-primary:active, .btn-success:active, .btn-danger:active, .btn-info:active {
    transform: translateY(-2px) scale(1);
}

.btn-primary:disabled, .btn-success:disabled, .btn-danger:disabled, .btn-info:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* Error Message */
.error-message {
    background: linear-gradient(135deg, rgba(250, 112, 154, 0.2) 0%, rgba(254, 225, 64, 0.2) 100%);
    border: 2px solid rgba(250, 112, 154, 0.5);
    color: #ffb3d1;
    padding: 20px 25px;
    border-radius: 15px;
    margin-bottom: 30px;
    font-weight: 500;
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Results */
.results {
    animation: fadeInUp 0.6s ease-out;
}

.result-section {
    background: var(--dark-surface);
    backdrop-filter: blur(20px);
    padding: 40px;
    border-radius: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--dark-border);
    transition: transform 0.3s, box-shadow 0.3s;
}

.result-section:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.result-section h2 {
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 800;
    border-bottom: 2px solid var(--dark-border);
    padding-bottom: 15px;
    letter-spacing: -0.5px;
}

.success-section {
    border-color: rgba(67, 233, 123, 0.5);
}

.decrypted-word {
    font-size: 3rem;
    font-weight: 900;
    text-align: center;
    padding: 40px;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 5px;
    text-transform: uppercase;
    animation: pulse-text 2s ease-in-out infinite;
}

@keyframes pulse-text {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Mapping Grid */
.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 20px;
}

.mapping-item {
    background: var(--dark-surface-light);
    padding: 25px 20px;
    border-radius: 18px;
    text-align: center;
    border: 2px solid var(--dark-border);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.mapping-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.2), transparent);
    transition: left 0.5s;
}

.mapping-item:hover::before {
    left: 100%;
}

.mapping-item:hover {
    border-color: #667eea;
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.4);
}

.mapping-item .letter {
    font-size: 2.5rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.mapping-item .prime {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Sequence Display */
.sequence-display {
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 1.5rem;
    padding: 35px;
    background: var(--dark-surface-light);
    border-radius: 18px;
    border: 2px solid var(--dark-border);
    word-break: break-word;
    line-height: 2.2;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: 2px;
}

.symbol-display {
    font-size: 2rem;
    letter-spacing: 4px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.notes-display {
    font-size: 1.6rem;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

/* Audio List */
.audio-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.audio-file-item {
    background: var(--dark-surface-light);
    padding: 20px 25px;
    border-radius: 15px;
    border: 2px solid var(--dark-border);
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.audio-file-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    background: var(--primary-gradient);
    transform: scaleY(0);
    transition: transform 0.3s;
}

.audio-file-item:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-sm);
    border-color: var(--dark-border);
}

.audio-file-item:hover::before {
    transform: scaleY(1);
}

.audio-file-item.playing {
    border-color: #43e97b;
    background: rgba(67, 233, 123, 0.15);
    box-shadow: 0 0 30px rgba(67, 233, 123, 0.4);
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 30px rgba(67, 233, 123, 0.4);
    }
    50% {
        box-shadow: 0 0 50px rgba(67, 233, 123, 0.6);
    }
}

.audio-file-item.playing::before {
    background: var(--success-gradient);
    transform: scaleY(1);
}

.audio-file-item .number {
    color: var(--text-muted);
    font-weight: 800;
    font-size: 1.2rem;
    min-width: 35px;
}

.audio-file-item .filename {
    color: var(--text-primary);
    flex: 1;
    font-size: 1.1rem;
    font-weight: 700;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-top: 30px;
    border-top: 2px solid var(--dark-border);
    flex-wrap: wrap;
}

.status-text {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 1rem;
    margin-left: auto;
    padding: 15px 25px;
    background: var(--dark-surface-light);
    border-radius: 12px;
    border: 1px solid var(--dark-border);
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 30px;
    color: var(--text-secondary);
    margin-top: 50px;
    background: var(--dark-surface);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    border: 2px solid var(--dark-border);
    font-size: 1rem;
    line-height: 1.8;
}

/* Responsive */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .tab-button {
        padding: 15px 25px;
        font-size: 1rem;
    }
    
    .mapping-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 15px;
    }
    
    .result-section {
        padding: 25px;
    }
    
    .playback-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-primary, .btn-success, .btn-danger, .btn-info {
        width: 100%;
    }
    
    .status-text {
        margin-left: 0;
        text-align: center;
    }
    
    .decrypted-word {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    header {
        padding: 30px 20px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .input-section {
        padding: 25px;
    }
    
    .sequence-display {
        font-size: 1.2rem;
        padding: 25px;
    }
    
    .symbol-display {
        font-size: 1.5rem;
    }
    
    .notes-display {
        font-size: 1.3rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: var(--dark-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-gradient);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-gradient);
}

/* Decryption Display */
.decryption-display {
    min-height: 120px;
    padding: 25px;
    background: var(--dark-surface-light);
    border: 2px solid var(--dark-border);
    border-radius: 15px;
    margin-bottom: 25px;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-content: flex-start;
    transition: all 0.3s;
}

.decryption-display:empty::before {
    content: attr(placeholder);
    color: var(--text-muted);
    font-style: italic;
    font-size: 1rem;
}

.note-chip {
    background: var(--primary-gradient);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow-sm);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    gap: 8px;
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Piano Keyboard */
.piano-keyboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
}

.piano-key {
    height: 120px;
    background: linear-gradient(to bottom, #ffffff 0%, #e0e0e0 100%);
    color: #333;
    border: none;
    border-radius: 0 0 10px 10px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
    box-shadow: 0 5px 0 #bbb, 0 10px 10px rgba(0,0,0,0.2);
    position: relative;
    user-select: none;
}

.piano-key:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #bbb, 0 2px 5px rgba(0,0,0,0.2);
    background: linear-gradient(to bottom, #f0f0f0 0%, #d0d0d0 100%);
}

.piano-key.high-note {
    background: linear-gradient(to bottom, #333 0%, #000 100%);
    color: white;
    box-shadow: 0 5px 0 #222, 0 10px 10px rgba(0,0,0,0.3);
    margin-top: -10px;
    height: 110px;
    border-radius: 0 0 8px 8px;
    z-index: 2;
}

.piano-key.high-note:active {
    box-shadow: 0 1px 0 #222, 0 2px 5px rgba(0,0,0,0.3);
    background: linear-gradient(to bottom, #444 0%, #111 100%);
}

.piano-key::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    height: 20px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.8), rgba(255,255,255,0));
    border-radius: 4px;
}

.keyboard-controls button {
    flex: 1;
}

