/* =========================================================
   CYBER TETRIS: PICTURE MATRIX - Cyberpunk Stylesheet
   ========================================================= */

:root {
    --bg-dark: #070913;
    --bg-panel: rgba(13, 18, 36, 0.75);
    --bg-card: rgba(18, 26, 51, 0.65);
    --glass-border: rgba(0, 245, 255, 0.22);
    --glass-border-focus: rgba(0, 245, 255, 0.85);
    
    --accent-cyan: #00f5ff;
    --accent-purple: #a855f7;
    --accent-pink: #ec4899;
    --accent-amber: #f59e0b;
    --accent-green: #10b981;
    --accent-red: #ef4444;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --glow-cyan: 0 0 15px rgba(0, 245, 255, 0.45);
    --glow-purple: 0 0 15px rgba(168, 85, 247, 0.45);
    --glow-amber: 0 0 15px rgba(245, 158, 11, 0.45);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(168, 85, 247, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 245, 255, 0.12) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 30px 30px, 30px 30px;
    display: flex;
    flex-direction: column;
}

/* Header Navigation (Matching Canvas Clash Standard) */
.game-header {
    position: sticky;
    top: 0;
    padding: 0.85rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(10, 14, 26, 0.88);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 100;
    gap: 1rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: #fff;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
}

.header-logo-img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 8px;
    filter: drop-shadow(0 0 10px rgba(0, 210, 255, 0.65));
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
}

.brand-logo:hover .header-logo-img {
    transform: scale(1.12) rotate(-3deg);
    filter: drop-shadow(0 0 16px rgba(236, 72, 153, 0.85));
}

.brand-logo .clash-text {
    background: linear-gradient(135deg, #00d2ff, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-center-auth {
    flex: 1;
    display: flex;
    justify-content: center;
    max-width: 650px;
}

.btn-chip-auth {
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: var(--radius-full);
    padding: 0.4rem 1.1rem;
    color: #cbd5e1;
    font-size: 0.82rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.btn-chip-auth:hover {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.3);
}

.user-hero-chip {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: var(--radius-full);
    padding: 0.4rem 1.1rem;
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.hero-score-badge {
    background: rgba(0, 210, 255, 0.2);
    border: 1px solid var(--accent-cyan);
    border-radius: var(--radius-full);
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-nav {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.84rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.btn-nav:hover {
    background: rgba(0, 245, 255, 0.15);
    border-color: var(--accent-cyan);
    color: #fff;
}

.btn-auth-pill {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.2), rgba(168, 85, 247, 0.2));
    border-color: var(--accent-cyan);
    font-weight: 600;
}

/* Mobile View Tabs */
.mobile-view-tabs {
    display: none;
    padding: 0.5rem 1rem;
    background: rgba(10, 14, 26, 0.95);
    border-bottom: 1px solid var(--glass-border);
    gap: 0.5rem;
}

.mobile-tab-btn {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.mobile-tab-btn.active {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--accent-cyan);
    color: #fff;
    box-shadow: 0 0 10px rgba(0, 245, 255, 0.25);
}

/* 3-Column Layout */
.tetris-main-container {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(380px, 1.25fr) minmax(440px, 1.4fr) minmax(320px, 1fr);
    gap: 1.25rem;
    padding: 1.25rem 1.5rem;
    max-width: 1750px;
    margin: 0 auto;
    width: 100%;
}

@media (max-width: 1400px) {
    .tetris-main-container {
        grid-template-columns: minmax(350px, 1.2fr) minmax(400px, 1.3fr) minmax(280px, 1fr);
    }
}

@media (max-width: 1200px) {
    .tetris-main-container {
        grid-template-columns: 1fr 1fr;
    }
    .tetris-hall-col {
        grid-column: 1 / -1;
    }
}

@media (max-width: 900px) {
    .tetris-main-container {
        grid-template-columns: 1fr;
    }
}

/* Column 1: Collections */
.tetris-collection-col {
    display: flex;
    flex-direction: column;
    min-height: 640px;
    height: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    overflow: hidden;
}

.gallery-col-header {
    padding: 0.85rem 1.1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #fff;
}

.gallery-search-box {
    flex: 1;
    min-width: 160px;
}

.gallery-search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 9999px;
    padding: 0.5rem 0.9rem;
    color: #fff;
    font-size: 0.84rem;
    outline: none;
    transition: all 0.25s ease;
}

.gallery-search-input:focus {
    border-color: var(--accent-cyan);
    background: rgba(0, 245, 255, 0.08);
    box-shadow: 0 0 14px rgba(0, 245, 255, 0.3);
}

.upload-zone {
    margin: 0.65rem 1rem;
    border: 2px dashed rgba(0, 245, 255, 0.4);
    border-radius: var(--radius-md);
    background: rgba(0, 245, 255, 0.04);
    padding: 0.65rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--accent-cyan);
    transition: all 0.25s ease;
}

