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

/* ==================== THEME VARIABLES ==================== */
:root {
    /* Dark Mode (Default) */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);
    --bg-input: rgba(255, 255, 255, 0.1);
    --bg-overlay: rgba(0, 0, 0, 0.7);
    --bg-tooltip: rgba(0, 0, 0, 0.95);
    
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #888888;
    --text-dim: #666666;
    
    --accent-primary: #00d4ff;
    --accent-secondary: #00a8cc;
    --accent-success: #22c55e;
    --accent-warning: #ffc107;
    --accent-error: #ef4444;
    --accent-purple: #a78bfa;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(0, 212, 255, 0.5);
    
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-glow: rgba(0, 212, 255, 0.3);
    
    --cloud-opacity: 0.05;
    --badge-bg: rgba(0, 0, 0, 0.3);
}

/* Light Mode */
[data-theme="light"] {
    --bg-primary: #f0f4f8;
    --bg-secondary: #e2e8f0;
    --bg-tertiary: #cbd5e1;
    --bg-card: rgba(255, 255, 255, 0.9);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-input: rgba(0, 0, 0, 0.05);
    --bg-overlay: rgba(255, 255, 255, 0.9);
    --bg-tooltip: rgba(30, 41, 59, 0.95);
    
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    
    --accent-primary: #0891b2;
    --accent-secondary: #0e7490;
    --accent-success: #16a34a;
    --accent-warning: #ca8a04;
    --accent-error: #dc2626;
    --accent-purple: #7c3aed;
    
    --border-color: rgba(0, 0, 0, 0.1);
    --border-accent: rgba(8, 145, 178, 0.5);
    
    --shadow-color: rgba(0, 0, 0, 0.1);
    --shadow-glow: rgba(8, 145, 178, 0.2);
    
    --cloud-opacity: 0.15;
    --badge-bg: rgba(0, 0, 0, 0.05);
}

/* Prevent white flash on page load/navigation */
html, body {
    background-color: var(--bg-primary);
}

html {
    overflow-x: hidden;
    width: 100%;
}

a, a:visited, a:hover, a:active {
    text-decoration: none;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-attachment: fixed; /* Ensure gradient covers entire viewport */
    min-height: 100vh;
    min-width: 100vw;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* Clouds Background */
.cloud {
    position: fixed;
    top: 50px;
    left: -200px;
    width: 100px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    z-index: 1;
    pointer-events: none;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
    animation: floatCloud linear infinite;
}

.cloud::after, .cloud::before {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: 50%;
}

.cloud::after {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 15px;
}

.cloud::before {
    width: 40px;
    height: 40px;
    top: -15px;
    left: 45px;
}

.cloud.pixelated {
    image-rendering: pixelated;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    width: 64px;
    height: 32px;
}

.cloud.pixelated::after, .cloud.pixelated::before {
    display: none;
}

@keyframes floatCloud {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 300px)); }
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input { 
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #00d4ff;
}

input:focus + .slider {
    box-shadow: 0 0 1px #00d4ff;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Settings Panel */
.settings-panel,
.history-settings {
    display: none;
    position: fixed;
    top: 45px;
    right: 16px;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    z-index: 2002;
    min-width: 200px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    animation: fadeIn 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.settings-panel.show,
.history-settings.show {
    display: block;
}

.settings-row,
.history-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-row:last-child,
.history-settings-row:last-child {
    border-bottom: none;
}

.settings-row label,
.history-settings-row label {
    font-size: 0.85rem;
    color: #ccc;
    margin: 0;
}

.history-settings-row select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
}

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

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
}

.lang-selector {
    position: relative;
}

.lang-dropdown {
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #ccc;
    transition: background 0.2s;
}

.lang-current:hover {
    background: rgba(0, 0, 0, 0.5);
}

.lang-current .flag {
    width: 16px;
    height: 11px;
    object-fit: cover;
}

.lang-current .lang-name {
    font-size: 0.75rem;
    text-transform: uppercase;
}

.lang-current .arrow {
    font-size: 0.5rem;
    margin-left: 2px;
    transition: transform 0.2s;
}

.lang-dropdown.open .arrow {
    transform: rotate(180deg);
}

.lang-options {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background: #333;
    border: none;
    overflow: hidden;
    display: none;
    min-width: 140px;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.lang-dropdown.open .lang-options {
    display: block;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
    color: #ccc;
}

.lang-option:hover {
    background: #444;
}

.lang-option .flag {
    width: 18px;
    height: 12px;
    object-fit: cover;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #00d4ff, #7b2cbf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

header p {
    color: #a0a0a0;
    font-size: 1rem;
}

.history {
    display: none;
    margin-bottom: 20px;
}

.history.show {
    display: block;
}

.history-label {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 8px;
}

.top-right-controls {
    position: fixed;
    top: 12px;
    right: 16px;
    z-index: 2001;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(0, 0, 0, 0.5);
}

.admin-panel-link {
    display: none;
    position: fixed;
    top: 50px;
    right: 16px;
    padding: 6px 12px;
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid #00d4ff;
    border-radius: 4px;
    color: #00d4ff;
    text-decoration: none;
    font-size: 0.75rem;
    z-index: 1000;
    transition: all 0.2s;
}

.admin-panel-link:hover {
    background: rgba(0, 212, 255, 0.3);
}

.history-settings {
    display: none;
    position: fixed;
    top: 50px;
    right: 16px;
    background: rgba(20, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    padding: 15px;
    z-index: 1001;
    min-width: 250px;
    animation: fadeIn 0.2s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.history-settings.show {
    display: block;
}

.history-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.history-settings-row:last-child {
    border-bottom: none;
}

.history-settings-row label {
    font-size: 0.85rem;
    color: #ccc;
    margin: 0;
}

.history-settings-row select {
    width: auto;
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 60px;
    flex-shrink: 0;
}

.history-settings-row button {
    padding: 6px 12px;
    font-size: 0.8rem;
    background: rgba(255, 82, 82, 0.2);
    border: 1px solid rgba(255, 82, 82, 0.4);
    color: #ff5252;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
}

.history-settings-row button:hover {
    background: rgba(255, 82, 82, 0.3);
    transform: none;
    box-shadow: none;
}

.history-items {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.5) rgba(0, 0, 0, 0.3);
}

.history-items::-webkit-scrollbar {
    height: 6px;
}

.history-items::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.history-items::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 3px;
}

.history-items::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

.history-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
    white-space: nowrap;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #00d4ff;
}

.history-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    image-rendering: pixelated;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    object-fit: none;
    object-position: center;
}

.history-item span {
    font-size: 0.9rem;
    color: #e0e0e0;
}

.history-item .hotel-flag {
    width: 18px;
    height: 12px;
    object-fit: cover;
    border-radius: 2px;
}

.history-item.pinned {
    border-color: rgba(0, 212, 255, 0.4);
    background: rgba(0, 212, 255, 0.1);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.history-item.pinned:active {
    cursor: grabbing;
}

.history-item.pinned::before {
    content: '📌';
    font-size: 10px;
    margin-right: 4px;
    pointer-events: none;
}

.history-item.pinned img,
.history-item.pinned span {
    pointer-events: none;
}

.history-item.dragging {
    opacity: 0.4;
}

.history-item.drag-over {
    border-color: #00d4ff;
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
    background: rgba(0, 212, 255, 0.2);
}

.profile-buttons {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 6px;
}

.profile-home-btn,
.profile-refresh-btn,
.profile-pin-btn,
.profile-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 212, 255, 0.15);
    color: #00d4ff;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    line-height: 0; /* Important for centering characters/elements */
    box-sizing: border-box;
}

