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

body {
    font-family: 'Arial', 'Noto Sans Devanagari', sans-serif;
    background: #e0e0e0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    min-height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
    padding: 20px;
}

.screen.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

/* Splash Screen */
#splash-screen {
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 50%, #ffa500 100%);
    justify-content: center;
    align-items: center;
    gap: 30px;
}

.splash-container {
    text-align: center;
    animation: fadeIn 0.8s ease-in;
}

.splash-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
}

.splash-title {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: slideDown 1s ease-out;
}

.splash-subtitle {
    font-size: 1.5rem;
    color: #f0f0f0;
    margin-bottom: 30px;
    animation: slideDown 1.2s ease-out;
}

.next-button {
    padding: 15px 50px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    animation: slideUp 1.4s ease-out;
}

.next-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    background: linear-gradient(135deg, #ff5252, #e53935);
}

.next-button:active {
    transform: translateY(-1px);
}

/* Voting Screen */
#voting-screen {
    background: #e0e0e0;
    padding: 10px;
    overflow-y: auto;
    gap: 20px;
    overflow-y: scroll;
    scrollbar-width: thin;
    scrollbar-track-color: transparent;
    -webkit-overflow-scrolling: touch;
    
}

/* EVM Machine Container */
.evm-machine {
    min-width: 400px;
    width: 100%;
    max-width: 1200px;
    background: #ffffff;
    border: 3px solid #333;
    border-radius: 5px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    
}

/* EVM Header */
.evm-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 20px;
    background: #f8f8f8;
    border-bottom: 2px solid #ddd;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: flex-start;
}

.ready-logo {
    color: #4caf50;
    font-size: 1rem;
    font-weight: bold;
}

.ready-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ready-dot {
    width: 12px;
    height: 12px;
    background: #000;
    border-radius: 50%;
}

.ready-text {
    font-size: 0.9rem;
    font-weight: bold;
    color: #000;
}

.unit-number {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}

.header-center {
    flex: 1;
    text-align: center;
    padding: 0 20px;
}

.commission-name {
    font-size:1.3rem;
    font-weight: bold;
    color: #000;
    
    
}

.commission-subname {
    font-size: 0.5rem; /* Smaller font to fit horizontally */
}

.election-details {
    font-size: 0.9rem;
    color: #333;
}

.header-right {
    text-align: right;
}

.ballot-unit-label {
    font-size: 1rem;
    font-weight: bold;
    color: #000;
}

/* EVM Body - Ballot and Buttons Layout */
.evm-body {
    display: flex;
    min-height: 600px;
    width: 100%;
}

/* Ballot Paper Section (Full Width with Integrated Buttons) */
.ballot-section {
    width: 100%;
    background: #ffffff;
    padding: 0;
    overflow-x: auto;
}

.ballot-header {
    display: grid;
    grid-template-columns: 70px 1fr 140px 60px 90px 30px;
    background: #f0f0f0;
    border-bottom: 2px solid #ccc;
    font-weight: bold;
    font-size: 1rem;
    padding: 15px 20px;
    color: #000;
    align-items: center;
    gap: 10px;
}

.ballot-header .col-serial {
    padding-left: 16px;
    font-weight: bold; /* Keep header label bold for clarity */
}

.ballot-header .col-name {
    text-align: left;
    padding-left: 15px;
}

.ballot-header .col-symbol {
    text-align: center;
}

.ballot-header .col-arrow,
.ballot-header .col-button,
.ballot-header .col-braille {
    text-align: center;
}

.ballot-rows {
    display: flex;
    flex-direction: column;
}

.candidate-row-ballot {
    display: grid;
    grid-template-columns: 70px 1fr 140px 60px 90px 30px;
    border-bottom: 1px solid #e0e0e0;
    padding: 18px 20px;
    align-items: center;
    transition: background-color 0.2s;
    min-height: 80px;
    gap: 10px;
}

.candidate-row-ballot:hover {
    background-color: #f9f9f9;
}

