@import url('https://fonts.googleapis.com/css2?family=Vend+Sans&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --purple: #a855f7;
    --purple-light: #c084fc;
    --purple-glow: rgba(168, 85, 247, 0.4);
    --black: #000000;
    --white: #ffffff;
    --gray: #666666;
    --border-radius: 8px;
}

body {
    font-family: 'Vend Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--black);
    color: var(--white);
    min-height: 100vh;
    font-size: 14px;
    overscroll-behavior-y: none;
    user-select: none;
}

input, textarea, [contenteditable], pre, code, a {
    user-select: text;
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px 0 8px;
    background: var(--black);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    height: 44px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 6px;
}

.logo {
    cursor: pointer;
    padding: 6px 10px;
    margin: -6px -10px -6px 0;
    border-radius: 4px;
}

.topbar-menu-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 18px;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}
.topbar-menu-btn:hover { color: #fff; }
.topbar-menu-btn.nav-open { color: var(--purple-light); }

.topbar-user-info {
    cursor: pointer;
    font-size: 12px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    padding: 10px 0 10px 14px;
    margin: -10px 0 -10px -14px;
}

.topbar-user-slide {
    position: relative;
    height: 1.3em;
    overflow: hidden;
}

.topbar-user-main {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.topbar-user-main span { line-height: 1; }

.topbar-user-sep {
    opacity: 0.4;
}

.topbar-queue-label {
    opacity: 0.4;
    font-size: 10px;
}

.topbar-user-logout {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    display: flex;
    align-items: center;
    color: #f87171;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    white-space: nowrap;
}

.topbar-user-slide.show-logout .topbar-user-main {
    transform: translateY(-100%);
    opacity: 0;
}

.topbar-user-slide.show-logout .topbar-user-logout {
    transform: translateY(0);
    opacity: 1;
}

/* Logo */
.logo {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 3px;
    flex-shrink: 0;
    margin: 0;
    cursor: pointer;
}

/* Tools nav overlay */
.tools-nav {
    position: fixed;
    top: 44px;
    left: 8px;
    right: 8px;
    z-index: 199;
    display: flex;
    gap: 0;
    padding: 10px 16px;
    border: 1px solid rgba(255,255,255,0.22);
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--purple) transparent;
    transform: translateY(calc(-100% - 10px));
    transition: transform 0.22s ease, visibility 0s linear 0.22s;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    background: rgba(8,8,8,0.85);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    visibility: hidden;
}

.tools-nav.nav-visible {
    transform: translateY(6px);
    transition: transform 0.22s ease, visibility 0s linear 0s;
    visibility: visible;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    padding-top: 60px;
}

/* Auth Section */
.auth-container {
    display: flex;
    flex-flow: column nowrap;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-box {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border: 2px solid var(--white);
    border-radius: var(--border-radius);
    background: var(--black);
    box-shadow: 0 0 30px var(--purple-glow);
    transition: box-shadow 0.3s ease;
}

.auth-box.error {
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
}

.auth-box input {
    width: 100%;
    padding: 14px 18px;
    margin-bottom: 16px;
    background: var(--black);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.auth-box input::placeholder {
    color: var(--gray);
}

.auth-box input:focus {
    border-color: var(--purple);
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--gray);
}

.link {
    color: var(--white);
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.link:hover {
    color: var(--purple);
}

/* Buttons */
.purple-btn {
    background: var(--purple);
    color: var(--white);
    border: none;
    padding: 14px 28px;
    border-radius: var(--border-radius);
    font-family: 'Vend Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.purple-btn.uploading {
    background: #7c3aed;
    cursor: default;
    box-shadow: none;
}

.purple-btn.uploading::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--purple);
    transition: width 0.4s ease;
    border-radius: var(--border-radius);
    z-index: 0;
}

.purple-btn.uploading span {
    position: relative;
    z-index: 1;
}

.purple-btn:hover {
    box-shadow: 0 0 20px var(--purple-glow), 0 0 40px var(--purple-glow);
    transform: translateY(-1px);
}

.purple-btn:active {
    transform: translateY(0);
}

.purple-btn.full-width {
    width: 100%;
}

.small-btn {
    background: transparent;
    color: var(--white);
    border: 1px solid var(--white);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-family: 'Vend Sans', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.small-btn:hover {
    background: var(--white);
    color: var(--black);
}

/* App Section */
.app-container {
    animation: fadeIn 0.3s ease;
}

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

/* Logout Button — commented out but kept for reference
.logout-btn-fixed { ... }
*/

.user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 13px;
}

#username {
    white-space: nowrap;
}