.profile-close-btn svg {
    margin: 0;
    padding: 0;
    display: block;
}

.profile-home-btn img {
    width: 16px;
    height: 16px;
    image-rendering: pixelated;
}

.profile-home-btn:hover,
.profile-refresh-btn:hover:not(.loading),
.profile-pin-btn:hover,
.profile-close-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
    transform: scale(1.1);
}

.profile-refresh-btn.loading {
    animation: spin 1s linear infinite;
    pointer-events: none;
    opacity: 0.7;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.profile-pin-btn.pinned {
    color: #00d4ff;
    background: rgba(0, 212, 255, 0.2);
}

.card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.main-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    justify-content: center;
}

/* Left Column - contains Newest Badges + Form + Badge Details */
.left-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex-shrink: 0;
    width: 860px;
}

/* Top Row inside Left Column - Newest Badges + Form side by side */
.left-top-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* Badge Details Module - full width of left-column */
.badge-module-card {
    width: 860px !important;
    max-width: 860px;
    padding: 30px 20px !important;
    margin-bottom: 0;
    box-sizing: border-box;
}


.main-layout .form-card {
    width: 480px;
    flex-shrink: 0;
}

.main-layout.has-result .form-card {
    margin-left: 0;
    margin-right: 0;
}

.main-layout .card {
    margin-bottom: 0;
}

.result-card {
    display: none;
    flex: 0 0 auto;
    min-width: 460px;
    width: 460px;
    max-width: 100%;
    height: 960px !important;
    max-height: 960px !important;
    overflow: hidden;
    overflow-y: auto;
    position: relative;
    box-sizing: border-box;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.result-card::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.result-card.show {
    display: block;
    animation: fadeIn 0.8s ease;
}

.badge-module-card.show {
    display: block !important;
    animation: fadeIn 0.5s ease;
}

/* Badge Module Flags Styling */
.modal-flags {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-bottom: 20px;
}

.badge-modal-flag {
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.badge-modal-flag:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
}

.badge-modal-flag.active {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
}

.badge-modal-flag img {
    width: 20px;
    height: 14px;
    object-fit: cover;
    border-radius: 2px;
}

/* Restore Stats Styling */
.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
    text-align: center;
    flex: 1;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* Restore Badge Grid Styling */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.badge-item {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.badge-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(0, 212, 255, 0.3);
    z-index: 2;
}

.badge-item img {
    max-width: 42px;
    max-height: 42px;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
}

/* User Info Layout Fix - Flexbox based (for result-card on startpage) */
.result-card .user-info {
    display: flex !important;
    flex-direction: row !important;
    gap: 15px !important;
    align-items: flex-start !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
    margin-bottom: 20px;
}

.avatar-wrapper {
    flex-shrink: 0 !important;
    align-self: stretch !important;
}

.user-details {
    flex: 1 !important;
    min-width: 0;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    padding-right: 160px; /* Space for profile buttons (4 buttons + gaps) */
}

.user-details .selected-badges {
    position: static !important;
    margin: 5px 0 !important;
    display: grid !important;
    grid-template-columns: repeat(2, 50px) !important;
    gap: 4px !important;
}

.user-details .motto {
    font-style: italic !important;
}

.user-details .creation-date {
    color: #888 !important;
    font-size: 0.85rem !important;
    white-space: nowrap;
}

.user-details .creation-date span {
    display: inline;
}

@media (max-width: 768px) {
    .result-card .user-info {
        flex-direction: row !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 15px !important;
    }
    .result-card .user-info .avatar {
        flex-shrink: 0 !important;
    }
    .result-card .user-details {
        flex: 1 !important;
        min-width: 0 !important;
    }
    .result-card .user-details .selected-badges {
        justify-content: flex-start !important;
    }
}

@media (max-width: 1100px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .badges-card {
        width: 100%;
        max-width: 500px;
        order: -1; /* Show on top */
        margin-bottom: 20px;
    }
    
    .newest-badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
        gap: 6px;
    }

    .main-layout .form-card,
    .main-layout.has-result .form-card {
        width: 100%;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
    }

    .result-card, .badge-module-card {
        width: 100%;
        max-width: 620px;
    }
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #e0e0e0;
}

input, select, textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #00d4ff;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.3);
}

input::placeholder, textarea::placeholder {
    color: #666;
}

textarea {
    resize: none;
    min-height: 48px;
    line-height: 1.4;
}

textarea.expanded {
    min-height: 100px;
}

.hint {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: #666;
}

.hint.hidden {
    display: none;
}

select option {
    background: #1a1a2e;
    color: #fff;
}

button {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #00d4ff, #7b2cbf);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* .user-info styles moved to line 655 */

.avatar-wrapper {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    width: 130px; /* Wider for more space */
    padding: 0;
    overflow: hidden;
}

.avatar {
    width: auto;
    height: auto;
    image-rendering: pixelated;
}

.user-right-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-header-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

/* When name is 7+ characters, stack vertically */
.user-header-row.stacked {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
}

/* Username scaling for long names */
.username {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
}

.username.scaled-small {
    font-size: 1.2rem;
}

.username.scaled-smaller {
    font-size: 1rem;
}

.username.scaled-tiny {
    font-size: 0.85rem;
}

.user-details h3 {
    margin-bottom: 2px;
}

#userOnlineStatus {
    display: inline-block;
    white-space: nowrap;
}

.user-details p {
    color: #a0a0a0;
    font-style: italic;
    margin-bottom: 4px;
}

.member-since {
    color: #888;
    font-size: 0.85rem;
    margin-top: 8px;
}

.selected-badges {
    display: grid;
    grid-template-columns: repeat(2, 50px);
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 8px;
    align-self: start;
    width: fit-content;
}

.selected-badges .selected-badge {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.selected-badges .selected-badge:hover:not(.empty) {
    background: rgba(0, 212, 255, 0.2);
    transform: scale(1.05);
}

.selected-badges .selected-badge img {
    max-width: 46px;
    max-height: 46px;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
}

.selected-badges .selected-badge.empty {
    background: rgba(255, 255, 255, 0.03);
    cursor: default;
}

.selected-badges .selected-badge.group-placeholder {
    background: rgba(0, 0, 0, 0.4);
    cursor: default;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.25);
}

.badge-image-large {
    max-width: 100px;
    max-height: 100px;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
}

.badge-result {
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin-top: 20px;
}

.badge-details-container {
    margin: 15px auto 0 auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    width: fit-content;
    text-align: left;
}

