:root {
    --bg-color: #0f111a;
    --card-bg: #1e2235;
    --accent-color: #00e5ff;
    --text-color: #ffffff;
    --accent-glow: rgba(0, 229, 255, 0.4);
}

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

body {
    background: linear-gradient(135deg, #0f111a 0%, #1a1d2e 100%);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    position: relative;
}

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0f111a 0%, #1a1d2e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-runes {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}

.loader-runes .rune {
    font-size: 4rem;
    color: var(--accent-color);
    animation: runeFloat 1.5s ease-in-out infinite;
    text-shadow: 0 0 20px var(--accent-glow);
}

.loader-runes .rune:nth-child(1) { animation-delay: 0s; }
.loader-runes .rune:nth-child(2) { animation-delay: 0.2s; }
.loader-runes .rune:nth-child(3) { animation-delay: 0.4s; }

.loading-text {
    font-size: 1.2rem;
    color: var(--accent-color);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes runeFloat {
    0%, 100% { transform: translateY(0px); opacity: 1; }
    50% { transform: translateY(-20px); opacity: 0.7; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.particle {
    position: absolute;
    font-size: 1.5rem;
    color: rgba(0, 229, 255, 0.1);
    animation: particleFloat linear infinite;
    pointer-events: none;
}

@keyframes particleFloat {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.3;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(-100vh) rotate(360deg);
        opacity: 0;
    }
}

.translator-container {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8),
                0 0 40px rgba(0, 229, 255, 0.1);
    width: 500px;
    max-width: 90%;
    text-align: center;
    border: 1px solid rgba(0, 229, 255, 0.2);
    position: relative;
    z-index: 1;
    animation: containerAppear 0.8s ease-out;
}

@keyframes containerAppear {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    margin-top: 0;
    color: var(--accent-color);
    font-size: 3rem;
    letter-spacing: 4px;
    position: relative;
    text-shadow: 0 0 20px var(--accent-glow);
    margin-bottom: 10px;
}

.glitch {
    position: relative;
    animation: glitchTitle 5s infinite;
}

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

.glitch:before {
    animation: glitch1 2.5s infinite;
    clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
    transform: translate(-2px, -2px);
    opacity: 0.8;
}

.glitch:after {
    animation: glitch2 2.5s infinite;
    clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
    transform: translate(2px, 2px);
    opacity: 0.8;
}

@keyframes glitch1 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -2px); }
}

@keyframes glitch2 {
    0%, 100% { transform: translate(0); }
    20% { transform: translate(2px, -2px); }
    40% { transform: translate(2px, 2px); }
    60% { transform: translate(-2px, -2px); }
    80% { transform: translate(-2px, 2px); }
}

.subtitle {
    color: #8892b0;
    font-size: 0.95rem;
    margin-bottom: 25px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

textarea {
    width: 100%;
    height: 120px;
    background: rgba(0,0,0,0.3);
    border: 2px solid #3f4769;
    border-radius: 12px;
    color: white;
    padding: 15px;
    box-sizing: border-box;
    resize: none;
    font-size: 1rem;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-glow);
    background: rgba(0,0,0,0.4);
}

.char-count {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: 0.75rem;
    color: #5a6484;
    pointer-events: none;
}

