:root {
    --primary-color: #ff9a9e;
    --secondary-color: #fecfef;
    --bg-color: #fff0f5;
    --text-color: #5d5d5d;
    --input-bg: #ffffff;
    --btn-color: #2ecc71;
    --btn-hover: #27ae60;
}

body {
    font-family: 'Comic Sans MS', 'Nunito', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    background-image: radial-gradient(var(--secondary-color) 20%, transparent 20%),
                      radial-gradient(var(--secondary-color) 20%, transparent 20%);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    color: var(--text-color);
}

.calculator-container {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 30px rgba(255, 154, 158, 0.3);
    width: 100%;
    max-width: 600px;
    border: 3px solid var(--secondary-color);
    box-sizing: border-box;
    position: relative;
}

.top-actions {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 10;
}

.action-btn {
    background: #fff;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: 12px;
    padding: 6px 12px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(255, 154, 158, 0.2);
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    letter-spacing: normal;
    text-transform: none;
    text-shadow: none;
    width: auto;
}

.action-btn:hover {
    background: var(--primary-color);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(255, 154, 158, 0.4);
}

.action-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(255, 154, 158, 0.2);
}

h1 {
    text-align: center;
    color: var(--primary-color);
    font-size: 24px;
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

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

label {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 14px;
    color: #ff758c;
}

input {
    padding: 12px 15px;
    border: 2px solid #ffe4e1;
    border-radius: 15px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
    background-color: var(--input-bg);
    color: #333;
    font-weight: bold;
    text-align: center;
}

/* 自定义下拉菜单样式 */
.custom-select {
    position: relative;
    width: 100%;
}

.select-selected {
    padding: 12px 15px;
    border: 2px solid #ffe4e1;
    border-radius: 15px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: #888;
    font-weight: bold;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    user-select: none;
}

.select-selected.has-value {
    color: #333;
}

.select-selected::after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #ff9a9e;
    transition: transform 0.3s ease;
}

.select-selected.select-arrow-active::after {
    transform: translateY(-50%) rotate(180deg);
}

.select-selected:focus, .select-selected.select-arrow-active {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(255, 154, 158, 0.3);
}

.select-items {
    position: absolute;
    background-color: #fff;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 99;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(255, 154, 158, 0.25);
    border: 2px solid #ffe4e1;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px;
}

.select-items::-webkit-scrollbar {
    width: 6px;
}

.select-items::-webkit-scrollbar-thumb {
    background: #fecfef;
    border-radius: 3px;
}

.select-items div {
    color: #555;
    padding: 10px 15px;
    cursor: pointer;
    border-radius: 10px;
    font-weight: bold;
    font-size: 15px;
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.select-items div:last-child {
    margin-bottom: 0;
}

.select-items div:hover, .same-as-selected {
    background-color: #fff0f5;
    color: var(--primary-color);
}

.select-hide {
    display: none;
}

input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(255, 154, 158, 0.3);
}

input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

button {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 8px 20px rgba(255, 154, 158, 0.5), 
                inset 0 -3px 0 rgba(0, 0, 0, 0.1);
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(255, 100, 150, 0.4);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(255, 154, 158, 0.7),
                inset 0 -3px 0 rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #ff8a8e 0%, #febfdf 100%);
}

button:active {
    transform: translateY(2px);
    box-shadow: 0 3px 10px rgba(255, 154, 158, 0.4),
                inset 0 -1px 0 rgba(0, 0, 0, 0.1);
}

.secondary-btn {
    padding: 12px;
    background: #fff;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    border-radius: 15px;
    font-size: 16px;
    font-weight: bold;
    box-shadow: none;
    letter-spacing: 1px;
    text-transform: none;
    text-shadow: none;
}