.badge-text-details {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.badge-result.success {
    background: rgba(0, 200, 83, 0.2);
    border: 1px solid rgba(0, 200, 83, 0.5);
}

.badge-result.error {
    background: rgba(255, 82, 82, 0.2);
    border: 1px solid rgba(255, 82, 82, 0.5);
}

.badge-result.warning {
    background: rgba(255, 165, 0, 0.2);
    border: 1px solid rgba(255, 165, 0, 0.5);
}

.badge-result.info {
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid rgba(0, 212, 255, 0.5);
}

.badge-result h4 {
    font-size: 1.3rem;
    margin-bottom: 10px;
}

.badge-result.success h4 {
    color: #00c853;
}

.badge-result.error h4 {
    color: #ff5252;
}

.badge-result.warning h4 {
    color: #ffa500;
}

.badge-result.info h4 {
    color: #00d4ff;
}

/* Badge-only mode - hide profile header */
.result-card.badge-only-mode .user-info,
.result-card.badge-only-mode .stats-row {
    display: none !important;
}

.result-card.badge-only-mode {
    padding-top: 15px;
}

.result-card.badge-only-mode .profile-buttons {
    margin-bottom: 0;
}

.badge-icon {
    width: 40px;
    height: 40px;
    margin: 10px auto;
}

.badge-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 15px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-align: left;
}

.badge-info img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.badge-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.badge-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.badge-desc {
    font-size: 0.8rem;
    color: #aaa;
}

.badge-results-list {
    display: flex;
    flex-direction: column;
    margin-top: 20px;
}

.badge-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
    margin-bottom: 15px;
}

.badge-result-item:last-child {
    margin-bottom: 0;
}

.badge-result-item.success {
    background: rgba(0, 200, 83, 0.15);
    border: 1px solid rgba(0, 200, 83, 0.3);
}

.badge-result-item.error {
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid rgba(255, 82, 82, 0.3);
}

.badge-result-item.warning {
    background: rgba(255, 165, 0, 0.15);
    border: 1px solid rgba(255, 165, 0, 0.3);
}

.badge-result-item img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.badge-result-item .badge-details {
    flex: 1;
}

.badge-result-item .badge-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.badge-result-item .badge-desc {
    font-size: 0.75rem;
    color: #888;
    margin-top: 2px;
}

.badge-result-item .badge-status {
    font-size: 0.75rem;
    margin-top: 2px;
}

.badge-result-item.success .badge-status {
    color: #00c853;
}

.badge-result-item.error .badge-status {
    color: #ff5252;
}

.badge-result-item.warning .badge-status {
    color: #ffa500;
}

.badge-date,
.badge-discovered,
.badge-owned,
.badge-discovered-single {
    display: block;
    font-size: 0.75rem;
    color: #00d4ff;
    margin-top: 2px;
}

.badge-discovered,
.badge-discovered-single {
    color: #aaa;
}

.all-badges-wrapper {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.5) rgba(0, 0, 0, 0.3);
}

.all-badges-wrapper::-webkit-scrollbar {
    width: 8px;
}

.all-badges-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.all-badges-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 4px;
}

.all-badges-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

.all-badges-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px;
}

.badge-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
}

.badge-pagination button {
    padding: 8px 16px;
    background: rgba(0, 212, 255, 0.2);
    border: 1px solid #00d4ff;
    border-radius: 6px;
    color: #00d4ff;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.badge-pagination button:hover:not(:disabled) {
    background: #00d4ff;
    color: #1a1a2e;
}

.badge-pagination button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.badge-pagination span {
    color: #888;
    font-size: 0.9rem;
    white-space: nowrap;
    min-width: 60px;
    text-align: center;
}

.badge-item {
    position: relative;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: transform 0.2s;
}

.badge-item:hover {
    transform: scale(1.2);
    z-index: 10;
}

.badge-item img {
    max-width: 40px;
    max-height: 40px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.badge-item .new-badge-label {
    position: absolute;
    top: -2px;
    left: -2px;
    background: #22c55e;
    color: #fff;
    font-size: 7px;
    font-weight: bold;
    padding: 1px 3px;
    border-radius: 3px;
    text-transform: uppercase;
    z-index: 5;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

#badgeTooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.95);
    border: 1px solid rgba(0, 212, 255, 0.5);
    border-radius: 8px;
    padding: 12px;
    width: 220px;
    z-index: 99999;
    pointer-events: none;
    display: none;
}

#badgeTooltip.show {
    display: block;
}

#badgeTooltip .tt-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #fff;
    margin-bottom: 4px;
}

#badgeTooltip .tt-code {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 6px;
}

#badgeTooltip .tt-desc {
    font-size: 0.8rem;
    color: #ccc;
    margin-bottom: 6px;
}

#badgeTooltip .tt-dates {
    font-size: 0.75rem;
    color: #00d4ff;
}

#badgeTooltip .tt-dates div {
    margin-top: 2px;
}

#badgeTooltip .tt-dates .discovered {
    color: #aaa;
}


.all-badges-count {
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 15px;
}

.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show {
    display: block;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    display: none;
    background: rgba(255, 82, 82, 0.2);
    border: 1px solid rgba(255, 82, 82, 0.5);
    padding: 15px;
    border-radius: 10px;
    color: #ff5252;
    margin-top: 20px;
}

.error-message.show {
    display: block;
}

.suggestion-box {
    display: none;
    background: rgba(0, 212, 255, 0.1);
    border: 1px solid rgba(0, 212, 255, 0.4);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
    text-align: center;
}

.suggestion-box.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.suggestion-box p {
    margin-bottom: 15px;
    color: #e0e0e0;
}

.suggestion-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.suggestion-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
    width: auto;
}

.suggestion-buttons button:hover {
    transform: scale(1.05);
}

.suggestion-buttons .btn-yes {
    background: #00c853;
    color: #fff;
}

.suggestion-buttons .btn-no {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

.suggestion-buttons .btn-hotel {
    background: linear-gradient(90deg, #00d4ff, #7b2cbf);
    color: #fff;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.stat {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: #00d4ff;
}

.stat-label {
    font-size: 0.8rem;
    color: #a0a0a0;
}

.top-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.top-stat-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 14px;
    text-align: center;
    text-decoration: none;
    transition: all 0.2s;
    min-width: 100px;
}

.top-stat-item:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    transform: translateY(-2px);
}

.top-stat-number {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: #00d4ff;
}

.top-stat-label {
    display: block;
    font-size: 0.75rem;
    color: #888;
    margin-top: 4px;
}

/* Mobile Startseite */
@media (max-width: 768px) {
    .top-stats .top-right-controls {
        position: absolute;
        top: -40px;
        right: 0;
    }
    
    .top-stats {
        position: relative;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 0 10px;
        padding-top: 50px;
    }
    
    .top-stat-item {
        min-width: unset;
        padding: 12px 8px;
    }
    
    .top-stat-number {
        font-size: 1.2rem;
    }
    
    .top-stat-label {
        font-size: 0.65rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .top-stats .top-right-controls {
        top: -35px;
    }
    
    .top-stats {
        gap: 6px;
        padding: 0 5px;
        padding-top: 45px;
    }
    
    .top-stat-item {
        padding: 10px 5px;
        border-radius: 8px;
    }
    
    .top-stat-number {
        font-size: 1rem;
    }
    
    .top-stat-label {
        font-size: 0.6rem;
        line-height: 1.2;
    }
    
    header h1 {
        font-size: 1.6rem;
    }
    
    header p {
        font-size: 0.85rem;
    }
}

footer {
    text-align: center;
    margin-top: 40px;
    color: #666;
    font-size: 0.9rem;
}

footer a {
    color: #00d4ff;
    text-decoration: none;
}

/* Newest Badges */
.badges-card {
    width: 360px;
    flex-shrink: 0;
    padding: 20px !important;
    position: relative; /* For dropdown positioning */
}

.badge-module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.badge-module-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.badge-module-close:hover {
    background: rgba(255,255,255,0.2);
}

.badge-module-body {
    display: flex;
    gap: 25px;
    align-items: stretch;
}

.badge-module-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-shrink: 0;
    min-width: 280px;
    max-width: 320px;
}

