:root {
    --bg-color: #111827;
    --surface-color: rgba(31, 41, 55, 0.5);
    --primary-color: #06b6d4;
    --font-color: #f9fafb;
    --font-secondary-color: #9ca3af;
    --border-color: rgba(107, 114, 128, 0.2);
    --danger-color: #f43f5e;
    --blur-effect: blur(5px);
    --font-family: 'Inter', 'Noto Sans SC', sans-serif;
    --bubble-theirs-bg: #374151;
    --bubble-mine-bg: var(--primary-color);
}

@property --p {
  syntax: '<angle>';
  inherits: false;
  initial-value: 360deg;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--font-color);
    line-height: 1.6;
}

body.fullscreen-active {
    overflow: hidden;
}


canvas#modern-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.2;
}

#app-container {
    height: 100%;
}

.view {
    height: 100%;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.view::-webkit-scrollbar {
    display: none;
}

.view.hidden {
    display: none;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.centered-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 20px;
}

.centered-container .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.card {
    background-color: var(--surface-color);
    padding: 2.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    text-align: center;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--font-secondary-color);
    margin-bottom: 2rem;
}

.form-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.form-section h2 {
    font-weight: 500;
    font-size: 1.25rem;
    margin-bottom: 1rem;
}

.description {
    color: var(--font-secondary-color);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: #1f2937;
    color: var(--font-color);
    font-size: 1rem;
    transition: all 0.2s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.3);
}

button {
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    width: 100%;
    transition: all 0.2s;
}

button:hover {
    filter: brightness(1.1);
}

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

.password-display {
    margin-top: 1rem;
    min-height: 2.5rem;
}

.loading-text {
    color: var(--font-secondary-color);
}

.password-container {
    margin-top: 1rem;
    padding: 1rem;
    background: #1f2937;
    border-radius: .5rem;
}

.password-box {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.password-text {
    flex-grow: 1;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--primary-color);
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.password-text.blurred {
    filter: var(--blur-effect);
}

.copy-button {
    width: auto;
    font-size: .875rem;
    padding: .5rem .75rem;
}

.error-text {
    color: var(--danger-color);
    margin-top: 1rem;
    min-height: 1.5rem;
    font-weight: 500;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    max-width: none;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(17, 24, 39, 0.8);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
    z-index: 15;
    justify-content: space-between;
}

.logo-small {
    font-size: 1.2rem;
    font-weight: 700;
    white-space: nowrap;
}

.room-info {
    color: var(--font-secondary-color);
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.countdown-timer {
    color: var(--font-secondary-color);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

#leave-room-btn {
    width: auto;
    padding: 0.25rem 0.75rem;
    background-color: #374151;
    font-size: 0.8rem;
}

#leave-room-btn:hover {
    background-color: var(--danger-color);
}

.chat-main {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    position: relative;
}

.user-list-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 250px;
    max-width: 70%;
    background-color: #1f2937;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    padding-top: 60px;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 20;
}

.user-list-panel.hidden {
    display: none;
}

.user-list-panel.open {
    transform: translateX(0);
}

.user-list-module {
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    font-size: 0.9rem;
}

.user-list-module::-webkit-scrollbar {
    display: none;
}

.user-list-module {
    scrollbar-width: none;
}

.creator-controls {
    flex-shrink: 0;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.creator-controls.hidden {
    display: none;
}

.user-category summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--font-color);
    padding: 0.25rem;
    list-style: none;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.user-category summary::-webkit-details-marker {
    display: none;
}

details.user-category > summary::before {
    content: '►';
    display: inline-block;
    transition: transform 0.2s ease-in-out;
    font-size: 0.7em;
    margin-right: 0.5rem;
    transform-origin: center;
}

details.user-category[open] > summary::before {
    transform: rotate(90deg);
}

.user-category ul {
    list-style: none;
    padding-left: 1rem;
    margin-top: 0.25rem;
}

.user-category li {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: 0.375rem;
    word-break: break-all;
    background-color: #374151;
    font-size: 0.85rem;
}

.user-category .empty-list {
    color: #6b7280;
    font-style: italic;
    background: none;
}

#user-list li.creator {
    color: var(--primary-color);
    font-weight: 700;
}

#user-list li.current-user {
    border-left: 3px solid var(--primary-color);
}

#temp-code-display .code-block {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background-color: #111827;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    text-align: left;
}

#temp-code-display p {
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
}

#temp-code-display strong {
    color: var(--font-color);
}

.blurred-text-hover {
    cursor: pointer;
    filter: var(--blur-effect);
    transition: filter 0.2s ease-in-out;
    user-select: none;
    background: #374151;
    padding: 0.1em 0.3em;
    border-radius: 4px;
}

.blurred-text-hover:hover,
.blurred-text-hover.revealed {
    filter: none;
}

#temp-code-display .copy-buttons {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

#temp-code-display button {
    flex-grow: 1;
    padding: 0.25rem;
    font-size: 0.75rem;
    background-color: #374151;
}