.storage-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.quota-bar-inline {
    width: 180px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.quota-fill {
    height: 100%;
    background: var(--purple);
    width: 0%;
    transition: width 0.3s ease, background-color 0.3s ease;
    border-radius: 3px;
    position: absolute;
    left: 0;
}

.quota-pending {
    height: 100%;
    background: #f59e0b;
    width: 0%;
    transition: width 0.3s ease, left 0.3s ease;
    border-radius: 3px;
    position: absolute;
    opacity: 0.7;
}

.quota-fill.warning {
    background: #f59e0b;
}

.quota-fill.danger {
    background: #ef4444;
}

.storage-text {
    font-size: 12px;
    color: var(--gray);
    white-space: nowrap;
}

.pending-storage {
    color: #f59e0b;
    font-weight: 600;
}

.user-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    min-width: auto;
}

.btn-icon {
    width: 16px;
    height: 16px;
    filter: invert(1);
}

.icon-btn:hover .btn-icon {
    filter: invert(0);
}

/* Tools Navigation — scrollbar */
.tools-nav::-webkit-scrollbar {
    height: 2px;
}

.tools-nav::-webkit-scrollbar-track {
    background: transparent;
}

.tools-nav::-webkit-scrollbar-thumb {
    background: var(--purple);
    border-radius: 1px;
}

.tools-nav::-webkit-scrollbar-thumb:hover {
    background: var(--purple-light);
}

.tool-btn {
    flex-shrink: 0;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    margin-right: 12px;
}

.tool-btn:last-child {
    margin-right: 0;
}

.tool-btn:hover {
    background: var(--white);
    color: var(--black);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.tool-btn.active {
    background: var(--purple);
    border-color: var(--purple);
}

/* Home view */
/* ── Home view ── */

#menuBtn { display: none; }

.home-view {
    position: relative;
    height: calc(100dvh - 60px - 12px);
    margin: 0 -20px -20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.home-terminal-wrap {
    position: relative;
    width: 100%;
    height: 25dvh;
    flex-shrink: 0;
}

.term-anim-picker {
    position: absolute;
    bottom: 6px;
    right: 8px;
    z-index: 10;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.4);
    font-size: 10px;
    font-family: "Courier New", Courier, monospace;
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.home-terminal {
    font-family: 'Courier New', Courier, monospace;
    font-size: 7px;
    line-height: 1.1;
    color: var(--purple-light);
    background: rgba(88, 28, 135, 0.10);
    border: 1px solid rgba(168, 85, 247, 0.18);
    height: 100%;
    overflow: hidden;
    padding: 2px 4px;
}

.home-terminal-content {
    white-space: pre;
}

.home-terminal-cursor {
    display: inline;
    animation: term-blink 1s step-end infinite;
}

@keyframes term-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.home-grid {
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 20px;
    width: 35%;
}

.home-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 11px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    cursor: pointer;
    background: rgba(0,0,0,0.40);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: border-color 0.15s, background 0.15s;
    text-align: center;
}

.home-card:hover {
    border-color: var(--purple);
    box-shadow: 0 0 10px var(--purple-glow);
    background: rgba(0,0,0,0.62);
}

.home-card:active {
    transform: scale(0.96);
}

.home-card-icon {
    font-size: 15px;
    font-weight: bold;
    color: var(--purple-light);
    line-height: 1.3;
    margin-bottom: 4px;
}

.home-card-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
    line-height: 1.2;
}

.home-card-desc {
    font-size: 9px;
    color: rgba(255,255,255,0.42);
    line-height: 1.1;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

/* Games view centered layout */
#gamesView {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
    grid-template-columns: 1fr;
}

/* Queue card "by user" attribution */
.queue-card-byuser {
    color: rgba(255,255,255,0.45);
    font-size: 11px;
}

.game-selection-panel,
.game-play-panel {
    width: 100%;
    max-width: 600px;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
}

