@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;700&family=Orbitron:wght@500;700&display=swap');

:root {
    --bg-1: #040914;
    --bg-2: #071a2c;
    --panel: rgba(9, 22, 38, 0.78);
    --panel-2: rgba(8, 19, 33, 0.92);
    --line: rgba(57, 217, 255, 0.28);
    --line-strong: rgba(57, 217, 255, 0.58);
    --text: #d9f7ff;
    --muted: #84b7c9;
    --cyan: #39d9ff;
    --green: #42ff87;
    --amber: #ffb347;
    --danger: #ff4f6f;
    --glow: 0 0 0 1px rgba(57, 217, 255, 0.24), 0 0 16px rgba(57, 217, 255, 0.2);
    --deep-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 24px;
    min-height: 100vh;
    display: flex;
    gap: 20px;
    color: var(--text);
    font-family: 'Chakra Petch', sans-serif;
    background:
        radial-gradient(1200px 600px at -10% -10%, rgba(66, 255, 135, 0.15), transparent 55%),
        radial-gradient(1100px 550px at 110% 0%, rgba(57, 217, 255, 0.18), transparent 52%),
        linear-gradient(150deg, var(--bg-1) 10%, #06152a 40%, var(--bg-2) 100%);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.14;
    background-image: linear-gradient(rgba(57, 217, 255, 0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(57, 217, 255, 0.3) 1px, transparent 1px);
    background-size: 42px 42px;
}

.main,
.sidebar {
    position: relative;
    z-index: 1;
    border-radius: 18px;
    background: linear-gradient(180deg, var(--panel), var(--panel-2));
    border: 1px solid var(--line);
    box-shadow: var(--deep-shadow), var(--glow);
    animation: panelEnter 420ms ease-out;
}

.main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.top-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.hud-cards {
    display: grid;
    grid-template-columns: repeat(4, minmax(80px, 1fr));
    gap: 10px;
    flex: 1;
}

.stat-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(7, 20, 34, 0.86);
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-card .label {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.stat-card .value {
    font-family: 'Orbitron', sans-serif;
    font-size: 13px;
    color: #dff8ff;
}

.command-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
}

.command-row input {
    margin-bottom: 0;
}

#clearSearchBtn,
#jumpLatestBtn {
    background: rgba(12, 45, 70, 0.85);
    color: #bfefff;
    border: 1px solid rgba(57, 217, 255, 0.35);
    box-shadow: none;
}

#clearSearchBtn:hover,
#jumpLatestBtn:hover {
    box-shadow: 0 0 14px rgba(57, 217, 255, 0.3);
}

.sidebar {
    width: 310px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

h3 {
    margin: 0 0 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--cyan);
    text-shadow: 0 0 12px rgba(57, 217, 255, 0.4);
}

#chatBox {
    flex-grow: 1;
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    border: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(3, 14, 24, 0.82), rgba(11, 62, 14, 0.9));
}

.chat-msg {
    background: rgba(8, 27, 45, 0.78);
    border: 1px solid rgba(57, 217, 255, 0.18);
    border-left: 4px solid var(--cyan);
    color: #d5f7ff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    word-break: break-word;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.chat-msg:hover {
    transform: translateX(2px);
    box-shadow: 0 0 14px rgba(57, 217, 255, 0.2);
}

.system-msg {
    background: rgba(5, 25, 20, 0.56);
    border: 1px dashed rgba(66, 255, 135, 0.42);
    color: #9efbc0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    text-align: center;
    font-style: italic;
}

.timestamp {
    float: right;
    margin-top: 2px;
    font-size: 11px;
    color: var(--muted);
}

input,
button {
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
    transition: all 0.2s ease;
}

input {
    width: 100%;
    margin-bottom: 8px;
    border: 1px solid var(--line);
    background: rgba(3, 14, 24, 0.95);
    color: var(--text);
    font-family: 'Chakra Petch', sans-serif;
}

input:focus {
    outline: none;
    border-color: var(--line-strong);
    box-shadow: 0 0 0 2px rgba(57, 217, 255, 0.2), 0 0 12px rgba(57, 217, 255, 0.24);
}

input:disabled {
    color: #6f93a5;
    background: rgba(5, 18, 31, 0.72);
}

button {
    border: 1px solid transparent;
    color: #02131f;
    font-family: 'Orbitron', sans-serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
}

button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#connectServerBtn,
#sendButton {
    background: linear-gradient(135deg, var(--cyan), #16b8ff);
    box-shadow: 0 0 12px rgba(57, 217, 255, 0.3);
}

#connectServerBtn { width: 100%; }

#connectServerBtn:hover,
#sendButton:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px rgba(57, 217, 255, 0.45);
}

.voice-panel,
.soundboard-grid,
.emoji-bar {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(6, 19, 31, 0.86);
}

