* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    overflow: hidden;
    background: #000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#ui-overlay button, #ui-overlay input, #ui-overlay textarea, #ui-overlay .clickable {
    pointer-events: all;
}

#login-screen, #login-form-screen, #signup-form-screen, #main-menu, #play-menu-screen, #collection-screen, #friends-screen, #profile-screen, #settings-screen, #customize-screen, #store-screen, #leaderboard-screen, #titles-screen, #achievements-screen, #events-screen, #fleet-screen, #lobby-screen, #challenge-create-screen, #challenge-lobby-screen, #challenge-join-screen, #results-screen, #banned-screen {
    pointer-events: all;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.8);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#start-screen h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

#start-screen p {
    font-size: 1.2rem;
    opacity: 0.7;
    margin-bottom: 2rem;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    padding: 1rem 2.5rem;
    font-size: 1.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

/* Countdown */
#countdown {
    font-size: 6rem;
    font-weight: bold;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Race HUD */
#race-hud {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 45vh;
    padding: 1.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    pointer-events: all;
    overflow-y: auto;
}

#planet-info {
    text-align: center;
    margin-bottom: 0.75rem;
}

#planet-name {
    font-size: 1.4rem;
    font-weight: bold;
    margin-right: 1rem;
}

#planet-rarity {
    padding: 0.2rem 0.8rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
}

.rarity-common { background: #6b7280; }
.rarity-uncommon { background: #059669; }
.rarity-rare { background: #2563eb; }
.rarity-epic { background: #7c3aed; }
.rarity-legendary { background: linear-gradient(135deg, #f59e0b, #ef4444); }

/* Typing Area */
#typing-area {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.75rem;
    padding: 1.2rem;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
    line-height: 1.7;
    max-height: 20vh;
    overflow-y: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#typing-text .typed {
    color: #4ade80;
}

#typing-text .current {
    background: rgba(102, 126, 234, 0.5);
    border-bottom: 2px solid #667eea;
}

#typing-text .error {
    background: rgba(239, 68, 68, 0.5);
    border-bottom: 2px solid #ef4444;
    color: #fca5a5;
}

#typing-text .untyped {
    opacity: 0.5;
}

/* Progress Bars */
#progress-bars {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-name {
    width: 80px;
    font-size: 0.8rem;
    text-align: right;
    opacity: 0.8;
}

.progress-track {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.1s linear;
}

.progress-fill.player { background: linear-gradient(90deg, #667eea, #764ba2); }
.progress-fill.bot { background: rgba(255, 255, 255, 0.4); }

/* Results Screen */
#results-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 400px;
}

#results-title {
    font-size: 2rem;
    margin-bottom: 1rem;
}

#results-planet {
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    opacity: 0.8;
}

#results-list {
    list-style: none;
    margin-bottom: 2rem;
    text-align: left;
}

#results-list li {
    padding: 0.5rem 1rem;
    margin-bottom: 0.3rem;
    border-radius: 0.3rem;
    background: rgba(255, 255, 255, 0.05);
}

#results-list li.winner {
    background: rgba(102, 126, 234, 0.2);
    border: 1px solid rgba(102, 126, 234, 0.4);
}

/* Auth Form */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
    width: 280px;
}

.auth-form input {
    padding: 0.8rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    border-color: #667eea;
}

.auth-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.auth-buttons button {
    flex: 1;
}

.error-text {
    color: #f87171;
    font-size: 0.85rem;
    text-align: center;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: none;
}

.btn-tertiary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.9rem;
    padding: 0.6rem 1.5rem;
}

.btn-tertiary:hover {
    background: rgba(255, 255, 255, 0.05);
    box-shadow: none;
}

/* Login Screen */
#login-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#login-screen h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

#login-screen p {
    font-size: 1.1rem;
    opacity: 0.7;
}

/* Main Menu */
#main-menu {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 550px;
    width: 90vw;
}

#main-menu h1 {
    font-size: 2.5rem;
    margin-bottom: 0.3rem;
}

#welcome-msg {
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 1rem;
}

.menu-stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.menu-stats span {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.menu-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.menu-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.5;
    margin-bottom: 0.25rem;
}

.menu-section button {
    width: 100%;
    padding: 0.7rem 0.5rem;
    font-size: 0.85rem;
}

#main-menu > .btn-tertiary {
    margin-top: 0.5rem;
}

/* Collection Screen */
#collection-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

#collection-screen h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

#collection-stats {
    margin-bottom: 1.5rem;
    opacity: 0.7;
}

#collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.collection-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.collection-card .card-name {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
}

.collection-card .card-rarity {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 0.75rem;
    display: inline-block;
}

.collection-card .card-date {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-top: 0.3rem;
}

.empty-collection {
    opacity: 0.5;
    padding: 2rem;
    font-style: italic;
}

/* Friends Screen */
#friends-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

#friends-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

#friends-screen h3 {
    font-size: 1rem;
    opacity: 0.6;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
    text-align: left;
}

.friends-search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.friends-search input {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.95rem;
    outline: none;
}

.friends-search input:focus {
    border-color: #667eea;
}

.friends-search button {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}

.friend-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.4rem;
    margin-bottom: 0.4rem;
    text-align: left;
}

.friend-name {
    font-weight: bold;
    font-size: 0.95rem;
    flex: 1;
}

.friend-name.clickable {
    cursor: pointer;
    color: #93b4f8;
}

.friend-name.clickable:hover {
    text-decoration: underline;
}

.friend-stat {
    font-size: 0.8rem;
    opacity: 0.6;
}

.btn-small {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem;
    border-radius: 0.3rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: #fff;
    cursor: pointer;
}

.btn-small:hover {
    transform: scale(1.05);
}

.btn-small.btn-accept { background: #059669; }
.btn-small.btn-decline { background: #dc2626; }
.btn-small.btn-remove { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }

.search-result-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: rgba(102, 126, 234, 0.1);
    border: 1px solid rgba(102, 126, 234, 0.3);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

#friend-search-result {
    margin-bottom: 0.5rem;
}

/* Profile Screen */
#profile-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

#profile-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

#profile-screen h3 {
    font-size: 1rem;
    opacity: 0.6;
    margin-bottom: 0.75rem;
}

/* Self Destruct Button */
.btn-destruct {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(220, 38, 38, 0.2);
    border: 1px solid rgba(220, 38, 38, 0.5);
    color: #fca5a5;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.4rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
}

.btn-destruct:hover {
    background: rgba(220, 38, 38, 0.4);
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(220, 38, 38, 0.3);
}

/* Settings Screen */
#settings-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 90vw;
}

#settings-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.settings-list {
    margin-bottom: 2rem;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.settings-label {
    font-size: 1rem;
}

.profile-created {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Auth Form Screens */
#login-form-screen, #signup-form-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#login-form-screen h2, #signup-form-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.profile-friends-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.profile-friend-tag {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0.3rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    color: #93b4f8;
    transition: background 0.2s;
}

.profile-friend-tag:hover {
    background: rgba(102, 126, 234, 0.2);
}

/* Customize Screen */
#customize-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 450px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

#customize-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.customize-section {
    margin-bottom: 1.25rem;
    text-align: left;
}

.customize-section h3 {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.customize-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.15);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: none;
}

.color-swatch.active {
    border-color: #fff;
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

/* Profile Rocket Preview */
.profile-rocket-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.rocket-preview-label {
    font-size: 0.85rem;
    opacity: 0.6;
    margin-right: 0.25rem;
}

.rocket-color-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.3);
    display: inline-block;
}

#profile-rocket-canvas {
    display: block;
    margin: 0.75rem auto;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Store Screen */
#store-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: all;
}

#store-screen h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.store-coins {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    color: #fbbf24;
}

.store-category {
    margin-bottom: 1.5rem;
    text-align: left;
}

.store-category h3 {
    font-size: 0.85rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.6rem;
}

.store-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.6rem;
    text-align: center;
    transition: border-color 0.2s;
}

.store-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.store-item.owned {
    border-color: rgba(74, 222, 128, 0.4);
    background: rgba(74, 222, 128, 0.05);
}

.store-item.too-expensive {
    opacity: 0.5;
}

.store-item-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin: 0 auto 0.4rem;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.store-item-name {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.store-item-price {
    font-size: 0.75rem;
    opacity: 0.7;
    margin-bottom: 0.3rem;
}

.store-buy-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Limited-time offers */
.limited-category h3 {
    opacity: 1;
    color: #fbbf24;
}

.limited-item {
    border-color: rgba(251, 191, 36, 0.4);
    background: linear-gradient(180deg, rgba(251, 191, 36, 0.08), rgba(255, 255, 255, 0.04));
}

.limited-item:hover {
    border-color: rgba(251, 191, 36, 0.7);
}

.limited-countdown {
    font-size: 0.7rem;
    font-weight: bold;
    color: #fbbf24;
    margin-bottom: 0.3rem;
    letter-spacing: 0.02em;
}

.coins-earned {
    margin-top: 0.5rem;
    font-size: 1.1rem;
    color: #fbbf24;
    font-weight: bold;
}

/* Leaderboard Screen */
#leaderboard-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 450px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

#leaderboard-screen h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.lb-tab {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    border-radius: 2rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.lb-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: transparent;
}

