:root {
    --primary: #ff4757;
    --primary-hover: #ff6b81;
    --secondary: #1e90ff;
    --bg-gradient: linear-gradient(135deg, #70a1ff 0%, #1e90ff 100%);
    --glass-bg: rgba(255, 255, 255, 0.2);
    --glass-border: rgba(255, 255, 255, 0.3);
    --text-dark: #2f3542;
    --text-light: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Open Sans', sans-serif;
}

body {
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-dark);
}

#app {
    width: 100%;
    max-width: 1000px;
    padding: 20px;
}

h1,
h2,
h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--text-dark);
}

.screen {
    display: none;
    width: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Glassmorphism */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    text-align: center;
}

/* Login */
#login-container .glass-panel {
    max-width: 400px;
    margin: 0 auto;
}

.logo {
    font-size: 3rem;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 5px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
    font-weight: 600;
}

/* Inputs & Buttons */
input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 15px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

input[type="text"]:focus {
    border-color: var(--primary);
    background: #fff;
}

.btn {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Fredoka One', cursive;
}

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 0 #cc3946;
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #cc3946;
}

.btn.primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #cc3946;
}

.btn.danger {
    background: #ff6b81;
    color: white;
    box-shadow: 0 4px 0 #c0392b;
}

.btn.small {
    padding: 8px 12px;
    font-size: 0.9rem;
    width: auto;
}

/* Lobby */
.lobby-panel {
    display: flex;
    flex-direction: column;
    padding: 30px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.lobby-header h2 {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#current-username {
    font-weight: bold;
    background: rgba(255, 255, 255, 0.3);
    padding: 5px 15px;
    border-radius: 20px;
    color: white;
}

.lobby-content {
    display: flex;
    gap: 20px;
    text-align: left;
}

@media (max-width: 768px) {
    .lobby-content {
        flex-direction: column;
    }
}

.rooms-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 20px;
}

.chat-section {
    flex: 1;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.rooms-section h3,
.chat-section h3 {
    margin-bottom: 15px;
    color: #2f3542;
}

.rooms-list {
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.room-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.room-info strong {
    display: block;
    font-size: 1.1rem;
    color: var(--primary);
}

.room-info span {
    font-size: 0.85rem;
    color: #747d8c;
}

#create-room-form {
    display: flex;
    gap: 10px;
}

#create-room-form .btn {
    width: auto;
    white-space: nowrap;
}

.chat-messages {
    flex-grow: 1;
    min-height: 200px;
    max-height: 250px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
}

.chat-msg {
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chat-msg strong {
    color: var(--primary);
}

#chat-form {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

#chat-form .btn {
    width: auto;
    padding: 8px 12px;
}

.online-users {
    font-size: 0.85rem;
    color: #57606f;
}

/* Game Screen */
#game-container {
    max-width: 800px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-radius: 12px 12px 0 0;
    padding: 15px 20px;
    border: 1px solid var(--glass-border);
    border-bottom: none;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-info .name {
    font-weight: bold;
    color: white;
    font-size: 1.1rem;
}

.player-info .score {
    background: white;
    color: var(--primary);
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    padding: 5px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.p1 .score {
    color: #ff4757;
}

.p2 .score {
    color: #1e90ff;
}

.game-status {
    font-weight: bold;
    color: white;
}

.canvas-container {
    background: #87CEEB;
    /* Sky blue */
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    border: 4px solid white;
    width: 100%;
    aspect-ratio: 4/3;
    /* Enforce game aspect ratio */
    max-height: 60vh;
    /* Don't grow larger than 60% of the screen height */
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.controls-hint {
    text-align: center;
    margin-top: 15px;
    color: white;
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.empty-state {
    text-align: center;
    color: #747d8c;
    font-style: italic;
    padding: 20px;
}