/* ==========================================================================
   LEGO Clicker - Style sheet (Premium CSS Design System)
   ========================================================================== */

/* Design Tokens & CSS Variables */
:root {
    --bg-main: #0b0d16;
    --bg-card: rgba(22, 28, 45, 0.6);
    --bg-header: rgba(13, 17, 28, 0.85);
    --border-glow: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* LEGO Colors */
    --lego-red: #e3000b;
    --lego-red-shaded: #b90008;
    --lego-red-dark: #8c0005;
    --lego-yellow: #ffcf00;
    --lego-yellow-dark: #d9b000;
    --lego-blue: #0055a5;
    --lego-green: #00aa47;
    --lego-orange: #f58220;
    
    /* Neon Accents */
    --accent: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.4);
    --accent-success: #10b981;
    --accent-success-glow: rgba(16, 185, 129, 0.3);

    /* Fonts */
    --font-headings: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

button,
.lego-clicker-button,
.upgrade-card,
.achievement-card,
.tab-btn,
.lb-sort-btn,
.lb-page-btn {
    touch-action: manipulation;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    line-height: 1.5;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* App Layout Grid */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header Styles */
.game-header {
    height: 70px;
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo-icon {
    filter: drop-shadow(0 0 8px rgba(227, 0, 11, 0.5));
    animation: rotateLogo 8s linear infinite alternate;
}

@keyframes rotateLogo {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(10deg); }
}

.logo-container h1 {
    font-family: var(--font-headings);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-container h1 span {
    color: var(--lego-yellow);
    text-shadow: 0 0 10px rgba(255, 207, 0, 0.3);
}

.quick-stats {
    display: flex;
    gap: 1.5rem;
}

.stat-badge {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glow);
    padding: 0.4rem 1rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-badge .label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.stat-badge .value {
    font-family: var(--font-headings);
    font-weight: 700;
    font-size: 1.05rem;
}

.text-accent {
    color: var(--lego-yellow) !important;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Button UI Components */
.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glow);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.2);
}

.icon-btn.muted svg {
    opacity: 0.4;
}

.primary-btn-sm {
    background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: var(--transition-fast);
}

.primary-btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.6);
}

.secondary-btn-sm {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-glow);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.secondary-btn-sm:hover {
    background: rgba(227, 0, 11, 0.15);
    border-color: rgba(227, 0, 11, 0.3);
    color: #ff8a8a;
    transform: translateY(-2px);
}

/* Main Content Workspace */
.game-main {
    flex: 1;
    display: grid;
    grid-template-columns: 360px 1fr 380px;
    height: calc(100vh - 70px);
    overflow: hidden;
}

.game-column {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-glow);
    height: 100%;
    overflow: hidden;
}

.game-column:last-child {
    border-right: none;
}

.column-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glow);
    background: rgba(255, 255, 255, 0.01);
}

.column-header h2 {
    font-family: var(--font-headings);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* LEFT COLUMN - CLICKER ZONE */
.click-column {
    background: linear-gradient(180deg, rgba(22, 28, 45, 0.3) 0%, rgba(13, 17, 28, 0.5) 100%);
    justify-content: flex-start;
    overflow-y: auto;
}

.click-column > * {
    flex-shrink: 0;
}

.clicker-stats {
    padding: 1rem 1.5rem 0.5rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.brick-count-wrapper {
    display: flex;
    flex-direction: column;
}

.brick-count {
    font-family: var(--font-headings);
    font-weight: 900;
    font-size: 2.8rem;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -1px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.brick-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
}

.bps-display {
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.bps-label {
    color: var(--text-muted);
}

.bps-value {
    color: var(--accent-success);
    font-weight: 700;
    font-family: var(--font-headings);
}

/* The Big Interactive LEGO Brick */
.interactive-brick-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 1rem 0;
}

.interactive-brick-glow {
    position: absolute;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(227, 0, 11, 0.2) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: 1;
    pointer-events: none;
    animation: pulsateGlow 4s ease-in-out infinite alternate;
}

@keyframes pulsateGlow {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.15); opacity: 1; }
}

.lego-clicker-button {
    background: none;
    border: none;
    outline: none;
    cursor: pointer;
    perspective: 1000px;
    z-index: 5;
    position: relative;
    padding: 0;
    transition: transform 0.1s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

#three-canvas-container {
    width: 260px;
    height: 260px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 5;
}

#three-canvas-container canvas {
    display: block;
    outline: none;
    pointer-events: none; /* Propagate click events to button */
}