.output-box {
    margin-top: 25px;
    background: rgba(0,0,0,0.4);
    padding: 20px;
    border-radius: 12px;
    min-height: 80px;
    text-align: left;
    border-left: 4px solid var(--accent-color);
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.label {
    font-size: 0.85rem;
    color: #8892b0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    font-family: inherit;
}

.copy-btn:hover {
    background: var(--accent-color);
    color: var(--bg-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.copy-btn.copied {
    background: #00ff88;
    border-color: #00ff88;
    color: #0f111a;
}

.copy-icon {
    font-size: 1rem;
}

.rune-text {
    font-size: 1.8rem;
    color: var(--accent-color);
    letter-spacing: 4px;
    word-break: break-all;
    text-shadow: 0 0 10px var(--accent-glow);
    line-height: 1.6;
}

@keyframes runeAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.github-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 25px;
    padding: 10px 20px;
    background: rgba(0,0,0,0.3);
    border: 1px solid #3f4769;
    border-radius: 8px;
    color: #8892b0;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.github-link:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2);
}

.github-link svg {
    transition: transform 0.3s ease;
}

.github-link:hover svg {
    transform: rotate(360deg);
}

.info-section {
    background: rgba(0, 229, 255, 0.05);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    text-align: left;
}

.info-section h3 {
    color: var(--accent-color);
    margin: 0 0 10px 0;
    font-size: 1.2rem;
}

.info-section p {
    color: #8892b0;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0 0 15px 0;
}

.example-runes {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.example-runes span {
    background: rgba(0,0,0,0.3);
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--accent-color);
    font-size: 0.9rem;
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(0,0,0,0.3);
    padding: 6px;
    border-radius: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #8892b0;
    font-size: 0.95rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.mode-btn.active {
    background: var(--accent-color);
    color: var(--bg-color);
    box-shadow: 0 4px 15px var(--accent-glow);
}

.mode-btn:hover:not(.active) {
    background: rgba(0, 229, 255, 0.1);
    color: var(--accent-color);
}

.translation-area {
    animation: fadeIn 0.4s ease-out;
}

.translation-area.hidden {
    display: none;
}

.arrow-divider {
    font-size: 2rem;
    color: var(--accent-color);
    margin: 15px 0;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-label {
    display: block;
    font-size: 0.85rem;
    color: #8892b0;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    text-align: left;
}

.english-text {
    font-size: 1.2rem;
    color: var(--text-color);
    line-height: 1.8;
    word-break: break-word;
}

@media (max-width: 600px) {
    .translator-container {
        padding: 25px;
        width: 95%;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .rune-text {
        font-size: 1.4rem;
    }
}

.history-toggle {
    position: fixed;
    left: 20px;
    top: 20px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid #00e5ff;
    color: #00e5ff;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.3s ease;
    font-size: 20px;
}

.history-toggle:hover {
    background: rgba(0, 229, 255, 0.2);
    transform: scale(1.05);
}

.history-sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    border-right: 2px solid #00e5ff;
    padding: 20px;
    transition: left 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

.history-sidebar.open {
    left: 0;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #00e5ff;
}

.history-header h3 {
    margin: 0;
    color: #00e5ff;
}

.clear-history {
    background: rgba(255, 0, 0, 0.3);
    border: 1px solid #ff4444;
    color: #ff8888;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-history:hover {
    background: rgba(255, 0, 0, 0.6);
    transform: scale(0.95);
}

.history-list {
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}

.history-item {
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 0;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-left: 3px solid #00e5ff;
}

.history-item:hover {
    background: rgba(0, 229, 255, 0.2);
    transform: translateX(5px);
}

.history-item.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

.history-text {
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-date {
    font-size: 0.7em;
    color: #00e5ff;
    margin-top: 5px;
}

.empty-history {
    text-align: center;
    color: #888;
    padding: 20px;
}

.drop-zone {
    border: 2px dashed #00e5ff;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    margin: 15px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 229, 255, 0.05);
}

.drop-zone.drag-over {
    background: rgba(0, 229, 255, 0.2);
    border-color: #00ccff;
    transform: scale(1.02);
}

.drop-zone p {
    margin: 0;
    color: #00e5ff;
}

.drop-zone small {
    color: #aaa;
}

.file-btn {
    background: rgba(0, 229, 255, 0.2);
    border: 1px solid #00e5ff;
    color: #00e5ff;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.file-btn:hover {
    background: rgba(0, 229, 255, 0.4);
}

.download-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
    transition: all 0.3s ease;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.action-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.translator-container {
    margin-left: 60px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* ─────────────────────────────────────────────
   MUSIC NOTICE + MUSIC CONTROL
───────────────────────────────────────────── */
.music-warning {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    background: linear-gradient(135deg, #0f111a 0%, #1a1d2e 100%);
    transition: opacity .45s ease, visibility .45s ease;
}

.music-warning.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.music-warning-card {
    width: min(480px, 100%);
    padding: 34px 28px;
    border: 1px solid rgba(0, 229, 255, .35);
    border-radius: 20px;
    text-align: center;
    background: rgba(30, 34, 53, .96);
    box-shadow: 0 22px 70px rgba(0,0,0,.7), 0 0 42px rgba(0,229,255,.15);
}

.warning-runes {
    color: var(--accent-color);
    letter-spacing: 12px;
    font-size: 1.7rem;
    text-shadow: 0 0 18px var(--accent-glow);
    margin-left: 12px;
    margin-bottom: 14px;
}

.warning-icon { font-size: 2.5rem; margin-bottom: 8px; }
.music-warning h2 { color: var(--accent-color); margin-bottom: 12px; }
.music-warning p { color: #d7defa; line-height: 1.55; }
.warning-small { color: #8f9abf !important; font-size: .88rem; margin-top: 10px; }
.warning-countdown { min-height: 24px; color: var(--accent-color); margin: 18px 0 8px; font-weight: 700; }
.music-warning-actions { display: grid; gap: 10px; margin-top: 14px; }
.music-choice {
    border: 1px solid rgba(0,229,255,.4);
    background: rgba(0,229,255,.08);
    color: white;
    border-radius: 10px;
    padding: 13px 16px;
    font-weight: 700;
    cursor: pointer;
}
.music-choice.primary { background: var(--accent-color); color: #071116; }
.music-choice:active { transform: scale(.98); }

.music-toggle {
    position: fixed;
    top: 18px;
    left: 18px;
    z-index: 20;
    border: 1px solid rgba(0,229,255,.35);
    background: rgba(15,17,26,.86);
    color: var(--accent-color);
    border-radius: 999px;
    padding: 9px 13px;
    cursor: pointer;
    box-shadow: 0 0 18px rgba(0,229,255,.12);
}

@media (max-width: 560px) {
    .music-toggle { top: 12px; left: 12px; font-size: .8rem; }
    .music-warning-card { padding: 28px 20px; }
}


/* ─────────────────────────────────────────────
   CONTROL POSITIONS + HISTORY PANEL FIX
───────────────────────────────────────────── */
.history-toggle {
    left: 20px;
    top: 20px;
    z-index: 1100;
}

.music-toggle {
    left: auto;
    right: 20px;
    top: 20px;
    z-index: 1100;
}

body.history-open .history-toggle {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-18px);
}

.history-sidebar {
    z-index: 1200;
    width: min(360px, 92vw);
    left: calc(-1 * min(360px, 92vw));
    padding: 18px;
}

.history-sidebar.open {
    left: 0;
}

.history-header {
    gap: 12px;
}

.history-header h3 {
    min-width: 0;
    font-size: 1.05rem;
    line-height: 1.2;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-history {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid rgba(0, 229, 255, .6);
    background: rgba(0, 229, 255, .10);
    color: var(--accent-color);
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.close-history:hover {
    background: var(--accent-color);
    color: #071116;
}

.history-list {
    max-height: calc(100vh - 110px);
    padding-right: 4px;
}

@media (max-width: 560px) {
    .history-toggle {
        top: 12px;
        left: 12px;
        padding: 9px 12px;
        font-size: .85rem;
    }

    .music-toggle {
        top: 12px;
        right: 12px;
        left: auto;
        font-size: .8rem;
    }

    .history-sidebar {
        width: min(340px, 94vw);
        left: calc(-1 * min(340px, 94vw));
        padding: 16px;
    }
}


/* ─────────────────────────────────────────────
   EXTRA-VISIBLE MOVING UPWARD RUNE EFFECTS
───────────────────────────────────────────── */

body::before,
body::after {
    content: "";
    position: fixed;
    width: 42rem;
    height: 42rem;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    filter: blur(48px);
    opacity: 0.46;
    animation: ambientGlowDrift 11s ease-in-out infinite alternate;
}

body::before {
    top: -15rem;
    left: -13rem;
    background: radial-gradient(
        circle,
        rgba(0, 229, 255, 0.78) 0%,
        rgba(0, 229, 255, 0.24) 40%,
        transparent 72%
    );
}

body::after {
    right: -14rem;
    bottom: -16rem;
    background: radial-gradient(
        circle,
        rgba(119, 94, 255, 0.68) 0%,
        rgba(0, 229, 255, 0.22) 42%,
        transparent 72%
    );
    animation-delay: -5.5s;
}

@keyframes ambientGlowDrift {
    from {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.34;
    }

    to {
        transform: translate3d(8rem, 5rem, 0) scale(1.22);
        opacity: 0.56;
    }
}

/* Put the effects above the plain background, but behind the app card. */
.particles {
    position: fixed;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    display: block;
    font-size: clamp(1.65rem, 3vw, 3.1rem);
    font-weight: 800;
    color: rgba(0, 245, 255, 0.94);
    text-shadow:
        0 0 7px rgba(255, 255, 255, 0.92),
        0 0 18px rgba(0, 229, 255, 1),
        0 0 42px rgba(0, 229, 255, 0.92),
        0 0 76px rgba(111, 83, 255, 0.78);
    filter: drop-shadow(0 0 12px rgba(0, 229, 255, 0.96));
    opacity: 0;
    will-change: transform, opacity;
    animation-name: particleFloat;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

@keyframes particleFloat {
    0% {
        transform:
            translate3d(0, 0, 0)
            rotate(var(--start-rotate, 0deg))
            scale(calc(var(--particle-scale, 1) * 0.8));
        opacity: 0;
    }

    6% { opacity: 0.76; }
    20% { opacity: 1; }
    72% { opacity: 1; }
    93% { opacity: 0.72; }

    100% {
        transform:
            translate3d(var(--drift-x, 4vw), -155vh, 0)
            rotate(var(--end-rotate, 720deg))
            scale(calc(var(--particle-scale, 1) * 1.22));
        opacity: 0;
    }
}

/* Keep the readable content above the bright effects. */
.translator-container {
    position: relative;
    z-index: 3;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.82),
        0 0 56px rgba(0, 229, 255, 0.26),
        0 0 130px rgba(67, 56, 202, 0.24);
}

@media (max-width: 650px) {
    .particle {
        font-size: clamp(1.45rem, 6vw, 2.35rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    body::after,
    .particle {
        animation: none !important;
    }
}
