body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    background-attachment: fixed; /* Keep gradient fixed so tone doesn't shift when scrolling */
    background-size: cover; /* Ensure gradient covers full viewport */
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Start at top so header isn't cut off on mobile */
    min-height: 100vh;
    color: white;
    line-height: 1.6;
    touch-action: manipulation; /* Prevent double-tap zoom and scrolling */
    /* Safe area for devices with notches/status bars so top content isn't cut off */
    padding-top: env(safe-area-inset-top, 12px);
}

.container {
    position: relative;
    background-color: rgba(255, 255, 255, 0.15);  
    padding: calc(10px + env(safe-area-inset-top, 0px));  
    border-radius: 12px;  
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    width: 100%; /* Full width on mobile */
    max-width: 350px;  
    margin: 10px;
    transition: all 0.3s ease;  
    overflow: hidden; /* Prevent content from overflowing */
}

.container:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);  
}

.calculator h1 {
    color: #3498db;
    text-align: center;
    margin-bottom: 10px;  
    font-size: 1.2em;  
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);  
}

.totals {
    background-color: rgba(52, 152, 219, 0.25);
    border: 1px solid #3498db;
    border-radius: 10px;
    padding: 8px;  
    margin-bottom: 10px;  
    text-align: center;
    font-size: 0.8em;  
    transition: background-color 0.3s ease;
}

.totals:hover {
    background-color: rgba(52, 152, 219, 0.3);
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;  
    margin-bottom: 10px;  
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-group.full-width {
    grid-column: span 2;
}

.input-grid input, 
.input-grid select {
    width: 100%;
    box-sizing: border-box;
}

input, select {
    font-size: 16px; /* Prevents auto zoom on iOS */
    padding: 8px;
    box-sizing: border-box; /* Ensures padding doesn't increase width */
    max-width: 100%; /* Prevent overflow */
    border: 1px solid #34495e;
    border-radius: 8px;
    background-color: rgba(52, 73, 94, 0.6);
    color: white;
    transition: all 0.3s ease;
    font-size: 0.8em;  
}

input:focus, select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 12px rgba(52, 152, 219, 0.4);
}

label {
    margin-bottom: 4px;  
    color: #bdc3c7;
    font-weight: 600;
    font-size: 0.8em;  
    transition: color 0.3s ease;
}

input:focus + label, select:focus + label {
    color: #3498db;
}

button, input, select {
    min-height: 44px; /* WCAG accessibility recommendation */
    min-width: 44px;
    margin: 5px 0;
    touch-action: manipulation;
}

textarea {
    font-size: 16px; /* Prevents auto zoom on iOS */
}

.additional-prices {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 8px;  
    margin-top: 10px;  
    transition: background-color 0.3s ease;
    overflow: auto; /* allow horizontal scroll on very small screens */
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Make the additional prices table responsive and inputs fluid */
#additionalPricesTable {
    width: 100%;
    min-width: 0; /* allow table to shrink to container; avoid fixed minimums that cause overflow */
    border-collapse: collapse;
    table-layout: auto; /* let columns size naturally and wrap inputs instead of forcing overflow */
    display: block; /* allow container scrolling on very narrow screens */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

#additionalPricesTable td {
    padding: 6px 8px;
    vertical-align: middle;
    word-break: break-word;
}

.price-input {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
    padding: 6px;
    border-radius: 6px;
}

.additional-prices:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

button {
    background-color: #2ecc71;
    color: white;
    border: none;
    padding: 6px 10px;  
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.8em;  
    transform: scale(1);
}

button:hover {
    background-color: #27ae60;
    transform: scale(1.05);
}

.lock-button {
    background-color: #f39c12;
    margin-top: 12px;
}

#donationsButton {
    position: absolute;
    top: 10px;  
    right: 10px;  
    width: 30px;  
    height: 30px;  
    border-radius: 50%;
    background-color: #e74c3c;
    color: white;
    border: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 10;
    transition: all 0.4s ease;
    font-size: 0.6em;  
    transform: rotate(0deg);
}

#donationsButton:hover {
    background-color: #c0392b;
    transform: rotate(360deg) scale(1.1);
}

.delete-btn {
    background: none;
    border: none;
    color: #e74c3c;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.delete-btn:hover {
    color: #c0392b;
}

#details {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;  
    font-size: 0.7em;  
}

#details th, #details td {
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 4px;  
    text-align: left;
}

#details thead {
    background-color: rgba(52, 152, 219, 0.3);
    font-size: 0.8em;  
}

#details tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

#details tr:hover {
    background-color: rgba(52, 152, 219, 0.1);
}

.selected-price {
    background-color: rgba(52, 152, 219, 0.3);  
    border: 1px solid #3498db;
    border-radius: 8px;
    padding: 8px;
    margin-top: 15px;  
    text-align: center;
    color: white;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.selected-price:hover {
    background-color: rgba(52, 152, 219, 0.4);
}

/* Ensure additional-prices stays inside viewport on very small screens and general adjustments */
@media screen and (max-width: 420px) {
    .container {
        width: 96%;
        margin: 6px;
        padding: 6px;
    }

    .input-grid {
        grid-template-columns: 1fr;
    }

    .input-group.full-width {
        grid-column: span 1;
    }

    /* Allow table to fit the container on very small screens */
    #additionalPricesTable {
        min-width: 0;
    }

    /* Slightly smaller font for cramped screens */
    .additional-prices, .additional-prices table, .additional-prices input {
        font-size: 0.85em;
    }
}

/* Media query for input font size */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="date"],
    select {
        font-size: 16px;
        padding: 8px;
    }
}

/* Prevent text selection and zooming */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Allow text input selection */
input[type="text"], 
input[type="number"], 
input[type="date"], 
textarea, 
select {
    -webkit-user-select: text;
    -khtml-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    touch-action: pan-y; /* Allow vertical scrolling only */
}