* {
    box-sizing: border-box;
}

:root {
    --bg-color: #121212;
    --card-color: #1e1e1e;
    --text-color: white;
    --muted-text: #cccccc;
    --border-color: #333333;
    --primary-color: #00b894;
    --stranger-bg: #333333;
    --stranger-text: white;
    --input-bg: white;
    --input-text: black;
    --dark-button: #222222;
    --leave-button: #636e72;
    --report-button: #d63031;
}

body.light-mode {
    --bg-color: #f2f2f2;
    --card-color: #ffffff;
    --text-color: #111111;
    --muted-text: #555555;
    --border-color: #dddddd;
    --primary-color: #00a884;
    --stranger-bg: #e8e8e8;
    --stranger-text: #111111;
    --input-bg: #ffffff;
    --input-text: #111111;
    --dark-button: #444444;
    --leave-button: #777777;
    --report-button: #d63031;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px;
    overflow: hidden;
}

/* Home page */
.home {
    text-align: center;
    background: var(--card-color);
    padding: clamp(25px, 5vw, 45px);
    border-radius: 15px;
    width: clamp(300px, 90vw, 450px);
}

.home h1 {
    font-size: clamp(30px, 5vw, 42px);
    margin-bottom: 10px;
}

.home p {
    color: var(--muted-text);
    margin-bottom: 20px;
}

#onlineCount {
    color: var(--primary-color);
    font-weight: bold;
}

button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 18px;
    font-size: 16px;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    margin: 4px;
}

button:hover {
    transform: scale(1.03);
}

/* Toggle switch */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 62px;
    height: 34px;
    margin: 4px;
    flex-shrink: 0;
    vertical-align: middle;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: #9e9e9e;
    border-radius: 34px;
    transition: 0.3s;
}

.slider::before {
    content: "☀️";
    position: absolute;
    height: 26px;
    width: 26px;
    left: 4px;
    top: 4px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;

    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
}

.theme-switch input:checked + .slider {
    background-color: #222222;
}

.theme-switch input:checked + .slider::before {
    transform: translateX(28px);
    content: "🌙";
}

/* Chat page */
.chat-container {
    display: none;
    flex-direction: column;
    background: var(--card-color);
    width: clamp(320px, 92vw, 900px);
    height: min(760px, calc(100dvh - 24px));
    border-radius: 15px;
    overflow: hidden;
}

.chat-header {
    background: var(--primary-color);
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.chat-header h2 {
    margin: 0;
    font-size: clamp(18px, 3vw, 24px);
    color: white;
    white-space: nowrap;
}

.chat-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.chat-header button {
    padding: 9px 10px;
    font-size: 14px;
}

#reportBtn {
    background: var(--report-button);
}

#nextBtn {
    background: var(--dark-button);
}

#leaveBtn {
    background: var(--leave-button);
}

.status {
    padding: 8px 10px;
    text-align: center;
    color: var(--muted-text);
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    background: var(--card-color);
    flex-shrink: 0;
    font-size: 14px;
}

.messages {
    flex: 1;
    min-height: 0;
    padding: clamp(10px, 2vw, 18px);
    overflow-y: auto;
    overflow-x: hidden;

    display: flex;
    flex-direction: column;
}

.message {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 8px;
    max-width: min(85%, 650px);
    line-height: 1.4;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
}

.message:first-child {
    margin-top: auto;
}

.stranger {
    background: var(--stranger-bg);
    color: var(--stranger-text);
}

.you {
    background: var(--primary-color);
    color: white;
    margin-left: 0;
    margin-right: auto;
}

.image-message {
    padding: 8px;
}

.image-label {
    font-size: 13px;
    margin-bottom: 6px;
    opacity: 0.9;
}

.chat-photo {
    display: block;
    max-width: 260px;
    max-height: 260px;
    width: auto;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

/* Chat input */
.chat-input {
    display: flex;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--input-bg);
}

#photoBtn {
    border-radius: 0;
    background: var(--dark-button);
    padding: 12px 14px;
    margin: 0;
    font-size: 20px;
}

.chat-input input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 14px;
    border: none;
    outline: none;
    font-size: 16px;
    background: var(--input-bg);
    color: var(--input-text);
}

.chat-input button {
    border-radius: 0;
    margin: 0;
}

/* Confirm box */
.confirm-box {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 15px;
}

.confirm-content {
    background: var(--card-color);
    color: var(--text-color);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    width: min(300px, 100%);
}

.confirm-content h3 {
    margin-top: 0;
}

.confirm-content p {
    color: var(--muted-text);
}

#confirmActionBtn {
    background: var(--report-button);
    margin-right: 10px;
}

#cancelActionBtn {
    background: var(--primary-color);
}

/* Tablets */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .chat-container {
        width: 100%;
        height: calc(100dvh - 20px);
        border-radius: 12px;
    }

    .chat-header {
        justify-content: center;
    }

    .chat-header h2 {
        width: 100%;
        text-align: center;
    }

    .chat-actions {
        justify-content: center;
    }
}

/* Mobiles */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }

    .home {
        width: 100%;
        padding: 30px 20px;
    }

    .home h1 {
        font-size: 30px;
    }

    .chat-container {
        width: 100%;
        height: calc(100dvh - 16px);
        border-radius: 10px;
    }

    .chat-header {
        padding: 10px;
        gap: 8px;
    }

    .chat-header h2 {
        font-size: 20px;
    }

    .chat-actions {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .chat-header button {
        padding: 8px 10px;
        font-size: 13px;
    }

    .theme-switch {
        width: 52px;
        height: 28px;
    }

    .slider::before {
        height: 22px;
        width: 22px;
        left: 3px;
        top: 3px;
        font-size: 12px;
    }

    .theme-switch input:checked + .slider::before {
        transform: translateX(24px);
        content: "🌙";
    }

    .messages {
        padding: 10px;
    }

    .message {
        max-width: 90%;
        font-size: 14px;
    }

    .chat-photo {
        max-width: 220px;
        max-height: 220px;
    }

    #photoBtn {
        padding: 10px 12px;
        font-size: 18px;
    }

    .chat-input input[type="text"] {
        font-size: 14px;
        padding: 12px;
    }

    .chat-input button {
        padding: 12px;
        font-size: 14px;
    }
}

/* Very small mobiles */
@media (max-width: 360px) {
    .chat-header button {
        padding: 7px 9px;
        font-size: 12px;
    }

    .chat-actions {
        gap: 4px;
    }

    .home h1 {
        font-size: 26px;
    }

    .chat-photo {
        max-width: 190px;
        max-height: 190px;
    }
}
#audioCallBtn {
    background: #0984e3;
}