* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    background-color: #2a1f1a;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    touch-action: manipulation;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}
#game-container {
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ========== 页面切换 ========== */
.page { display: none; flex-direction: column; align-items: center; }
.page.active { display: flex; }

/* ========== 加载页 ========== */
#loading-page {
    color: #d7ccc8;
    font-size: 18px;
    gap: 16px;
}
.loading-dots::after {
    content: '';
    animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}
.loading-bar-wrap {
    width: 200px;
    height: 6px;
    background: #4e342e;
    border-radius: 3px;
    overflow: hidden;
}
.loading-bar {
    height: 100%;
    width: 0%;
    background: #ffb74d;
    border-radius: 3px;
    transition: width 0.2s;
}

/* ========== 启动页 ========== */
#start-page {
    gap: 20px;
    padding-bottom: 70px;
}
#start-page .game-title {
    font-size: 32px;
    font-weight: bold;
    color: #ffb74d;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    letter-spacing: 3px;
}
#start-page .game-subtitle {
    font-size: 14px;
    color: #a1887f;
    margin-top: -10px;
}

/* ========== 分数区 ========== */
#score-area {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
    z-index: 10;
}
.score-box {
    text-align: center;
}
.score-label {
    font-size: 12px;
    color: #bcaaa4;
    margin-bottom: 2px;
    letter-spacing: 1px;
}
#score, #high-score {
    font-size: 24px;
    font-weight: bold;
    color: #f7ebd3;
}
#high-score {
    color: #a1887f;
}
#combo-box {
    min-width: 60px;
}
#combo-val {
    font-size: 20px;
    font-weight: bold;
    color: #ff8a65;
    text-shadow: 0 0 8px rgba(255,138,101,0.4);
    transition: transform 0.15s;
}
#combo-val.pop {
    transform: scale(1.4);
}

/* ========== 浮动提示文字 ========== */
#float-text {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: bold;
    color: #ffd54f;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8), 0 0 20px rgba(255,213,79,0.6);
    pointer-events: none;
    opacity: 0;
    z-index: 50;
    white-space: nowrap;
}
@keyframes floatUp {
    0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.5); }
    20%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    40%  { opacity: 1; transform: translate(-50%, -55%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -90%) scale(0.9); }
}
#float-text.show {
    animation: floatUp 1.2s ease-out forwards;
}

/* ========== Monitor 画布 ========== */
#monitor, .monitor-preview {
    position: relative;
    width: min(64vw, 315px);
    aspect-ratio: 1/1;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border-radius: 8px;
    overflow: hidden;
}
.layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -webkit-user-drag: none;
    user-drag: none;
}

/* 层级顺序（从底到顶） */
#bg            { z-index: 0; }
#actor-body    { z-index: 1; }
#eyes          { z-index: 2; }
#actor-handfree{ z-index: 3; }
#table         { z-index: 5; }
#cat-body      { z-index: 6; }
#bubble        { z-index: 7; }
#mood          { z-index: 8; }
#cat-head      { z-index: 9; transform-origin: bottom center; }
#arm           { z-index: 10; }
#bitten        { z-index: 100; }

@keyframes catBreatheBody {
    0%, 100% { transform: scaleY(1); }
    50%      { transform: scaleY(1.018); }
}
@keyframes catBreatheHead {
    0%, 100% { transform: scaleY(1)    translateY(0); }
    50%      { transform: scaleY(1.012) translateY(-1%); }
}
#cat-body.breathing {
    transform-origin: bottom center;
    animation: catBreatheBody 2.8s ease-in-out infinite;
}
#cat-head.breathing,
#bubble.breathing,
#mood.breathing {
    transform-origin: bottom center;
    animation: catBreatheHead 2.8s ease-in-out infinite;
}

.fur-particle {
    position: absolute;
    width: 18%;
    height: auto;
    z-index: 20;
    pointer-events: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    -webkit-user-drag: none;
    user-drag: none;
    will-change: transform, opacity;
    animation: furFall var(--dur, 1.5s) linear forwards;
}
@keyframes furFall {
    0%   { transform: translate(0, 0) rotate(0deg) scale(var(--scl, 1)); opacity: 1; }
    25%  { opacity: 1; }
    100% { transform: translate(var(--dx, 20px), var(--dy, 120%)) rotate(var(--rot, 40deg)) scale(var(--scl, 1)); opacity: 0; }
}