.upload-zone:hover {
    background: rgba(0, 245, 255, 0.12);
    border-color: var(--accent-cyan);
    transform: translateY(-1px);
}

.upload-zone .upload-icon {
    font-size: 1.25rem;
}

/* Custom Image URL Zone */
.custom-url-zone {
    margin: 8px 1rem 12px 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.custom-url-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}
.custom-url-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.85rem;
    font-family: inherit;
    outline: none;
    transition: all 0.25s ease;
    box-sizing: border-box;
}
.custom-url-input:focus {
    background: rgba(15, 23, 42, 0.95);
    border-color: var(--accent-cyan);
    box-shadow: var(--glow-cyan);
}
.custom-url-input::placeholder {
    color: var(--text-dim);
    font-size: 0.82rem;
}
.btn-load-url {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1rem;
    background: linear-gradient(135deg, #00f5ff 0%, #3b82f6 50%, #a855f7 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 245, 255, 0.35);
    transition: all 0.25s ease;
    flex-shrink: 0;
    height: 38px;
    box-sizing: border-box;
}
.btn-load-url:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 245, 255, 0.6);
    filter: brightness(1.1);
}
.btn-load-url:active {
    transform: translateY(1px);
}
.custom-url-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding-left: 2px;
    line-height: 1.3;
}

.tree-gallery-container {
    flex: 1;
    display: grid;
    grid-template-columns: 210px 1fr;
    overflow: hidden;
    border-top: 1px solid var(--glass-border);
    min-height: 520px;
}

@media (max-width: 700px) {
    .tree-gallery-container {
        grid-template-columns: 1fr;
    }
}

.gallery-tree-sidebar {
    background: rgba(10, 15, 28, 0.6);
    border-right: 1px solid var(--glass-border);
    overflow-y: auto;
    padding: 0.6rem 0.45rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.tree-section-header {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-dim);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.35rem 0.55rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 0.25rem;
}

.tree-categories-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.tree-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    user-select: none;
    margin-bottom: 1px;
}

.tree-node:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    transform: translateX(2px);
}

.tree-node.active {
    background: linear-gradient(135deg, rgba(0, 245, 255, 0.22) 0%, rgba(168, 85, 247, 0.22) 100%);
    border-color: rgba(0, 245, 255, 0.5);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 10px rgba(0, 245, 255, 0.2);
}

.tree-node.user-node {
    background: rgba(234, 179, 8, 0.12);
    border-color: rgba(234, 179, 8, 0.3);
    color: #fef08a;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.tree-node.user-node:hover {
    background: rgba(234, 179, 8, 0.22);
    color: #fff;
}

.tree-node.user-node.active {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.35) 0%, rgba(249, 115, 22, 0.3) 100%);
    border-color: #eab308;
    color: #fff;
}

.tree-node.most-jigged-node {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.35);
    color: #fed7aa;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.tree-node.most-jigged-node:hover {
    background: rgba(249, 115, 22, 0.24);
    border-color: rgba(249, 115, 22, 0.6);
    color: #fff;
}

.tree-node.most-jigged-node.active {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.35) 0%, rgba(249, 115, 22, 0.35) 100%);
    border-color: #f97316;
    color: #fff;
    box-shadow: 0 0 14px rgba(249, 115, 22, 0.35);
}

.tree-node.community-node {
    background: rgba(6, 182, 212, 0.12);
    border-color: rgba(6, 182, 212, 0.35);
    color: #a5f3fc;
    font-weight: 600;
    margin-bottom: 0.45rem;
}

.tree-node.community-node:hover {
    background: rgba(6, 182, 212, 0.24);
    border-color: rgba(6, 182, 212, 0.6);
    color: #fff;
}

.tree-node.community-node.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.35) 0%, rgba(6, 182, 212, 0.35) 100%);
    border-color: #06b6d4;
    color: #fff;
    box-shadow: 0 0 14px rgba(6, 182, 212, 0.35);
}

.tree-node-left {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-icon {
    font-size: 1.05rem;
    line-height: 1;
    flex-shrink: 0;
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-count-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.12rem 0.42rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    flex-shrink: 0;
}

.tree-node.active .tree-count-badge {
    background: var(--accent-cyan);
    color: #000;
}

/* Gallery Pictures Area */
.gallery-grid-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
    overflow: hidden;
    min-width: 0;
}