.candidate-row-ballot.selected {
    background-color: #e3f2fd;
}

.ballot-serial {
    text-align: center;
    padding-left: 10px; /* Moves it inward from the left edge */
    font-size: 1.2rem;
    font-weight: normal; /* Removes the bold styling */
    color: #000;
}

.ballot-name {
    text-align: left;
    font-size: 1.25rem;
    color: #000;
    padding-left: 15px;
    display: flex;
    align-items: center;
    line-height: 1.4;
    word-wrap: break-word;
}

.candidate-name {
    display: inline-block;
    width: 75%;
}

.ballot-name.selected-name .candidate-name {
    font-size: 1.4rem;
    font-weight: bold;
    color: #1976d2;
}

.ballot-symbol {
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
}

.symbol-image {
    width: 70px;
    height: 70px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Arrow and Button within Ballot Row */
.row-arrow-button {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.arrow-indicator-inline {
    font-size: 2.5rem;
    color: #e74c3c;
    font-weight: 900;
    display: inline-block;
    line-height: 1;
    text-shadow: 
        -2px 0 0 #e74c3c,
        2px 0 0 #e74c3c,
        0 -2px 0 #e74c3c,
        0 2px 0 #e74c3c,
        -1px -1px 0 #e74c3c,
        1px -1px 0 #e74c3c,
        -1px 1px 0 #e74c3c,
        1px 1px 0 #e74c3c;
    transition: all 0.2s ease;
}

/* Red Blink Animation for Inline Arrow */
.arrow-indicator-inline.blinking {
    animation: arrowBlinkInline 0.5s ease-in-out;
}

@keyframes arrowBlinkInline {
    0% {
        color: #e74c3c;
        text-shadow: 
            -2px 0 0 #e74c3c,
            2px 0 0 #e74c3c,
            0 -2px 0 #e74c3c,
            0 2px 0 #e74c3c,
            -1px -1px 0 #e74c3c,
            1px -1px 0 #e74c3c,
            -1px 1px 0 #e74c3c,
            1px 1px 0 #e74c3c,
            0 0 20px rgba(231, 76, 60, 0.6);
    }
    50% {
        color: #ff0000;
        text-shadow: 
            -3px 0 0 #ff0000,
            3px 0 0 #ff0000,
            0 -3px 0 #ff0000,
            0 3px 0 #ff0000,
            -2px -2px 0 #ff0000,
            2px -2px 0 #ff0000,
            -2px 2px 0 #ff0000,
            2px 2px 0 #ff0000,
            0 0 40px rgba(255, 0, 0, 1),
            0 0 60px rgba(255, 0, 0, 0.8),
            0 0 80px rgba(255, 0, 0, 0.6);
    }
    100% {
        color: #e74c3c;
        text-shadow: 
            -2px 0 0 #e74c3c,
            2px 0 0 #e74c3c,
            0 -2px 0 #e74c3c,
            0 2px 0 #e74c3c,
            -1px -1px 0 #e74c3c,
            1px -1px 0 #e74c3c,
            -1px 1px 0 #e74c3c,
            1px 1px 0 #e74c3c,
            0 0 20px rgba(231, 76, 60, 0.6);
    }
}


/* Vote Button - Blue, Oval, Recessed */
.vote-button {
    width: 75px;
    height: 45px;
    padding: 0;
    font-size: 0;
    border: none;
    background: #1976d2;
    border-radius: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 
        inset 0 3px 8px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    flex-shrink: 0;
}

.vote-button::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    height: 40%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    border-radius: 25px 25px 0 0;
}

.vote-button:hover:not(:disabled) {
    background: #1565c0;
    box-shadow: 
        inset 0 3px 8px rgba(0, 0, 0, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2),
        0 3px 6px rgba(0, 0, 0, 0.2);
}

.vote-button:active:not(:disabled) {
    box-shadow: 
        inset 0 4px 10px rgba(0, 0, 0, 0.4),
        inset 0 -3px 6px rgba(0, 0, 0, 0.3);
    transform: translateY(1px);
}

.vote-button.active {
    background: #1976d2;
}

.vote-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;

    background: #90a4ae;
    pointer-events: none;
}