.lb-list {
    list-style: none;
    text-align: left;
    margin-bottom: 1.5rem;
}

.lb-list li {
    padding: 0.6rem 1rem;
    margin-bottom: 0.3rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.4rem;
    font-size: 0.95rem;
}

.lb-list li:first-child {
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.lb-list li:nth-child(2) {
    background: rgba(192, 192, 192, 0.1);
    border: 1px solid rgba(192, 192, 192, 0.2);
}

.lb-list li:nth-child(3) {
    background: rgba(205, 127, 50, 0.1);
    border: 1px solid rgba(205, 127, 50, 0.2);
}

/* Offline Screen */
#offline-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(220, 38, 38, 0.3);
    pointer-events: all;
}

#offline-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.offline-msg {
    opacity: 0.7;
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Lobby Screen */
#lobby-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#lobby-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

#lobby-players {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.5rem;
    min-height: 60px;
}

.lobby-player {
    background: rgba(102, 126, 234, 0.15);
    border: 1px solid rgba(102, 126, 234, 0.3);
    padding: 0.5rem 1.5rem;
    border-radius: 0.4rem;
    font-size: 0.95rem;
}

#lobby-timer {
    opacity: 0.6;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Challenge Screens */
#challenge-create-screen, #challenge-lobby-screen, #challenge-join-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
}

#challenge-create-screen h2, #challenge-lobby-screen h2, #challenge-join-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.challenge-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.challenge-form label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.challenge-form textarea {
    width: 100%;
    padding: 0.8rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.95rem;
    resize: vertical;
    font-family: inherit;
    outline: none;
}

.challenge-form textarea:focus {
    border-color: #667eea;
}

.challenge-options {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.challenge-options label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}

#challenge-time-options {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#challenge-time-options input {
    width: 70px;
    padding: 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.9rem;
    text-align: center;
}

.challenge-preview {
    font-size: 0.8rem;
    opacity: 0.5;
}

#challenge-code-display {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 0.3em;
    color: #667eea;
    margin-bottom: 0.5rem;
}

.challenge-share-msg {
    opacity: 0.6;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

#challenge-lobby-players {
    margin-bottom: 1.5rem;
}

/* Play Menu */
#play-menu-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 90vw;
}

#play-menu-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.submenu-buttons {
    margin-bottom: 1.5rem;
}

.submenu-buttons button {
    width: 100%;
    margin-bottom: 0.5rem;
}

.submenu-desc {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 0.25rem;
    margin-bottom: 1rem;
}

.lb-name {
    color: #93b4f8;
    cursor: pointer;
}

.lb-name:hover {
    text-decoration: underline;
}

/* Collection rarity sections */
.collection-rarity-section {
    margin-bottom: 1.25rem;
    text-align: left;
}

.collection-rarity-section h3 {
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
    border-radius: 1rem;
    display: inline-block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.collection-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
}

.collection-card.undiscovered {
    opacity: 0.4;
    border-style: dashed;
}

.card-unknown {
    font-size: 1.2rem;
    opacity: 0.5;
}

.rarity-stellar { background: linear-gradient(135deg, #ff00ff, #00ffff); color: #000; font-weight: bold; }

/* Part buttons in customization */
.part-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.part-btn:hover {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
    transform: none;
    box-shadow: none;
}

.part-btn.active {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.2);
}

.store-item-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

.store-item-desc {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-bottom: 0.2rem;
}

/* Events Screen */
#events-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: all;
}

#events-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.event-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    text-align: left;
    transition: border-color 0.2s;
}

.event-card:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.event-card.event-completed {
    opacity: 0.6;
    border-color: rgba(74, 222, 128, 0.3);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.event-name {
    font-weight: bold;
    font-size: 1rem;
}

.event-ends {
    font-size: 0.75rem;
    opacity: 0.5;
}

.event-desc {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}

.event-reward {
    font-size: 0.8rem;
    color: #fbbf24;
    margin-bottom: 0.5rem;
}

.event-status {
    font-size: 0.85rem;
    color: #4ade80;
    font-weight: bold;
}

.event-play-btn {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
}

/* Lobby Chat */
#lobby-chat {
    margin-top: 1rem;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    overflow: hidden;
}