/* Badge Found Header - "Badge gefunden!" style */
.badge-found-header {
    text-align: center;
    margin-bottom: 12px;
}

.badge-found-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #00c853;
    margin-bottom: 4px;
}

.badge-found-subtitle {
    font-size: 0.85rem;
    color: #aaa;
}

/* Badge Found Box - Profile style bordered box */
.badge-found-box {
    background: rgba(0, 200, 83, 0.1);
    border: 1px solid rgba(0, 200, 83, 0.4);
    border-radius: 10px;
    padding: 12px;
}

.badge-found-code-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.badge-found-code {
    font-size: 0.85rem;
    font-weight: bold;
    color: #00d4ff;
    font-family: monospace;
    cursor: pointer;
    transition: color 0.2s;
}

.badge-found-code:hover {
    text-decoration: underline;
    color: #4de8ff;
}

.badge-found-level {
    font-size: 0.8rem;
    font-weight: 600;
    color: #a78bfa;
    font-family: monospace;
    background: rgba(167, 139, 250, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-found-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.badge-found-content img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.badge-found-text {
    flex: 1;
    min-width: 0;
}

.badge-found-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #00d4ff;
    margin-bottom: 4px;
}

.badge-found-desc {
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.4;
    margin-bottom: 6px;
}

.badge-found-date {
    font-size: 0.75rem;
    color: #00d4ff;
}

/* Legacy classes for backwards compatibility */
.badge-module-image {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    flex-shrink: 0;
}

.badge-module-image img {
    max-width: 50px;
    max-height: 50px;
    image-rendering: pixelated;
}

.badge-module-text {
    flex: 1;
    min-width: 0;
}

.badge-module-code {
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 4px;
}

.badge-module-name {
    font-size: 0.95rem;
    color: #00d4ff;
    margin-bottom: 4px;
}

.badge-module-desc {
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.4;
}

.badge-module-flags {
    flex-shrink: 0;
}

.badge-module-flags .modal-flags {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
}

/* Right side container - Flags + Owners stacked */
.badge-module-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.badge-module-owners {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.badge-module-owners .owners-flags-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.badge-module-owners .owners-flags-row .modal-flags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.badge-module-owners .owners-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.badge-module-owners .owners-header .owners-title {
    font-size: 0.85rem;
    color: #aaa;
}

.badge-module-owners .owners-count {
    color: #00d4ff;
    font-size: 0.75rem;
    background: rgba(0, 212, 255, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

.badge-module-owners .owners-list {
    min-height: 285px;
    max-height: 285px;
    overflow-y: auto;
}

@media (max-width: 900px) {
    .badge-module-body {
        flex-direction: column;
        align-items: center;
    }
    
    .badge-module-info {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        align-items: center;
    }
    
    .badge-found-box {
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .badge-found-content {
        justify-content: center;
    }
    
    .badge-found-text {
        text-align: left;
    }
    
    .badge-module-right {
        width: 100%;
    }
    
    .badge-module-flags .modal-flags {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .badge-module-owners {
        width: 100%;
    }
}

.newest-badges-dropdown-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.newest-badges-current {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #ccc;
    transition: background 0.2s;
}

.newest-badges-current:hover {
    background: rgba(0, 0, 0, 0.5);
}

.newest-badges-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 2px;
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    display: none;
    min-width: 120px;
    z-index: 101;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.newest-badges-dropdown.show {
    display: block;
}

.newest-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.85rem;
    color: #ccc;
}

.newest-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.newest-option img {
    width: 18px;
    height: 12px;
    object-fit: cover;
}

.newest-badges-header {
    font-size: 1.1rem;
    color: #fff;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 600;
    padding-right: 90px;
}

.newest-badges-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 columns */
    gap: 8px;
    /* Remove background/padding inside the card */
    border: none;
    padding: 0;
    background: transparent;
}

.newest-badges-grid .new-badge-item {
    width: 100%; /* Fill grid cell */
    height: 54px; /* Slightly taller */
}

.new-badge-item {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    border: 1px solid transparent;
}

.new-badge-item:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.3);
    z-index: 10;
}

.new-badge-item img {
    max-width: 42px;
    max-height: 42px;
    image-rendering: pixelated;
}

.newest-badges-pagination {
    justify-content: center; /* Center buttons */
    margin-top: 15px;
}

@media (max-width: 1100px) {
    .main-layout {
        flex-direction: column;
        align-items: center;
    }
    
    .left-column {
        width: 100%;
        max-width: 500px;
    }
    
    .left-top-row {
        flex-direction: column;
        width: 100%;
    }
    
    .badges-card {
        width: 100% !important;
        max-width: 500px;
        margin-bottom: 0;
    }
    
    .form-card {
        width: 100% !important;
        max-width: 500px;
    }
    
    .badge-module-card {
        max-width: 500px;
    }
    
    .newest-badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}

/* Badge Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
}

.modal-overlay.show {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.badge-modal {
    background: #1a1a2e;
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 16px;
    padding: 0;
    width: 90%;
    max-width: 400px;
    max-height: 90vh; /* Limit height */
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
    overflow: hidden;
}

.badge-modal-header {
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.badge-modal-title {
    font-weight: 600;
    color: #fff;
}

.badge-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: auto;
    line-height: 1;
}

.badge-modal-close:hover {
    color: #fff;
    transform: none;
    box-shadow: none;
}

.badge-modal-content {
    padding: 20px;
    text-align: center;
    overflow-y: auto; /* Scroll if content is too long */
    flex: 1;
}

.badge-modal-image-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-modal-image {
    width: auto;
    height: auto;
    max-width: 64px;
    max-height: 64px;
    image-rendering: pixelated;
    transform: scale(1.5);
}

.badge-modal-code {
    display: inline-block;
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 15px;
    font-family: monospace;
    cursor: pointer;
}

.badge-modal-code:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.badge-modal-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #00d4ff;
    margin-bottom: 8px;
}

.badge-modal-desc {
    color: #ccc;
    font-size: 0.95rem;
    line-height: 1.4;
    min-height: 3rem;
}

.badge-modal-flags {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.badge-owners {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

.badge-owners h4 {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.owners-list {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.5) rgba(0, 0, 0, 0.3);
}

.owner-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    transition: background 0.2s;
    text-decoration: none;
}

.owner-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.owner-item img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    object-fit: none;
    object-position: center;
}

.owner-item .name {
    font-size: 0.85rem;
    color: #fff;
    flex: 1;
}

.owner-item .date {
    font-size: 0.75rem;
    color: #888;
}