.fallback-css-brick.hidden {
    display: none !important;
}

.lego-clicker-button:hover .lego-brick-3d {
    transform: rotateX(-25deg) rotateY(-40deg) scale(1.05);
    filter: brightness(1.1) drop-shadow(0 15px 25px rgba(227, 0, 11, 0.3));
}

.lego-clicker-button:active .lego-brick-3d {
    transform: rotateX(-35deg) rotateY(-50deg) scale(0.92) translateY(8px);
    filter: brightness(0.9) drop-shadow(0 5px 8px rgba(0,0,0,0.4));
}

/* 3D LEGO BRICK CSS */
.lego-brick-3d {
    position: relative;
    width: 160px;
    height: 60px;
    transform-style: preserve-3d;
    transform: rotateX(-30deg) rotateY(-45deg);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.2s ease;
    filter: drop-shadow(0 10px 18px rgba(0,0,0,0.5));
}

.lego-brick-3d .face {
    position: absolute;
    transform-style: preserve-3d;
}

.lego-brick-3d .top {
    width: 160px;
    height: 80px;
    transform: rotateX(90deg) translateZ(40px);
    background: var(--lego-red);
    box-shadow: inset 0 0 12px rgba(255,255,255,0.25);
}

.lego-brick-3d .front {
    width: 160px;
    height: 60px;
    transform: translateZ(40px);
    background: var(--lego-red-shaded);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
}

.lego-brick-3d .right-side {
    width: 80px;
    height: 60px;
    transform: rotateY(90deg) translateZ(120px); /* 160/2 + 80/2 = 120px translation to align with edge */
    background: var(--lego-red-dark);
    box-shadow: inset 0 0 10px rgba(0,0,0,0.4);
}

/* Studs on LEGO Brick */
.lego-brick-3d .stud {
    position: absolute;
    width: 24px;
    height: 24px;
    background: var(--lego-red);
    border-radius: 50%;
    transform: translateZ(5px);
    transform-style: preserve-3d;
    box-shadow: 
        inset 1px 1px 2px rgba(255, 255, 255, 0.5), 
        2px 2px 4px rgba(0, 0, 0, 0.3),
        inset -1px -1px 2px rgba(0, 0, 0, 0.3);
}

/* Position 8 studs in 2x4 grid */
.lego-brick-3d .stud:nth-child(1) { top: 12px; left: 16px; }
.lego-brick-3d .stud:nth-child(2) { top: 12px; left: 52px; }
.lego-brick-3d .stud:nth-child(3) { top: 12px; left: 88px; }
.lego-brick-3d .stud:nth-child(4) { top: 12px; left: 124px; }
.lego-brick-3d .stud:nth-child(5) { top: 44px; left: 16px; }
.lego-brick-3d .stud:nth-child(6) { top: 44px; left: 52px; }
.lego-brick-3d .stud:nth-child(7) { top: 44px; left: 88px; }
.lego-brick-3d .stud:nth-child(8) { top: 44px; left: 124px; }

.click-instruction {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

/* Stats panel at bottom left */
.stats-panel {
    margin: 0.5rem 1.5rem 1.5rem 1.5rem;
    padding: 1.05rem 1.25rem;
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glow);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.stats-panel h3 {
    font-family: var(--font-headings);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 0.5rem;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.stat-name {
    color: var(--text-secondary);
}

.stat-val {
    font-weight: 600;
    color: var(--text-primary);
}

/* CENTER COLUMN - LEGO TOWER */
.tower-column {
    flex: 1;
}

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

.altitude-hud {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
    font-family: var(--font-headings);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.1);
}

.tower-viewport-container {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    background: #000;
}

/* Left Vertical Progress Meter */
.progress-vertical-bar {
    width: 44px;
    background: rgba(0, 0, 0, 0.4);
    border-right: 1px solid var(--border-glow);
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    z-index: 10;
}

.progress-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, var(--lego-yellow) 0%, var(--lego-red) 100%);
    box-shadow: 0 0 15px rgba(227, 0, 11, 0.4);
    transition: height 0.5s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.progress-milestones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.milestone-marker {
    position: absolute;
    width: 100%;
    border-top: 1px dashed rgba(255, 255, 255, 0.2);
    padding-left: 4px;
    transform: translateY(-50%);
}

.milestone-marker.completed {
    border-top-color: var(--lego-yellow);
}

