* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    min-height: 100vh;
    background-color: #1a1a2e;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    padding: 16px;
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

#game-area {
    flex: 1;
    display: flex;
    align-items: stretch;
    padding: 0 24px 24px;
    gap: 16px;
    min-height: 0;
}

.endpoint {
    width: 180px;
    flex-shrink: 0;
    border: 2px solid #3a3a5c;
    border-radius: 8px;
    background-color: #16213e;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px;
}

.endpoint h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #a0a0d0;
}

#network-canvas {
    flex: 1;
    min-width: 0;
    border: 1px solid #2a2a4a;
    border-radius: 8px;
    background-color: #0f1a2e;
}

.controls {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.param-label {
    font-size: 0.7rem;
    font-family: "Courier New", monospace;
    color: #a0a0d0;
    text-align: center;
}

.param-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.param-input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    border: 1px solid #3a3a5c;
    border-radius: 4px;
    background-color: #0f1a2e;
    color: #e0e0e0;
    font-size: 0.75rem;
    font-family: "Courier New", monospace;
    outline: none;
}

.param-input:focus {
    border-color: #6c63ff;
}

.scale-note {
    font-size: 0.6rem;
    color: #666;
    font-style: italic;
}

#speed-input {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    accent-color: #6c63ff;
}

#idle-start-input,
#lock-scale-input {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
    accent-color: #6c63ff;
}

#size-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    background-color: #0f1a2e;
    color: #e0e0e0;
    font-size: 0.875rem;
    outline: none;
}

#size-input:focus {
    border-color: #6c63ff;
}

#send-btn {
    padding: 8px 0;
    border: none;
    border-radius: 6px;
    background-color: #6c63ff;
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

#send-btn:hover:not(:disabled) {
    background-color: #5a52e0;
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-row {
    display: flex;
    gap: 6px;
}

#reset-btn, #fit-btn {
    flex: 1;
    padding: 8px 0;
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    background-color: transparent;
    color: #a0a0d0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

#reset-btn:hover, #fit-btn:hover {
    background-color: #1a1a3e;
    border-color: #6c63ff;
}

.log {
    flex: 1;
    width: 100%;
    margin-top: 16px;
    overflow-y: auto;
    min-height: 0;
    font-family: "Courier New", monospace;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    padding: 2px 0;
    line-height: 1.4;
}

.log-entry.ack { color: #6bcb77; }
.log-entry.data { color: #4d96ff; }
.log-entry.status { color: #888; font-style: italic; }

/* Send Buffer */
#send-buffer {
    width: 100%;
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    margin-top: 12px;
    padding: 8px;
    background-color: #0f1a2e;
}

#send-buffer h3 {
    margin: 0 0 6px;
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
}

#send-buffer h3 #buffer-count {
    color: #a0a0d0;
}

#buffer-entries {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 120px;
    overflow-y: auto;
}

.buffer-entry {
    font-family: "Courier New", monospace;
    font-size: 0.7rem;
    padding: 3px 6px;
    border-left: 3px solid #555;
    color: #888;
    border-radius: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.buffer-entry.queued {
    border-left-color: #555;
    color: #888;
}

.buffer-entry.in-flight {
    border-left-color: #4d96ff;
    color: #e0e0e0;
}

.buffer-entry.acked {
    border-left-color: #6bcb77;
    color: #6bcb77;
}
