:root {
    --primary-gold: #D4AF37;
    --primary-gold-rgb: 212, 175, 55;
    --bg-dark: #0f0f0f;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f0f0f0;
    --text-sub: #a0a0a0;

    /* Active Palette (Dynamic) */
    --active-primary: #D4AF37;
    --active-secondary: #F8F9FA;
    --active-accent: #2C3E50;
    --active-primary-rgb: 212, 175, 55;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Thai', 'Mitr', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

.background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 50% 50%, #1a1a1a 0%, #000 100%);
}

.background-animation::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://www.transparenttextures.com/patterns/dark-wood.png');
    /* Subtle texture */
    opacity: 0.1;
    mix-blend-mode: overlay;
}

.background-animation::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: radial-gradient(circle at center, var(--active-primary) 0%, transparent 50%);
    opacity: 0.08;
    animation: pulse 12s infinite alternate ease-in-out;
}

@keyframes pulse {
    0% {
        transform: translate(-25%, -25%) scale(1);
    }

    100% {
        transform: translate(-25%, -25%) scale(1.1);
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    padding: 4rem 0;
    animation: fadeInDown 1s ease-out;
}

.logo-text {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--active-primary);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    text-shadow: 0 0 20px rgba(var(--active-primary-rgb), 0.3);
}

.logo-text span {
    display: block;
    font-size: 1rem;
    color: var(--text-sub);
    letter-spacing: 5px;
}

.subtitle {
    color: var(--text-sub);
    font-weight: 300;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 4rem;
    font-size: 2rem;
    position: relative;
}

.section-title::after {
    content: '';
    display: block;
    width: 50px;
    height: 3px;
    background: var(--active-primary);
    margin: 10px auto;
}

/* Voting Grid */
.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.color-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1);
    cursor: pointer;
    backdrop-filter: blur(10px);
}

.color-card:hover {
    transform: translateY(-10px);
    border-color: var(--active-primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.color-card.selected {
    border: 2px solid var(--active-primary);
    background: rgba(var(--active-primary-rgb), 0.1);
}

.palette-preview {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.color-circle {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 3px solid var(--bg-dark);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    margin-right: -10px;
}

.color-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

/* Global Vote Button */
.global-vote-container {
    text-align: center;
    margin-bottom: 5rem;
    animation: fadeInUp 0.8s ease-out;
}

.main-vote-btn {
    background: var(--active-primary);
    color: #000;
    border: none;
    padding: 1.2rem 4rem;
    border-radius: 50px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(var(--active-primary-rgb), 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.main-vote-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 15px 40px rgba(var(--active-primary-rgb), 0.5);
}

.main-vote-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.main-vote-btn:disabled {
    background: var(--card-bg);
    color: var(--text-sub);
    cursor: not-allowed;
    box-shadow: none;
    border: 1px solid var(--glass-border);
}

/* Member ID Card */
.id-card-container {
    perspective: 1000px;
    margin-top: 2rem;
}

.id-card {
    max-width: 450px;
    margin: 0 auto;
    background: rgba(var(--active-primary-rgb), 0.05);
    border: 2px solid var(--active-primary);
    border-radius: 20px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: floating 3s ease-in-out infinite;
    backdrop-filter: blur(20px);
}

@keyframes floating {

    0%,
    100% {
        transform: translateY(0) rotateX(2deg);
    }

    50% {
        transform: translateY(-10px) rotateX(5deg);
    }
}

.card-glow {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at center, rgba(var(--active-primary-rgb), 0.15) 0%, transparent 60%);
    pointer-events: none;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.sect-symbol {
    font-size: 2.5rem;
    color: var(--active-primary);
    text-shadow: 0 0 10px rgba(var(--active-primary-rgb), 0.5);
}

.sect-info h3 {
    font-size: 1.5rem;
    color: var(--active-primary);
    margin-bottom: 0px;
}

.sect-info p {
    font-size: 0.75rem;
    color: var(--text-sub);
    letter-spacing: 2px;
    margin-top: -5px;
}

.card-body {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.profile-pic {
    width: 100px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.pic-placeholder {
    font-size: 3rem;
    opacity: 0.3;
}

.member-details {
    flex: 1;
}

.detail-row {
    margin-bottom: 0.8rem;
    display: flex;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.detail-row .label {
    color: var(--text-sub);
}

.detail-row .value {
    color: var(--active-primary);
    font-weight: 700;
}

.energy-bar-wrap {
    margin-top: 1rem;
}

.energy-bar-wrap .label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-sub);
    margin-bottom: 0.3rem;
}

.energy-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.energy-fill {
    height: 100%;
    width: 75%;
    background: linear-gradient(90deg, var(--active-primary), var(--active-accent));
    box-shadow: 0 0 10px rgba(var(--active-primary-rgb), 0.5);
    transition: all 0.5s ease;
}

.card-footer {
    margin-top: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 0.7rem;
    color: var(--text-sub);
}

.seal {
    border: 2px solid var(--active-primary);
    color: var(--active-primary);
    padding: 0.1rem 0.4rem;
    transform: rotate(-15deg);
    font-weight: 900;
    opacity: 0.5;
    text-transform: uppercase;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--active-primary);
    color: #000;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-weight: 700;
    z-index: 1000;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

footer {
    text-align: center;
    padding: 4rem;
    color: var(--text-sub);
    font-size: 0.8rem;
}

/* Modal Overlay */
.modal-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: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    max-width: 500px;
    width: 90%;
    padding: 3rem;
    border-radius: 30px;
    text-align: center;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-title {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: var(--active-primary);
}

.modal-desc {
    color: var(--text-sub);
    margin-bottom: 2rem;
}

#selected-name-display {
    color: var(--active-primary);
    font-weight: 700;
}

/* Input Styles */
.input-container {
    text-align: left;
    margin-bottom: 2rem;
}

.input-container label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-sub);
    margin-bottom: 0.5rem;
}

.input-container input {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 12px;
    color: #fff;
    outline: none;
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

.input-container input:focus {
    border-color: var(--active-primary);
}

.warning-text {
    font-size: 0.85rem;
    color: #ff4d4d;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 1rem;
}

.secondary-btn {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-sub);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.primary-btn {
    flex: 2;
    padding: 1rem;
    background: var(--active-primary);
    border: none;
    color: #000;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(var(--active-primary-rgb), 0.3);
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .logo-text {
        font-size: 2.2rem;
    }

    .container {
        padding: 1rem;
    }

    /* Make grid single column on small screens for easier tapping */
    .color-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .color-card {
        padding: 1.8rem;
        border-radius: 16px;
        min-height: 100px;
    }

    .palette-preview {
        margin-bottom: 1rem;
    }

    .color-circle {
        width: 60px;
        height: 60px;
        margin-right: -6px;
        border-width: 4px;
    }

    .color-card h3 {
        font-size: 1.25rem;
    }

    .main-vote-btn {
        width: 100%;
        padding: 1.2rem 1rem;
        font-size: 1.1rem;
        border-radius: 14px;
    }

    .id-card {
        max-width: 95%;
        padding: 1.5rem;
    }

    .card-body {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
    }

    .profile-pic {
        width: 80px;
        height: 80px;
    }

    footer {
        padding: 2rem;
    }

    /* Ensure modal content fits small screens */
    .modal-content {
        padding: 1.5rem;
        border-radius: 18px;
    }
}

/* Disable hover lift on touch devices to avoid accidental movement */
@media (hover: none) {
    .color-card:hover {
        transform: none;
    }
}

/* Slightly larger base font for readability on small screens */
@media (max-width: 420px) {
    body {
        font-size: 16px;
    }
}