.game-selection-panel h2 {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
}

@media (max-width: 968px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .game-selection-panel,
    .game-play-panel {
        padding: 16px;
    }
}



/* Upload Section */
.upload-section,
.items-section {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
}

.upload-section h2,
.items-section h2 {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
}

/* Items header with reload button */
.items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.items-header h2 {
    margin-bottom: 0;
}

.reload-btn {
    background: transparent;
    border: 1px solid var(--white);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reload-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 15px var(--purple-glow);
}

.reload-btn img {
    width: 18px;
    height: 18px;
    transition: transform 0.6s ease;
}

.reload-btn.spinning img {
    animation: spin-counterclockwise 0.6s ease;
}

@keyframes spin-counterclockwise {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(-360deg);
    }
}

/* Tabs */
.tab-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: var(--purple);
    border-color: var(--purple);
}

.tab-content {
    animation: fadeIn 0.2s ease;
}

/* File Drop Zone */
.file-drop-zone {
    border: 2px dashed var(--white);
    border-radius: var(--border-radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.file-drop-zone:hover {
    border-color: var(--purple);
    background: rgba(168, 85, 247, 0.05);
}

.file-drop-zone.drag-over {
    border-color: var(--purple);
    background: rgba(168, 85, 247, 0.1);
    box-shadow: 0 0 20px var(--purple-glow);
}

.file-drop-zone p {
    font-size: 13px;
    color: var(--gray);
}

.file-preview {
    padding: 16px;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 13px;
}

.file-preview img {
    max-width: 100%;
    border-radius: var(--border-radius);
    margin-top: 8px;
}

/* Zip Options */
.zip-options {
    margin-bottom: 16px;
}

.zip-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 12px;
}

.zip-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--purple);
}

.zip-checkbox span {
    user-select: none;
}

.zip-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-left: 28px;
}

.zip-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--black);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.zip-input::placeholder {
    color: var(--gray);
}

.zip-input:focus {
    border-color: var(--purple);
}

/* Share Options */
.share-options {
    margin-bottom: 16px;
}

.share-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.share-input-row .zip-input {
    flex: 1;
}

.lock-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lock-toggle:hover {
    opacity: 0.8;
}

.lock-toggle img {
    width: 20px;
    height: 20px;
}


/* Text Input */
textarea {
    width: 100%;
    padding: 14px 18px;
    background: var(--black);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

textarea::placeholder {
    color: var(--gray);
}

textarea:focus {
    border-color: var(--purple);
}

/* URL Shortener */
.url-input {
    width: 100%;
    padding: 14px 18px;
    background: var(--black);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}

.url-input::placeholder {
    color: var(--gray);
}

.url-input:focus {
    border-color: var(--purple);
}

.url-input[type="number"]::-webkit-outer-spin-button,
.url-input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.url-input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Dice Roller */
.dice-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dice-controls label {
    font-size: 12px;
    color: var(--gray);
    margin-top: 8px;
}

.dice-result {
    padding: 24px;
    border: 1px solid var(--purple);
    border-radius: var(--border-radius);
    background: rgba(168, 85, 247, 0.05);
}

#base64Output textarea {
    width: 100%;
    min-height: 300px;
}

/* QR Code */
.qr-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

#qrCanvas {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    background: var(--white);
    padding: 16px;
}


.result-total {
    text-align: center;
    margin-bottom: 24px;
}

.total-label {
    display: block;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 8px;
}

.total-value {
    display: block;
    font-size: 48px;
    font-weight: bold;
    color: var(--purple-light);
}

.individual-rolls {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 16px;
}

.rolls-label {
    display: block;
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 12px;
}

.rolls-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.roll-item {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
}