.milestone-marker span {
    font-size: 0.6rem;
    color: var(--text-secondary);
    display: block;
    background: rgba(11, 13, 22, 0.8);
    padding: 1px 2px;
    border-radius: 3px;
    width: fit-content;
}

.milestone-marker.completed span {
    color: var(--lego-yellow);
}

/* Tower Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    height: 100%;
}

#tower-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#tower-canvas:active {
    cursor: grabbing;
}

.viewport-hud {
    position: absolute;
    pointer-events: none;
    z-index: 8;
}

.top-hud {
    top: 15px;
    left: 20px;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glow);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
}

.top-hud span {
    font-family: var(--font-headings);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drag-tip {
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.6);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    opacity: 0.6;
    animation: fadePulse 2s ease-in-out infinite;
}

@keyframes fadePulse {
    0% { opacity: 0.3; }
    50% { opacity: 0.7; }
    100% { opacity: 0.3; }
}

.snap-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 9;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.3);
    transition: var(--transition-fast);
}

.snap-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.snap-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

/* RIGHT COLUMN - SHOP & UPGRADES */
.shop-column {
    background: linear-gradient(180deg, rgba(13, 17, 28, 0.5) 0%, rgba(22, 28, 45, 0.3) 100%);
}

.tabs-header {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-secondary);
    padding: 0.5rem;
    font-family: var(--font-headings);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-fast);
    position: relative;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-glow);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    right: 20%;
    height: 2px;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    border-radius: 2px;
}

.shop-content-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.shop-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1.25rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateX(10px);
}

.shop-panel.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Upgrade Card Styles */
.upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.upgrade-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-normal);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.upgrade-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.08);
}