.message-panel {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

.messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column-reverse;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages::-webkit-scrollbar {
    display: none;
}

.message-bubble {
    position: relative;
    max-width: 85%;
    margin-bottom: 0.75rem;
    transition: opacity 0.3s, transform 0.3s;
    cursor: pointer;
    display: flex;
    align-self: flex-start;
}

.message-bubble-content {
    padding: 0.65rem 1rem;
    border-radius: 1.5rem;
    transition: filter 0.2s ease-in-out;
    filter: var(--blur-effect);
    position: relative;
    word-wrap: break-word;
    word-break: break-all;
}

.message-bubble.revealed .message-bubble-content {
    filter: none;
}

.message-bubble.mine {
    align-self: flex-end;
}


.message-bubble.theirs .message-bubble-content {
    background-color: var(--bubble-theirs-bg);
    border-bottom-left-radius: 0.5rem;
}

.message-bubble.mine .message-bubble-content {
    background-color: var(--bubble-mine-bg);
    color: #1f2937;
    border-bottom-right-radius: 0.5rem;
}

.message-bubble-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    height: 20px;
    width: 20px;
    background-repeat: no-repeat;
}

.message-bubble.theirs .message-bubble-content::after {
    left: -10px;
    background: radial-gradient(circle at 0 0, transparent, transparent 19px, var(--bubble-theirs-bg) 20px);
}

.message-bubble.mine .message-bubble-content::after {
    right: -10px;
    background: radial-gradient(circle at 100% 0, transparent, transparent 19px, var(--bubble-mine-bg) 20px);
}


.message-bubble.mine .message-sender {
    color: #1f2937;
}

.message-bubble.system {
    background: none;
    color: var(--font-secondary-color);
    font-style: italic;
    font-size: 0.875rem;
    align-self: center;
    cursor: default;
}

.message-sender {
    font-weight: 700;
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    color: var(--primary-color);
}

.message-timestamp {
    font-size: 0.7rem;
    color: var(--font-secondary-color);
    margin-left: 0.5rem;
    font-weight: 400;
}

.message-bubble.mine .message-timestamp {
    color: rgba(31, 41, 55, 0.7);
}


.message-content img.message-image {
    max-width: 250px;
    max-height: 250px;
    width: auto;
    height: auto;
    object-fit: cover;
    border-radius: 0.75rem;
    margin-top: 0.5rem;
    display: block;
    cursor: pointer;
}

.image-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.image-fullscreen-overlay.active {
    opacity: 1;
    visibility: visible;
}

.image-fullscreen-overlay img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

.fullscreen-close-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    line-height: 1;
    transition: opacity 0.2s;
}

.fullscreen-close-btn:hover {
    opacity: 0.8;
}

.message-countdown {
    position: absolute;
    top: -4px;
    width: 20px;
    height: 20px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.pie-timer {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(var(--font-secondary-color) var(--p), transparent 0);
    opacity: 0.8;
    transform: scaleX(-1);
    transition: --p 0.25s linear;
    position: relative;
}

.message-bubble.theirs .message-countdown {
    left: auto;
    right: -5px;
}

.message-bubble.mine .message-countdown {
    left: -5px;
}

.message-bubble.timer-active .message-countdown {
    opacity: 1;
}

.message-input-area {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    background-color: rgba(17, 24, 39, 0.8);
    transition: opacity 0.3s;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

.message-input-area.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

textarea#message-input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    background-color: #1f2937;
    color: var(--font-color);
    font-family: var(--font-family);
    font-size: 1rem;
    padding: 0.75rem;
    resize: none;
    overflow-y: hidden;
    max-height: 120px;
    line-height: 1.5;
    border-radius: 12px;
}

textarea#message-input::-webkit-scrollbar { display: none; }
textarea#message-input { scrollbar-width: none; }

textarea#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.icon-button {
    background-color: #374151;
    color: var(--font-secondary-color);
    border-radius: 12px;
    height: 48px;
    width: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.icon-button:hover {
    background-color: #4b5563;
    color: var(--font-color);
}

#send-button {
    background-color: var(--primary-color);
    color: white;
}

#send-button:hover {
    background-color: var(--primary-color);
    filter: brightness(1.1);
}

.icon-button svg {
    width: 1.25rem;
    height: 1.25rem;
}

.particle-container {
    position: fixed;
    width: 1px;
    height: 1px;
    pointer-events: none;
    z-index: 100;
}

.particle {
    position: absolute;
    width: var(--size);
    height: var(--size);
    background: var(--color);
    border-radius: 2px;
    animation-name: disintegrate;
    animation-duration: 1s;
    animation-fill-mode: forwards;
    animation-timing-function: ease-out;
}

@keyframes disintegrate {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: var(--transform-end);
    }
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 19;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-toggle {
    background: transparent;
    border-radius: 8px;
    border: none;
    color: var(--font-secondary-color);
    padding: 0.5rem;
    width: auto;
    z-index: 25;
    display: none;
    transition: background-color 0.2s, color 0.2s;
}

.menu-toggle:hover {
    background-color: #374151;
    color: var(--font-color);
}

@media (max-width: 480px) {
    .card {
        padding: 1.5rem;
    }

    .message-content img.message-image {
      max-width: 220px;
      max-height: 220px;
    }

    .message-bubble {
        max-width: 90%;
        margin-right: 0.5rem;
        margin-left: 0.5rem;
    }

    .message-input-area {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    textarea#message-input {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    .icon-button {
        height: 40px;
        width: 40px;
    }

    .icon-button svg {
        width: 1rem;
        height: 1rem;
    }

    .messages {
        padding: 1rem;
    }

    .chat-header {
        padding: 0.25rem 0.5rem;
    }

    .logo-small {
        font-size: 1rem;
        flex: 1;
        text-align: left;
    }

    .room-info {
        display: none;
    }

    #leave-room-btn {
        padding: 0.1rem 0.5rem;
        font-size: 0.7rem;
    }
}