/* Select */
.styled-select {
    width: 100%;
    padding: 12px 18px;
    background: var(--black);
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.styled-select:focus {
    border-color: var(--purple);
}

/* Items List */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-card {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    padding: 16px;
    transition: all 0.2s;
    overflow: hidden;
}

.item-card.url-highlight {
    border-color: var(--purple) !important;
    box-shadow: 0 0 15px var(--purple-glow);
    transition: all 0.3s ease;
}

.item-card.clickable {
    cursor: pointer;
}

.item-card.clickable:hover {
    border-color: var(--purple);
    box-shadow: 0 0 15px var(--purple-glow);
    transform: translateX(2px);
}

.item-card.text-item {
    border-left: 3px solid var(--purple);
}

.item-image-preview {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-top: 12px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.item-name {
    font-weight: 600;
    font-size: 13px;
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.item-name.text-preview {
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 55%, transparent 100%);
}

.burn-badge {
    display: inline-block;
    background: var(--purple);
    color: var(--white);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

/* Inline copyable code spans */
.code-block {
    color: var(--purple-light);
    font-family: monospace;
    background: rgba(168, 85, 247, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    display: inline;
    transition: background 0.2s;
}
.code-block:hover {
    background: rgba(168, 85, 247, 0.25);
}
.code-block::after {
    content: 'click to copy';
    position: absolute;
    top: -24px;
    right: 0;
    background: var(--purple);
    color: var(--white);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 9px;
    font-family: 'Vend Sans', sans-serif;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
}
.code-block:hover::after {
    opacity: 1;
}

/* Secondary button */
.secondary-btn {
    background: transparent;
    color: var(--gray);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 14px 28px;
    border-radius: var(--border-radius);
    font-family: 'Vend Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}
.secondary-btn:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--white);
}
.secondary-btn.full-width {
    width: 100%;
}

/* Downloader */
.dl-fetching {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 20px;
    color: var(--gray);
    font-size: 13px;
}

.dl-spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: dl-spin 0.75s linear infinite;
}

@keyframes dl-spin {
    to { transform: rotate(360deg); }
}

.dl-media-card {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: flex-start;
}

.dl-thumbnail {
    width: 148px;
    height: 83px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.dl-media-info {
    flex: 1;
    min-width: 0;
}

.dl-source-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}

.dl-source-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

.dl-uploader {
    font-size: 11px;
    color: var(--gray);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dl-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    margin-bottom: 6px;
    overflow: hidden;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

.dl-meta {
    font-size: 11px;
    color: var(--gray);
    margin: 0;
}

.dl-progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.dl-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--purple);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.dl-progress-bar.pulsing {
    width: 100%;
    animation: dl-pulse 1.2s ease-in-out infinite;
}

@keyframes dl-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.dl-status-label {
    font-size: 13px;
    color: var(--gray);
    margin: 0;
}

.dl-ready-filename {
    font-size: 13px;
    color: var(--white);
    margin-bottom: 16px;
    word-break: break-all;
}

.dl-error-msg {
    font-size: 13px;
    color: #ef4444;
    margin: 0;
}

/* Compact info bar (shown in downloader after download, and in queue now-playing) */
.dl-compact-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0 12px;
}

.dl-compact-icon {
    width: 22px;
    height: 22px;
    border-radius: 4px;
    flex-shrink: 0;
    object-fit: contain;
}

.dl-compact-text {
    flex: 1;
    min-width: 0;
}

.dl-compact-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dl-compact-meta {
    display: block;
    font-size: 11px;
    color: var(--gray);
    margin-top: 2px;
}

/* Media player */
.dl-player-wrap {
    border-radius: var(--border-radius);
    overflow: hidden;
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.06);
    position: relative;
}

.dl-player-wrap video {
    width: 100%;
    display: block;
    max-height: 360px;
    background: #000;
    object-fit: contain;
}

.dl-player-wrap.dl-player-audio-mode {
    background: transparent;
    border-color: transparent;
}

.dl-player-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.3s ease;
}

/* Fullscreen overrides */
.dl-player-wrap:fullscreen,
.dl-player-wrap:-webkit-full-screen {
    background: #000;
    border-radius: 0;
    border: none;
}

.dl-player-wrap:fullscreen video,
.dl-player-wrap:-webkit-full-screen video {
    width: 100%;
    height: 100%;
    max-height: none;
    object-fit: contain;
}

.dl-player-wrap:fullscreen .dl-player-controls,
.dl-player-wrap:-webkit-full-screen .dl-player-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
    padding: 28px 16px 14px;
    z-index: 1;
}

.dl-player-wrap.dl-player-audio-mode .dl-player-controls {
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.15);
    border-radius: var(--border-radius);
}