.secondary-btn:hover {
    background: var(--bg-color);
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(255, 154, 158, 0.2);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    border: 4px solid var(--secondary-color);
    position: relative;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.modal-content h2 {
    text-align: center;
    color: var(--primary-color);
    margin-top: 0;
}

.config-body {
    text-align: left;
    padding: 10px 15px;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 20px;
}

.config-body::-webkit-scrollbar {
    width: 8px;
}

.config-body::-webkit-scrollbar-thumb {
    background: #fecfef;
    border-radius: 4px;
}

.config-section {
    background: var(--bg-color);
    border: 2px dashed #ff9a9e;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.02);
}

.config-section h3 {
    color: #ff758c;
    margin-top: 0;
    font-size: 16px;
    border-bottom: 2px dotted #ffe4e1;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid #ffe4e1;
}

.config-item label {
    margin-bottom: 0;
    color: #666;
    font-size: 13px;
    font-weight: bold;
}

.config-item input {
    width: 50px;
    padding: 5px;
    font-size: 13px;
    text-align: right;
    border: none;
    border-bottom: 2px solid #fecfef;
    border-radius: 0;
    background: transparent;
    color: #333;
    font-weight: bold;
}

.config-item input:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Receipt Modal Styles */
.receipt-modal {
    max-width: 420px;
    position: relative;
    overflow: hidden;
}

.receipt-watermark {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.08;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    overflow: hidden;
}

.receipt-watermark span {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
    transform: rotate(-30deg);
    padding: 20px 30px;
    white-space: nowrap;
    user-select: none;
}

.receipt-body {
    border-top: 2px dashed #ffe4e1;
    border-bottom: 2px dashed #ffe4e1;
    padding: 15px 10px;
    margin: 15px 0;
    max-height: 40vh;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

.receipt-body::-webkit-scrollbar {
    width: 6px;
}

.receipt-body::-webkit-scrollbar-thumb {
    background: #fecfef;
    border-radius: 3px;
}

.receipt-summary {
    position: relative;
    z-index: 1;
}

.receipt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    color: #666;
    font-size: 14px;
    font-weight: bold;
    position: relative;
    z-index: 1;
}

.receipt-item.highlight {
    color: #ff758c;
    margin-top: 10px;
}

.receipt-item.total {
    font-size: 18px;
    color: var(--primary-color);
    margin-top: 10px;
}

.receipt-knives {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.receipt-knife-item {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 5px 10px 5px 5px;
    border-radius: 10px;
    border: 1px solid #ffe4e1;
    gap: 8px;
}

.receipt-knife-item img {
    width: 40px;
    height: 30px;
    object-fit: cover;
    border-radius: 5px;
}

.receipt-knife-item span {
    font-size: 12px;
    color: #555;
}

.ratio-input-wrapper, .total-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ratio-prefix {
    font-size: 18px;
    font-weight: 900;
    color: #ff758c;
}

.total-suffix {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
}

.receipt-summary .receipt-item input {
    width: 90px;
    padding: 8px 10px;
    font-size: 16px;
    text-align: right;
    border: 2px solid #ffe4e1;
    border-radius: 10px;
    background: #fff;
    color: var(--primary-color);
    font-weight: 900;
    transition: all 0.3s;
}

.receipt-summary .receipt-item input:focus {
    border-color: var(--btn-color);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.3);
    outline: none;
}

.receipt-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.receipt-actions button {
    width: 100%;
    margin: 0 !important;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #ccc;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--primary-color);
}

.knife-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.knife-item {
    cursor: pointer;
    border: 3px solid #ffe4e1;
    border-radius: 15px;
    padding: 10px;
    text-align: center;
    transition: all 0.2s;
    background: var(--input-bg);
    position: relative;
}

.knife-item img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 8px;
}

.knife-item span {
    display: block;
    font-size: 12px;
    color: #555;
    font-weight: bold;
}

.knife-item.selected {
    border-color: var(--btn-color);
    background: #e8f8f5;
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}

.knife-item.selected::after {
    content: '💖';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 20px;
    background: #fff;
    border-radius: 50%;
    padding: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.modal-confirm-btn {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
    text-shadow: none;
    letter-spacing: 1px;
}

.modal-confirm-btn:hover {
    background: linear-gradient(135deg, #27ae60 0%, #219a52 100%);
    box-shadow: 0 8px 20px rgba(46, 204, 113, 0.6);
}

@media (max-width: 600px) {
    .top-actions {
        position: static;
        justify-content: flex-end;
        margin-bottom: 15px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .config-grid {
        grid-template-columns: 1fr;
    }
}