.badge-modal-flag {
    width: 24px;
    height: 16px;
    cursor: pointer;
    border-radius: 2px;
    opacity: 0.4;
    transition: all 0.2s;
    border: 1px solid transparent;
    object-fit: cover;
}

.badge-modal-flag:hover {
    opacity: 1;
    transform: scale(1.2);
}

.badge-modal-flag.active {
    opacity: 1;
    border-color: #00d4ff;
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
    transform: scale(1.1);
}
.newest-badges-pagination button {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 4px 10px !important;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem !important;
    width: auto;
    min-width: 30px;
}

.newest-badges-pagination button:hover:not(:disabled) {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
    color: #00d4ff;
}

/* MISSING CSS RESTORED */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

.badge-item {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.badge-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    border-color: rgba(0, 212, 255, 0.3);
    z-index: 2;
}

.badge-item img {
    max-width: 42px;
    max-height: 42px;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: pixelated;
}


.stats-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    text-align: center;
    flex: 1;
    position: relative;
}

.stat-item:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 15%;
    height: 70%;
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* --- MOBILE OPTIMIZATIONS --- */
@media (max-width: 900px) {
    /* CRITICAL: Force everything to stay within viewport */
    html, body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* Container & Layout */
    .container {
        padding: 20px 10px;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .main-layout {
        flex-direction: column;
        align-items: center;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Cards - Fluid Width with overflow protection */
    .card, .form-card, .result-card, .badges-card, .badge-module-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        margin-right: 0 !important;
        margin-left: 0 !important;
        padding: 15px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Left column on mobile */
    .left-column {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .left-top-row {
        width: 100% !important;
        flex-direction: column !important;
    }

    /* Result card styling - FORCE contain everything */
    .result-card { 
        height: auto !important;
        max-height: none !important;
        position: relative !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* All children inside result-card must stay within bounds */
    .result-card * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .result-card .user-info,
    .result-card .stats-row,
    .result-card #allBadgesContainer,
    .result-card #friendsContainer,
    .result-card #groupsContainer,
    .result-card #singleBadgeResult,
    .result-card #bulkBadgeResults {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Stats row - ensure all 3 items visible */
    .stats-row {
        display: flex !important;
        width: 100% !important;
    }
    
    .stat-item {
        flex: 1 !important;
        min-width: 0 !important;
    }
    
    .badge-module-card { 
        margin-top: 20px;
    }

    /* Profile Header Stack */
    .user-info {
        flex-direction: column !important;
        align-items: center !important;
        text-align: center !important;
    }

    .avatar-wrapper {
        align-self: center !important;
        margin-bottom: 15px;
        /* Reset height constraints for vertical stacking */
        height: auto; 
    }

    .user-details {
        padding-right: 0 !important;
        align-items: center !important;
        width: 100%;
    }

    .user-header-row {
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Profile Buttons - Move to top, ensure visible */
    .profile-buttons {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        width: auto !important;
        max-width: 100% !important;
        justify-content: flex-end !important;
        margin-bottom: 10px;
        flex-shrink: 0;
        gap: 8px;
    }
    
    .profile-buttons button {
        flex-shrink: 0 !important;
    }

    /* Stats Row - ensure all 3 items visible */
    .stats-row {
        display: flex !important;
        width: 100% !important;
        padding: 8px 5px !important;
        gap: 2px !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }
    
    .stat-item {
        flex: 1 1 0 !important;
        min-width: 0 !important;
        max-width: 33.33% !important;
        padding: 8px 4px !important;
        text-align: center;
    }
    
    .stat-value {
        font-size: 0.95rem;
    }
    .stat-label {
        font-size: 0.65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Grids */
    .badges-grid, .all-badges-grid, .newest-badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr)) !important;
    }
    
    /* Pagination */
    .badge-pagination {
        flex-wrap: wrap;
    }
    
    /* Tooltip Mobile Fix (Bottom Sheet style or just hidden/static?) */
    /* Usually tooltips on hover don't work well on touch. We rely on click opening the module. */
    
    /* Settings Modal Centered - override animation transform */
    .history-settings {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 90% !important;
        max-width: 320px;
        right: auto !important;
        max-height: 80vh;
        overflow-y: auto;
        animation: fadeInMobile 0.2s ease !important;
    }
    
    @keyframes fadeInMobile {
        from { 
            opacity: 0; 
            transform: translate(-50%, -50%) scale(0.95); 
        }
        to { 
            opacity: 1; 
            transform: translate(-50%, -50%) scale(1); 
        }
    }
    
    /* Stats row clickable on mobile - ensure pointer events work */
    .stat-item.clickable {
        cursor: pointer;
        -webkit-tap-highlight-color: rgba(0, 212, 255, 0.2);
        touch-action: manipulation;
    }
}

/* ==================== Refresh Overlay ==================== */
.refresh-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.refresh-overlay.active {
    opacity: 1;
    visibility: visible;
}

.refresh-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 212, 255, 0.2);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: refreshSpin 1s linear infinite;
}

.refresh-overlay-text {
    margin-top: 15px;
    color: #00d4ff;
    font-size: 14px;
    font-weight: 500;
}

.refresh-overlay-status {
    margin-top: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.refresh-overlay-status.success {
    color: #00c853;
}

@keyframes refreshSpin {
    to { transform: rotate(360deg); }
}

/* --- MOBILE SELECTED BADGES FIX --- */
@media (max-width: 900px) {
    .user-details .selected-badges {
        margin: 10px auto !important;
        justify-content: center !important;
    }
    .selected-badges {
        margin: 10px auto !important;
        align-self: center !important;
    }
    .profile-buttons {
        position: absolute;
        top: 15px;
        right: 15px;
        width: auto;
    }
    .member-since,
    .creation-date,
    .user-details p {
        text-align: center !important;
        width: 100%;
    }
    
    /* Mobile: Friends/Groups Header stacking */
    .friends-header,
    .groups-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .friends-header > div,
    .groups-header > div {
        justify-content: center !important;
        flex-wrap: wrap !important;
    }
    
    #friendsSearchBox,
    #groupsSearchBox {
        width: 100% !important;
        max-width: none !important;
    }
    
    #friendsSearchInput,
    #groupsSearchInput {
        width: 100% !important;
        flex: 1 !important;
    }
    
    /* Prevent horizontal scroll flash */
    #friendsContainer,
    #groupsContainer {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Friends/Groups list items - prevent overflow */
    .friends-list-inline,
    .groups-list-inline,
    .friends-list,
    .groups-list,
    #friendsList,
    #groupsList {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }
    
    .friend-item-inline,
    .group-item-inline {
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

/* --- WIDER PHONES: Desktop Layout for User Info --- */
@media (min-width: 500px) {
    .user-info {
        flex-direction: row !important;
        align-items: flex-start !important;
        text-align: left !important;
    }
    .avatar-wrapper {
        align-self: stretch !important;
        margin-bottom: 0 !important;
    }
    .user-details .selected-badges {
        margin: 5px 0 !important;
        justify-content: flex-start !important;
    }
    .selected-badges {
        margin: 5px 0 !important;
        align-self: start !important;
    }
    .member-since,
    .creation-date,
    .user-details p {
        text-align: left !important;
    }
}

/* --- FORCE HORIZONTAL LAYOUT ON MOST PHONES --- */
@media (min-width: 380px) {
    .user-info {
        flex-direction: row !important;
        align-items: flex-start !important;
        text-align: left !important;
        gap: 15px !important;
    }
    .avatar-wrapper {
        flex-shrink: 0 !important;
        align-self: stretch !important;
        margin-bottom: 0 !important;
    }
    .user-details {
        flex: 1 !important;
        align-items: flex-start !important;
    }
    .user-details .selected-badges,
    .selected-badges {
        margin: 5px 0 !important;
        align-self: start !important;
        justify-content: flex-start !important;
    }
    .user-header-row {
        justify-content: flex-start !important;
    }
    .member-since,
    .creation-date,
    .user-details p {
        text-align: left !important;
    }
}

/* --- FIX BUTTON POSITION ON MOBILE --- */
@media (max-width: 900px) {
    .result-card {
        padding-top: 50px !important;
    }
    .profile-buttons {
        top: 10px !important;
        right: 10px !important;
    }
}

/* Sort Buttons for Owners */
.owners-sort {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.sort-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #aaa;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    background: rgba(0, 212, 255, 0.2);
    border-color: rgba(0, 212, 255, 0.5);
    color: #00d4ff;
}

.sort-btn.active {
    background: rgba(0, 212, 255, 0.3);
    border-color: #00d4ff;
    color: #00d4ff;
}

/* Owners Header with Sorting */
.owners-header {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.owners-title {
    flex: 1;
}

.owners-date-header {
    width: 80px;
    text-align: right;
}

.owners-count {
    color: #00d4ff;
    min-width: 30px;
    text-align: right;
}

.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s ease;
}

.sortable:hover {
    color: #00d4ff;
}

.sortable.active {
    color: #00d4ff;
}

.sort-arrow {
    font-size: 0.75rem;
    margin-left: 3px;
    opacity: 0.8;
}

/* ==================== FRIENDS MODAL ==================== */
.stat-item.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.stat-item.clickable:hover {
    transform: scale(1.05);
    color: #00d4ff;
}

.stat-item.clickable:hover .stat-value {
    color: #00d4ff;
}

#friendsModalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

#friendsModalOverlay.active {
    display: flex;
}

.friends-modal {
    background: linear-gradient(145deg, #1e1e35, #252545);
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.friends-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-wrap: wrap;
    gap: 10px;
}

.friends-modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
}

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

.friends-search-input {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 0.9rem;
    width: 200px;
}

.friends-search-input:focus {
    outline: none;
    border-color: #00d4ff;
}

.friends-search-input::placeholder {
    color: #666;
}

.friends-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.2s;
}

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