.dl-ctrl-btn {
    background: none;
    border: none;
    color: var(--white);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.dl-ctrl-btn:hover {
    opacity: 1;
}

.q-seek-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.q-thumb-preview {
    position: absolute;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.q-thumb-preview.hidden { display: none; }

.q-thumb-frame {
    border-radius: 4px;
    overflow: hidden;
    background-repeat: no-repeat;
    border: 1px solid rgba(168,85,247,0.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}

.q-thumb-time {
    font-size: 11px;
    color: #fff;
    background: rgba(0,0,0,0.7);
    padding: 1px 5px;
    border-radius: 3px;
}

.q-seek-wrap .dl-seek-bar {
    flex: 1;
}

.dl-seek-bar {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
    transition: height 0.15s;
}

.dl-seek-bar:hover {
    height: 6px;
}

.dl-seek-fill {
    height: 100%;
    background: var(--purple);
    border-radius: 2px;
    width: 0%;
    pointer-events: none;
}

.dl-time-display {
    font-size: 11px;
    color: var(--gray);
    white-space: nowrap;
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.item-time {
    font-size: 11px;
    color: var(--gray);
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.time-icon {
    width: 12px;
    height: 12px;
    opacity: 0.6;
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 12px;
}

.item-content {
    font-size: 12px;
    color: var(--gray);
    word-break: break-all;
    overflow-wrap: anywhere;
    min-width: 0;
    margin-bottom: 8px;
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.item-actions button {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.item-actions button:hover {
    background: var(--white);
    color: var(--black);
}

.item-actions button.delete-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: var(--white);
}

.item-actions button.open-note-btn {
    background: var(--purple);
    border-color: var(--purple);
    font-weight: bold;
}

.note-lock-icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-left: 6px;
}

.item-actions button.open-note-btn:hover {
    background: var(--purple-light);
    border-color: var(--purple-light);
    color: var(--white);
}

.empty-state {
    text-align: center;
    color: var(--gray);
    padding: 40px 20px;
    font-size: 13px;
}

/* Status Message */
.status-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    background: var(--purple);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: slideIn 0.3s ease;
    font-size: 13px;
    max-width: 300px;
}

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

.status-message.error {
    background: #ef4444;
}

.status-message.success {
    background: #10b981;
}

/* Loading Spinner */
.loading-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    gap: 20px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
}

.loading-spinner svg {
    width: 100%;
    height: 100%;
    stroke: var(--purple);
}

/* Detail View */
.detail-view {
    animation: fadeIn 0.3s ease;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--white);
    color: var(--white);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.back-btn:hover {
    background: var(--white);
    color: var(--black);
}

.detail-content {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
    margin-bottom: 20px;
}

.detail-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
    font-size: 14px;
    line-height: 1.6;
}

.detail-text a {
    color: var(--purple-light);
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.detail-text a:hover {
    color: var(--purple);
}

.detail-actions {
    display: flex;
    gap: 12px;
}

.detail-actions button {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-actions button:hover {
    background: var(--white);
    color: var(--black);
}

.detail-actions button.delete-btn:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: var(--white);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }

    .container {
        padding: 16px;
        padding-top: 60px;
    }

    .home-view {
        /* container padding is 16px on mobile, escape that */
        height: calc(100dvh - 60px - 12px);
        margin: 0 -16px -16px;
    }

    .home-grid {
        gap: 6px;
        width: 92%;
        margin-top: 16px;
    }

    .auth-box {
        padding: 30px 24px;
    }

    .upload-section,
    .items-section {
        padding: 20px;
    }

    .file-drop-zone {
        padding: 30px 16px;
    }
}

/* Games */
.game-menu-btn {
    width: 100%;
    padding: 16px;
    margin-bottom: 12px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.game-menu-btn:hover {
    background: var(--purple);
    border-color: var(--purple);
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    padding: 0 8px;
    box-sizing: border-box;
}

.game-canvas {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    background: var(--black);
    cursor: pointer;
    max-width: 100%;
    width: 100%;
    height: auto;
}

@media (max-width: 968px) {
    .game-container {
        padding: 0;
    }
}

.game-header {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
}

.game-score {
    font-size: 18px;
    font-weight: bold;
    color: var(--purple-light);
}

.game-controls {
    display: flex;
    gap: 8px;
}

.game-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-btn:hover {
    background: var(--purple);
    border-color: var(--purple);
}

.tictactoe-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 300px;
    margin: 20px auto;
}

.tictactoe-cell {
    width: 100%;
    aspect-ratio: 1;
    background: transparent;
    border: 2px solid var(--white);
    border-radius: var(--border-radius);
    color: var(--white);
    font-family: 'Vend Sans', sans-serif;
    font-size: 48px;
    cursor: pointer;
    transition: all 0.2s;
}

.tictactoe-cell:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--purple);
}

