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

:root {
    --primary: 23 10% 23%;
    --primary-light: 23 10% 35%;
    --text: 23 10% 15%;
    --text-secondary: 23 10% 50%;
    --bg: 0 0% 100%;
    --border: 0 0% 90%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background-color: hsl(var(--bg));
    color: hsl(var(--text));
    font-size: 14px;
}

.app-container { min-height: 100vh; display: flex; flex-direction: column; }

/* LANDING PAGE */
.landing-page { display: flex; flex-direction: column; min-height: 100vh; }

.top-header {
    background: white;
    border-bottom: 1px solid hsl(var(--border));
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.site-title {
    font-size: 24px;
    font-weight: 700;
    color: hsl(var(--primary));
    font-family: Georgia, serif;
    letter-spacing: -0.5px;
}

.top-nav ul {
    list-style: none;
    display: flex;
    gap: 32px;
}

.top-nav a {
    color: hsl(var(--text));
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: color 0.2s;
}

.top-nav a:hover {
    color: hsl(var(--primary));
}

.landing-main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 40px 20px;
}

.intro-section {
    text-align: center;
    margin-bottom: 60px;
}

.intro-section h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
    font-family: Georgia, serif;
    color: hsl(var(--primary));
}

.intro-section p {
    font-size: 14px;
    color: hsl(var(--text-secondary));
}

/* CATEGORIES */
.categories-section {
    margin-bottom: 60px;
}

.categories-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: hsl(var(--text));
}

.categories-wrapper {
    background: white;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    padding: 24px;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid hsl(var(--border));
    position: sticky;
    top: 0;
    background: white;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: hsl(var(--text));
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: hsl(var(--text-secondary));
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 4px;
}

.modal-close:hover {
    background: hsl(var(--border));
    color: hsl(var(--text));
}

.modal-puzzles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
    padding: 20px;
}

.categories-list {
    display: block;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
}

.category-item:hover {
    background: hsl(var(--border));
}

.cat-image {
    width: 100% !important;
    height: 100px !important;
    border-radius: 8px !important;
    margin-bottom: 8px !important;
}

.category-puzzles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.cat-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.cat-name {
    font-size: 14px;
    font-weight: 600;
    color: hsl(var(--text));
    margin-bottom: 0;
    text-align: left;
}

.cat-count {
    font-size: 12px;
    color: hsl(var(--text-secondary));
    text-align: right;
}

/* PUZZLES SECTION */
.puzzles-section {
    margin-bottom: 60px;
}

.puzzles-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: hsl(var(--text));
}

.puzzles-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 16px;
}

.puzzle-item {
    background: white;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.puzzle-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.puzzle-thumb {
    width: 100%;
    height: 120px;
}

.puzzle-title {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    color: hsl(var(--text));
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.puzzle-rating {
    padding: 0 12px 12px;
    font-size: 11px;
    color: hsl(var(--text-secondary));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.puzzle-count {
    font-size: 10px;
}

/* MULTIPLAYER SECTION */
.multiplayer-section {
    margin-bottom: 60px;
}

.multiplayer-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: hsl(var(--text));
}

.multiplayer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
}

.multiplayer-item {
    background: white;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.multiplayer-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.game-thumb {
    width: 100%;
    height: 140px;
}

.game-title {
    padding: 12px;
    font-size: 12px;
    font-weight: 600;
    color: hsl(var(--text));
}

.game-stat {
    padding: 0 12px 12px;
    font-size: 11px;
    color: hsl(var(--text-secondary));
}

.stat-sep {
    margin: 0 2px;
}

/* STATS */
.stats-section {
    margin-bottom: 60px;
    background: white;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    padding: 24px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 24px;
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: hsl(var(--primary));
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: hsl(var(--text-secondary));
}

/* AUTH SECTION */
.auth-section {
    margin-bottom: 40px;
}

.auth-box {
    max-width: 400px;
    margin: 0 auto;
    background: white;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    padding: 32px;
}

.auth-box h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    font-family: Georgia, serif;
}

.auth-box p {
    font-size: 12px;
    color: hsl(var(--text-secondary));
    margin-bottom: 24px;
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid hsl(var(--border));
}

.auth-tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    color: hsl(var(--text-secondary));
    cursor: pointer;
    font-weight: 600;
    font-size: 12px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.auth-tab.active {
    color: hsl(var(--primary));
    border-bottom-color: hsl(var(--primary));
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 12px;
    border: 1px solid hsl(var(--border));
    border-radius: 4px;
    font-size: 13px;
}

.auth-form input:focus {
    outline: none;
    border-color: hsl(var(--primary));
}

/* BUTTONS */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-primary {
    width: 100%;
    background: hsl(var(--primary));
    color: white;
}

.btn-primary:hover {
    background: hsl(var(--primary-light));
}

.btn-secondary {
    background: white;
    color: hsl(var(--primary));
    border: 1px solid hsl(var(--primary));
}

/* FOOTER */
.landing-footer {
    text-align: center;
    padding: 16px 20px;
    font-size: 12px;
    color: hsl(var(--text-secondary));
    border-top: 1px solid hsl(var(--border));
    background: white;
}

/* MAIN LAYOUT (LOGGED IN) */
.main-layout { display: flex; flex: 1; }
.sidebar { width: 240px; background: hsl(var(--primary)); color: white; padding: 20px; overflow-y: auto; }
.nav-header { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.logo-img { width: 28px; height: 28px; }
.nav-header h1 { font-size: 18px; }
.nav-section { margin-bottom: 24px; }
.nav-section h2 { font-size: 11px; text-transform: uppercase; opacity: 0.7; margin-bottom: 8px; }
.nav-link { display: block; padding: 8px 10px; color: rgba(255,255,255,0.8); text-decoration: none; border-radius: 4px; margin-bottom: 4px; transition: 0.2s; }
.nav-link:hover { background: rgba(255,255,255,0.1); }

.main-content { flex: 1; display: flex; flex-direction: column; }
.app-header { padding: 12px 20px; border-bottom: 1px solid hsl(var(--border)); display: flex; gap: 12px; }
.content-area { flex: 1; padding: 20px; overflow-y: auto; }
.rooms-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.room-card { background: white; border: 1px solid hsl(var(--border)); padding: 16px; border-radius: 4px; }

.chat-sidebar { width: 240px; background: hsl(var(--bg)); border-left: 1px solid hsl(var(--border)); padding: 16px; display: flex; flex-direction: column; }
.chat-messages { flex: 1; overflow-y: auto; margin-bottom: 12px; }
.chat-input-area { display: flex; gap: 8px; }
.chat-input-area input { flex: 1; padding: 8px; border: 1px solid hsl(var(--border)); border-radius: 4px; }

@media (max-width: 768px) {
    .top-nav { display: none; }
    .categories-list { grid-template-columns: repeat(4, 1fr); }
    .puzzles-list { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .sidebar { display: none; }
    .chat-sidebar { display: none; }
}
