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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Entry Page Layout */
#entry-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    gap: 20px;
}

#entry-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding-top: 20px;
}

#entry-right {
    width: 100%;
    background-color: #222;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    max-height: 300px;
}

#entry-right h2 {
    font-size: 18px;
    color: #888;
    margin-bottom: 15px;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

#public-chats-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.no-chats {
    color: #555;
    text-align: center;
    font-size: 14px;
    margin-top: 20px;
}

.public-chat-item {
    background-color: #2a2a2a;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.public-chat-item:hover {
    background-color: #333;
}

.public-chat-item .chat-name {
    font-weight: 600;
    color: #e0e0e0;
    font-size: 15px;
}

.public-chat-item .chat-users {
    color: #888;
    font-size: 13px;
    background-color: #1a1a1a;
    padding: 3px 8px;
    border-radius: 10px;
}

/* Visibility Page */
#visibility-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    gap: 20px;
}

#visibility-chat-code {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
}

.visibility-option {
    background-color: #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.toggle-label span:first-child {
    font-size: 16px;
    color: #e0e0e0;
}

.toggle-description {
    font-size: 13px;
    color: #888;
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #444;
    transition: 0.3s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: #e0e0e0;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4a9eff;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Common Styles */
h1 {
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 5px;
}

p {
    color: #888;
    font-size: 14px;
}

input {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    border: 1px solid #333;
    border-radius: 8px;
    background-color: #2a2a2a;
    color: #e0e0e0;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

input:focus {
    border-color: #666;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background-color: #3a3a3a;
    color: #e0e0e0;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: #4a4a4a;
}

button:active {
    background-color: #555;
}

.error-message {
    color: #ff6b6b;
    font-size: 14px;
    min-height: 20px;
}

#exit-chat-btn {
    padding: 4px 12px;
    font-size: 13px;
    background-color: #4a3030;
    color: #ff9999;
    border: 1px solid #663333;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

#exit-chat-btn:hover {
    background-color: #5a3838;
    color: #ffaaaa;
}

#exit-chat-btn:active {
    background-color: #3a2020;
}

/* Chat Page */
#chat-page {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

#chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background-color: #2a2a2a;
    border-bottom: 1px solid #333;
    gap: 10px;
    flex-shrink: 0;
}

#chat-code-header {
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#user-count {
    font-size: 13px;
    color: #888;
    flex-shrink: 0;
}

#messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    margin-top: auto;
}

.message {
    padding: 8px 12px;
    background-color: #2a2a2a;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
    flex-shrink: 0;
}

.message.own-message {
    align-self: flex-end;
    background-color: #2a3a5c;
    margin-left: auto;
}

.message:not(.own-message):not(.system) {
    align-self: flex-start;
    margin-right: auto;
}

.message.system {
    background-color: transparent;
    color: #666;
    font-size: 12px;
    text-align: center;
    max-width: 100%;
    align-self: center;
}

.message .username {
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 2px;
}

.message.own-message .username {
    color: #6bb5ff;
}

.message:not(.own-message):not(.system) .username {
    color: #4a9eff;
}

.message .text {
    font-size: 15px;
    color: #e0e0e0;
    line-height: 1.4;
}

.message .time {
    font-size: 10px;
    color: #666;
    margin-top: 2px;
}

#input-area {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    background-color: #2a2a2a;
    border-top: 1px solid #333;
    flex-shrink: 0;
}

#message-input {
    flex: 1;
    max-width: none;
}

#send-btn {
    white-space: nowrap;
    flex-shrink: 0;
}

#connection-status {
    text-align: center;
    padding: 3px;
    font-size: 11px;
    color: #666;
    background-color: #222;
    flex-shrink: 0;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    #entry-page {
        padding: 40px;
        align-items: center;
    }

    #entry-left {
        padding-top: 40px;
    }

    #entry-right {
        max-width: 500px;
        align-self: center;
    }
}