.tictactoe-cell:disabled {
    cursor: not-allowed;
}

.game-status {
    text-align: center;
    font-size: 18px;
    margin: 20px 0;
    color: var(--purple-light);
    font-weight: bold;
}

/* Easter Egg Floating Animation */
.easter-egg-float {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.easter-egg-float.hidden {
    opacity: 0;
    pointer-events: none;
}

.easter-egg-image {
    max-width: min(400px, 80vw);
    max-height: min(400px, 60vh);
    width: auto;
    height: auto;
    border-radius: var(--border-radius);
    border: 3px solid var(--purple);
    box-shadow: 0 0 40px var(--purple-glow), 0 10px 30px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    display: block;
}

.easter-egg-text {
    font-size: clamp(18px, 3vw, 28px);
    color: var(--white);
    text-align: center;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 0 20px var(--purple-glow), 0 0 10px rgba(138, 43, 226, 0.8),
                 2px 2px 8px rgba(0, 0, 0, 0.9);
    padding: 8px 16px;
    background: rgba(138, 43, 226, 0.2);
    backdrop-filter: blur(8px);
    border-radius: 8px;
    border: 1px solid rgba(138, 43, 226, 0.4);
    white-space: nowrap;
    max-width: 90vw;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

@keyframes floatGentle {
    0%, 100% {
        transform: translateY(0) translateX(0) rotate(var(--float-rotation));
    }
    25% {
        transform: translateY(-15px) translateX(8px) rotate(calc(var(--float-rotation) + 2deg));
    }
    50% {
        transform: translateY(-8px) translateX(-5px) rotate(var(--float-rotation));
    }
    75% {
        transform: translateY(-20px) translateX(10px) rotate(calc(var(--float-rotation) - 2deg));
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.7) rotate(var(--float-rotation));
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(var(--float-rotation));
    }
}

@keyframes fadeOutScale {
    from {
        opacity: 1;
        transform: scale(1) rotate(var(--float-rotation));
    }
    to {
        opacity: 0;
        transform: scale(0.85) rotate(var(--float-rotation));
    }
}

@media (max-width: 968px) {
    .easter-egg-image {
        max-width: 85vw;
        max-height: 50vh;
    }

    .easter-egg-text {
        font-size: clamp(16px, 4vw, 24px);
        padding: 6px 12px;
    }
}

/* ── Queue ───────────────────────────────────────────────────────────────── */

/* Override the two-column main-content grid — ID beats class, no !important needed */
#queueView {
    display: block;
}

.queue-panel {
    border: 1px solid var(--white);
    border-radius: var(--border-radius);
    padding: 24px;
}

.queue-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--purple);
    color: var(--white);
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
}

.queue-header {
    margin-bottom: 16px;
}

.queue-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.queue-header-row h2 {
    margin: 0;
}

.queue-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.queue-reload-btn {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.3s;
}

.queue-reload-btn:hover {
    opacity: 1;
}

.queue-reload-btn.spinning {
    animation: queue-spin 0.5s linear;
}

@keyframes queue-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

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

.small-btn-danger {
    border-color: #f87171;
    color: #f87171;
}
.small-btn-danger:hover {
    background: #f87171;
    color: var(--black);
}

.queue-clear-slide {
    position: relative;
    overflow: hidden;
}
#queueClearBtn {
    transition: transform 0.22s ease, opacity 0.22s ease;
}
#queueClearConfirmBtn {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}
.queue-clear-slide.show-confirm #queueClearBtn {
    transform: translateY(-100%);
    opacity: 0;
}
.queue-clear-slide.show-confirm #queueClearConfirmBtn {
    transform: translateY(0);
    opacity: 1;
}