#lobby-chat-messages {
    height: 120px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.chat-msg {
    font-size: 0.8rem;
    word-break: break-word;
}

.chat-name {
    font-weight: bold;
    color: #93b4f8;
}

.lobby-chat-input {
    display: flex;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.lobby-chat-input input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.85rem;
    outline: none;
}

.lobby-chat-input button {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    border-radius: 0;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* Global Chat on Main Menu */
#global-chat {
    margin-top: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0.5rem;
    overflow: hidden;
    text-align: left;
}

#global-chat h3 {
    font-size: 0.8rem;
    padding: 0.4rem 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0;
    opacity: 0.7;
}

#global-chat-messages {
    height: 100px;
    overflow-y: auto;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* Banned Screen */
#banned-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 3rem 4rem;
    border-radius: 1rem;
    border: 1px solid rgba(220, 38, 38, 0.4);
    max-width: 450px;
    width: 90vw;
    pointer-events: all;
}

#banned-screen h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #fca5a5;
}

#ban-reason-text {
    opacity: 0.7;
    margin-bottom: 1.5rem;
}

#appeal-form textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.9rem;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 0.75rem;
}

#appeal-status {
    margin-top: 1rem;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Achievements Screen */
#achievements-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: all;
}

#achievements-screen h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

#achievements-count {
    opacity: 0.6;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.achievement-category {
    margin-bottom: 1.25rem;
    text-align: left;
}

.achievement-category h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.5;
    margin-bottom: 0.5rem;
}

.achievement-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.4rem;
    margin-bottom: 0.3rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.achievement-item.unlocked {
    background: rgba(102, 126, 234, 0.08);
    border-color: rgba(102, 126, 234, 0.2);
}

.achievement-item.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 1.3rem;
    width: 2rem;
    text-align: center;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.achievement-desc {
    font-size: 0.75rem;
    opacity: 0.6;
}

/* Glassmorphism for all menu panels */
#login-form-screen, #signup-form-screen, #play-menu-screen,
#collection-screen, #friends-screen, #profile-screen,
#settings-screen, #customize-screen, #store-screen,
#leaderboard-screen, #events-screen, #achievements-screen,
#lobby-screen, #challenge-create-screen, #challenge-lobby-screen,
#challenge-join-screen, #results-screen, #offline-screen, #banned-screen {
    backdrop-filter: blur(10px);
    background: rgba(0, 0, 0, 0.7) !important;
}

/* Announcements */
#announcement-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    pointer-events: all;
}

.announcement {
    padding: 0.7rem 1.5rem;
    font-size: 0.9rem;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}

.announcement-info {
    background: rgba(102, 126, 234, 0.9);
    color: #fff;
}

.announcement-warning {
    background: rgba(217, 119, 6, 0.9);
    color: #fff;
}

.announcement-success {
    background: rgba(5, 150, 105, 0.9);
    color: #fff;
}

/* Planet Builder */
#planet-builder-screen {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 700px;
    width: 95vw;
    max-height: 85vh;
    overflow-y: auto;
    pointer-events: all;
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.builder-header h2 {
    font-size: 1.5rem;
}

.builder-controls {
    display: flex;
    gap: 0.5rem;
}

.builder-layout {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

#planet-builder-canvas {
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.builder-shop {
    flex: 1;
    max-height: 300px;
    overflow-y: auto;
}

.builder-shop h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 0.5rem;
}

.builder-shop-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    margin-bottom: 0.3rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.3rem;
}

.builder-item-color {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    flex-shrink: 0;
}

.builder-item-info {
    flex: 1;
    min-width: 0;
}

.builder-item-name {
    font-size: 0.8rem;
    font-weight: bold;
}

.builder-item-desc {
    font-size: 0.65rem;
    opacity: 0.5;
}

#builder-coins {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #fbbf24;
}

#builder-placed-list h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.5;
    margin-bottom: 0.5rem;
}

.placed-building-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    margin-bottom: 0.25rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.3rem;
}

.placed-building-name {
    flex: 1;
    font-size: 0.8rem;
}

/* Storage Screen */
#storage-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: all;
}

#storage-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .builder-layout {
        flex-direction: column;
    }
    #planet-builder-canvas {
        width: 100%;
        height: 200px;
    }
}

/* Make discovered planet cards clickable */
.collection-card:not(.undiscovered) {
    cursor: pointer;
    pointer-events: all;
    transition: border-color 0.2s, transform 0.2s;
}

.collection-card:not(.undiscovered):hover {
    border-color: rgba(102, 126, 234, 0.5);
    transform: scale(1.03);
}

