:root {
    --bg-color: #0b132b;
    --text-color: #E0E0E0;
    --accent-color: #5bc0be;
    --accent-glow: rgba(91, 192, 190, 0.4);
    --surface-color: #1c2541;
    --border-color: #3a506b;
    --error-color: #e63946;
}

body.light-theme {
    --bg-color: #ffffff;
    /* Soft white */
    --text-color: #111111;
    --accent-color: #ff9a9e;
    /* Pastel pink */
    --accent-glow: rgba(255, 154, 158, 0.4);
    --surface-color: #fcfcfc;
    --border-color: #e0e0e0;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 80px 0 40px 0;
}

/* Background Pattern */
.waves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at var(--mouse-x, 50%) var(--mouse-y, 50%), var(--accent-glow) 0%, transparent 25%),
        repeating-linear-gradient(45deg, var(--border-color) 0, var(--border-color) 1px, transparent 1px, transparent 40px),
        repeating-linear-gradient(-45deg, var(--border-color) 0, var(--border-color) 1px, transparent 1px, transparent 40px);
    background-position:
        0 0,
        calc(var(--mouse-x, 50%) / -20) calc(var(--mouse-y, 50%) / -20),
        calc(var(--mouse-x, 50%) / -20) calc(var(--mouse-y, 50%) / -20);
    opacity: 0.5;
    transition: background-color 0.3s ease;
}

/* Theme Switcher Wrapper */
.theme-switch-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 20;
}

.theme-label {
    font-size: 0.9rem;
    color: var(--text-color);
    font-weight: 600;
}

.theme-switch {
    display: inline-block;
    height: 24px;
    position: relative;
    width: 44px;
}

.theme-switch input {
    display: none;
}

.slider {
    background-color: var(--surface-color);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    background-color: var(--text-color);
    bottom: 4px;
    content: "";
    height: 16px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 16px;
}

input:checked+.slider {
    background-color: var(--accent-color);
}

input:checked+.slider:before {
    transform: translateX(20px);
    background-color: var(--bg-color);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.container {
    display: flex;
    gap: 40px;
    z-index: 10;
    max-width: 1000px;
    width: 90%;
    flex-wrap: wrap;
    justify-content: center;
}

/* Neumorphic Portal Cards */
.portal {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 30px;
    width: 400px;
    min-height: 350px;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.portal:hover {
    transform: translateY(-5px);
}

.portal-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    text-align: center;
    color: var(--accent-color);
}

.anonymous-hint {
    font-size: 0.85rem;
    color: #888;
    text-align: center;
    margin-bottom: 15px;
    font-style: italic;
}

/* Form Elements */
textarea {
    width: 100%;
    flex-grow: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 15px;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: none;
    margin-bottom: 10px;
    transition: border-color 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--accent-color);
}

textarea::placeholder {
    color: #666;
}

.character-count {
    text-align: right;
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 15px;
}

/* Buttons */
.neo-button {
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 0;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.neo-button:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.neo-button:active {
    background: var(--accent-glow);
    color: var(--text-color);
}

.neo-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    border-color: var(--border-color);
}

/* Display Area */
.message-display {
    flex-grow: 1;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow-y: auto;
    word-break: break-word;
    position: relative;
    /* For absolutely positioning the score */
}

/* Voting Controls */
.voting-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 10px;
}

.voting-controls.hidden {
    display: none;
}

.stars {
    display: flex;
    gap: 5px;
}

.star {
    font-size: 1.8rem;
    color: #444;
    /* Default dark color */
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.star:hover,
.star.active {
    color: #ffca28;
    /* Gold/yellow star */
    text-shadow: 0 0 10px rgba(255, 202, 40, 0.4);
}

.star:hover {
    transform: scale(1.2);
}

.thumb-down {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, filter 0.2s ease;
    filter: grayscale(100%);
}

.thumb-down:hover {
    transform: scale(1.2);
    filter: grayscale(0%);
}

/* Score Display */
.message-score {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 0.9rem;
    color: var(--accent-color);
    font-weight: bold;
    opacity: 0.7;
}

/* Top Echoes */
.top-echoes-container {
    margin-top: 40px;
    width: 100%;
}

.top-echoes {
    width: 840px;
    min-height: 200px;
    margin: 0 auto;
}

.top-messages-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    max-height: 400px;
    padding: 10px;
    /* Add padding all around to prevent shadow clipping */
}

.top-messages-list::-webkit-scrollbar {
    width: 6px;
}

.top-messages-list::-webkit-scrollbar-track {
    background: transparent;
    /* Changed from surface color to transparent */
}

.top-messages-list::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 10px;
}

.top-message-item {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 0;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Slightly more gap between text and score */
}

.top-message-text {
    font-size: 1rem;
    line-height: 1.4;
    word-break: break-word;
}

.top-message-score {
    font-size: 0.8rem;
    color: var(--accent-color);
    text-align: right;
    font-weight: 600;
}

.message-text {
    font-size: 1.2rem;
    line-height: 1.5;
    animation: fadeIn 1s ease-in-out;
}

.placeholder-text {
    color: #666;
    font-style: italic;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 15px 25px;
    border-radius: 0;
    border-left: 4px solid var(--error-color);
    font-weight: 600;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-left-color: var(--accent-color);
}

@media (max-width: 900px) {
    .container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
        padding-top: 40px;
        padding-bottom: 40px;
        max-height: 100vh;
        overflow-y: auto;
        justify-content: flex-start;
    }

    .portal,
    .top-echoes {
        width: 100%;
        max-width: 400px;
        min-height: 300px;
    }
}