.queue-unread-label {
    font-size: 12px;
    color: var(--gray);
}

#queuePlayerView {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.queue-player-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.queue-back-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 24px;
    cursor: pointer;
    padding: 10px 14px 10px 4px;
    margin: -10px -14px -10px -4px;
    opacity: 0.7;
    flex-shrink: 0;
    transition: opacity 0.15s;
    line-height: 1;
}

.queue-back-btn:hover { opacity: 1; }

.queue-now-playing-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.q-info-row1 {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q-info-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.q-info-author {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.q-info-row2 {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.q-info-date {
    opacity: 0.7;
}

.queue-vol-btn {
    padding: 4px 6px !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.queue-vol-icon {
    width: 18px;
    height: 18px;
    opacity: 0.75;
    display: block;
}

.queue-vol-btn.muted .queue-vol-icon {
    opacity: 0.3;
}

.queue-dl-btn {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.65);
    font-size: 18px;
    cursor: pointer;
    padding: 8px 4px 8px 10px;
    flex-shrink: 0;
    line-height: 1;
    transition: color 0.15s;
}
.queue-dl-btn.visible {
    display: block;
}
.queue-dl-btn:hover {
    color: #fff;
}

/* Carousel viewer */
.queue-carousel-wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    touch-action: pan-y;
}

.queue-carousel-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.queue-carousel-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.queue-carousel-video-play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.7);
    color: var(--white);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.queue-carousel-video-play:hover { background: rgba(168,85,247,0.7); }

.queue-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: var(--white);
    font-size: 28px;
    width: 36px;
    height: 52px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    transition: background 0.15s;
    border-radius: 4px;
}

.queue-carousel-nav:hover { background: rgba(0,0,0,0.75); }
.queue-carousel-prev { left: 0; }
.queue-carousel-next { right: 0; }

.queue-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 5px;
    padding: 8px 0 4px;
}

.carousel-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: background 0.2s;
}

.carousel-dot.active { background: var(--white); }

.queue-carousel-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 10px;
}

.queue-carousel-counter {
    font-size: 12px;
    color: var(--gray);
}

.queue-carousel-music-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    padding: 4px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.queue-carousel-music-btn.playing {
    border-color: var(--purple);
    color: var(--purple-light);
}

.queue-carousel-music-btn:hover {
    border-color: rgba(255,255,255,0.4);
    color: var(--white);
}

.queue-card-carousel-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0,0,0,0.7);
    border-radius: 4px;
    font-size: 10px;
    color: var(--white);
    padding: 2px 5px;
    z-index: 2;
}

.queue-player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #0a0a0a;
    z-index: 1;
}

.queue-player-loading.hidden { display: none; }

.queue-dl-status-text {
    font-size: 13px;
    color: var(--gray);
}

.queue-player-progress-track {
    width: 55%;
    height: 3px;
    background: #2a2a2a;
    border-radius: 2px;
}

.queue-player-progress-fill {
    height: 100%;
    background: var(--purple);
    border-radius: 2px;
    transition: width 0.3s;
    width: 0%;
}

#queuePlayerView .dl-player-wrap {
    display: flex;
    flex-direction: column;
    max-height: 65dvh;
    overflow: visible;
}

#qPlayerWrap:fullscreen,
#qPlayerWrap:-webkit-full-screen {
    display: block;
    max-height: none;
    width: 100%;
    height: 100%;
    position: relative;
}

#qPlayerWrap:fullscreen #qVideoArea,
#qPlayerWrap:-webkit-full-screen #qVideoArea {
    height: 100%;
    border-radius: 0;
}

.queue-video-area {
    position: relative;
    flex: 1;
    min-height: 160px;
    overflow: hidden;
    background: #000;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.queue-video-area video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

#queuePlayerView .dl-player-controls {
    flex-shrink: 0;
    transition: opacity 0.25s, transform 0.25s;
}

#queuePlayerView .dl-player-controls.ctrl-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}

#qPlayerWrap:fullscreen .dl-player-controls.ctrl-hidden,
#qPlayerWrap:-webkit-full-screen .dl-player-controls.ctrl-hidden {
    transform: translateY(100%);
    opacity: 0;
}

