:root {
    --gold-1: #fff3a0;
    --gold-2: #ffd84d;
    --gold-3: #f5b800;
    --gold-4: #c98a00;
    --gold-shadow: #7a4d00;
    --black-1: #000000;
    --black-2: #0a0a0a;
    --black-3: #141414;
    --black-4: #1c1c1c;
    --red-accent: #d72638;
    --green-ok: #4ade80;
    --pixel-border: 4px;
}

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

html, body {
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1305 0%, #050300 55%, #000 100%);
    color: var(--gold-1);
    font-family: 'VT323', monospace;
    font-size: 20px;
    overflow-x: hidden;
    image-rendering: pixelated;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 10%, rgba(255, 216, 77, 0.06) 0%, transparent 35%),
        radial-gradient(circle at 80% 90%, rgba(255, 216, 77, 0.05) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

.scanlines {
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.02) 0px,
        rgba(255, 255, 255, 0.02) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 9998;
    mix-blend-mode: overlay;
}

.vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: none;
    z-index: 9997;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 980px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* HEADER */
.header {
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 24px;
    background: linear-gradient(180deg, var(--black-3), var(--black-1));
    border: var(--pixel-border) solid var(--gold-3);
    box-shadow:
        0 0 0 4px var(--black-1),
        0 0 0 8px var(--gold-4),
        0 0 30px rgba(255, 216, 77, 0.35),
        inset 0 0 30px rgba(0, 0, 0, 0.8);
    position: relative;
}

.header::before, .header::after {
    content: "★";
    position: absolute;
    top: -12px;
    color: var(--gold-2);
    font-size: 22px;
    text-shadow: 0 0 8px var(--gold-3);
}

.header::before { left: -12px; }
.header::after { right: -12px; }

.logo-frame {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    padding: 6px;
    background: var(--black-1);
    border: 3px solid var(--gold-3);
    box-shadow:
        inset 0 0 12px rgba(255, 216, 77, 0.4),
        0 0 18px rgba(255, 216, 77, 0.4);
    image-rendering: pixelated;
    animation: coin-glow 2.5s ease-in-out infinite;
}

.logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
}

@keyframes coin-glow {
    0%, 100% { box-shadow: inset 0 0 12px rgba(255, 216, 77, 0.4), 0 0 18px rgba(255, 216, 77, 0.4); }
    50% { box-shadow: inset 0 0 18px rgba(255, 216, 77, 0.7), 0 0 28px rgba(255, 216, 77, 0.7); }
}

.title-block { flex: 1; }

.title {
    font-family: 'Press Start 2P', monospace;
    font-size: 42px;
    line-height: 1;
    color: var(--gold-2);
    letter-spacing: 4px;
    text-shadow:
        3px 3px 0 var(--gold-shadow),
        6px 6px 0 var(--black-1),
        0 0 18px rgba(255, 216, 77, 0.7);
    margin-bottom: 8px;
}

.subtitle {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: var(--gold-1);
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 var(--black-1);
    margin-bottom: 10px;
    opacity: 0.9;
}

.tagline {
    font-size: 20px;
    color: var(--gold-1);
    opacity: 0.85;
    letter-spacing: 1px;
}

/* PANELS */
.panel {
    background: linear-gradient(180deg, rgba(20, 14, 0, 0.85), rgba(8, 6, 0, 0.95));
    border: var(--pixel-border) solid var(--gold-3);
    padding: 24px;
    position: relative;
    box-shadow:
        0 0 0 2px var(--black-1),
        0 0 0 6px var(--gold-shadow),
        0 0 24px rgba(255, 216, 77, 0.15),
        inset 0 0 24px rgba(0, 0, 0, 0.7);
}

.panel-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: var(--gold-2);
    margin-bottom: 18px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 var(--black-1);
    border-bottom: 2px dashed var(--gold-4);
    padding-bottom: 10px;
}

.panel-hint {
    font-size: 16px;
    color: var(--gold-1);
    opacity: 0.65;
    margin: -8px 0 16px;
}

/* QUEUE */
.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.queue-header .panel-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }

.queue-count {
    display: inline-block;
    margin-left: 8px;
    padding: 2px 8px;
    background: var(--black-1);
    border: 2px solid var(--gold-3);
    color: var(--gold-2);
    font-size: 12px;
    vertical-align: middle;
}