.gallery-active-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.85rem;
    background: rgba(15, 23, 42, 0.5);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.active-category-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.active-category-icon {
    font-size: 1.15rem;
}

.active-category-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #fff;
}

.active-category-badge {
    font-size: 0.74rem;
    color: var(--accent-cyan);
    font-weight: 700;
    background: rgba(0, 245, 255, 0.12);
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
    gap: 0.65rem;
    overflow-y: auto;
    padding-right: 0.3rem;
    flex: 1;
}

.preset-grid::-webkit-scrollbar {
    width: 6px;
}

.preset-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 245, 255, 0.25);
    border-radius: 3px;
}

.preset-card {
    position: relative;
    height: 110px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    background: #090d16;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.preset-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.preset-card:hover img {
    transform: scale(1.08);
}

.preset-card:hover, .preset-card.active, .preset-card.selected {
    border-color: var(--accent-cyan);
    transform: translateY(-2px);
    box-shadow: 0 0 16px rgba(0, 245, 255, 0.5);
}

.preset-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.15) 60%, transparent 100%);
    padding: 0.4rem 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
}

.preset-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.preset-tag {
    font-size: 0.62rem;
    color: var(--accent-cyan);
    font-weight: 600;
}

.puzzle-daily-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(249, 115, 22, 0.6);
    color: #fed7aa;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 0.12rem 0.38rem;
    border-radius: 9999px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}


/* Column 2: Center Arena */
.tetris-arena-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
}

.setup-card {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

.setup-hero-banner {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.setup-hero-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-overlay-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.25rem;
    background: linear-gradient(transparent, rgba(7, 9, 19, 0.95) 80%);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.daily-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    padding: 0.2rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    width: fit-content;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.hero-puzzle-title {
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}

.hero-puzzle-cat {
    font-size: 0.82rem;
    color: var(--accent-cyan);
}

/* Difficulty Control Box */
.difficulty-control-box {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.diff-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.diff-title {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.diff-active-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-cyan);
}

.diff-slider {
    width: 100%;
    accent-color: var(--accent-cyan);
    cursor: pointer;
}

.diff-ticks-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.diff-tick.active {
    color: var(--accent-cyan);
    font-weight: 700;
}

/* Options */
.options-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.option-toggle {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s ease;
}

.option-toggle input {
    accent-color: var(--accent-cyan);
}

.option-toggle.active {
    border-color: var(--accent-cyan);
    background: rgba(0, 245, 255, 0.1);
}

/* Start & Resume Buttons */
.btn-start-tetris {
    background: linear-gradient(135deg, #00f5ff 0%, #a855f7 50%, #ec4899 100%);
    border: none;
    border-radius: var(--radius-md);
    color: #fff;
    padding: 0.95rem;
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    box-shadow: 0 0 25px rgba(0, 245, 255, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.btn-start-tetris:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 35px rgba(236, 72, 153, 0.6);
}

.tetris-resume-banner {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.resume-banner-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.resume-texts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.resume-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #fff;
}

.resume-meta {
    font-size: 0.76rem;
    color: #a7f3d0;
}

.resume-banner-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-resume-cta {
    background: #10b981;
    color: #000;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
}

.btn-discard-cta {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #ef4444;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
}

/* ==========================================================================
   2. GAMEPLAY SCREEN (DEDICATED FULL VIEWPORT ARENA)
   ========================================================================== */
.gameplay-screen {
    width: 100%;
    min-height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.5rem 1.5rem;
    position: relative;
    z-index: 10;
    box-sizing: border-box;
    gap: 0.85rem;
}

/* Top Navigation HUD */
.game-hud {
    width: 100%;
    max-width: 1100px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1.25rem;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    gap: 0.85rem;
    flex-wrap: nowrap;
    z-index: 50;
}

.hud-left-group, .hud-right-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.btn-back-menu {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    font-weight: 700;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.btn-back-menu:hover {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--accent-cyan);
    color: #fff;
    transform: translateX(-2px);
    box-shadow: 0 0 12px rgba(0, 245, 255, 0.35);
}

.glass-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
    padding: 0.35rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

.stat-item i {
    font-style: normal;
    color: var(--accent-cyan);
}

.stat-lbl-sub {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
    margin-left: 2px;
}

/* Top Center Picture Preview */
.hud-picture-preview-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--glass-border);
    padding: 0.25rem 0.55rem;
    border-radius: var(--radius-full);
}

.hud-pic-thumb-box {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    border: 1px solid var(--accent-cyan);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(0, 245, 255, 0.35);
}

.hud-pic-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hud-pic-reveal-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    font-size: 0.55rem;
    font-weight: 800;
    text-align: center;
    color: var(--accent-cyan);
}

.hud-pic-controls {
    display: flex;
    align-items: center;
    gap: 2px;
}

.btn-pic-zoom {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    color: #fff;
    font-size: 0.68rem;
    padding: 2px 5px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-pic-zoom:hover {
    background: var(--accent-cyan);
    color: #000;
}

.btn-tool {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 0.45rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    user-select: none;
}

.btn-tool:hover {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--accent-cyan);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 0 14px rgba(0, 245, 255, 0.4);
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background: rgba(0, 245, 255, 0.25);
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 245, 255, 0.4);
    transform: translateY(-1px);
}