.friends-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    min-height: 200px;
}

.friends-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
}

.friends-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.friends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: all 0.2s;
    cursor: pointer;
}

.friend-item:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(5px);
}

.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.friend-avatar img {
    width: auto;
    height: 55px;
    margin-top: 8px;
}

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

.friend-name {
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-motto {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.friend-since {
    font-size: 0.8rem;
    color: #00d4ff;
    white-space: nowrap;
    text-align: right;
}

.friend-since-label {
    font-size: 0.7rem;
    color: #666;
    display: block;
}

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

.friends-modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    color: #888;
}

.friends-count {
    color: #00d4ff;
    font-weight: 500;
}

.friends-sync-info {
    font-size: 0.75rem;
    color: #666;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .friends-modal {
        max-height: 90vh;
    }
    
    .friends-modal-header {
        padding: 15px;
    }
    
    .friends-search-input {
        width: 150px;
        font-size: 0.85rem;
        padding: 6px 10px;
    }
    
    .friend-item {
        padding: 8px 10px;
        gap: 10px;
    }
    
    .friend-avatar {
        width: 36px;
        height: 36px;
    }
    
    .friend-avatar img {
        height: 48px;
    }
    
    .friend-name {
        font-size: 0.9rem;
    }
    
    .friend-since {
        font-size: 0.75rem;
    }
}

/* ==================== FRIENDS INLINE LIST ==================== */
.friends-list-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 344px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.5) rgba(0, 0, 0, 0.3);
}

.friends-list-inline::-webkit-scrollbar {
    width: 8px;
}

.friends-list-inline::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.friends-list-inline::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 4px;
}

.friends-list-inline::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

.friend-item-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
    min-height: 64px;
    height: 64px;
    box-sizing: border-box;
}

.friend-item-inline:hover {
    background: rgba(0, 212, 255, 0.1);
    transform: translateX(3px);
}

.friend-avatar-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(0, 212, 255, 0.4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.friend-avatar-wrapper img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    object-position: center top;
    margin-top: 8px;
}

.friend-item-inline > img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    object-fit: cover;
    object-position: center top;
}

.friend-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.friend-item-name {
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item-motto {
    font-size: 0.75rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.friend-item-date {
    font-size: 0.8rem;
    color: #00d4ff;
    white-space: nowrap;
    font-weight: 500;
}

/* ==================== GROUPS INLINE LIST ==================== */

.groups-list-inline {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 344px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.5) rgba(0, 0, 0, 0.3);
}

.groups-list-inline::-webkit-scrollbar {
    width: 8px;
}

.groups-list-inline::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.groups-list-inline::-webkit-scrollbar-thumb {
    background: rgba(0, 212, 255, 0.5);
    border-radius: 4px;
}

.groups-list-inline::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 212, 255, 0.7);
}

.group-item-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    transition: all 0.2s;
    min-height: 64px;
    height: 64px;
    box-sizing: border-box;
}

.group-item-inline:hover {
    background: rgba(0, 212, 255, 0.1);
}