.queue-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.queue-play-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.queue-player-loading { z-index: 1; }

.queue-play-overlay-btn {
    width: 64px;
    height: 64px;
    background: rgba(139, 92, 246, 0.38);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    padding-left: 4px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s;
}

.queue-play-overlay:hover .queue-play-overlay-btn {
    transform: scale(1.1);
}

/* Keyboard / double-tap OSD indicators */
.q-osd {
    position: absolute;
    background: rgba(20, 20, 20, 0.46);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 10px 20px;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    white-space: nowrap;
}

.q-osd.visible { opacity: 1; }

.q-osd-seek {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15px;
    min-width: 90px;
    text-align: center;
}

.q-osd-vol {
    top: 16px;
    right: 16px;
    min-width: 70px;
    text-align: center;
}

.queue-vol-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.queue-vol-popup {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(18, 18, 18, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 8px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.queue-vol-popup.open {
    display: flex;
}

.queue-vol-slider {
    writing-mode: vertical-lr;
    direction: rtl;
    appearance: slider-vertical;
    -webkit-appearance: slider-vertical;
    width: 28px;
    height: 80px;
    cursor: pointer;
    accent-color: var(--purple);
}

.queue-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.queue-card {
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--border-radius);
    overflow: visible;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.queue-card:hover {
    background: rgba(255, 255, 255, 0.07);
}

.queue-card.now-playing {
    box-shadow: 0 0 0 2px var(--purple);
}

.queue-card {
    transition: background 0.2s, opacity 0.5s;
}

.queue-card.not-cached::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: var(--dl-progress, 0%);
    right: 0;
    background: rgba(0, 0, 0, 0.58);
    pointer-events: none;
    z-index: 1;
    transition: left 1.8s linear;
    border-radius: var(--border-radius);
}

.queue-card.watched .queue-card-thumb img {
    filter: grayscale(1);
}

.queue-card-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #111;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.queue-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: filter 0.2s;
}

.queue-thumb-placeholder {
    width: 100%;
    height: 100%;
    background: #1a1a1a;
}

.queue-card-pending,
.queue-card-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--gray);
    font-size: 20px;
}

.queue-card-refetch {
    font-size: 11px;
    padding: 3px 8px;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: var(--white);
    cursor: pointer;
}

.queue-card-refetch:hover { background: rgba(255,255,255,0.14); }

.queue-card-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0);
    transition: background 0.2s;
}

.queue-card:hover .queue-card-overlay {
    background: rgba(0, 0, 0, 0.45);
}

.queue-play-icon {
    color: var(--white);
    font-size: 28px;
    opacity: 0;
    transition: opacity 0.2s;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
}

.queue-card:hover .queue-play-icon {
    opacity: 1;
}

.queue-now-label {
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    background: var(--purple);
    padding: 3px 8px;
    border-radius: 4px;
}

.queue-unread-exclaim {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--purple);
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 0 0 2px #fff;
    z-index: 5;
}

.queue-card-delete {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    color: var(--white);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0;
    z-index: 2;
}

    .queue-card-delete span {
          transform: translateY(-1px);
    }

@media (hover: none) {
    .queue-card-delete { opacity: 0.7; }
}

.queue-card:hover .queue-card-delete {
    opacity: 1;
}

.queue-card-delete:hover {
    background: rgba(239, 68, 68, 0.85);
}

.queue-card-watch-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background: rgba(0, 0, 0, 0.75);
    border: none;
    color: var(--white);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 0;
    z-index: 2;
}

@media (hover: none) {
    .queue-card-watch-btn { opacity: 0.7; }
}

.queue-card:hover .queue-card-watch-btn {
    opacity: 1;
}

.queue-card-watch-btn:hover {
    background: rgba(168, 85, 247, 0.85);
}

.queue-card-info {
    padding: 8px 10px 10px;
}

.queue-card-title-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-bottom: 4px;
}

.queue-card-addedat {
    margin-left: auto;
    flex-shrink: 0;
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    white-space: nowrap;
}

.queue-card-icon {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-top: 2px;
    object-fit: contain;
}

.queue-card-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.queue-card-meta {
    font-size: 11px;
    color: var(--gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
