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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    height: 100vh;
    overflow: hidden;
}

/* Nickname Overlay */
.nickname-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.nickname-overlay.hidden {
    display: none;
}

/* Main Chat Container - Fullscreen */
.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
}

.screen {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.hidden {
    display: none;
}

/* Nickname Screen */
.nickname-form {
    padding: 60px 40px;
    text-align: center;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
}

.nickname-form h1 {
    color: #333;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 300;
}

.nickname-form p {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

#nickname-input {
    width: 100%;
    max-width: 300px;
    padding: 15px 20px;
    margin-bottom: 20px;
    border: 2px solid #e1e1e1;
    border-radius: 25px;
    font-size: 16px;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

#nickname-input:focus {
    border-color: #667eea;
}

#join-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

#join-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

#join-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.error {
    color: #e74c3c;
    margin-top: 10px;
    font-size: 14px;
}

.anonymous-option {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e1e1e1;
}

.join-anonymous-btn {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 300px;
}

.join-anonymous-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

.join-anonymous-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Chat Screen */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chat-header h1 {
    font-size: 1.8em;
    font-weight: 300;
}

.user-info {
    font-size: 14px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pinned-message {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-bottom: 2px solid #f39c12;
    padding: 12px 20px;
    animation: slideDown 0.3s ease-out;
}

.pinned-message.hidden {
    display: none;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.pinned-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #856404;
}

.pin-icon {
    font-size: 14px;
}

.pinned-label {
    font-weight: 600;
    flex: 1;
}

.pinned-timer {
    font-size: 11px;
    background: rgba(133, 100, 4, 0.1);
    padding: 2px 6px;
    border-radius: 10px;
}

.unpin-btn {
    background: none;
    border: none;
    color: #856404;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.unpin-btn:hover {
    background: rgba(133, 100, 4, 0.1);
}

.pinned-content {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    padding: 10px;
    border-left: 3px solid #f39c12;
}

.pinned-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.pinned-nickname {
    font-weight: 600;
    color: #667eea;
    font-size: 13px;
}

.pinned-time {
    font-size: 11px;
    color: #856404;
}

.pinned-message-text {
    color: #333;
    line-height: 1.4;
    margin-bottom: 6px;
    font-size: 14px;
}

.pinned-score {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #27ae60;
    font-weight: 600;
}

.login-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

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

.login-btn.hidden {
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 8px;
    padding: 8px 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    animation: fadeIn 0.3s ease-in;
}

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

@keyframes flashIn {
    0% { opacity: 0; transform: translateY(-10px); background-color: #fff3cd; }
    25% { opacity: 1; transform: translateY(0); background-color: #fff3cd; }
    50% { background-color: #ffeaa7; }
    75% { background-color: #fff3cd; }
    100% { opacity: 1; transform: translateY(0); background-color: white; }
}

.message.flash {
    animation: flashIn 1.2s ease-out;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3px;
}

.message-nickname {
    font-weight: 600;
    color: #667eea;
    font-size: 13px;
}

.message-time {
    font-size: 11px;
    color: #888;
}

.message-content {
    color: #333;
    line-height: 1.3;
    margin-bottom: 6px;
    font-size: 14px;
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.rating-btn, .reply-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 12px;
    transition: background-color 0.2s;
    font-size: 13px;
}

.rating-btn:hover:not(:disabled), .reply-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

.rating-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.reply-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.upvote {
    color: #27ae60;
}

.downvote {
    color: #e74c3c;
}

.reply-btn {
    color: #667eea;
}

.message-score {
    color: #666;
    font-weight: 500;
    min-width: 30px;
    text-align: center;
}

.message-score.positive {
    color: #27ae60;
}

.message-score.negative {
    color: #e74c3c;
}

.message-reply {
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    border-radius: 5px;
    padding: 6px 8px;
    margin-bottom: 6px;
    font-size: 11px;
}

.reply-header-msg {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.reply-icon-msg {
    color: #667eea;
    font-size: 11px;
}

.reply-to-msg {
    color: #667eea;
    font-weight: 600;
}

.reply-content-msg {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 300px;
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid #e1e1e1;
    flex-shrink: 0;
    position: relative;
}

.reply-preview {
    background: #f8f9fa;
    border: 1px solid #e1e1e1;
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.reply-preview.hidden {
    display: none;
}

.reply-content {
    padding: 12px;
}

.reply-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.reply-icon {
    color: #667eea;
    font-size: 16px;
    font-weight: bold;
}

.reply-to {
    font-size: 12px;
    color: #667eea;
    flex: 1;
}

.reply-cancel {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.reply-cancel:hover {
    background: #e1e1e1;
}

.reply-message {
    font-size: 13px;
    color: #666;
    background: white;
    padding: 8px 10px;
    border-radius: 6px;
    border-left: 3px solid #667eea;
    max-height: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.emoticon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s;
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoticon-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

.emoticon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.emoticon-picker {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    background: white;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    z-index: 1000;
    overflow: hidden;
}

.emoticon-picker.hidden {
    display: none;
}

.emoticon-categories {
    display: flex;
    border-bottom: 1px solid #e1e1e1;
    background: #f8f9fa;
}

.emoticon-category {
    background: none;
    border: none;
    padding: 12px 8px;
    cursor: pointer;
    font-size: 16px;
    flex: 1;
    transition: background 0.2s;
    border-radius: 0;
}

.emoticon-category:hover {
    background: #e9ecef;
}

.emoticon-category.active {
    background: #667eea;
    color: white;
}

.emoticon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.emoticon-item {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoticon-item:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

#message-input {
    flex: 1;
    padding: 12px 20px;
    border: 2px solid #e1e1e1;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

#message-input:focus:not(:disabled) {
    border-color: #667eea;
}

#message-input:disabled {
    background: #f5f5f5;
    color: #999;
}

#send-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

#send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

#send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.chat-info {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e1e1e1;
    text-align: center;
    flex-shrink: 0;
}

.chat-info p {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.system-message {
    text-align: center;
    color: #888;
    font-style: italic;
    font-size: 14px;
    margin: 10px 0;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 15px;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Responsive Design */
@media (max-width: 600px) {
    .nickname-form {
        padding: 40px 20px;
        margin: 20px;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-header h1 {
        font-size: 1.5em;
    }
    
    .user-info {
        flex-direction: column;
        gap: 5px;
        text-align: right;
    }
    
    .chat-messages {
        padding: 10px;
    }
    
    .message {
        padding: 6px 10px;
        margin-bottom: 6px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
    
    .emoticon-picker {
        left: 10px;
        right: 10px;
        max-height: 250px;
    }
    
    .emoticon-grid {
        grid-template-columns: repeat(6, 1fr);
        padding: 8px;
    }
    
    .emoticon-item {
        font-size: 18px;
        padding: 6px;
    }
    
    .emoticon-category {
        font-size: 14px;
        padding: 10px 6px;
    }
    
    .pinned-message {
        padding: 10px 15px;
    }
    
    .pinned-content {
        padding: 8px;
    }
    
    .pinned-message-text {
        font-size: 13px;
    }
    
    .pinned-header {
        font-size: 11px;
    }
}