.builder-status {
    text-align: center;
    padding: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 0.4rem;
}

/* Fleet Screens */
#fleet-screen, #fleet-create-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 2.5rem 3rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    pointer-events: all;
}

#fleet-screen h2, #fleet-create-screen h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

#fleet-screen h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    opacity: 0.5;
    margin: 1rem 0 0.5rem;
    text-align: left;
}

.fleet-no-fleet {
    margin-bottom: 1.5rem;
}

.fleet-no-fleet p {
    opacity: 0.6;
    margin-bottom: 1rem;
}

.fleet-header-info {
    margin-bottom: 1rem;
}

.fleet-tag {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.fleet-name-display {
    font-size: 1.2rem;
    font-weight: bold;
}

.fleet-meta {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-top: 0.25rem;
}

.fleet-desc {
    font-size: 0.85rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.fleet-invite-section {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin: 1rem 0;
}

.fleet-invite-section input {
    flex: 1;
    padding: 0.4rem 0.75rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.85rem;
}

#fleet-invite-msg {
    font-size: 0.75rem;
    opacity: 0.7;
}

.fleet-members-list {
    text-align: left;
}

.fleet-member-row, .fleet-invite-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0.3rem;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.fleet-member-row span:first-child, .fleet-invite-row span:first-child {
    flex: 1;
}

/* Ranked Mode */
.ranked-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.75rem 1.5rem;
    border: 2px solid;
    border-radius: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    margin-top: 1rem;
}

.ranked-tier {
    font-size: 1.1rem;
    font-weight: bold;
}

.ranked-elo {
    font-size: 0.9rem;
    opacity: 0.8;
}

.ranked-record {
    font-size: 0.75rem;
    opacity: 0.5;
}

.ranked-result {
    font-weight: bold;
    font-size: 1rem;
}

#ranked-btn {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    border: none;
}

#ranked-btn:hover {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.4);
}

/* Planet Exploration HUD */
#explore-hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}
#explore-hud.hidden { display: none; }

#explore-top {
    position: absolute;
    top: 1rem;
    left: 1rem;
    right: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}
#explore-planet-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

#explore-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -120px);
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    border: 1px solid rgba(255,255,255,0.2);
}
#explore-label.hidden { display: none; }

#explore-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.55);
    font-size: 0.8rem;
    text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}

#explore-use-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -70px);
    background: rgba(102,126,234,0.85);
    color: #fff;
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}
#explore-use-prompt.hidden { display: none; }

#explore-emote-bar {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    gap: 0.4rem;
    pointer-events: auto;
}
#explore-emote-bar .emote-btn {
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    padding: 0;
}
#explore-emote-bar .emote-btn:hover { background: rgba(102,126,234,0.6); }

#explore-feed {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    width: 320px;
    max-width: 40vw;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    max-height: 180px;
    overflow-y: auto;
    font-size: 0.85rem;
    pointer-events: none;
}
#explore-feed .feed-line {
    background: rgba(0,0,0,0.45);
    border-radius: 0.4rem;
    padding: 0.2rem 0.5rem;
    color: #fff;
    align-self: flex-start;
    max-width: 100%;
    word-break: break-word;
}

/* Titles Screen */
#titles-screen {
    text-align: center;
    background: rgba(0, 0, 0, 0.9);
    padding: 2rem 2.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
#titles-screen h2 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}
#equipped-title-display {
    margin-bottom: 1rem;
    opacity: 0.85;
}
.titles-owned-count {
    font-weight: 600;
    opacity: 0.9;
    margin-bottom: 0.4rem;
}
.titles-cat-count {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.6;
    margin-left: 0.4rem;
}
/* The list is the only part that scrolls, so the header and Back button stay visible. */
#titles-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    text-align: left;
    margin-bottom: 1rem;
    padding-right: 0.25rem;
}
.titles-category {
    margin-bottom: 1rem;
}
.titles-category h3 {
    font-size: 1rem;
    opacity: 0.7;
    margin: 0.75rem 0 0.5rem;
    position: sticky;
    top: 0;
    background: rgba(0, 0, 0, 0.9);
    padding: 0.25rem 0;
}
.title-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.6rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 0.4rem;
}
.title-row.title-locked { opacity: 0.55; }
.title-name-display { font-weight: 600; min-width: 90px; }
.title-desc { flex: 1; font-size: 0.85rem; opacity: 0.75; }
.title-locked-text { font-size: 0.85rem; opacity: 0.7; }
