:root {
    --msn-blue-light: #b1d6f0;
    --msn-blue-dark: #4287c8;
    --xp-blue: #0055ea;
    --xp-light: #6699ff;
    --xp-orange: #f28b29;
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.5);
    --danger-red: #d32f2f;
    --success-green: #28a745;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('bg.png') no-repeat center center fixed;
    background-size: cover;
}

#background-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('bg_grass.png') no-repeat center center fixed;
    background-size: cover;
    z-index: -1;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

#background-layer.show-game-bg {
    opacity: 1;
}

#app {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#chat-ui {
    width: 1100px;
    height: 800px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.6s ease;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.glass-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.2));
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-top: 1px solid rgba(255, 255, 255, 0.9);
    border-left: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.25);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.login-card {
    padding: 2rem;
    width: 320px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.logo-container {
    margin-bottom: 1rem;
    color: var(--msn-blue-dark);
}

.msn-logo {
    width: 80px;
}

h1 {
    color: var(--msn-blue-dark);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.input-group {
    margin-bottom: 1rem;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.8);
}

.file-label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9rem;
    color: #444;
    cursor: pointer;
    text-decoration: underline;
}

#pfp-preview-container {
    width: 60px;
    height: 60px;
    margin: 5px auto;
    border: 2px solid white;
    border-radius: 50%;
    overflow: hidden;
}

#pfp-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mode-selection {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
    justify-content: center;
}

.glossy-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 5px;
    background: linear-gradient(to bottom, #f0f0f0, #ccc);
    cursor: pointer;
    transition: all 0.2s;
}

.glossy-btn.active {
    background: linear-gradient(to bottom, var(--xp-light), var(--xp-blue));
    color: white;
}

.primary-btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 5px;
    background: linear-gradient(to bottom, var(--msn-blue-dark), #2a5a8a);
    color: white;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.primary-btn:hover {
    filter: brightness(1.1);
}

.danger-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background: linear-gradient(to bottom, #ef5350, #b71c1c);
    color: white;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.8rem;
}

.danger-btn:hover {
    filter: brightness(1.1);
}

.xp-header {
    height: 80px;
    background: linear-gradient(135deg, var(--xp-blue), var(--xp-light));
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.avatar-border {
    width: 54px;
    height: 54px;
    border: 2px solid white;
    border-radius: 4px;
    padding: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.avatar-border img {
    width: 100%;
    height: 100%;
    border-radius: 2px;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-size: 1.2rem;
    font-weight: bold;
}

.status-text {
    font-size: 0.8rem;
    opacity: 0.8;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-title {
    font-style: italic;
    font-weight: bold;
    opacity: 0.7;
    margin-right: 10px;
}

.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    background: rgba(235, 244, 250, 0.8);
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(255, 255, 255, 0.5);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 10px 15px;
    background: #ddeeff;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contact-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.contact-item:hover {
    background: rgba(255, 255, 255, 0.6);
}

.contact-item.active {
    background: linear-gradient(to right, rgba(100, 180, 255, 0.2), transparent);
    border-left: 4px solid var(--xp-blue);
}

.contact-item.general-room {
    font-weight: bold;
    color: var(--msn-blue-dark);
}

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.action-bar {
    height: 40px;
    background: #f5f6f7;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    transition: transform 0.2s;
}

.icon-btn:hover img {
    transform: scale(1.1);
}

.icon-btn:hover {
    background: #e0e0e0;
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    position: relative;
    font-size: 0.95rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.message.received {
    align-self: flex-start;
    background: #f0f0f0;
    border: 1px solid #e0e0e0;
}

.message.sent {
    align-self: flex-end;
    background: #e1ffc7;
    border: 1px solid #d0f0b0;
    flex-direction: row-reverse;
}

.message .msg-avatar {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.msg-body {
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

.sender-name {
    font-size: 0.75rem;
    color: #555;
    font-weight: bold;
    margin-bottom: 4px;
}

.msg-content {
    word-wrap: break-word;
    line-height: 1.4;
}

.message img.custom-emoji {
    height: 24px;
    vertical-align: middle;
}

.game-invite p {
    margin-bottom: 8px;
    font-weight: bold;
}

.game-invite button {
    background-color: var(--success-green) !important;
    color: white;
    font-weight: bold;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.game-invite button:hover {
    filter: brightness(1.1);
}

.input-area {
    min-height: 80px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid #ccddee;
}

.file-staging {
    background: #e8f0fe;
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #b1d6f0;
    font-size: 0.9em;
    display: flex;
    align-items: center;
}

#message-input {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 4px;
    resize: none;
    padding: 10px;
    font-size: 1rem;
    outline: none;
    min-height: 50px;
}

.input-controls {
    display: flex;
    gap: 10px;
}

.input-controls textarea {
    flex: 1;
}

#send-btn {
    width: 100px;
    background: var(--msn-blue-dark);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.game-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(240, 248, 255, 0.8));
    padding: 3rem;
    text-align: center;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 100px);
    grid-template-rows: repeat(3, 100px);
    gap: 10px;
    margin: 30px auto;
    transform: perspective(600px) rotateX(25deg);
    transform-style: preserve-3d;
}

.cell {
    width: 100px;
    height: 100px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.4));
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    color: var(--msn-blue-dark);
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.1), inset 2px 2px 5px rgba(255, 255, 255, 1);
    transition: transform 0.2s, background 0.2s;
}

.cell:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 8px 8px 20px rgba(0, 0, 0, 0.15);
}

.cell:active {
    transform: translateY(2px);
}

.call-card {
    width: 800px;
    padding: 20px;
}

.video-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
    height: 400px;
    background: black;
    border-radius: 8px;
    overflow: hidden;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#local-video {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 150px;
    height: 100px;
    border: 2px solid white;
    border-radius: 4px;
    object-fit: cover;
    background: #333;
}

.call-controls {
    display: flex;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

@media (max-width: 768px) {
    #chat-ui {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .sidebar {
        display: none;
    }

    .call-card {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .video-container {
        height: 70%;
    }
}

.hidden {
    display: none !important;
}