/* Braille Dots */
.braille-dots {
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.braille-dot {
    width: 5px;
    height: 5px;
    background: #666;
    border-radius: 50%;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 50px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 5px solid #1976d2;
    animation: scaleIn 0.4s ease-out;
    max-width: 500px;
}

.success-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, #27ae60, #229954);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    color: #fff;
    margin: 0 auto 20px;
    animation: bounceIn 0.6s ease-out;
    box-shadow: 0 10px 30px rgba(39, 174, 96, 0.5);
}

.modal-title {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.modal-message {
    font-size: 1.3rem;
    color: #34495e;
    margin-bottom: 30px;
    line-height: 1.6;
}

/* Mobile Responsive for Modal */
@media (max-width: 768px) {
    /* Ensure the header stays within screen bounds */
    .evm-header {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 8px 10px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Shrink the center text to fit the mobile width */
    .commission-name {
        font-size: 0.8rem; /* Smaller size to prevent overflow */
        line-height: 1.2;
        text-align: center;
        white-space: normal; /* Allows wrapping if necessary */

    }

    .commission-subname {
        font-size: 0.5rem; /* Smaller font to fit horizontally */
    }

    /* Scale down the 'Ready' and 'Ballot Unit' icons */
    .header-left, .header-right {
        transform: scale(0.85);
        transform-origin: center;
    }
    
    /* Ensure the machine container doesn't force a horizontal scroll on small screens */
    .evm-machine {
        min-width: unset; 
        width: 100%;
        overflow-x: hidden;
    }
}

.modal-button {
    padding: 15px 50px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    background: linear-gradient(135deg, #3498db, #2980b9);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes scaleIn {
    from {
        transform: scale(0.5);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .ballot-header,
    .candidate-row-ballot {
        /* Adjusted to give '1fr' more priority */
        grid-template-columns: 60px 1.5fr 120px 50px 80px 25px;
        gap: 8px;
        padding: 15px 10px;
    }
    
    .arrow-indicator-inline {
        font-size: 2rem;
    }
    
    .vote-button {
        width: 70px;
        height: 40px;
    }
}

@media (max-width: 768px) {
    /* Prevent the header from stacking so it stays horizontal */
    .evm-header {
        flex-direction: row; 
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        padding: 10px;
    }

    .header-center {
        padding: 4px;
    }

    .commission-name {
        font-size: 0.9rem; /* Smaller font to fit horizontally */
    }

    .commission-subname {
        font-size: 0.5rem; /* Smaller font to fit horizontally */
    }

    /* Critical: Change grid columns to allow Name to stay horizontal */
    .ballot-header,
.candidate-row-ballot {
    grid-template-columns: 40px 1fr 75px 25px 10px 5px;
}


    .ballot-name {
        font-size: 0.95rem;
        padding-left: 4px;
        white-space: nowrap; /* Forces name to stay on one line */
        overflow: hidden;
        text-overflow: ellipsis; /* Adds ... if name is extremely long */
    }

    .candidate-name {
        width: 100%; /* Use full available grid space */
    }

    .symbol-image {
        width: 50px;
        height: 50px;
    }

    .vote-button {
        width: 55px;
        height: 35px;
    }

    .arrow-indicator-inline {
        position: relative;
        z-index: 1;
        font-size: 1.5rem;
        margin-right: 6px;
        align-self: center;
        transform: translateY(2px);
    }

    /* Hide braille on very small screens to save horizontal space */
    .braille-dots, .col-braille {
        display: none;
    }

    .ballot-name.selected-name .candidate-name {
        font-size: 0.85rem; /* Slightly larger but controlled */
        font-weight: bold;
    }
}