html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#game {
    width: 100vw;
    height: 100vh;
}

#canvas {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#canvas:active {
    cursor: grabbing;
}

.notification {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    z-index: 1000;
}

.stats {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .stats {
        top: 5px;
        right: 5px;
        gap: 4px;
    }
    
    .completion {
        padding: 6px 12px;
        font-size: 14px;
    }
    
    .elapsed-time {
        padding: 6px 10px;
        font-size: 12px;
    }

    .active-players {
        padding: 6px 10px;
        font-size: 12px;
    }

    .player-color {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .color-indicator {
        width: 16px;
        height: 16px;
    }
    
    .notification {
        top: 60px;
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .round-status {
        padding: 20px 30px;
        font-size: 18px;
        max-width: 80%;
    }
}

@media (max-width: 480px) {
    .stats {
        flex-direction: row;
        top: auto;
        bottom: 10px;
        right: 10px;
        left: 10px;
        justify-content: space-between;
        align-items: center;
    }
    
    .completion {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .elapsed-time {
        font-size: 11px;
        padding: 4px 8px;
    }

    .active-players {
        font-size: 11px;
        padding: 4px 8px;
    }

    .player-color {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .color-indicator {
        width: 14px;
        height: 14px;
    }
    
    .notification {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .round-status {
        font-size: 16px;
        padding: 15px 20px;
    }
}

.completion {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 18px;
    font-weight: bold;
}

.elapsed-time {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.active-players {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

.player-color {
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    display: inline-block;
}

.round-status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 30px 50px;
    border-radius: 10px;
    font-family: Arial, sans-serif;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    z-index: 2000;
}

.hidden {
    display: none;
}

.zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.zoom-button {
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 24px;
    font-weight: bold;
    font-family: Arial, sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.zoom-button:hover {
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.zoom-button:active {
    background: rgba(50, 50, 50, 0.95);
    transform: scale(0.95);
}

@media (max-width: 480px) {
    .zoom-controls {
        bottom: 80px;
        right: 10px;
        gap: 6px;
    }

    .zoom-button {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }
}

.connection-status {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 152, 0, 0.95);
    color: white;
    padding: 8px 16px;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    z-index: 1500;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: pulse 1.5s ease-in-out infinite;
}

.connection-status.hidden {
    display: none !important;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
    animation: blink 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.tutorial {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(5px);
}

.tutorial.hidden {
    display: none !important;
}

.tutorial-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.tutorial-content h2 {
    margin: 0 0 20px 0;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 28px;
    text-align: center;
}

.tutorial-content h3 {
    margin: 15px 0 10px 0;
    color: #555;
    font-family: Arial, sans-serif;
    font-size: 18px;
}

.tutorial-section {
    margin-bottom: 20px;
}

.tutorial-section p {
    margin: 8px 0;
    color: #666;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.tutorial-section p strong {
    color: #333;
}

.tutorial-button {
    width: 100%;
    padding: 12px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: Arial, sans-serif;
    margin-top: 10px;
    transition: background 0.2s;
}

.tutorial-button:hover {
    background: #45a049;
}

.tutorial-button:active {
    background: #3d8b40;
}

@media (max-width: 768px) {
    .tutorial-content {
        padding: 20px;
        margin: 20px;
        max-width: 90%;
    }

    .tutorial-content h2 {
        font-size: 24px;
    }

    .tutorial-content h3 {
        font-size: 16px;
    }

    .tutorial-section p {
        font-size: 13px;
    }

    .connection-status {
        top: 60px;
        font-size: 12px;
        padding: 6px 12px;
    }
}

/* Chat Container - Top Left */
.chat-container {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 320px;
    max-height: 500px;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    z-index: 1500;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.chat-container.minimized {
    max-height: 45px;
}

.chat-container.minimized .chat-messages,
.chat-container.minimized .chat-input-container {
    display: none;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header h3 {
    margin: 0;
    color: white;
    font-family: Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
}

.chat-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    transition: opacity 0.2s;
}

.chat-toggle:hover {
    opacity: 0.7;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 200px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-message-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-username {
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: bold;
}

.chat-timestamp {
    font-family: Arial, sans-serif;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

.chat-message-text {
    font-family: Arial, sans-serif;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    word-wrap: break-word;
    line-height: 1.4;
}

.chat-input-container {
    display: flex;
    gap: 6px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 0 0 8px 8px;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 8px 10px;
    color: white;
    font-family: Arial, sans-serif;
    font-size: 13px;
    outline: none;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.chat-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.chat-send {
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-send:hover {
    background: #45a049;
}

.chat-send:active {
    background: #3d8b40;
}

/* Username Dialog */
.username-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
    backdrop-filter: blur(5px);
}

.username-dialog.hidden {
    display: none !important;
}

.username-dialog-content {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.username-dialog-content h2 {
    margin: 0 0 10px 0;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 24px;
    text-align: center;
}

.username-dialog-content p {
    margin: 0 0 20px 0;
    color: #666;
    font-family: Arial, sans-serif;
    font-size: 14px;
    text-align: center;
}

.username-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    box-sizing: border-box;
    margin-bottom: 15px;
    outline: none;
}

.username-input:focus {
    border-color: #4CAF50;
}

.username-dialog-buttons {
    display: flex;
    justify-content: center;
}

.username-submit {
    padding: 12px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    font-family: Arial, sans-serif;
    transition: background 0.2s;
}

.username-submit:hover {
    background: #45a049;
}

.username-submit:active {
    background: #3d8b40;
}

/* Color Picker Section */
.color-picker-section {
    margin: 15px 0 20px 0;
}

.color-picker-label {
    display: block;
    color: #666;
    font-family: Arial, sans-serif;
    font-size: 14px;
    margin-bottom: 10px;
    text-align: center;
}

.color-picker-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.color-picker {
    width: 80px;
    height: 40px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    outline: none;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

.color-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid #ddd;
    display: inline-block;
    background: #4CAF50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-container {
        width: 280px;
    }
}

@media (max-width: 480px) {
    .chat-container {
        width: calc(100% - 20px);
        left: 10px;
        right: 10px;
        top: 10px;
        bottom: auto;
        max-height: 250px;
    }

    /* Start minimized on mobile */
    .chat-container.mobile-default {
        max-height: 45px;
    }

    .chat-container.mobile-default .chat-messages,
    .chat-container.mobile-default .chat-input-container {
        display: none;
    }

    .chat-messages {
        max-height: 150px;
        min-height: 100px;
    }

    .chat-header h3 {
        font-size: 14px;
    }

    .chat-message-text,
    .chat-input,
    .chat-send {
        font-size: 12px;
    }
}