/* ===========================
   粪便超人 · 像素风可爱版
   =========================== */

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    /* 字体后备链：网络字体（可能加载失败）→ 系统中文字体 → 通用 */
    font-family: 'ZCOOL KuaiLe', 'Comic Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', '微软雅黑', sans-serif;
    background: #FFF8E7;
    color: #2D2D2D;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    image-rendering: pixelated;
}

#app {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* ---------- 页面切换 ---------- */
.page {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.page.active {
    display: flex;
}

/* ---------- 像素风大标题 ---------- */
.pixel {
    /* 像素风：等宽英文 + 中文回退 */
    font-family: 'Press Start 2P', 'VT323', 'Courier New', 'Consolas', monospace;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    font-smooth: never;
    letter-spacing: 2px;
}

.pixel-cn {
    font-family: 'ZCOOL KuaiLe', 'Press Start 2P', 'PingFang SC', 'Microsoft YaHei', '微软雅黑', monospace;
    letter-spacing: 4px;
}

.title {
    font-size: clamp(32px, 6vw, 64px);
    color: #FFD93D;
    text-shadow:
        3px 0 0 #2D2D2D, 0 3px 0 #2D2D2D, 3px 3px 0 #2D2D2D,
        6px 6px 0 #E63946, 9px 9px 0 #2D2D2D;
    letter-spacing: 4px;
    text-align: center;
    margin: 20px 0 10px;
    animation: titleBounce 1.6s ease-in-out infinite;
}

.title-sub {
    font-size: clamp(28px, 5vw, 56px);
    color: #E63946;
    text-shadow:
        2px 0 0 #2D2D2D, 0 2px 0 #2D2D2D, 2px 2px 0 #2D2D2D,
        4px 4px 0 #FFD93D;
    text-align: center;
    margin: 0 0 20px;
}

.title-small {
    font-size: clamp(28px, 4vw, 48px);
    color: #E63946;
    text-shadow: 2px 2px 0 #FFD93D, 4px 4px 0 #2D2D2D;
    text-align: center;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.subtitle {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: clamp(20px, 2.5vw, 32px);
    color: #2D2D2D;
    margin-top: 16px;
    text-align: center;
    text-shadow: 1px 1px 0 #FFF;
}

.subtitle-small {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: clamp(16px, 1.5vw, 22px);
    color: #555;
    margin-top: 8px;
    text-align: center;
}

.emoji-row {
    font-size: 40px;
    margin: 20px 0 30px;
    letter-spacing: 16px;
    animation: emojiSpin 3s linear infinite;
}

@keyframes emojiSpin {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(2deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.hint {
    margin-top: 24px;
    font-size: 16px;
    color: #888;
    font-style: italic;
    text-align: center;
}

/* ---------- 像素按钮 ---------- */
.doodle-btn {
    font-family: 'ZCOOL KuaiLe', sans-serif;
    font-weight: 700;
    border: 4px solid #2D2D2D;
    border-radius: 12px;
    background: #FFF8E7;
    color: #2D2D2D;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 5px 5px 0 #2D2D2D;
    position: relative;
    text-shadow: 1px 1px 0 #FFF;
}

.doodle-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0 #2D2D2D;
}

.doodle-btn:active {
    transform: translate(3px, 3px);
    box-shadow: 2px 2px 0 #2D2D2D;
}

.doodle-btn.big {
    font-size: 28px;
    padding: 18px 40px;
    min-width: 280px;
}

.doodle-btn.small {
    font-size: 18px;
    padding: 10px 20px;
    margin: 6px;
}

.doodle-btn.yellow {
    background: #FFD93D;
}

.doodle-btn.green {
    background: #7BC950;
    color: #FFF;
    text-shadow: 1px 1px 0 #2D2D2D;
}

.doodle-btn.gray {
    background: #DDD;
}

.doodle-btn.absolute {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

/* ---------- 名册编辑 ---------- */
.name-list {
    width: 100%;
    max-width: 700px;
    margin: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.name-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #FFFFFF;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: 3px 3px 0 #2D2D2D;
    transition: transform 0.1s;
}

.name-row:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #2D2D2D;
}

.name-index {
    font-family: 'Press Start 2P', monospace;
    font-size: 18px;
    color: #E63946;
    min-width: 40px;
    text-align: center;
}

.name-input {
    flex: 1;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 22px;
    border: none;
    background: transparent;
    outline: none;
    color: #2D2D2D;
    padding: 4px 8px;
    border-bottom: 2px dashed transparent;
}

.name-input:focus {
    border-bottom-color: #E63946;
}

.name-input::placeholder {
    color: #BBB;
    font-style: italic;
}

.btn-del {
    background: #E63946;
    color: #FFF8E7;
    border: 2px solid #2D2D2D;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 #2D2D2D;
}

.btn-del:hover {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #2D2D2D;
}

.edit-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

/* ---------- 游戏内 HUD ---------- */
#game-page {
    padding: 0;
    background: #87CEEB;
    /* 关键：让 canvas 绝对定位能填满整个页面 */
    align-items: stretch;
    justify-content: flex-start;
    flex-direction: row;
}

#game-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: block;
    z-index: 0;
}

.hud {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #FFD93D;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 10px 16px;
    box-shadow: 4px 4px 0 #2D2D2D;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 20px;
    min-width: 160px;
}

.hud-item {
    color: #2D2D2D;
    text-shadow: 1px 1px 0 #FFF;
}

.hud-item span {
    color: #E63946;
    font-weight: 700;
    font-size: 24px;
}

.mode-banner {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    background: #FFD93D;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 8px 20px;
    box-shadow: 4px 4px 0 #2D2D2D;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 20px;
    color: #2D2D2D;
    white-space: nowrap;
    text-shadow: 1px 1px 0 #FFF;
}

.cam-preview-wrap {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 5;
    width: 200px;
    height: 150px;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 4px 4px 0 #2D2D2D;
    background: #000;
    transform: scaleX(-1);
}

#cam-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#hand-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transform: scaleX(-1);
}

