* {
    box-sizing: border-box;
    touch-action: manipulation;
}

body {
    margin: 0;
    padding: 10px;
    font-family: Arial, sans-serif;
    background-color: #f0f0f0;
    -webkit-tap-highlight-color: transparent;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

h1 {
    text-align: center;
    color: #333;
    margin: 0;
    font-size: 1.5em;
}

.main-content {
    flex: 1;
    display: flex;
    gap: 15px;
    padding: 15px;
    min-height: 0;
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }
}

.drawing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.canvas-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.canvas-navigation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    padding: 8px 12px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: #5a6268;
}

.nav-btn:active {
    transform: scale(0.95);
}

.canvas-dots {
    display: flex;
    gap: 5px;
}

.canvas-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all 0.2s;
}

.canvas-dot.active {
    background: #007bff;
    transform: scale(1.2);
}

.canvas-dot:hover {
    transform: scale(1.1);
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    border: 2px solid #333;
    background: white;
    min-height: 0;
    border-radius: 5px;
    overflow: hidden;
}

#drawingCanvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
    touch-action: none;
}

.tools-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
}

.tool-btn {
    padding: 10px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    flex: 1;
    min-width: 60px;
    transition: all 0.2s;
    font-size: 12px;
}

.tool-btn:hover {
    background: #5a6268;
}

.tool-btn.active {
    background: #007bff;
    transform: scale(1.05);
}

.tool-btn:active {
    transform: scale(0.95);
}

.side-panel {
    width: 350px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-height: 0;
}

@media (max-width: 768px) {
    .side-panel {
        width: 100%;
        height: 300px;
    }
}

.users-panel, .chat-panel {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #dee2e6;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.panel-header h3 {
    margin: 0;
    flex: 1;
}

.user-list, .chat-messages {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    max-height: 200px;
}

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

.user-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.user-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.user-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.user-item {
    display: flex;
    align-items: center;
    margin: 8px 0;
    padding: 8px;
    border-radius: 5px;
    background: white;
    border-left: 4px solid;
    transition: all 0.2s;
}

.user-item:hover {
    background: #313131 !important
    transform: translateY(-1px);
}

.user-you {
    background: #e3f2fd;
    font-weight: bold;
}

.user-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    margin-right: 10px;
    border: 1px solid #ccc;
    flex-shrink: 0;
}

.highlight-user {
    background: #ffff99 !important;
}

.chat-message {
    margin: 8px 0;
    padding: 8px;
    background: white;
    border-radius: 5px;
    border-left: 3px solid;
    transition: all 0.2s;
}

.chat-message:hover {
    background: #f8f9fa !important;
}

.message-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.message-user {
    font-weight: bold;
}

.message-time {
    color: #999;
    font-size: 11px;
}

.chat-input-container {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.chat-input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: #007bff;
}

.send-btn {
    padding: 8px 12px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #0056b3;
}

.send-btn:active {
    transform: scale(0.95);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

button {
    padding: 10px 15px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    min-height: 44px;
    flex: 1;
    min-width: 80px;
    transition: all 0.2s;
}

button:hover {
    background: #0056b3;
}

button:active {
    transform: scale(0.95);
}

.save-btn {
    background: #28a745;
}

.save-btn:hover {
    background: #218838;
}

.eraser-active {
    background: #dc3545 !important;
}

.eraser-active:hover {
    background: #c82333 !important;
}

.brush-active {
    background: #17a2b8 !important;
}

.brush-active:hover {
    background: #138496 !important;
}

.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 8px;
}

.color-option {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.color-option.available:hover {
    transform: scale(1.2);
    border-color: #333;
}

.color-option.taken {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.color-option.taken::after {
    content: "✗";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #ff0000;
    font-weight: bold;
    font-size: 14px;
}

.color-option.active {
    border: 3px solid #000;
    transform: scale(1.3);
}

.color-option:active {
    transform: scale(1.1);
}

.name-input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin: 10px 0;
    width: 100%;
    box-sizing: border-box;
    font-size: 14px;
    transition: border-color 0.2s;
}

.name-input:focus {
    outline: none;
    border-color: #007bff;
}

.my-info {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border-left: 4px solid;
    transition: all 0.2s;
}

.my-info:hover {
    background: #313131 !important;
}

.drawing-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.screenshots-panel {
    padding: 15px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

.screenshots-panel h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.screenshot-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
    border-left: 4px solid #28a745;
    transition: all 0.2s;
}

.screenshot-item:hover {
    background: #f8f9fa !important;
    transform: translateX(3px);
}

.screenshot-info {
    flex: 1;
}

.screenshot-actions {
    display: flex;
    gap: 10px;
}

.screenshot-btn {
    padding: 5px 10px;
    background: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 12px;
    transition: all 0.2s;
}

.screenshot-btn:hover {
    background: #0056b3;
    text-decoration: none;
    color: white;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px;
    background: #28a745;
    color: white;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 300px;
    font-size: 14px;
}

.notification.error {
    background: #dc3545;
}

.notification.info {
    background: #17a2b8;
}

@keyframes slideIn {
    from { 
        transform: translateX(100%); 
        opacity: 0; 
    }
    to { 
        transform: translateX(0); 
        opacity: 1; 
    }
}

.shape-preview {
    position: absolute;
    pointer-events: none;
    border: 2px dashed #007bff;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        border-radius: 5px;
    }
    
    .header {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.2em;
    }
    
    .main-content {
        padding: 10px;
        gap: 10px;
    }
    
    .side-panel {
        gap: 10px;
    }
    
    .users-panel, .chat-panel {
        padding: 10px;
    }
    
    .tool-btn {
        font-size: 11px;
        padding: 8px 5px;
    }
    
    button {
        padding: 8px 10px;
        font-size: 12px;
        min-height: 40px;
    }
    
    .color-option {
        width: 25px;
        height: 25px;
    }
}

/* Темная тема */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }
    
    .container {
        background: #2d2d2d;
        box-shadow: 0 0 10px rgba(0,0,0,0.3);
    }
    
    .header {
        background: #3d3d3d;
        border-bottom-color: #4d4d4d;
    }
    
    h1 {
        color: #e0e0e0;
    }
    
    .users-panel, .chat-panel {
        background: #3d3d3d;
        border-color: #4d4d4d;
    }
    
    .user-item, .chat-message, .my-info {
        background: #2d2d2d;
    }
    
    .color-palette, .tools-panel {
        background: #3d3d3d;
    }
    
    .screenshots-panel {
        background: #3d3d3d;
        border-top-color: #4d4d4d;
    }
    
    .screenshot-item {
        background: #2d2d2d;
    }
    
    .name-input, .chat-input {
        background: #2d2d2d;
        border-color: #4d4d4d;
        color: #e0e0e0;
    }
    
    .name-input:focus, .chat-input:focus {
        border-color: #007bff;
    }
}

/* Анимации загрузки */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Улучшения доступности */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Фокус для клавиатурной навигации */
button:focus-visible,
.color-option:focus-visible,
.tool-btn:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Состояния disabled */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

button:disabled:hover {
    background: #007bff !important;
}