:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --button-gradient: linear-gradient(45deg, #11998e 0%, #38ef7d 100%);
    --bg-color: #1a1a2e;
    --text-color: #ffffff;
    --card-bg: rgba(255, 255, 255, 0.05);
    --input-bg: rgba(255, 255, 255, 0.1);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(100, 100, 255, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(200, 50, 255, 0.1) 0%, transparent 40%);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    overflow: hidden;
    /* Prevent scrolling */
    touch-action: none;
    /* Disable default touch actions (scrolling/zoom) */
}

.container {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--glass-border);
    padding: 1.5rem;
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 500px;
    width: 90%;
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    font-weight: 800;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: -1px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    margin-bottom: 25px;
}

input,
select {
    padding: 15px;
    border-radius: 12px;
    border: var(--glass-border);
    background: var(--input-bg);
    color: white;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.3s ease;
    font-family: inherit;
    outline: none;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

input:focus,
select:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 4px rgba(118, 75, 162, 0.2);
}

select {
    appearance: none;
    /* simple styling fix */
    cursor: pointer;
}

button {
    background: var(--button-gradient);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    width: 100%;
    transition: transform 0.2s, box-shadow 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(56, 239, 125, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(56, 239, 125, 0.4);
}

button:active {
    transform: translateY(0);
}

.join-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#lobby,
#game {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#game {
    position: relative;
}

#quitBtn {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(255, 100, 100, 0.2);
    color: rgba(255, 255, 255, 0.5);
    border: none;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#quitBtn:hover {
    background: rgba(255, 100, 100, 0.6);
    color: #fff;
}

#backBtn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

#backBtn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.hidden {
    display: none !important;
}

#join-only {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#join-only p {
    color: #ccc;
    font-size: 1.1rem;
    margin: 0;
}

#join-only strong {
    color: #38ef7d;
}

#join-only input {
    width: 100%;
}

#join-only button {
    width: 100%;
}


#info-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 0.5rem;
}

#spectatorInfo {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.4);
    padding: 6px 12px;
    border-radius: 12px;
    /* margin-bottom removal */
    color: #a8a8b3;
    font-size: 0.9rem;
    font-weight: 500;
}

#spectatorInfo svg {
    opacity: 0.8;
}

#status {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #e0e0e0;
}

#room-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 20px;
}

#currentRoomId {
    font-weight: bold;
    color: #e0e0e0;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

#currentRoomId:hover {
    color: #38ef7d;
}

#gameCanvas {
    background-color: #f8f9fa;
    /* Keep board light for contrast of ink */
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    cursor: crosshair;
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    /* Ensure it fits on mobile screens vertically */
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
        width: 95%;
    }

    h1 {
        font-size: 1.8rem;
    }

    #timers-container {
        font-size: 1rem;
    }

    button {
        padding: 12px 20px;
    }
}

#timers-container {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
}

.timer {
    font-family: 'Roboto Mono', monospace;
    padding: 8px 16px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
}

#message {
    margin-top: 15px;
    color: #ff6b6b;
    font-weight: bold;
    min-height: 24px;
}