/* Centered Viewport Wrapper */
.tetris-viewport-wrapper {
    flex: 1;
    width: 100%;
    max-width: 1100px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    min-height: 0;
}

/* Floating Bottom Control Bar */
.game-bottombar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 0.45rem 1.25rem;
    border-radius: var(--radius-full);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
    z-index: 50;
    flex-wrap: wrap;
}

/* Playfield & Controls Layout */
.tetris-arena-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1rem 0;
}

.tetris-side-hud {
    width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.cyber-box {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
}

.cyber-box-title {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--accent-cyan);
    letter-spacing: 0.05em;
}

.speed-bar-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
}

.speed-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00f5ff, #ec4899);
    transition: width 0.3s ease;
}

.speed-next-notice {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-align: center;
}

.key-hint-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Tetris Canvas Wrapper */
.tetris-canvas-wrapper {
    position: relative;
    background: #111420;
    border: 2px solid var(--accent-cyan);
    border-radius: var(--radius-md);
    box-shadow: 0 0 30px rgba(0, 245, 255, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

#tetris-board-canvas {
    display: block;
    background: #1c2132; /* Gray base matrix background */
}

.laser-clear-flash {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0;
    background: rgba(0, 245, 255, 0.4);
    transition: opacity 0.15s ease;
}

/* Touch Controls Sidebar */
.tetris-controls-sidebar {
    width: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.control-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.btn-touch-action {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: #fff;
    padding: 0.85rem 0.5rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    user-select: none;
    transition: all 0.1s ease;
}

.btn-touch-action:active, .btn-touch-action.touch-pressed {
    background: rgba(0, 245, 255, 0.35);
    border-color: var(--accent-cyan);
    transform: scale(0.95);
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.5);
}

.touch-btn-icon {
    font-size: 1.4rem;
}

.touch-btn-lbl {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-muted);
}

.touch-row-horiz {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.btn-touch-rotate {
    background: rgba(168, 85, 247, 0.18);
    border-color: rgba(168, 85, 247, 0.4);
}

.btn-touch-rotate:active {
    background: rgba(168, 85, 247, 0.45);
}

.btn-touch-down {
    background: rgba(236, 72, 153, 0.18);
    border-color: rgba(236, 72, 153, 0.4);
}

.btn-touch-down:active {
    background: rgba(236, 72, 153, 0.45);
}

/* Column 3: Leaderboard */
.tetris-leaderboard-col {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 105px);
    overflow: hidden;
}

.panel-header {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.leaderboard-filters-row {
    display: flex;
    gap: 0.35rem;
    padding: 0.5rem 0.85rem;
    border-bottom: 1px solid var(--glass-border);
    overflow-x: auto;
}

.lb-pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
}

.lb-pill.active {
    background: rgba(0, 245, 255, 0.2);
    border-color: var(--accent-cyan);
    color: #fff;
    font-weight: 700;
}

.user-best-box {
    margin: 0.5rem 0.85rem;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-md);
    padding: 0.6rem;
}

.user-best-title {
    font-size: 0.75rem;
    font-weight: 800;
    color: #fbbf24;
    margin-bottom: 0.3rem;
}

.user-best-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    font-size: 0.72rem;
    color: #cbd5e1;
}

.leaderboard-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.lb-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.lb-item-rank {
    font-weight: 900;
    width: 22px;
    color: var(--text-dim);
}