.queue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
    padding: 4px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--gold-4);
}

.queue-list::-webkit-scrollbar { width: 10px; }
.queue-list::-webkit-scrollbar-track { background: var(--black-2); }
.queue-list::-webkit-scrollbar-thumb { background: var(--gold-4); border: 1px solid var(--black-1); }

.queue-item {
    display: grid;
    grid-template-columns: 28px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--black-2);
    border: 2px solid var(--gold-shadow);
    transition: border-color 0.15s, background 0.15s;
}

.queue-item-processing {
    border-color: var(--gold-2);
    background: rgba(255, 216, 77, 0.05);
    animation: queue-pulse 1.2s ease-in-out infinite;
}

.queue-item-done { border-color: var(--green-ok); }
.queue-item-error { border-color: var(--red-accent); }

@keyframes queue-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 216, 77, 0); }
    50% { box-shadow: 0 0 14px 1px rgba(255, 216, 77, 0.45); }
}

.queue-status {
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    color: var(--gold-2);
    text-align: center;
}

.queue-item-done .queue-status { color: var(--green-ok); }
.queue-item-error .queue-status { color: var(--red-accent); }

.queue-name {
    font-size: 18px;
    color: var(--gold-1);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.queue-size {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--gold-1);
    opacity: 0.85;
    white-space: nowrap;
}

.queue-size.ok { color: var(--green-ok); opacity: 1; }
.queue-size.bad { color: var(--red-accent); opacity: 1; }

.queue-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.queue-link, .queue-remove {
    background: var(--black-1);
    border: 2px solid var(--gold-3);
    color: var(--gold-2);
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.1s;
    padding: 0;
}

.queue-link:hover, .queue-remove:hover {
    background: var(--gold-3);
    color: var(--black-1);
}

.queue-remove { border-color: var(--gold-shadow); color: var(--gold-1); }
.queue-remove:hover { background: var(--red-accent); color: var(--black-1); border-color: var(--red-accent); }

.overall-progress {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    color: var(--gold-2);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.actions .btn-gold + .btn-gold { margin-top: 12px; }

/* DROP ZONE */
.drop-zone {
    cursor: pointer;
    transition: all 0.2s;
    border-style: dashed;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--gold-1);
    box-shadow:
        0 0 0 2px var(--black-1),
        0 0 0 6px var(--gold-2),
        0 0 36px rgba(255, 216, 77, 0.6),
        inset 0 0 24px rgba(255, 216, 77, 0.1);
    transform: translateY(-2px);
}

.drop-inner {
    text-align: center;
    padding: 28px 20px;
}

.coin-icon {
    font-size: 64px;
    color: var(--gold-2);
    text-shadow:
        4px 4px 0 var(--gold-shadow),
        0 0 20px rgba(255, 216, 77, 0.7);
    margin-bottom: 14px;
    animation: spin-coin 4s linear infinite;
    display: inline-block;
}

@keyframes spin-coin {
    0%, 100% { transform: scaleX(1); }
    50% { transform: scaleX(-1); }
}

.drop-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 16px;
    color: var(--gold-1);
    margin-bottom: 10px;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0 var(--black-1);
}

.drop-desc {
    font-size: 18px;
    color: var(--gold-1);
    opacity: 0.75;
    margin-bottom: 20px;
}

.file-name {
    margin-top: 14px;
    font-size: 18px;
    color: var(--green-ok);
    word-break: break-all;
}

/* OPTIONS */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.option {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.55);
    border: 2px solid var(--gold-4);
    transition: border-color 0.2s;
}

.option:focus-within {
    border-color: var(--gold-1);
    box-shadow: 0 0 12px rgba(255, 216, 77, 0.5);
}

.option-label {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--gold-2);
    letter-spacing: 1px;
}

.option input,
.option select {
    background: var(--black-1);
    border: 2px solid var(--gold-3);
    color: var(--gold-1);
    padding: 8px 10px;
    font-family: 'VT323', monospace;
    font-size: 20px;
    width: 100%;
    outline: none;
}

.option input:focus,
.option select:focus { border-color: var(--gold-1); }

.option-hint {
    font-size: 14px;
    color: var(--gold-1);
    opacity: 0.6;
}