@keyframes bonusGlow {
    0%, 100% { filter: brightness(1) drop-shadow(0 0 0px rgba(129, 199, 132, 0)); }
    50%      { filter: brightness(1.15) drop-shadow(0 0 20px rgba(129, 199, 132, 0.6)); }
}
#monitor.bonus {
    animation: bonusGlow 0.8s ease-in-out infinite;
}
/* ========== 静电干扰（3000分解锁） ========== */
@keyframes staticFlicker {
    0%   { opacity: 0.15; }
    20%  { opacity: 0.7; }
    40%  { opacity: 0.25; }
    60%  { opacity: 0.9; }
    80%  { opacity: 0.2; }
    100% { opacity: 0.15; }
}
#monitor.static-active::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(180, 200, 220, 0.1) 0px,
        rgba(180, 200, 220, 0.1) 2px,
        transparent 2px,
        transparent 5px
    );
    pointer-events: none;
    z-index: 60;
    animation: staticFlicker 0.06s steps(3) infinite;
    mix-blend-mode: screen;
}

/* ========== 手机震动（5000分解锁） ========== */
@keyframes shake {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    15%  { transform: translate(-4px, 2px) rotate(-0.5deg); }
    30%  { transform: translate(3px, -3px) rotate(0.5deg); }
    45%  { transform: translate(-2px, 1px) rotate(-0.3deg); }
    60%  { transform: translate(5px, -1px) rotate(0.4deg); }
    75%  { transform: translate(-3px, 3px) rotate(-0.5deg); }
    90%  { transform: translate(2px, -2px) rotate(0.3deg); }
}
#monitor.vibration-active {
    animation: shake 0.1s ease-in-out infinite;
    will-change: transform;
}

#bitten {
    display: none;
    opacity: 0;
    transition: opacity 0.12s ease-out;
}
#bitten.show {
    display: block;
    opacity: 1;
}

@keyframes armSway {
    0%   { transform: translateX(0) translateY(0); }
    25%  { transform: translateX(-4px) translateY(-4px); }
    50%  { transform: translateX(2px) translateY(-2px); }
    75%  { transform: translateX(12px) translateY(-10px); }
    100% { transform: translateX(0) translateY(0); }
}
@keyframes eyesSway {
    0%   { transform: translateX(0) translateY(0); }
    25%  { transform: translateX(-1px) translateY(-0.5px); }
    50%  { transform: translateX(0) translateY(0); }
    75%  { transform: translateX(1px) translateY(-0.5px); }
    100% { transform: translateX(0) translateY(0); }
}
.arm-anim  { animation: armSway 1.0s ease-in-out infinite; }
.eyes-anim { animation: eyesSway 1.0s ease-in-out infinite; animation-delay: 0.1s; }

/* ========== 控制按钮 ========== */
#ctrl-btn {
    width: min(42vw, 210px);
    margin-top: 8px;
    cursor: pointer;
    -webkit-user-drag: none;
    user-drag: none;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    z-index: 10;
    transition: transform 0.08s;
}
#ctrl-btn:active { transform: scale(0.95); }

/* 启动页按钮用 CtrlButton on.png 当开始按钮 */
.big-btn {
    margin-top: 10px;
    padding: 12px 32px;
    font-size: 18px;
    font-weight: bold;
    background-color: #ffb74d;
    color: #3e2723;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: 0 4px 0 #e6953b, 0 6px 12px rgba(0,0,0,0.3);
    transition: all 0.08s;
    letter-spacing: 2px;
}
.big-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #e6953b, 0 3px 6px rgba(0,0,0,0.3);
}
.btn-row {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    flex-wrap: wrap;
    justify-content: center;
}
.btn-secondary {
    background-color: #8d6e63;
    color: white;
    box-shadow: 0 4px 0 #5d4037, 0 6px 12px rgba(0,0,0,0.3);
    font-size: 15px;
    padding: 10px 22px;
    font-weight: normal;
    letter-spacing: 1px;
}
.btn-secondary:active {
    box-shadow: 0 2px 0 #5d4037, 0 3px 6px rgba(0,0,0,0.3);
}

#status-text {
    margin-top: 8px;
    font-size: 16px;
    color: #d7ccc8;
    height: 24px;
    z-index: 10;
}

