/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #1a1a2e;
    color: #eee;
    font-family: 'Segoe UI', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

.hidden {
    display: none !important;
}

/* --- Header --- */
#header {
    text-align: center;
    margin-bottom: 48px;
    position: relative;
}

#logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 8px;
}

.logo-chess {
    font-size: 3rem;
    color: #e2b96f;
}

.logo-text {
    font-size: 2.5rem;
    font-weight: bold;
    color: #e2b96f;
    letter-spacing: 4px;
}

#tagline {
    color: #888;
    font-size: 1rem;
    letter-spacing: 2px;
}

/* --- Campus --- */
#campus {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

/* --- Buildings / Mode Cards --- */
#buildings h2,
#lobby h2 {
    color: #e2b96f;
    font-size: 1rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 16px;
}

#mode-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.mode-card {
    background: #16213e;
    border: 2px solid #2a2a4a;
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-card:hover {
    border-color: #e2b96f;
    transform: translateY(-2px);
}

.mode-card.selected {
    border-color: #e2b96f;
    background: #1e2d4a;
}

.mode-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.mode-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #e2b96f;
    margin-bottom: 4px;
}

.mode-time {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 4px;
}

.mode-desc {
    font-size: 0.75rem;
    color: #666;
}

/* --- Action Buttons --- */
#actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.btn-primary {
    background: #e2b96f;
    color: #1a1a2e;
    border: none;
    padding: 14px 40px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 1px;
}

.btn-primary:hover {
    background: #f0cc88;
}

.btn-secondary {
    background: transparent;
    color: #e2b96f;
    border: 2px solid #e2b96f;
    padding: 14px 40px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e2b96f;
    color: #1a1a2e;
}

.btn-danger {
    background: transparent;
    color: #ff6b6b;
    border: 2px solid #ff6b6b;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: #ff6b6b;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: #666;
    border: 1px solid #333;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 12px;
}

.btn-ghost:hover {
    color: #aaa;
    border-color: #555;
}

/* --- Waiting State --- */
#waiting {
    text-align: center;
    padding: 40px;
    background: #16213e;
    border-radius: 12px;
    border: 2px solid #2a2a4a;
}

#waiting-spinner {
    font-size: 3rem;
    color: #e2b96f;
    animation: spin 2s linear infinite;
    display: inline-block;
    margin-bottom: 16px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

#waiting-text {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 12px;
}

#waiting-room-id {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 20px;
    font-family: monospace;
}

#waiting .btn-secondary {
    margin-right: 12px;
    padding: 10px 24px;
    font-size: 0.9rem;
}

/* --- Time Control Panel --- */
#time-control {
    background: #16213e;
    border: 2px solid #e2b96f;
    border-radius: 12px;
    padding: 24px;
    margin-top: 8px;
}

.tc-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.tc-row label {
    color: #e2b96f;
    font-size: 1rem;
    min-width: 140px;
}

.tc-row input[type="range"] {
    flex: 1;
    accent-color: #e2b96f;
    height: 6px;
    cursor: pointer;
}

.tc-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}


@media (max-width: 480px) {
    body {
        padding: 16px 12px;
    }

    .logo-text {
        font-size: 1.6rem;
        letter-spacing: 2px;
    }

    .logo-chess {
        font-size: 2rem;
    }

    #mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .mode-card {
        padding: 16px 10px;
    }

    .mode-name {
        font-size: 0.95rem;
    }

    #actions {
        flex-direction: column;
        gap: 10px;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        text-align: center;
        padding: 14px 20px;
    }

    .tc-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .tc-buttons button {
        width: 100%;
    }

    #waiting .btn-secondary,
    #waiting .btn-danger {
        width: 100%;
        margin: 6px 0;
    }
}

/* --- Lobby Room List --- */
#lobby {
    background: #16213e;
    border-radius: 12px;
    padding: 24px;
    border: 2px solid #2a2a4a;
}

#room-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 60px;
}

.room-list-empty {
    color: #555;
    font-size: 0.9rem;
    text-align: center;
    padding: 20px;
}

.room-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a2e;
    border-radius: 8px;
    padding: 12px 16px;
    border: 1px solid #2a2a4a;
    transition: border-color 0.2s;
}

.room-entry:hover {
    border-color: #e2b96f;
}

.room-entry-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.room-entry-mode {
    color: #e2b96f;
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.room-entry-id {
    color: #555;
    font-size: 0.8rem;
    font-family: monospace;
}

.btn-join {
    background: #e2b96f;
    color: #1a1a2e;
    border: none;
    padding: 6px 20px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-join:hover {
    background: #f0cc88;
}

/* --- Account corner --- */
#account-corner {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

#account-username {
    color: #e2b96f;
    font-weight: bold;
    margin-right: 4px;
}

/* --- Auth modal --- */
#auth-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

#auth-box {
    background: #16213e;
    border: 2px solid #e2b96f;
    border-radius: 16px;
    padding: 32px;
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    color: #888;
    border: 2px solid #2a2a4a;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.auth-tab.active {
    color: #e2b96f;
    border-color: #e2b96f;
}

#login-form, #register-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-box input {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-family: inherit;
}

#auth-box input:focus {
    outline: none;
    border-color: #e2b96f;
}

.auth-error {
    color: #ff6b6b;
    font-size: 0.8rem;
}

/* --- Hamburger menu button --- */
.menu-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    border: 1px solid #333;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: border-color 0.2s;
}

.menu-toggle:hover {
    border-color: #e2b96f;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #e2b96f;
}

/* --- Side menu panel --- */
#side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 400;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

#side-menu-box {
    background: #16213e;
    border-right: 2px solid #2a2a4a;
    width: 260px;
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
}

.menu-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 1.2rem;
    cursor: pointer;
}

.menu-close:hover {
    color: #e2b96f;
}

#side-menu-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 48px;
}

.menu-link {
    background: transparent;
    border: 1px solid #2a2a4a;
    color: #ccc;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
}

.menu-link:hover {
    border-color: #e2b96f;
    color: #e2b96f;
}

/* --- Content overlays (How to Play / About / Impressum) --- */
.content-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 450;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.content-box {
    background: #16213e;
    border: 2px solid #2a2a4a;
    border-radius: 16px;
    padding: 40px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.content-box h2 {
    color: #e2b96f;
    font-size: 1.6rem;
    margin-bottom: 16px;
}

.content-box h3 {
    color: #e2b96f;
    font-size: 1.1rem;
    margin: 0;
}

.content-box p {
    color: #ccc;
    line-height: 1.6;
    margin-bottom: 14px;
    font-size: 0.95rem;
}

.content-intro {
    color: #999;
    font-style: italic;
}

.content-outro {
    color: #999;
    font-size: 0.85rem;
    border-top: 1px solid #2a2a4a;
    padding-top: 14px;
}

.content-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 1.3rem;
    cursor: pointer;
}

.content-close:hover {
    color: #e2b96f;
}

.piece-guide {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
}

.piece-guide-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.piece-guide-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
}