.group-badge-wrapper {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(0, 212, 255, 0.4);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.group-badge-wrapper img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.group-badge-wrapper.no-badge {
    background: rgba(0, 0, 0, 0.6);
}

.group-badge-wrapper.no-badge::after {
    content: '?';
    color: rgba(255, 255, 255, 0.3);
    font-size: 18px;
    font-weight: bold;
}

.group-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.group-item-name {
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-item-desc {
    font-size: 0.75rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-item-tags {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.group-tag {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.group-tag.admin {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.group-tag.type {
    background: rgba(139, 69, 255, 0.2);
    color: #a78bfa;
    border: 1px solid rgba(139, 69, 255, 0.3);
}

/* ==================== LIGHT MODE OVERRIDES ==================== */
[data-theme="light"] {
    /* Main backgrounds */
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 50%, #cbd5e1 100%);
}

[data-theme="light"] body {
    background: linear-gradient(135deg, #f0f4f8 0%, #e2e8f0 50%, #cbd5e1 100%);
    color: #1e293b;
}

/* Cards and containers */
[data-theme="light"] .card,
[data-theme="light"] .form-card,
[data-theme="light"] .result-card,
[data-theme="light"] .badges-card,
[data-theme="light"] .badge-module-card,
[data-theme="light"] .list-card,
[data-theme="light"] .chart-card {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Form inputs */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    background: rgba(0, 0, 0, 0.05) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: #1e293b !important;
}

[data-theme="light"] input::placeholder {
    color: #64748b !important;
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus {
    border-color: #0891b2 !important;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.1) !important;
}

/* Buttons */
[data-theme="light"] .submit-btn,
[data-theme="light"] .pagination-btn,
[data-theme="light"] .refresh-btn {
    background: rgba(8, 145, 178, 0.15);
    border-color: #0891b2;
    color: #0891b2;
}

[data-theme="light"] .submit-btn:hover,
[data-theme="light"] .pagination-btn:hover:not(:disabled),
[data-theme="light"] .refresh-btn:hover {
    background: #0891b2;
    color: #fff;
}

/* Text colors */
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] h4,
[data-theme="light"] .badge-name,
[data-theme="light"] .list-name,
[data-theme="light"] .friend-name,
[data-theme="light"] .friend-item-name,
[data-theme="light"] .group-item-name {
    color: #1e293b !important;
}

[data-theme="light"] p,
[data-theme="light"] .badge-desc,
[data-theme="light"] .friend-motto,
[data-theme="light"] .friend-item-motto,
[data-theme="light"] .group-item-desc {
    color: #475569 !important;
}

[data-theme="light"] .badge-code,
[data-theme="light"] .list-code {
    color: #64748b !important;
}

/* Accent colors */
[data-theme="light"] .accent,
[data-theme="light"] .list-count,
[data-theme="light"] .stat-value,
[data-theme="light"] .friend-since,
[data-theme="light"] .friend-item-date {
    color: #0891b2 !important;
}

/* Language dropdown */
[data-theme="light"] .lang-current,
[data-theme="light"] .settings-btn {
    background: rgba(100, 116, 139, 0.15);
    border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .settings-btn:hover,
[data-theme="light"] .lang-current:hover {
    background: rgba(100, 116, 139, 0.25);
}

[data-theme="light"] .lang-options {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .lang-option {
    color: #475569;
}

[data-theme="light"] .lang-option:hover {
    background: rgba(8, 145, 178, 0.1);
    color: #0891b2;
}

/* Tooltips */
[data-theme="light"] #badgeTooltip,
[data-theme="light"] .breakdown-tooltip {
    background: rgba(30, 41, 59, 0.95);
    color: #fff;
}

/* Badge items */
[data-theme="light"] .badge-item,
[data-theme="light"] .selected-badge {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .badge-item:hover,
[data-theme="light"] .selected-badge:hover {
    background: rgba(8, 145, 178, 0.1);
}

/* Result states */
[data-theme="light"] .badge-result.success {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.3);
}

[data-theme="light"] .badge-result.error {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
}

/* Stats boxes */
[data-theme="light"] .stat-box {
    background: rgba(0, 0, 0, 0.03);
}

/* Settings panel */
[data-theme="light"] .history-settings,
[data-theme="light"] .period-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .history-settings-row label {
    color: #475569;
}

/* List items */
[data-theme="light"] .list-item,
[data-theme="light"] .friend-item,
[data-theme="light"] .friend-item-inline,
[data-theme="light"] .group-item-inline {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .list-item:hover,
[data-theme="light"] .friend-item:hover,
[data-theme="light"] .friend-item-inline:hover,
[data-theme="light"] .group-item-inline:hover {
    background: rgba(8, 145, 178, 0.08);
}

/* Scrollbars */
[data-theme="light"] ::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Clouds - more visible in light mode */
[data-theme="light"] .cloud,
[data-theme="light"] .cloud.pixelated {
    opacity: 0.3;
}

/* Back link */
[data-theme="light"] .back-link {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
    color: #0891b2;
}

[data-theme="light"] .back-link:hover {
    background: rgba(8, 145, 178, 0.1);
    border-color: #0891b2;
}

/* Admin panel link */
[data-theme="light"] .admin-panel-link {
    background: rgba(255, 255, 255, 0.9);
    color: #0891b2;
}

/* Modal overlays */
[data-theme="light"] .modal-overlay,
[data-theme="light"] .badge-modal-overlay {
    background: rgba(0, 0, 0, 0.5);
}

/* Playercard specific */
[data-theme="light"] .playercard {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

/* Tags */
[data-theme="light"] .new-badge-label {
    background: #16a34a;
}

[data-theme="light"] .group-tag.admin {
    background: rgba(202, 138, 4, 0.15);
    color: #a16207;
    border-color: rgba(202, 138, 4, 0.3);
}

[data-theme="light"] .group-tag.type {
    background: rgba(124, 58, 237, 0.15);
    color: #6d28d9;
    border-color: rgba(124, 58, 237, 0.3);
}

/* ==================== ADDITIONAL LIGHT MODE TEXT FIXES ==================== */

/* Header title and subtitle */
[data-theme="light"] header h1 {
    color: #0891b2 !important;
}

[data-theme="light"] header p {
    color: #475569 !important;
}

/* Top stats */
[data-theme="light"] .top-stat-item {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .top-stat-number {
    color: #0891b2 !important;
}

[data-theme="light"] .top-stat-label {
    color: #475569 !important;
}

/* Recent searches / History */
[data-theme="light"] .history-label {
    color: #475569 !important;
}

[data-theme="light"] .history-item {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .history-item span {
    color: #1e293b !important;
}

[data-theme="light"] .history-item-name {
    color: #1e293b !important;
}

[data-theme="light"] .history-item-hotel {
    color: #64748b !important;
}

/* Settings panel */
[data-theme="light"] .history-settings-row select {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: #1e293b !important;
}

[data-theme="light"] .history-settings > div:first-child {
    color: #1e293b !important;
}

/* Newest badges card */
[data-theme="light"] .newest-badges-header {
    color: #1e293b !important;
}

[data-theme="light"] #newestBadgesSubtitle {
    color: #64748b !important;
}

[data-theme="light"] .newest-badges-current {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
}

[data-theme="light"] .newest-badges-dropdown {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .newest-option {
    color: #475569;
}

[data-theme="light"] .newest-option:hover {
    background: rgba(8, 145, 178, 0.1);
    color: #0891b2;
}

/* Form labels */
[data-theme="light"] .form-group label {
    color: #475569 !important;
}

[data-theme="light"] .hint {
    color: #64748b !important;
}

/* Username in result card */
[data-theme="light"] .username,
[data-theme="light"] #resultUsername {
    color: #1e293b !important;
}

/* Motto */
[data-theme="light"] .motto,
[data-theme="light"] #resultMotto {
    color: #475569 !important;
}

/* Member since / Creation date */
[data-theme="light"] .creation-date {
    color: #64748b !important;
}

[data-theme="light"] .creation-date span {
    color: #64748b !important;
}

/* Stats row */
[data-theme="light"] .stat-item {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .stat-label {
    color: #64748b !important;
}

/* Badge results */
[data-theme="light"] .badge-result-title {
    color: #1e293b !important;
}

[data-theme="light"] .badge-result-text {
    color: #475569 !important;
}

[data-theme="light"] .badge-name,
[data-theme="light"] .badge-name h3 {
    color: #1e293b !important;
}

[data-theme="light"] .badge-desc,
[data-theme="light"] .badge-desc p {
    color: #475569 !important;
}

[data-theme="light"] .badge-details {
    color: #64748b !important;
}

/* All badges header */
[data-theme="light"] #allBadgesCount {
    color: #475569 !important;
}

[data-theme="light"] #badgeSearchBox {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] #badgeSearchInput {
    color: #1e293b !important;
}

/* Page info */
[data-theme="light"] #badgePageInfo {
    color: #64748b !important;
}

/* Friends container */
[data-theme="light"] #friendsTitle,
[data-theme="light"] #groupsTitle {
    color: #475569 !important;
}

[data-theme="light"] #friendsCount,
[data-theme="light"] #groupsCount {
    color: #0891b2 !important;
}

[data-theme="light"] #friendsSearchBox,
[data-theme="light"] #groupsSearchBox {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] #friendsSearchInput,
[data-theme="light"] #groupsSearchInput {
    color: #1e293b !important;
}

/* Footer */
[data-theme="light"] .site-footer {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(0, 0, 0, 0.1);
    color: #64748b;
}

[data-theme="light"] .site-footer p {
    color: #64748b !important;
}

[data-theme="light"] .site-footer a {
    color: #0891b2 !important;
}

/* Badge modal */
[data-theme="light"] .badge-modal {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .badge-modal-title {
    color: #1e293b !important;
}

[data-theme="light"] .badge-modal-name {
    color: #1e293b !important;
}

[data-theme="light"] .badge-modal-desc {
    color: #475569 !important;
}

[data-theme="light"] .badge-modal-code {
    color: #64748b !important;
}

/* Owners section */
[data-theme="light"] .owners-header,
[data-theme="light"] .owners-title {
    color: #475569 !important;
}

[data-theme="light"] .owners-count {
    color: #0891b2 !important;
}

[data-theme="light"] .owners-list {
    color: #1e293b !important;
}

/* Badge module card */
[data-theme="light"] .badge-module-header h3 {
    color: #1e293b !important;
}

[data-theme="light"] .badge-found-title {
    color: #16a34a !important;
}

[data-theme="light"] .badge-found-subtitle {
    color: #475569 !important;
}

[data-theme="light"] .badge-found-box {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .badge-found-name {
    color: #1e293b !important;
}

[data-theme="light"] .badge-found-desc {
    color: #475569 !important;
}

[data-theme="light"] .badge-found-date {
    color: #64748b !important;
}

[data-theme="light"] .badge-found-code {
    color: #0891b2 !important;
}

[data-theme="light"] .badge-found-level {
    color: #7c3aed !important;
    background: rgba(124, 58, 237, 0.1);
}

/* Lang selector text */
[data-theme="light"] .lang-name {
    color: #1e293b !important;
}

[data-theme="light"] .lang-current .arrow {
    color: #64748b !important;
}

/* Online status - keep colored */
[data-theme="light"] #userOnlineStatus {
    /* Keep green/red colors for online status */
}

/* Error message */
[data-theme="light"] .error-message {
    color: #dc2626 !important;
}

/* Refresh overlay */
[data-theme="light"] .refresh-overlay {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .refresh-overlay-text {
    color: #1e293b !important;
}

[data-theme="light"] .refresh-overlay-status {
    color: #475569 !important;
}

/* Pagination buttons */
[data-theme="light"] .badge-pagination button,
[data-theme="light"] #newestPrevBtn,
[data-theme="light"] #newestNextBtn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
    color: #475569 !important;
}

[data-theme="light"] .badge-pagination button:hover:not(:disabled),
[data-theme="light"] #newestPrevBtn:hover:not(:disabled),
[data-theme="light"] #newestNextBtn:hover:not(:disabled) {
    background: #0891b2;
    color: #fff !important;
}

/* Profile buttons */
[data-theme="light"] .profile-refresh-btn,
[data-theme="light"] .profile-pin-btn,
[data-theme="light"] .profile-close-btn,
[data-theme="light"] .profile-home-btn {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.15);
}

/* Close buttons */
[data-theme="light"] .badge-modal-close,
[data-theme="light"] .badge-module-close {
    color: #64748b !important;
}

[data-theme="light"] .badge-modal-close:hover,
[data-theme="light"] .badge-module-close:hover {
    color: #dc2626 !important;
}

/* Switch slider track */
[data-theme="light"] .switch .slider {
    background: rgba(0, 0, 0, 0.2);
}

/* Period dropdown for stats page */
[data-theme="light"] .period-current {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.15);
    color: #1e293b;
}

[data-theme="light"] .period-option {
    color: #475569;
}

[data-theme="light"] .period-option:hover {
    background: rgba(8, 145, 178, 0.1);
    color: #0891b2;
}

/* ==================== MOBILE: DARKER MODULE BACKGROUNDS ==================== */
/* Makes cards/modules more opaque on mobile for better readability over background image */
@media (max-width: 900px) {
    /* Main cards - darker background for readability */
    .card,
    .form-card,
    .result-card,
    .badges-card,
    .badge-module-card {
        background: rgba(10, 10, 25, 0.85) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
    }
    
    /* Stats row inside result card */
    .stats-row {
        background: rgba(0, 0, 0, 0.5) !important;
    }
    
    /* Top stat items on homepage */
    .top-stat-item {
        background: rgba(10, 10, 25, 0.85) !important;
        backdrop-filter: blur(10px) !important;
        -webkit-backdrop-filter: blur(10px) !important;
    }
    
    /* History items */
    .history-item {
        background: rgba(10, 10, 25, 0.85) !important;
    }
    
    /* Settings panels */
    .settings-panel,
    .history-settings {
        background: rgba(10, 10, 25, 0.95) !important;
        backdrop-filter: blur(15px) !important;
        -webkit-backdrop-filter: blur(15px) !important;
    }
    
    /* Badge modal */
    .badge-modal {
        background: rgba(15, 15, 35, 0.98) !important;
    }
    
    /* Friends modal */
    .friends-modal {
        background: rgba(15, 15, 35, 0.98) !important;
    }
    
    /* Dropdown menus */
    .lang-options,
    .newest-badges-dropdown {
        background: rgba(15, 15, 35, 0.98) !important;
    }
    
    /* Badge items grid */
    .badge-item,
    .new-badge-item {
        background: rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Selected badges */
    .selected-badges {
        background: rgba(0, 0, 0, 0.5) !important;
    }
    
    /* Avatar wrapper */
    .avatar-wrapper {
        background: rgba(0, 0, 0, 0.5) !important;
    }
    
    /* Friends/Groups list items */
    .friend-item-inline,
    .group-item-inline {
        background: rgba(0, 0, 0, 0.4) !important;
    }
    
    /* Owner items in badge modal */
    .owner-item {
        background: rgba(0, 0, 0, 0.4) !important;
    }
}

/* Light mode mobile - also needs darker backgrounds for contrast */
@media (max-width: 900px) {
    [data-theme="light"] .card,
    [data-theme="light"] .form-card,
    [data-theme="light"] .result-card,
    [data-theme="light"] .badges-card,
    [data-theme="light"] .badge-module-card {
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(12px) !important;
        -webkit-backdrop-filter: blur(12px) !important;
    }
    
    [data-theme="light"] .top-stat-item {
        background: rgba(255, 255, 255, 0.95) !important;
    }
    
    [data-theme="light"] .history-item {
        background: rgba(255, 255, 255, 0.95) !important;
    }
    
    [data-theme="light"] .settings-panel,
    [data-theme="light"] .history-settings {
        background: rgba(255, 255, 255, 0.98) !important;
    }
}