.upgrade-card.affordable:hover {
    border-color: rgba(59, 130, 246, 0.3);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.upgrade-card.locked {
    filter: opacity(0.4) grayscale(1);
    cursor: not-allowed;
    pointer-events: none;
}

/* Upgrade Icon Styles */
.upgrade-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.upgrade-icon-wrapper svg {
    width: 26px;
    height: 26px;
}

/* Colors for specific upgrade icons based on index */
.upgrade-card[data-index="0"] .upgrade-icon-wrapper { background: rgba(239, 68, 68, 0.15); border-color: rgba(239, 68, 68, 0.3); color: #ef4444; }
.upgrade-card[data-index="1"] .upgrade-icon-wrapper { background: rgba(245, 130, 32, 0.15); border-color: rgba(245, 130, 32, 0.3); color: #f58220; }
.upgrade-card[data-index="2"] .upgrade-icon-wrapper { background: rgba(254, 240, 138, 0.15); border-color: rgba(254, 240, 138, 0.3); color: #fef08a; }
.upgrade-card[data-index="3"] .upgrade-icon-wrapper { background: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: #10b981; }
.upgrade-card[data-index="4"] .upgrade-icon-wrapper { background: rgba(6, 182, 212, 0.15); border-color: rgba(6, 182, 212, 0.3); color: #06b6d4; }
.upgrade-card[data-index="5"] .upgrade-icon-wrapper { background: rgba(59, 130, 246, 0.15); border-color: rgba(59, 130, 246, 0.3); color: #3b82f6; }
.upgrade-card[data-index="6"] .upgrade-icon-wrapper { background: rgba(139, 92, 246, 0.15); border-color: rgba(139, 92, 246, 0.3); color: #8b5cf6; }
.upgrade-card[data-index="7"] .upgrade-icon-wrapper { background: rgba(236, 72, 153, 0.15); border-color: rgba(236, 72, 153, 0.3); color: #ec4899; }
.upgrade-card[data-index="8"] .upgrade-icon-wrapper { background: rgba(244, 63, 94, 0.15); border-color: rgba(244, 63, 94, 0.3); color: #f43f5e; }
.upgrade-card[data-index="9"] .upgrade-icon-wrapper { background: rgba(14, 165, 233, 0.15); border-color: rgba(14, 165, 233, 0.3); color: #0ea5e9; }

.upgrade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.upgrade-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.upgrade-title {
    font-size: 0.9rem;
    font-weight: 700;
}

.upgrade-qty {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
}

.upgrade-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 1px;
}

.upgrade-effects {
    font-size: 0.7rem;
    color: var(--accent-success);
    margin-top: 2px;
}

.upgrade-cost-row {
    margin-top: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.upgrade-cost {
    font-family: var(--font-headings);
    font-weight: 700;
    font-size: 0.85rem;
    color: #ef4444; /* red by default when unaffordable */
}

.upgrade-card.affordable .upgrade-cost {
    color: var(--accent-success);
}

.upgrade-cost-icon {
    width: 12px;
    height: 12px;
    margin-right: 3px;
    display: inline-block;
    vertical-align: middle;
}

/* Achievements List Styles */
.achievements-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: var(--transition-normal);
}

.achievement-card.locked {
    filter: opacity(0.35) grayscale(0.8);
}

.achievement-badge {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border: 1px solid var(--border-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.achievement-card.unlocked .achievement-badge {
    background: linear-gradient(135deg, var(--lego-yellow) 0%, var(--lego-orange) 100%);
    border-color: var(--lego-yellow);
    box-shadow: 0 0 10px rgba(255, 207, 0, 0.4);
    color: #0b0d16;
}

.achievement-info {
    display: flex;
    flex-direction: column;
}

.achievement-name {
    font-size: 0.85rem;
    font-weight: 700;
}

.achievement-desc {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.achievement-status {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.achievement-card.unlocked .achievement-status {
    color: var(--accent-success);
    font-weight: 600;
}

/* ==========================================================================
   Leaderboard / Žebříček
   ========================================================================== */
.leaderboard-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.leaderboard-sort {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.3rem;
    padding: 0.25rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
}

.lb-sort-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.45rem 0.5rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8rem;
    border-radius: 7px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lb-sort-btn:hover {
    color: var(--text-primary);
}

.lb-sort-btn.active {
    background: linear-gradient(135deg, var(--lego-yellow) 0%, var(--lego-yellow-dark) 100%);
    color: #1b1b1b;
    box-shadow: 0 3px 10px rgba(255, 207, 0, 0.3);
}

.lb-refresh-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glow);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}

.lb-refresh-btn:hover {
    color: var(--text-primary);
    transform: rotate(120deg);
}

.leaderboard-me {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    padding: 0.6rem 0.85rem;
    margin-bottom: 0.85rem;
    font-size: 0.85rem;
}

.lb-me-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.lb-me-rank {
    color: var(--lego-yellow);
    font-family: var(--font-headings);
    font-weight: 800;
    font-size: 1rem;
}

.lb-me-name {
    color: var(--text-primary);
    font-weight: 600;
}

.lb-me-value {
    color: var(--text-secondary);
    margin-left: auto;
}

.lb-me-value strong {
    color: var(--text-primary);
    font-family: var(--font-headings);
}

.lb-me-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.leaderboard-empty {
    color: var(--text-muted);
    text-align: center;
    padding: 1.5rem 0;
    font-size: 0.9rem;
}

.lb-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0.85rem;
    background: rgba(22, 28, 45, 0.5);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
    transition: var(--transition-fast);
}

.lb-row:hover {
    background: rgba(22, 28, 45, 0.8);
    border-color: rgba(255, 255, 255, 0.15);
}

.lb-row.is-me {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.45);
    box-shadow: 0 0 14px rgba(59, 130, 246, 0.15);
}

.lb-rank {
    font-family: var(--font-headings);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-secondary);
    width: 36px;
    text-align: center;
}

.lb-rank-1 { color: #ffcf00; text-shadow: 0 0 12px rgba(255, 207, 0, 0.6); }
.lb-rank-2 { color: #d4d4d8; text-shadow: 0 0 10px rgba(212, 212, 216, 0.4); }
.lb-rank-3 { color: #d97706; text-shadow: 0 0 8px rgba(217, 119, 6, 0.4); }

.lb-info {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.lb-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-you {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    margin-left: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    vertical-align: middle;
}

.lb-secondary {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.lb-value {
    text-align: right;
}

.lb-value-num {
    display: block;
    font-family: var(--font-headings);
    font-weight: 800;
    font-size: 1rem;
    color: var(--lego-yellow);
}

.lb-value-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.leaderboard-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lb-page-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glow);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.lb-page-btn:not(:disabled):hover {
    background: var(--accent);
    border-color: var(--accent);
}

.lb-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.lb-page-status {
    text-align: center;
}

.lb-total {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Floating Effects Styles */
.floating-num {
    position: absolute;
    pointer-events: none;
    font-family: var(--font-headings);
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--lego-yellow);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8), 0 0 10px rgba(255, 207, 0, 0.5);
    z-index: 100;
    animation: floatUp 0.8s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes floatUp {
    0% {
        transform: translate(-50%, -50%) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    15% {
        transform: translate(-50%, -100%) scale(1.1) rotate(var(--rot));
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -200%) scale(1) rotate(var(--rot));
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -240%) scale(0.8) rotate(var(--rot));
        opacity: 0;
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 25px;
    left: 25px;
    background: rgba(13, 17, 28, 0.95);
    border: 1px solid var(--lego-yellow);
    border-radius: 12px;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 207, 0, 0.25);
    z-index: 999;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.toast-content {
    display: flex;
    flex-direction: column;
}

.toast-title {
    font-family: var(--font-headings);
    font-weight: 800;
    color: var(--lego-yellow);
    font-size: 0.95rem;
}

.toast-desc {
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* ==========================================================================
   Auth Overlay (Login & Register)
   ========================================================================== */
.auth-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(227, 0, 11, 0.18), transparent 55%),
        radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.18), transparent 55%),
        rgba(7, 9, 17, 0.92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
    transition: opacity 0.35s ease;
}

.auth-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2rem 2rem 1.75rem;
    border-radius: 18px;
    text-align: center;
    box-shadow:
        0 30px 60px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 0 50px rgba(227, 0, 11, 0.15);
    animation: authCardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 16px rgba(227, 0, 11, 0.5));
}

.auth-title {
    font-family: var(--font-headings);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 0.4rem;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.auth-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
    padding: 0.3rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glow);
    border-radius: 12px;
    margin-bottom: 1.25rem;
}

.auth-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.55rem 0.75rem;
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 9px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    background: linear-gradient(135deg, var(--lego-red) 0%, var(--lego-red-shaded) 100%);
    color: white;
    box-shadow: 0 6px 16px rgba(227, 0, 11, 0.35);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    text-align: left;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.auth-field-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
}

.auth-field input {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
    padding: 0.7rem 0.85rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: var(--transition-fast);
    user-select: text;
    -webkit-user-select: text;
}

.auth-field input::placeholder {
    color: var(--text-muted);
}

.auth-field input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-field input:invalid:not(:placeholder-shown) {
    border-color: rgba(227, 0, 11, 0.6);
}

.auth-submit {
    margin-top: 0.4rem;
    background: linear-gradient(135deg, var(--lego-red) 0%, var(--lego-red-dark) 100%);
    color: white;
    border: none;
    padding: 0.8rem 1rem;
    border-radius: 11px;
    font-family: var(--font-headings);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(227, 0, 11, 0.35);
    transition: var(--transition-fast);
}

.auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(227, 0, 11, 0.5);
}

.auth-submit:disabled {
    opacity: 0.55;
    cursor: progress;
    transform: none;
    box-shadow: none;
}

.auth-error {
    background: rgba(227, 0, 11, 0.12);
    border: 1px solid rgba(227, 0, 11, 0.4);
    color: #ffb4b4;
    padding: 0.6rem 0.85rem;
    border-radius: 9px;
    font-size: 0.85rem;
    line-height: 1.35;
}

.auth-error.hidden {
    display: none;
}

.auth-hint {
    margin-top: 0.4rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* User badge in header */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glow);
    border-radius: 10px;
    color: var(--text-primary);
    max-width: 180px;
}

.user-badge.hidden {
    display: none;
}

.user-badge-icon {
    color: var(--lego-yellow);
    flex-shrink: 0;
}

.user-badge-name {
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.secondary-btn-sm.hidden,
.primary-btn-sm.hidden {
    display: none;
}

/* ==========================================================================
   Responsive — tablet & mobile
   ========================================================================== */
@media (max-width: 900px) {
    .game-main {
        grid-template-columns: 1fr;
        height: auto;
        overflow-y: auto;
    }

    .app-container {
        height: auto;
        overflow-y: auto;
    }

    body {
        overflow-y: auto;
    }

    .game-column {
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-glow);
    }

    /* Věž je hlavní vizuální motiv — ať zabere většinu viewportu */
    .tower-viewport-container {
        height: 75vh;
        min-height: 540px;
        max-height: 760px;
    }

    /* Kompaktnější clicker stats, ať se rovnou pod headerem hodí velký brick */
    .clicker-stats {
        padding: 0.6rem 1rem 0.3rem;
    }

    .brick-count {
        font-size: 2.1rem;
    }

    .brick-label {
        font-size: 0.7rem;
    }

    .bps-display {
        font-size: 0.85rem;
        margin-top: 0.25rem;
    }

    .interactive-brick-container {
        padding: 0.5rem 0 1rem;
        min-height: 280px;
    }

    .interactive-brick-glow {
        width: 220px;
        height: 220px;
    }

    .stats-panel {
        margin: 0.5rem 1rem 1rem;
        padding: 0.8rem 1rem;
    }

    .stats-panel h3 {
        font-size: 0.85rem;
        margin-bottom: 0.5rem;
        padding-bottom: 0.4rem;
    }

    .stat-item {
        font-size: 0.8rem;
    }

    /* Heading "Klikací Zóna" je na mobilu redundantní (brick mluví sám) */
    .click-column > .column-header {
        display: none;
    }

    /* Touch-friendly tap targets */
    .upgrade-card {
        padding: 0.85rem 0.9rem;
    }

    .achievement-card {
        padding: 0.85rem;
    }

    /* Brick HUD nad věží */
    .altitude-hud {
        font-size: 0.95rem;
        padding: 0.2rem 0.55rem;
    }

    /* Na desktopu jsou shop-panely position:absolute uvnitř flexu s pevnou výškou.
       Na mobilu s height:auto by se kolabovaly na 0px — proto je tu narovnáme do
       běžného flow, neaktivní schováme přes display:none. */
    .shop-content-container {
        height: auto;
        overflow: visible;
    }

    .shop-panel {
        position: relative;
        height: auto;
        overflow-y: visible;
        opacity: 1;
        pointer-events: auto;
        transform: none;
        transition: none;
        display: none;
    }

    .shop-panel.active {
        display: block;
    }

    /* Header se na mobilu zalomí a quick-stats se schovají (ta info je v hlavních sloupcích) */
    .game-header {
        height: auto;
        padding: 0.6rem 0.9rem;
        flex-wrap: wrap;
        gap: 0.55rem;
        row-gap: 0.55rem;
    }

    .logo-container {
        gap: 0.55rem;
    }

    .logo-container h1 {
        font-size: 1.1rem;
    }

    .header-logo-icon {
        width: 30px;
        height: 30px;
    }

    .quick-stats {
        display: none;
    }

    .header-actions {
        gap: 0.4rem;
        margin-left: auto;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .primary-btn-sm,
    .secondary-btn-sm {
        padding: 0.4rem 0.7rem;
        font-size: 0.78rem;
        border-radius: 8px;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
    }

    .user-badge {
        padding: 0.3rem 0.6rem;
        max-width: 140px;
    }

    .user-badge-name {
        font-size: 0.78rem;
    }

    /* Trochu kompaktnější sloupce */
    .column-header {
        padding: 1rem 1.1rem;
    }

    .column-header h2 {
        font-size: 1.1rem;
    }

    /* Leaderboard ergonomie na užším displeji */
    .leaderboard-me {
        font-size: 0.8rem;
        gap: 0.35rem 0.6rem;
    }

    .lb-me-value {
        margin-left: 0;
        width: 100%;
    }

    .lb-row {
        gap: 0.6rem;
        padding: 0.5rem 0.65rem;
    }

    .lb-rank {
        width: 28px;
        font-size: 1rem;
    }

    .lb-value-num {
        font-size: 0.95rem;
    }

    .lb-name {
        font-size: 0.88rem;
    }
}

/* Užší telefony */
@media (max-width: 480px) {
    .game-header {
        padding: 0.45rem 0.6rem;
    }

    .logo-container h1 {
        font-size: 0.95rem;
        letter-spacing: -0.3px;
    }

    .header-logo-icon {
        width: 26px;
        height: 26px;
    }

    .header-actions {
        width: 100%;
        margin-left: 0;
    }

    .primary-btn-sm,
    .secondary-btn-sm {
        padding: 0.4rem 0.55rem;
        font-size: 0.72rem;
        flex: 1 1 auto;
        text-align: center;
    }

    .user-badge {
        max-width: none;
        flex: 0 1 auto;
    }

    .tower-viewport-container {
        height: 70vh;
        min-height: 480px;
    }

    .brick-count {
        font-size: 1.85rem;
    }

    .clicker-stats,
    .stats-panel {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .column-header {
        padding: 0.85rem 0.95rem;
    }

    .lb-sort-btn {
        font-size: 0.72rem;
        padding: 0.4rem 0.3rem;
    }

    .lb-value-label {
        font-size: 0.6rem;
    }

    .auth-card {
        padding: 1.5rem 1.25rem 1.25rem;
    }

    .auth-title {
        font-size: 1.4rem;
    }
}
