/* Premium Portal Stylesheet */
:root {
    --purple-primary: #7c3aed;
    --purple-light: #a855f7;
    --purple-dark: #6d28d9;
    --glass-bg: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-shadow: 0 32px 80px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.5);
    --text-more-muted: rgba(255, 255, 255, 0.3);
}

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

body {
    background: linear-gradient(135deg, #1a0533 0%, #2d1060 30%, #4a1a8c 60%, #6b2fb5 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Page container */
.page-wrapper {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
}

/* Top bar buttons */
.top-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.top-action-btn:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.15);
}

/* Tab switcher */
.tab-switcher {
    display: flex;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 4px;
    gap: 4px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-weight: 800;
    font-size: 0.82rem;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-light));
    color: #fff;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

/* Volume control icon button */
.volume-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.volume-btn:active {
    transform: scale(0.95);
}

/* Avatar container */
.profile-section {
    display: flex;
    justify-content: center;
    margin-bottom: -32px;
    position: relative;
    z-index: 20;
}

.avatar-wrapper {
    position: relative;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.avatar-wrapper:hover {
    transform: scale(1.05) rotate(3deg);
}

.avatar-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.5), inset 0 2px 4px rgba(255,255,255,0.2);
    object-fit: cover;
}

.avatar-edit-badge {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    color: var(--purple-primary);
    font-size: 0.85rem;
}

/* Main card style */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    box-shadow: var(--glass-shadow);
    padding: 44px 24px 28px 24px;
    position: relative;
    z-index: 10;
    width: 100%;
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.card-title-row span {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #c4b5fd;
}

/* Input boxes */
.input-group {
    margin-bottom: 16px;
}

.custom-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 16px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    transition: all 0.25s ease;
}

.custom-input:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(167, 139, 250, 0.7);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15), 0 4px 20px rgba(0, 0, 0, 0.2);
}

.pin-input {
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 6px;
}

/* CTAs */
.btn-primary {
    width: 100%;
    background: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #1d4ed8 100%);
    border: none;
    color: #fff;
    font-weight: 900;
    font-size: 1.05rem;
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4), 0 2px 0 rgba(255, 255, 255, 0.1) inset;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:active {
    transform: scale(0.98);
}

.divider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 22px 0;
}

.divider-line {
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.divider-text {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-more-muted);
    letter-spacing: 1.5px;
}

.create-subtext {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.btn-create-trigger {
    width: 100%;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 50%, #15803d 100%);
    border: none;
    color: #fff;
    font-weight: 900;
    font-size: 1.05rem;
    padding: 16px;
    border-radius: 16px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.4), 0 2px 0 rgba(255, 255, 255, 0.1) inset;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-create-trigger:active {
    transform: scale(0.98);
}

/* Expandable Dropdown / Menu styling */
.create-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #180935;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 50;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

.create-dropdown-menu.show {
    display: flex;
    animation: slideDown 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.dropdown-item {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    transition: background 0.2s;
    text-align: left;
    background: transparent;
    border-left: none;
    border-right: none;
    border-top: none;
    cursor: pointer;
    width: 100%;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.dropdown-item:active {
    background: rgba(255, 255, 255, 0.15);
}

.dropdown-icon {
    font-size: 1.4rem;
}

/* Lobby section styling */
.lobby-container {
    margin-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.lobby-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.lobby-title-row span {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #fca5a5; /* light red */
}

.lobby-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 2px;
}

.lobby-list::-webkit-scrollbar {
    width: 4px;
}

.lobby-list::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
}

.lobby-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.lobby-item:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255,255,255,0.15);
}

.lobby-item-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.lobby-item-icon {
    font-size: 1.3rem;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
}

.lobby-item-details {
    min-width: 0;
    flex: 1;
}

.lobby-item-name {
    font-weight: 700;
    font-size: 0.88rem;
    color: #fff;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-item-info {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.lobby-item-badge {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 8px;
    white-space: nowrap;
}

.lobby-close-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    margin-right: 6px;
}

.lobby-close-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.no-lobbies {
    text-align: center;
    padding: 30px 0;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #13072e;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    max-width: 380px;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.show .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #1a0b3b;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 800;
}

.modal-close-icon {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255,255,255,0.7);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

/* Avatar list */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.avatar-select-item {
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: all 0.2s;
    aspect-ratio: 1;
    overflow: hidden;
}

.avatar-select-item:hover {
    transform: scale(1.08);
}

.avatar-select-item.selected {
    border-color: #a855f7;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}

.avatar-select-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Friends list */
.friends-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 350px;
    overflow-y: auto;
    margin-top: 14px;
}

.friend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    border-radius: 16px;
}

.friend-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.friend-mini-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.95rem;
}

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

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

.friend-remove-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
}

/* Embed singleplayer trex iframe */
.trex-iframe-card {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 30px;
    overflow: hidden;
    width: 100%;
    box-shadow: var(--glass-shadow);
}

.trex-iframe {
    width: 100%;
    height: 480px;
    border: none;
    display: block;
    background: transparent;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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