/* ============================================================
   软西瓜 · 真实水果半流体合成 —— 暖色清新风格
   温暖的米白纸感底色 + 木质玻璃容器 + 真实水果插画
   ============================================================ */

/* 字体已本地化：见 css/fonts.css（自托管 Noto Sans SC 400/600/700/800/900，无外链） */

:root {
    --bg-main: #f3ece1;
    --bg-card: #fffdf8;
    --border-soft: rgba(180, 165, 140, 0.32);
    --shadow-soft: 0 10px 36px rgba(120, 98, 64, 0.14);
    --text-dark: #3d3929;
    --text-muted: #8f8471;
    --accent-green: #5a8c3c;
    --accent-red: #e04848;
    --accent-warm: #d4a853;
    --accent-pink: #e8788a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-main);
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: var(--text-dark);
}

/* 背景纹理与柔和光斑 */
.ambient-lights {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
    background:
        radial-gradient(ellipse at 18% 12%, rgba(255, 220, 160, 0.34) 0%, transparent 52%),
        radial-gradient(ellipse at 84% 88%, rgba(196, 226, 160, 0.28) 0%, transparent 52%);
}

/* 主容器布局 */
.app-container {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    padding: 10px;
}

/* 游戏核心视窗 */
.game-viewport {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    height: 100%;
    max-height: 840px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-soft);
    border-radius: 26px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

/* ---------------- 顶部状态栏 ---------------- */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 9px 14px;
    background: linear-gradient(180deg, #fffdf8 0%, #fdf9f0 100%);
    border-bottom: 1px solid rgba(180, 165, 140, 0.16);
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

.brand-mark { font-size: 20px; line-height: 1; }

.brand-title {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.5px;
    color: var(--text-dark);
}

/* 计分板 */
.score-board {
    display: flex;
    gap: 6px;
}

.score-box {
    background: rgba(90, 140, 60, 0.08);
    padding: 4px 11px;
    border-radius: 12px;
    border: 1px solid rgba(90, 140, 60, 0.16);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.score-label {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.4px;
}

.score-val {
    font-size: 20px;
    font-weight: 900;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.score-box.best .score-val {
    color: var(--accent-green);
}

/* 右侧预览区 */
.preview-box {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(212, 168, 83, 0.10);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(212, 168, 83, 0.24);
    flex-shrink: 0;
}

.preview-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-muted);
}

#nextPreviewCanvas {
    display: block;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f6efe2 100%);
    box-shadow: inset 0 0 0 1px rgba(180, 165, 140, 0.25);
}

/* ---------------- 画布区 ---------------- */
.canvas-wrapper {
    position: relative;
    flex: 1;
    width: 100%;
    overflow: hidden;
    cursor: pointer;
    background: #faf5ea;
    box-shadow: inset 0 6px 14px -8px rgba(120, 98, 64, 0.35);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------------- 底部工具栏 ---------------- */
.bottom-toolbar {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px 14px 10px 14px;
    background: linear-gradient(180deg, #fdf9f0 0%, #fffdf8 100%);
    border-top: 1px solid rgba(180, 165, 140, 0.16);
    z-index: 10;
}

.tier-caption {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 0 2px;
}

.caption-title {
    font-size: 10px;
    font-weight: 800;
    color: var(--accent-green);
    letter-spacing: 0.3px;
}

.caption-sub {
    font-size: 8.5px;
    font-weight: 600;
    color: var(--text-muted);
}

/* 真实水果图鉴横条 */
.fruit-tier-bar {
    display: flex;
    gap: 3px;
    align-items: flex-end;
    justify-content: space-between;
    padding: 5px 7px 3px 7px;
    background: linear-gradient(180deg, rgba(90, 140, 60, 0.055), rgba(212, 168, 83, 0.055));
    border-radius: 14px;
    border: 1px solid rgba(90, 140, 60, 0.13);
    overflow-x: auto;
}

.fruit-tier-bar::-webkit-scrollbar { display: none; }

.tier-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.tier-thumb {
    display: block;
}

.tier-size {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: -0.3px;
    white-space: nowrap;
    line-height: 1.1;
}

.tier-arrow {
    color: var(--text-muted);
    font-size: 10px;
    flex-shrink: 0;
    opacity: 0.35;
    margin-bottom: 9px;
}

/* 工具栏行 */
.toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fluid-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-green);
    background: rgba(90, 140, 60, 0.08);
    padding: 5px 10px;
    border-radius: 16px;
    border: 1px solid rgba(90, 140, 60, 0.18);
}

.badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulseDot 1.6s infinite alternate;
}

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

.btn-group {
    display: flex;
    gap: 6px;
}

.glass-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(180, 165, 140, 0.32);
    border-radius: 11px;
    color: var(--text-dark);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 1px 3px rgba(120, 98, 64, 0.08);
}

.glass-btn:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(120, 98, 64, 0.14);
}

.glass-btn:active {
    transform: translateY(1px) scale(0.97);
}

.glass-btn.compress-action {
    background: rgba(224, 72, 72, 0.10);
    border-color: rgba(224, 72, 72, 0.28);
    color: var(--accent-red);
    font-weight: 700;
}

.glass-btn.compress-action:hover {
    background: rgba(224, 72, 72, 0.16);
}

.btn-icon { font-size: 13px; }

/* ---------------- 提示悬浮条 ---------------- */
.hint-banner {
    position: absolute;
    top: 74px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 253, 248, 0.9);
    backdrop-filter: blur(6px);
    padding: 4px 14px;
    border-radius: 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    border: 1px solid rgba(180, 165, 140, 0.24);
    white-space: nowrap;
    z-index: 5;
    animation: fadeHint 7s forwards;
}

@keyframes fadeHint {
    0%, 72% { opacity: 1; }
    100% { opacity: 0; }
}

/* 压缩挤压Q弹动画 (Squish & Spring Rebound) */
.jelly-compress {
    animation: containerCompress 0.65s cubic-bezier(0.25, 1, 0.5, 1) both;
}

@keyframes containerCompress {
    0% { transform: scale(1, 1); }
    30% { transform: scale(0.965, 1.015) translateY(3px); }
    55% { transform: scale(1.025, 0.975) translateY(-3px); }
    75% { transform: scale(0.99, 1.008) translateY(1px); }
    100% { transform: scale(1, 1); }
}

/* ---------------- 游戏结束模态框 ---------------- */
.modal-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(245, 240, 232, 0.86);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 100%;
    max-width: 300px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-soft);
    border-radius: 22px;
    padding: 26px 24px;
    text-align: center;
    box-shadow: 0 18px 44px rgba(120, 98, 64, 0.18);
    transform: scale(0.92);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-card {
    transform: scale(1);
}

.modal-title {
    font-size: 22px;
    font-weight: 900;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.modal-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 18px;
}

.final-score-display {
    background: rgba(90, 140, 60, 0.07);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 20px;
    border: 1px solid rgba(90, 140, 60, 0.14);
}

.final-score-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.final-score-val {
    font-size: 38px;
    font-weight: 900;
    color: var(--accent-green);
}

.modal-primary-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #6b9f47 0%, #4f8033 100%);
    border: none;
    border-radius: 13px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 5px 16px rgba(90, 140, 60, 0.32);
    transition: all 0.2s ease;
}

.modal-primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 9px 22px rgba(90, 140, 60, 0.4);
}

.modal-primary-btn:active {
    transform: translateY(1px);
}

/* ---------------- 窄屏适配 ---------------- */
@media (max-width: 380px) {
    .brand-title { display: none; }
    .score-val { font-size: 18px; }
    .preview-label { display: none; }
    .caption-sub { display: none; }
    .tier-size { font-size: 7px; }
    .glass-btn { padding: 6px 9px; }
}