.cam-label {
    position: absolute;
    bottom: 4px;
    left: 6px;
    color: #FFD93D;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 12px;
    text-shadow: 1px 1px 0 #000;
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 4px;
}

.cam-preview-wrap.hidden {
    display: none;
}

/* AI 检测状态视觉反馈 */
.cam-preview-wrap.cam-detected {
    box-shadow: 0 0 0 4px #7BC950, 0 0 20px #7BC950;
}
.cam-preview-wrap.cam-no-detect {
    box-shadow: 0 0 0 3px #E63946;
}

/* ---------- 暂停按钮（圆形，移动端友好）---------- */
.btn-pause {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 7;
    width: 48px;
    height: 48px;
    background: #FFF8E7;
    border: 3px solid #2D2D2D;
    border-radius: 50%;
    font-size: 22px;
    box-shadow: 3px 3px 0 #2D2D2D;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.btn-pause:active {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 #2D2D2D;
}

/* ---------- 二维码（主菜单）---------- */
.qr-section {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.qr-box {
    background: #FFF8E7;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 8px;
    box-shadow: 4px 4px 0 #2D2D2D;
    display: flex;
    align-items: center;
    justify-content: center;
}
#qr-canvas {
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}
#qr-canvas img,
#qr-canvas canvas {
    width: 140px;
    height: 140px;
    display: block;
    image-rendering: pixelated;
}
.qr-hint {
    color: #FFD93D;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 16px;
    text-shadow: 2px 2px 0 #2D2D2D;
    margin-top: 4px;
}
.qr-url {
    color: #FFF8E7;
    font-family: 'VT323', monospace;
    font-size: 14px;
    background: rgba(0, 0, 0, 0.4);
    padding: 2px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
}

/* ---------- 移动端调量滑块 ---------- */
.mobile-power-bar {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 7;
    background: rgba(255, 248, 231, 0.95);
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 8px 14px;
    box-shadow: 4px 4px 0 #2D2D2D;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.mobile-power-bar.hidden {
    display: none;
}
.mpb-label {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 16px;
    color: #2D2D2D;
    white-space: nowrap;
}
.mpb-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 10px;
    background: linear-gradient(to right, #FFD93D 0%, #E63946 100%);
    border: 2px solid #2D2D2D;
    border-radius: 8px;
    outline: none;
    touch-action: pan-y;
}
.mpb-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 28px;
    background: #E63946;
    border: 3px solid #2D2D2D;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 2px 2px 0 #2D2D2D;
}
.mpb-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    background: #E63946;
    border: 3px solid #2D2D2D;
    border-radius: 50%;
    cursor: pointer;
}
.mpb-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    color: #2D2D2D;
    min-width: 50px;
    text-align: right;
}

/* ---------- 移动端操作提示 ---------- */
.mobile-hint {
    position: absolute;
    top: 80px;
    right: 20px;
    z-index: 7;
    background: rgba(0, 0, 0, 0.7);
    color: #FFF8E7;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    line-height: 1.6;
    border: 2px solid #FFD93D;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    max-width: 180px;
}
.mobile-hint.hidden {
    display: none;
}
.mobile-hint b {
    color: #FFD93D;
}

