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

body {
    font-family: 'Arial', sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* 上方控制区 - 占20% */
.control-panel {
    height: 20vh;
    background-color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #ddd;
    position: relative;
}

.plate-controls {
    display: flex;
    gap: 30px;
    align-items: flex-end;
}

.plate-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

/* 碟子按钮样式 */
.plate-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid #333;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.plate-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.plate-btn:active {
    transform: scale(0.95);
}

/* 碟子颜色 - 使用图片素材 */
.plate-btn {
    background-image: url('../images/plates.png');
    background-size: 500% 100%;
    background-repeat: no-repeat;
    border: none;
}

.plate-red {
    background-position: 0% 50%;
}

.plate-white {
    background-position: 25% 50%;
}

.plate-gold {
    background-position: 50% 50%;
}

.plate-black {
    background-position: 75% 50%;
}

.plate-silver {
    background-position: 100% 50%;
}

/* 数量控制 */
.quantity-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.minus-btn {
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.minus-btn:hover {
    background: #ff6b7a;
}

.minus-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.quantity {
    font-size: 18px;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.price {
    font-size: 14px;
    color: #666;
}

/* 下方显示区 - 占80% */
.display-area {
    height: 80vh;
    position: relative;
    background: linear-gradient(135deg, #f5e6d3 0%, #e8d5b7 100%);
    overflow: hidden;
}

/* 返回按钮 */
.back-btn {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(46, 204, 113, 0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    z-index: 20;
    /* 确保在P1/P2/P3之上 */
    transition: background 0.2s;
    color: white;
}

.back-btn:hover {
    background: #2ecc71;
}

/* 清除按钮 */
.clear-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(231, 76, 60, 0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    z-index: 20;
    transition: background 0.2s;
    color: white;
}

.clear-btn:hover {
    background: #e74c3c;
}

/* 总计按钮 */
.total-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 215, 0, 0.9);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 20;
    /* 确保在P1/P2/P3之上 */
    transition: background 0.2s;
}

.total-btn:hover {
    background: #ffd700;
}

/* 俯视图 */
.table-view {
    width: 100%;
    height: 100%;
}

.top-view .table-surface {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(135deg, #f5e6d3 0%, #e8d5b7 100%);
}

/* 桌子纹理 */
.table-surface::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        repeating-linear-gradient(90deg,
            transparent,
            transparent 100px,
            rgba(139, 90, 43, 0.05) 100px,
            rgba(139, 90, 43, 0.05) 101px),
        repeating-linear-gradient(0deg,
            transparent,
            transparent 100px,
            rgba(139, 90, 43, 0.05) 100px,
            rgba(139, 90, 43, 0.05) 101px);
}

/* 碟子容器 */
.plates-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 俯视图碟子 */
.plate-item {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-image: url('../images/plates.png');
    background-size: 600% 115%;
    background-repeat: no-repeat;
}

.plate-item.plate-red {
    background-position: 2.6% 58%;
}

.plate-item.plate-white {
    background-position: 26.7% 50.7%;
}

.plate-item.plate-gold {
    background-position: 50% 63%;
}

.plate-item.plate-black {
    background-position: 74% 52%
}

.plate-item.plate-silver {
    background-position: 97.6% 59%;
}

@keyframes dropIn {
    from {
        transform: translate(-50%, -50%) translateY(-100px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

@keyframes dropOut {
    from {
        transform: translate(-50%, -50%);
        opacity: 1;
    }

    to {
        transform: translate(-50%, -50%) translateY(100px);
        opacity: 0;
    }
}

/* 正视图 */
.front-view {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5e6d3 0%, #e8d5b7 100%);
}

.table-side {
    width: 100%;
    height: 95%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 78px;
}

/* 桌子侧面 */
.table-side::before {
    content: '';
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to bottom, #deb887, #d2a679);
    border-top: 4px solid #c49a6c;
}

/* 碟子堆叠 */
.stack-container {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 3px;
    z-index: 1;
    max-height: calc(100% - 150px);
    overflow: visible;
    padding: 10px;
}

.stack-plate {
    width: 140px;
    height: 18px;
    border-radius: 50%;
    border: none;
    animation: stackIn 0.3s ease-out;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background-image: url('../images/plates.png');
    background-size: 593% 114%;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
}

.stack-plate.plate-red {
    background-position: 2.5% 51%;
}

.stack-plate.plate-white {
    background-position: 25.9% 50%;
}

.stack-plate.plate-gold {
    background-position: 50% 50%;
}

.stack-plate.plate-black {
    background-position: 74.1% 50%;
}

.stack-plate.plate-silver {
    background-position: 97.9% 50%;
}

@keyframes stackIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

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

/* 总价显示 */
.total-display {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 20px 40px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.total-display .label {
    font-size: 16px;
    color: #666;
    margin-right: 10px;
}

.total-display .amount {
    color: #e74c3c;
    font-size: 32px;
}

/* 移动端适配 */
@media (max-width: 768px) {

    /* 禁用 hover 效果（触摸设备） */
    .plate-btn:hover,
    .minus-btn:hover,
    .back-btn:hover,
    .clear-btn:hover,
    .total-btn:hover {
        transform: none;
        box-shadow: none;
    }

    /* 添加触摸反馈 */
    .plate-btn:active,
    .minus-btn:active,
    .back-btn:active,
    .total-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }

    .clear-btn:active {
        opacity: 0.8;
    }

    /* 上方控制区 */
    .control-panel {
        height: 18vh;
        padding: 5px;
    }

    .plate-controls {
        gap: 8px;
    }

    .plate-control {
        gap: 4px;
    }

    /* 碟子按钮缩小 */
    .plate-btn {
        width: 45px;
        height: 45px;
        border-width: 2px;
    }

    /* 数量控制 */
    .minus-btn {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    .quantity {
        font-size: 14px;
        min-width: 18px;
    }

    .price {
        font-size: 11px;
    }

    /* 顶部按钮 */
    .back-btn,
    .total-btn {
        padding: 8px 12px;
        font-size: 14px;
        bottom: 10px;
    }

    .back-btn {
        left: 10px;
    }

    .total-btn {
        right: 10px;
    }

    /* 清除按钮 */
    .clear-btn {
        top: 8px;
        right: 8px;
        padding: 8px 12px;
        font-size: 14px;
    }

    /* 俯视图碟子 */
    .plate-item {
        width: 200px;
        height: 200px;
    }

    /* 正视图碟子 */
    .stack-container {
        width: 150px;
        max-height: calc(100% - 130px);
        gap: 3px;
        overflow: visible;
    }

    .stack-plate {
        width: 130px;
        height: 16px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    /* 总价显示 */
    .total-display {
        padding: 12px 24px;
        font-size: 18px;
        bottom: 20px;
    }

    .total-display .label {
        font-size: 14px;
    }

    .total-display .amount {
        font-size: 24px;
    }
}

/* 超小屏幕适配（如 iPhone SE） */
@media (max-width: 375px) {
    .plate-btn {
        width: 38px;
        height: 38px;
    }

    .plate-controls {
        gap: 6px;
    }

    .quantity {
        font-size: 12px;
        min-width: 16px;
    }

    .price {
        font-size: 10px;
    }

    .minus-btn {
        width: 18px;
        height: 18px;
        font-size: 9px;
    }

    .back-btn,
    .total-btn {
        padding: 6px 10px;
        font-size: 12px;
        bottom: 10px;
    }

    .back-btn {
        left: 10px;
    }

    .total-btn {
        right: 10px;
    }

    .clear-btn {
        top: 6px;
        right: 6px;
        padding: 6px 10px;
        font-size: 12px;
    }
}


/* p1 - p2 - p3 定位 */
.table-view {
    position: relative;
}


.p2-p3-box,
.p1 {
    position: absolute;
    width: 100%;
    height: calc((100% - 200px)/2);
    z-index: 10;
}

.p2-p3-box {
    bottom: 70px;
    display: flex;
    justify-content: space-between;
}

.p2 {
    flex: 2
}

.p3 {
    flex: 1
}

.p2-p3-box,
.p1,
.p2,
.p3 {
    /* border: 2px solid #000; */
}


/* ==================== 自定义碟样式 ==================== */

/* 自定义碟标签 */
.custom-plate-tag {
    background-image: url('../images/俯视图.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin: 4px;
    animation: fadeIn 0.3s ease-out;
    max-width: 150px;
    max-height: 150px;
    aspect-ratio: 1/1;
    flex: 1;
}

.custom-plate-tag:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.custom-plate-tag:active {
    transform: scale(0.95);
}

.custom-plate-tag .price {
    font-size: 16px;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.custom-plate-tag .hint {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.front-view {

    .p1,
    .p2-p3-box {
        top: 0;
        width: calc((100% - 150px) / 2);
        height: calc(100% - 100px);
    }

    .p1 {
        left: 0;
    }

    .p2-p3-box {
        right: 0;
        flex-direction: column;

        .p2 {
            flex: 1;
        }

        .p3 {
            flex: none;
            height: 150px;
        }
    }

    .custom-plate-tag {
        background-image: url('../images/正视图.png');
        max-width: 150px;
        max-height: 150px;
        aspect-ratio: 554/221;
        flex: 1;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0);
        border-radius: 0px;
        background-size: contain;
    }
}

/* P3输入区域 */
.p3-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    height: 100%;
    justify-content: center;
}

.p3-input {
    width: 100%;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
    transition: border-color 0.2s;
    font-weight: bold;
}

.p3-input:focus {
    outline: none;
    border-color: #9b59b6;
    box-shadow: 0 0 0 3px rgba(155, 89, 182, 0.1);
}

.p3-input::placeholder {
    font-weight: normal;
    opacity: 0.5;
}

.p3-confirm-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.p3-confirm-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.p3-confirm-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* P1和P2容器样式优化 */
.p1 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    overflow-y: auto;
    /* background: rgba(255, 255, 255, 0.3); */
    /* backdrop-filter: blur(5px); */
}

.p2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 10px;
    overflow-y: auto;
    /* background: rgba(255, 255, 255, 0.3); */
    /* backdrop-filter: blur(5px); */
}

/* 移动端适配 */
@media (max-width: 768px) {

    .p1,
    .p2-p3-box {
        height: calc((100% - 300px)/2);

    }

    .p2-p3-box {
        bottom: 50px;
    }

    .custom-plate-tag {
        padding: 6px 10px;
        font-size: 12px;
        margin: 3px;
        max-width: 150px;
        max-height: 150px;
        min-width: 40px;
        min-height: 40px;
    }

    .custom-plate-tag .price {
        font-size: 14px;
        color: white;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }

    .p3-input {
        font-size: 14px;
        padding: 8px;
    }

    .p3-confirm-btn {
        font-size: 14px;
        padding: 10px;
    }

    .p1,
    .p2 {
        padding: 6px;
        gap: 3px;
    }
}

/* 超小屏幕适配（如 iPhone SE） */
@media (max-width: 375px) {

    .p1,
    .p2-p3-box {
        height: 120px;
    }

    .p2-p3-box {
        bottom: 45px;
    }

    .custom-plate-tag {
        padding: 4px 8px;
        font-size: 11px;
        margin: 2px;
        max-width: 150px;
        max-height: 150px;
    }

    .custom-plate-tag .price {
        font-size: 16px;
        color: white;
        text-shadow: 3px 3px 4px rgba(0, 0, 0, 0.9);

    }

    .p3-input {
        font-size: 12px;
        padding: 6px;
    }

    .p3-confirm-btn {
        font-size: 12px;
        padding: 8px;
    }
}