.voice-panel {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#joinVoiceBtn {
    width: 100%;
    background: linear-gradient(135deg, var(--green), #00d37a);
    box-shadow: 0 0 12px rgba(66, 255, 135, 0.28);
}

#joinVoiceBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px rgba(66, 255, 135, 0.4);
}

.voice-actions {
    display: flex;
    gap: 8px;
}

.voice-actions button {
    flex: 1;
    font-size: 12px;
    padding: 10px;
}

#muteButton {
    color: #d2f6ff;
    background: rgba(16, 61, 88, 0.85);
    border-color: rgba(57, 217, 255, 0.35);
}

#muteButton.muted-active,
#leaveVoiceButton {
    color: #ffe7ec;
    background: rgba(152, 24, 48, 0.9);
    border-color: rgba(255, 79, 111, 0.45);
}

.emoji-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
}

.emoji-btn {
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    padding: 4px;
    font-size: 20px;
}

.emoji-btn:hover {
    background: rgba(57, 217, 255, 0.14);
}

.soundboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
}

.sound-btn {
    border-color: rgba(255, 179, 71, 0.42);
    background: linear-gradient(135deg, var(--amber), #ff9533);
    color: #231300;
    font-size: 12px;
    padding: 8px;
}

.sound-btn:hover {
    box-shadow: 0 0 14px rgba(255, 179, 71, 0.46);
}

ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

#channelsList li,
#userList li {
    padding: 9px 12px;
    margin-bottom: 6px;
    border-radius: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#channelsList li {
    background: rgba(6, 17, 30, 0.7);
    color: #91d5ea;
    border: 1px solid transparent;
}

#channelsList li.channel-item.active {
    color: #f4fcff;
    border-color: var(--line-strong);
    background: rgba(17, 56, 85, 0.82);
    box-shadow: 0 0 14px rgba(57, 217, 255, 0.2);
}

#channelsList li:hover {
    color: #dcf9ff;
    border-color: var(--line-strong);
    background: rgba(12, 38, 61, 0.72);
}

#channelsList li::before {
    content: '#';
    color: var(--cyan);
    font-weight: 700;
    width: 10px;
}

#userList li {
    border: 1px solid rgba(66, 255, 135, 0.28);
    background: rgba(5, 25, 20, 0.62);
    color: #bdf8d4;
}

#userList li::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px rgba(66, 255, 135, 0.75);
}

.logo-container {
    text-align: center;
    margin-bottom: 5px;
}

.logo-img {
    max-width: 220px;
    height: auto;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 0 12px rgba(57, 217, 255, 0.3));
}

.chat-input-row {
    display: flex;
    gap: 12px;
    width: 100%;
}

.chat-input-row input { margin-bottom: 0; }

#sendButton { width: 110px; }

.main.state-connecting {
    border-color: rgba(255, 179, 71, 0.45);
}

.main.state-live {
    border-color: rgba(66, 255, 135, 0.45);
}

.main.state-reconnecting {
    border-color: rgba(255, 79, 111, 0.45);
}

.typing-indicator-area {
    color: #9bdcf0;
}

.message-mention {
    color: #42ff87;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(66, 255, 135, 0.42);
}

.reaction-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.reaction-chip,
.reaction-quick-btn {
    border: 1px solid rgba(57, 217, 255, 0.28);
    border-radius: 999px;
    padding: 2px 8px;
    font-family: 'Chakra Petch', sans-serif;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
}

.reaction-chip {
    color: #c8f5ff;
    background: rgba(6, 34, 56, 0.78);
}

.reaction-chip.active {
    color: #032015;
    border-color: rgba(66, 255, 135, 0.65);
    background: linear-gradient(135deg, rgba(66, 255, 135, 0.95), rgba(31, 224, 118, 0.95));
}

.reaction-quick-btn {
    color: #95e3ff;
    background: rgba(9, 22, 36, 0.8);
    border-style: dashed;
}

.reaction-chip:hover,
.reaction-quick-btn:hover {
    border-color: rgba(57, 217, 255, 0.58);
    box-shadow: 0 0 10px rgba(57, 217, 255, 0.28);
}

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

@media (max-width: 980px) {
    body {
        padding: 14px;
        gap: 14px;
        flex-direction: column;
    }

    .sidebar,
    .main {
        width: 100%;
    }

    .sidebar {
        order: 2;
        max-height: 40vh;
    }

    .main {
        order: 1;
        min-height: 56vh;
    }

    .top-hud {
        flex-direction: column;
        align-items: stretch;
    }

    .hud-cards {
        grid-template-columns: repeat(2, minmax(80px, 1fr));
    }

    .command-row {
        grid-template-columns: 1fr 1fr;
    }

    .command-row input {
        grid-column: 1 / -1;
    }
}