/* ---------- 移动端响应式 ---------- */
@media (max-width: 600px) {
    .cam-preview-wrap {
        width: 110px !important;
        height: 82px !important;
        top: 10px;
        right: 10px;
        left: auto;
    }
    .cam-label {
        font-size: 10px;
    }
    .hud {
        top: 10px !important;
        right: 130px !important;
        left: auto !important;
        font-size: 12px !important;
        padding: 6px 10px !important;
    }
    .hud-item {
        font-size: 12px !important;
    }
    .mode-banner {
        font-size: 12px !important;
        padding: 6px 10px !important;
        top: 10px !important;
    }
    .btn-pause {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    .control-panel {
        font-size: 11px !important;
        padding: 8px 10px !important;
    }
    .title {
        font-size: 32px !important;
    }
    .title-sub {
        font-size: 22px !important;
    }
    .subtitle {
        font-size: 14px !important;
    }
    .qr-box {
        padding: 6px;
    }
    #qr-canvas,
    #qr-canvas img,
    #qr-canvas canvas {
        width: 110px;
        height: 110px;
    }
}
.debug-panel.hidden {
    display: none;
}

/* ---------- 控制面板 ---------- */
.control-panel {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 6;
    background: #FFF8E7;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 10px 18px;
    box-shadow: 4px 4px 0 #2D2D2D;
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 16px;
    color: #2D2D2D;
    text-align: center;
    min-width: 260px;
}

.control-panel.alert {
    background: #E63946;
    color: #FFF8E7;
    animation: panelPulse 0.8s ease-in-out infinite;
}

@keyframes panelPulse {
    0%, 100% { transform: translateX(-50%) scale(1); }
    50% { transform: translateX(-50%) scale(1.04); }
}

.ctrl-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #E63946;
    text-shadow: 1px 1px 0 #FFF;
}

.control-panel.alert .ctrl-title {
    color: #FFD93D;
    text-shadow: 1px 1px 0 #2D2D2D;
}

.ctrl-row {
    margin: 3px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

kbd {
    display: inline-block;
    background: #FFD93D;
    border: 2px solid #2D2D2D;
    border-radius: 6px;
    padding: 2px 8px;
    font-family: 'Press Start 2P', monospace;
    font-weight: 700;
    font-size: 12px;
    box-shadow: 2px 2px 0 #2D2D2D;
    min-width: 24px;
    text-align: center;
}

.ctrl-hint {
    font-size: 13px;
    margin-top: 4px;
    opacity: 0.85;
    font-style: italic;
}

.btn-toggle {
    margin-top: 10px;
    padding: 8px 16px;
    background: #4A6FA5;
    color: #FFF8E7;
    border: 3px solid #2D2D2D;
    border-radius: 8px;
    font-family: 'ZCOOL KuaiLe', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 2px 2px 0 #2D2D2D;
    transition: transform 0.1s;
}
.btn-toggle:hover {
    background: #5A8FBD;
}
.btn-toggle:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #2D2D2D;
}

/* ---------- 主菜单按钮组 ---------- */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    margin-top: 20px;
}

/* ---------- 通关结算 ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: 30px 0;
    max-width: 900px;
    width: 100%;
}

.stat-card {
    background: #FFFFFF;
    border: 3px solid #2D2D2D;
    border-radius: 12px;
    padding: 20px 12px;
    box-shadow: 5px 5px 0 #2D2D2D;
    text-align: center;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translate(-2px, -2px) rotate(-1deg);
    box-shadow: 7px 7px 0 #2D2D2D;
}

.stat-label {
    font-family: 'ZCOOL KuaiLe', cursive;
    font-size: 20px;
    color: #555;
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Press Start 2P', monospace;
    font-size: 32px;
    color: #E63946;
    text-shadow: 2px 2px 0 #FFD93D;
    font-weight: 700;
}

.win-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-top: 20px;
}

/* ---------- 背景星星 ---------- */
.bg-stars {
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-size: 30px;
    letter-spacing: 80px;
    line-height: 100px;
    word-spacing: 80px;
    opacity: 0.3;
    animation: starsTwinkle 2s ease-in-out infinite;
    overflow: hidden;
}

@keyframes starsTwinkle {
    0%, 100% { opacity: 0.25; }
    50% { opacity: 0.6; }
}

.page::-webkit-scrollbar {
    width: 12px;
}
.page::-webkit-scrollbar-track {
    background: #FFF8E7;
}
.page::-webkit-scrollbar-thumb {
    background: #E63946;
    border: 2px solid #FFF8E7;
    border-radius: 6px;
}