/* 启动页说明 */
.instruction {
    margin-top: 10px;
    font-size: 13px;
    color: #8d6e63;
    line-height: 1.8;
    max-width: 320px;
}
.instruction .icon { color: #ffb74d; font-weight: bold; }

/* ========== 排行榜 ========== */
.leaderboard {
    width: min(85vw, 320px);
    background: rgba(62, 39, 24, 0.7);
    border-radius: 12px;
    padding: 12px 14px;
    margin-top: 10px;
    border: 2px solid #8d6e63;
}
.leaderboard-title {
    text-align: center;
    font-size: 15px;
    color: #ffb74d;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 8px;
}
.leaderboard-list {
    font-size: 13px;
    color: #d7ccc8;
}
.lb-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px dashed rgba(141, 110, 99, 0.3);
}
.lb-row:last-child { border-bottom: none; }
.lb-rank {
    width: 28px;
    font-weight: bold;
    color: #ffb74d;
    text-align: center;
}
.lb-rank.gold   { color: #ffd54f; text-shadow: 0 0 6px rgba(255,213,79,0.5); }
.lb-rank.silver { color: #e0e0e0; }
.lb-rank.bronze { color: #ffab91; }
.lb-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 8px;
    text-align: left;
}
.lb-score {
    color: #fff3e0;
    font-weight: bold;
    min-width: 50px;
    text-align: right;
}
.lb-empty {
    text-align: center;
    color: #8d6e63;
    padding: 10px 0;
    font-size: 12px;
}
.lb-my-rank {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #8d6e63;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #ffcc80;
}
.lb-loading {
    text-align: center;
    color: #8d6e63;
    padding: 10px 0;
    font-size: 12px;
}

/* ========== 提交分数弹窗 ========== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal-overlay.show {
    display: flex;
}
.modal-box {
    background: #4e342e;
    border: 3px solid #8d6e63;
    border-radius: 16px;
    padding: 24px 28px;
    width: min(85vw, 320px);
    text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.modal-title {
    font-size: 20px;
    color: #ffb74d;
    font-weight: bold;
    margin-bottom: 8px;
}
.modal-score {
    font-size: 36px;
    color: #fff3e0;
    font-weight: bold;
    margin: 10px 0;
    text-shadow: 0 0 12px rgba(255,183,77,0.4);
}
.modal-hint {
    font-size: 12px;
    color: #a1887f;
    margin-bottom: 14px;
}
.modal-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 16px;
    border: 2px solid #8d6e63;
    border-radius: 8px;
    background: #3e2723;
    color: #f7ebd3;
    text-align: center;
    outline: none;
    margin-bottom: 14px;
    font-family: inherit;
}
.modal-input:focus {
    border-color: #ffb74d;
}
.modal-input::placeholder { color: #6d4c41; }
.modal-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.modal-btns .big-btn {
    font-size: 14px;
    padding: 9px 18px;
}
.modal-result {
    font-size: 14px;
    color: #81c784;
    margin-bottom: 12px;
    min-height: 20px;
}
.modal-result.error { color: #ef5350; }

/* ========== 信息按钮 & 规则弹窗 ========== */
.info-btn {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    right: max(20px, env(safe-area-inset-right, 0px));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #8d6e63;
    background: rgba(78, 52, 46, 0.85);
    color: #ffb74d;
    font-size: 20px;
    font-weight: bold;
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 0;
    line-height: 1;
    transition: transform 0.15s, background 0.15s;
}
.info-btn:hover { background: #5d4037; transform: scale(1.1); }
.info-btn:active { transform: scale(0.95); }

.rules-content {
    font-size: 13px;
    color: #d7ccc8;
    text-align: left;
    line-height: 1.7;
    max-height: 55vh;
    overflow-y: auto;
    padding-right: 6px;
}
.rules-content::-webkit-scrollbar { width: 6px; }
.rules-content::-webkit-scrollbar-track { background: transparent; }
.rules-content::-webkit-scrollbar-thumb { background: #8d6e63; border-radius: 3px; }
.rule-section { margin-bottom: 14px; }
.rule-title {
    color: #ffcc80;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 4px;
}
.rule-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 4px;
}
.rule-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.rule-icon img {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated;
}
.rule-icon .bubble-img {
    z-index: 1;
}
.rule-icon .mood-img {
    z-index: 2;
}
.rule-text { flex: 1; }
.rule-text b { color: #ffb74d; }
.rule-tip {
    background: rgba(255,183,77,0.1);
    border-left: 3px solid #ffb74d;
    padding: 8px 10px;
    border-radius: 0 6px 6px 0;
    margin-top: 8px;
    font-size: 12px;
    color: #ffcc80;
}
.rule-credits {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #5d4037;
    font-size: 12px;
    color: #a1887f;
    line-height: 1.8;
}
.rule-credits a {
    color: #ffb74d;
    text-decoration: none;
    word-break: break-all;
}
.rule-credits a:hover {
    text-decoration: underline;
}