/* BUTTONS */
.btn-gold {
    display: inline-block;
    font-family: 'Press Start 2P', monospace;
    font-size: 14px;
    letter-spacing: 2px;
    padding: 14px 22px;
    background: linear-gradient(180deg, var(--gold-1) 0%, var(--gold-2) 40%, var(--gold-3) 60%, var(--gold-4) 100%);
    color: var(--black-1);
    border: 3px solid var(--black-1);
    box-shadow:
        0 0 0 3px var(--gold-3),
        4px 4px 0 var(--black-1),
        4px 4px 0 6px var(--gold-shadow);
    cursor: pointer;
    text-shadow: 1px 1px 0 var(--gold-1);
    text-decoration: none;
    text-align: center;
    transition: transform 0.08s, box-shadow 0.08s;
    user-select: none;
}

.btn-gold:hover {
    transform: translate(-1px, -1px);
    box-shadow:
        0 0 0 3px var(--gold-2),
        6px 6px 0 var(--black-1),
        6px 6px 0 8px var(--gold-shadow);
    filter: brightness(1.08);
}

.btn-gold:active {
    transform: translate(3px, 3px);
    box-shadow:
        0 0 0 3px var(--gold-3),
        1px 1px 0 var(--black-1),
        1px 1px 0 3px var(--gold-shadow);
}

.btn-gold:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.3);
}

.btn-big {
    font-size: 18px;
    padding: 18px 36px;
    width: 100%;
}

.btn-ghost {
    background: transparent;
    color: var(--gold-1);
    border: 2px solid var(--gold-4);
    padding: 10px 18px;
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    cursor: pointer;
    letter-spacing: 1px;
    margin-top: 8px;
    transition: all 0.15s;
}

.btn-ghost:hover {
    border-color: var(--gold-1);
    color: var(--gold-2);
    background: rgba(255, 216, 77, 0.05);
}

/* LOG / PROGRESS */
.progress-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.progress-bar {
    flex: 1;
    height: 22px;
    background: var(--black-1);
    border: 2px solid var(--gold-3);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background:
        repeating-linear-gradient(
            45deg,
            var(--gold-2),
            var(--gold-2) 8px,
            var(--gold-3) 8px,
            var(--gold-3) 16px
        );
    transition: width 0.25s ease;
    box-shadow: 0 0 12px rgba(255, 216, 77, 0.7);
}

.progress-text {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: var(--gold-2);
    min-width: 50px;
    text-align: right;
}

.log {
    background: var(--black-1);
    border: 2px solid var(--gold-4);
    color: var(--gold-1);
    padding: 12px;
    max-height: 180px;
    overflow-y: auto;
    font-family: 'VT323', monospace;
    font-size: 16px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

.log::-webkit-scrollbar { width: 10px; }
.log::-webkit-scrollbar-track { background: var(--black-2); }
.log::-webkit-scrollbar-thumb { background: var(--gold-4); border: 1px solid var(--black-1); }

/* RESULT */
.result-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 640px) {
    .result-grid { grid-template-columns: 1fr; }
    .header { flex-direction: column; text-align: center; }
    .title { font-size: 30px; }
}

.preview-frame {
    width: 256px;
    height: 256px;
    background: var(--black-1);
    border: 3px solid var(--gold-3);
    box-shadow:
        0 0 0 3px var(--black-1),
        0 0 0 6px var(--gold-shadow),
        0 0 24px rgba(255, 216, 77, 0.5);
    image-rendering: pixelated;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#resultVideo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}

.result-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--gold-4);
    font-size: 18px;
}

.info-row span { color: var(--gold-1); opacity: 0.7; }
.info-row b { color: var(--gold-2); font-weight: normal; font-family: 'Press Start 2P', monospace; font-size: 11px; }

.info-row b.ok { color: var(--green-ok); }
.info-row b.bad { color: var(--red-accent); }

/* FOOTER */
.footer {
    text-align: center;
    padding: 12px;
    color: var(--gold-1);
    opacity: 0.7;
    font-size: 16px;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.footer-specs {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--gold-2);
    opacity: 0.75;
}

.gold { color: var(--gold-2); text-shadow: 0 0 6px var(--gold-3); }

/* SPINNER STATE */
.converting .coin-icon { animation: spin-coin 0.6s linear infinite; }
