:root {
    --bg-color: #121212;
    --text-color: #ffffff;
    --accent-color: #ff9800;
    --input-bg: #1e1e1e;
    --header-bg: #1a1a1a;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

header {
    background-color: var(--header-bg);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    width: 100%;
    max-width: 800px;
}

h1 {
    color: var(--accent-color);
    margin-bottom: 20px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

select, input, button {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--accent-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 16px;
}

button {
    background-color: var(--accent-color);
    cursor: pointer;
    transition: opacity 0.3s;
    min-width: 100px;
}

button:hover {
    opacity: 0.8;
}

#clearButton {
    background-color: #f44336;
    border-color: #d32f2f;
}

#clearButton:hover {
    opacity: 0.8;
}

#customSize {
    display: none;
}

.grid-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 20px;
    max-width: 100%;
    overflow-x: auto;
}

.grid-row {
    display: flex;
    gap: 5px;
    justify-content: center;
}

.grid-cell {
    width: 40px;
    height: 40px;
    background-color: var(--input-bg);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    text-align: center;
    color: var(--text-color);
    font-size: 14px;
    text-transform: uppercase;
    font-weight: bold;
}

/* Discord Preview Container Styles */
.discord-preview-container {
    background-color: #2b2d31 !important;
    border: 1px solid #3f4248;
    border-radius: 8px;
    margin-top: 20px;
    width: 100%;
    max-width: 800px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    text-align: left;
}

.discord-preview-header {
    background-color: #1e1f22;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3f4248;
}

.discord-preview-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: bold;
    color: #f2f3f5;
    font-size: 15px;
}

.discord-preview-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.char-count {
    font-size: 13px;
    color: #949ba4;
    font-family: monospace;
}

.char-count.warning {
    color: #f0b232;
}

.char-count.danger {
    color: #f23f43;
    font-weight: bold;
}

button.discord-btn {
    background-color: #5865f2 !important;
    color: #ffffff !important;
    border: none !important;
    padding: 6px 14px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background-color 0.2s !important;
    min-width: auto !important;
}

button.discord-btn:hover {
    background-color: #4752c4 !important;
    opacity: 1 !important;
}

.discord-chat-box {
    background-color: #313338;
    padding: 16px;
    min-height: 120px;
    max-height: 500px;
    overflow-y: auto;
}

.discord-message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.discord-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #5865f2;
}

.discord-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.discord-message-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.discord-message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.discord-author {
    color: #f2f3f5;
    font-weight: 600;
    font-size: 15px;
}

.discord-bot-tag {
    background-color: #5865f2;
    color: #ffffff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 12px;
    text-transform: uppercase;
}

.discord-timestamp {
    color: #949ba4;
    font-size: 12px;
    margin-left: 4px;
}

.discord-message-content {
    color: #dbdee1;
    font-family: "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.discord-preview-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
}

.discord-spoiler {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 4px;
    border-radius: 4px;
    font-size: 18px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    box-sizing: border-box;
}

.discord-spoiler.spoiler-hidden {
    background-color: #2b2d31 !important;
    color: transparent !important;
    border: 1px solid #1e1f22 !important;
}

.discord-spoiler.spoiler-hidden:hover {
    background-color: #232428 !important;
    border-color: #35373c !important;
}

.discord-spoiler.spoiler-revealed {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #dbdee1 !important;
    border: 1px solid transparent !important;
}

.discord-preview-footer {
    background-color: #2b2d31;
    color: #949ba4;
    padding: 8px 16px;
    font-size: 12px;
    text-align: center;
    border-top: 1px solid #3f4248;
}

.output-container {
    background-color: var(--input-bg);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    position: relative;
    width: 100%;
    max-width: 800px;
    text-align: center;
}

#output {
    white-space: pre-wrap;
    word-break: break-all;
    margin-bottom: 10px;
    text-align: center;
    font-family: monospace;
}

.controls select {
    min-width: 120px;
}

#emojiSelect {
    min-width: 150px;
}

.copyright {
    color: var(--accent-color);
    margin-top: 20px;
    font-size: 14px;
    text-align: center;
}

@media (max-width: 600px) {
    .grid-cell {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .controls {
        flex-direction: column;
    }

    .discord-preview-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .discord-preview-actions {
        width: 100%;
        justify-content: space-between;
    }

    .discord-spoiler {
        min-width: 26px;
        height: 26px;
        font-size: 15px;
    }
}

.emoji-panel {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--input-bg);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 10px;
    z-index: 1000;
}

.emoji-panel.active {
    display: block;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.emoji-grid button {
    width: 40px;
    height: 40px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    border: 1px solid var(--accent-color);
    border-radius: 4px;
    transition: transform 0.2s;
}

.emoji-grid button:hover {
    background-color: var(--accent-color);
    transform: scale(1.1);
}

#emojiButton {
    background-color: var(--accent-color);
}

#emojiButton.active {
    background-color: var(--bg-color);
    border-color: var(--accent-color);
}

.error-message {
    color: #f44336;
    text-align: center;
    margin: 10px 0;
    font-weight: bold;
    min-height: 20px;
}
