* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #EDE8E1;
    min-height: 100vh;
    color: #333;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container */
.container {
    max-width: 500px;
    width: 100%;
}

/* Typography */
h1 {
    color: white;
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #3D2F2F;
}

/* Card */
.card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    width: 100%;
}

.btn-primary {
    background: #8B6F47;
    color: white;
}

.btn-primary:hover {
    background: #6F5739;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 111, 71, 0.4);
}

.btn-secondary {
    background: #A68968;
    color: white;
}

.btn-secondary:hover {
    background: #8B6F47;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(166, 137, 104, 0.4);
}

.btn-link {
    background: #48bb78;
    color: white;
    width: auto;
    margin-left: 10px;
}

.btn-link:hover {
    background: #38a169;
}

/* Input */
input[type="text"],
input[type="url"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 15px;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="url"]:focus {
    outline: none;
    border-color: #8B6F47;
}

/* Room Code Display */
.room-code {
    font-size: 2rem;
    font-weight: bold;
    color: #8B6F47;
    letter-spacing: 0.3rem;
}

/* Loading Spinner */
.loading {
    text-align: center;
    padding: 20px 0;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #8B6F47;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

/* Debate Screen */
#debate-screen.active {
    display: block;
    padding: 0;
}

.debate-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: white;
}

.debate-header {
    background: linear-gradient(135deg, #8B6F47 0%, #A68968 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.room-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.room-info h2 {
    color: white;
    margin: 0;
    font-size: 1.2rem;
}

.user-count {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f7fafc;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 70%;
    word-wrap: break-word;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    background: #8B6F47;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.message.other {
    background: white;
    color: #333;
    border: 1px solid #e2e8f0;
    align-self: flex-start;
}

.message.system {
    background: #fef3c7;
    color: #92400e;
    align-self: center;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid #fbbf24;
    max-width: 90%;
}

.message.link {
    border-left: 4px solid #48bb78;
}

.message-header {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.85rem;
    opacity: 0.8;
}

.message-content {
    margin-bottom: 4px;
}

.message-link {
    color: #3182ce;
    text-decoration: underline;
    word-break: break-all;
}

.message.own .message-link {
    color: #bee3f8;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.6;
    margin-top: 4px;
}

/* Input Area */
.input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
}

.username-section {
    width: 100%;
}

#username-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.95rem;
    margin-bottom: 0;
    transition: all 0.3s ease;
}

.username-config-btn {
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.username-config-btn:hover {
    background: #f7fafc;
    border-color: #8B6F47;
}

.message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    padding: 8px 12px;
    transition: border-color 0.3s ease;
}

.message-input-wrapper:focus-within {
    border-color: #8B6F47;
}

#message-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    padding: 8px;
    line-height: 1.5;
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.btn-icon:hover {
    background: #f7fafc;
}

.btn-send {
    background: #8B6F47;
    color: white;
    border: none;
    border-radius: 18px;
    padding: 8px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-send:hover {
    background: #6F5739;
    transform: translateY(-1px);
}

.btn-send:active {
    transform: translateY(0);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions .btn {
    width: auto;
    flex: 1;
}

/* Responsive */
@media (max-width: 768px) {
    .input-area {
        flex-wrap: wrap;
    }
    
    .message {
        max-width: 85%;
    }
    
    .room-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Counters */
.counters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.observer-count {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Observer Chat Sidebar */
.observer-chat-sidebar {
    position: fixed;
    right: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.observer-chat-sidebar.open {
    right: 0;
}

.observer-chat-header {
    background: #8B6F47;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.observer-chat-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.close-chat-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.observer-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.observer-input {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid #e2e8f0;
}

.observer-input input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    font-size: 0.9rem;
}

.btn-send-small {
    background: #8B6F47;
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.3s ease;
}

.btn-send-small:hover {
    background: #6F5739;
}

.toggle-chat-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.toggle-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.observer-message {
    background: #f7fafc;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
}

.observer-message-username {
    font-weight: 600;
    color: #8B6F47;
    font-size: 0.85rem;
    margin-bottom: 2px;
}

/* Recent room styling */
.recent-room-text {
    color: #6A6A6A;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

/* Modern icon buttons */
.btn-icon svg,
.username-config-btn svg {
    display: block;
}

.btn-send svg {
    display: inline-block;
    vertical-align: middle;
}

/* Ongoing Debates */
.btn-link-style {
    background: transparent;
    color: #8B6F47;
    border: 2px solid #8B6F47;
}

.btn-link-style:hover {
    background: #8B6F47;
    color: white;
}

.btn-back {
    background: transparent;
    border: none;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 20px;
    padding: 10px;
    transition: opacity 0.3s ease;
}

.btn-back:hover {
    opacity: 0.8;
}

.debates-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.debate-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.debate-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

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

.debate-room-code {
    font-weight: 600;
    color: #8B6F47;
    font-size: 1.1rem;
}

.debate-live {
    background: #ef4444;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.debate-participants {
    color: #6A6A6A;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.debate-messages {
    color: #999;
    font-size: 0.85rem;
}