.lb-item.top-1 .lb-item-rank { color: #fbbf24; }
.lb-item.top-2 .lb-item-rank { color: #cbd5e1; }
.lb-item.top-3 .lb-item-rank { color: #d97706; }

.lb-item-player {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
}

.lb-item-name {
    font-weight: 700;
    color: #fff;
}

.lb-item-meta {
    font-size: 0.68rem;
    color: var(--text-dim);
}

.lb-item-val {
    font-weight: 800;
    color: var(--accent-cyan);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Modals Backdrops */
.modal-backdrop, .victory-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-backdrop.show, .victory-modal-backdrop.show {
    display: flex;
}

.glass-modal {
    background: rgba(15, 20, 38, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9), 0 0 25px rgba(0, 245, 255, 0.2);
    width: 100%;
    max-width: 580px;
    overflow: hidden;
}

.modal-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: #fff;
}

/* Pause Modal */
.pause-modal-card {
    text-align: center;
    padding: 1.75rem 1.5rem;
    max-width: 520px;
}

.pause-icon-badge {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.pause-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.35rem;
}

.pause-subtitle {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.pause-meta-chips {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
}

.pause-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 700;
}

.pause-modal-actions-3col {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.btn-cta {
    background: linear-gradient(135deg, #00f5ff, #a855f7);
    border: none;
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #f87171;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* Keybinds Modal */
.keybinds-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.keybind-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.6rem 0.85rem;
}

.keybind-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.86rem;
    font-weight: 600;
}

.btn-key-slot {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--accent-cyan);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.82rem;
    cursor: pointer;
    min-width: 100px;
    text-align: center;
}

.btn-key-slot.recording {
    background: rgba(236, 72, 153, 0.3);
    border-color: var(--accent-pink);
    color: #fff;
    animation: pulseKey 0.8s infinite alternate;
}

@keyframes pulseKey {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

/* Ad Mockup */
.ad-modal-card {
    max-width: 480px;
    padding: 1.5rem;
    text-align: center;
}

.ad-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.ad-badge {
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid #f59e0b;
    color: #fbbf24;
    font-size: 0.68rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 4px;
}

.ad-timer-countdown {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
}

.ad-video-mockup {
    background: #000;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    margin-bottom: 1.25rem;
}

.ad-mock-icon {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
}

.ad-mock-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.35rem;
}

.ad-mock-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.ad-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.ad-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--accent-cyan);
    transition: width 1s linear;
}

.ad-modal-footer {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ad-vip-prompt {
    font-size: 0.78rem;
    color: #cbd5e1;
}

.btn-skip-ad {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 0.65rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
}

.btn-skip-ad:not(:disabled) {
    background: var(--accent-green);
    color: #000;
    border-color: var(--accent-green);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* Victory / Game Over */
.victory-card {
    background: rgba(15, 20, 38, 0.96);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 480px;
    width: 100%;
    text-align: center;
    box-shadow: 0 0 40px rgba(0, 245, 255, 0.3);
}

.victory-trophy {
    font-size: 3.5rem;
    margin-bottom: 0.5rem;
}

.victory-title {
    font-size: 1.5rem;
    font-weight: 900;
    color: #fff;
    margin-bottom: 0.35rem;
}

.victory-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin: 1.5rem 0;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.5rem;
}

.v-stat-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

.v-stat-lbl {
    font-size: 0.62rem;
    font-weight: 800;
    color: var(--text-dim);
}

.victory-actions {
    display: flex;
    gap: 0.75rem;
}

.btn-v-action {
    flex: 1;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-v-replay {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: #fff;
}

.btn-v-hall {
    background: linear-gradient(135deg, #00f5ff, #a855f7);
    border: none;
    color: #fff;
    box-shadow: 0 0 15px rgba(0, 245, 255, 0.35);
}

/* Zoom Modal */
.zoom-modal-card {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.zoom-modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.zoom-modal-body img {
    max-width: 100%;
    max-height: 78vh;
    object-fit: contain;
    border-radius: 8px;
}

/* Ambient Particles */
#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
}

/* Responsive Media Queries */
@media (max-width: 1200px) {
    .tetris-main-container {
        grid-template-columns: 320px 1fr 300px;
        gap: 1rem;
        padding: 1rem;
    }
}

@media (max-width: 992px) {
    .mobile-view-tabs {
        display: flex;
    }

    .tetris-main-container {
        display: block;
        padding: 0.85rem;
    }

    .tetris-collection-col, .tetris-arena-col, .tetris-leaderboard-col {
        display: none;
        height: auto;
    }

    .tetris-collection-col.mobile-active,
    .tetris-arena-col.mobile-active,
    .tetris-leaderboard-col.mobile-active {
        display: flex;
    }

    .tetris-arena-layout {
        flex-direction: column;
        align-items: center;
    }

    .tetris-side-hud {
        flex-direction: row;
        width: 100%;
        max-width: 320px;
        justify-content: space-between;
    }

    .desktop-only {
        display: none;
    }

    .tetris-controls-sidebar {
        width: 100%;
        max-width: 320px;
    }

    .control-btn-group {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .btn-touch-action {
        flex: 1;
        padding: 0.75rem 0.35rem;
    }

    .touch-row-horiz {
        display: contents;
    }
}
