* {
    margin: 0; padding: 0; box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* 移除移动端点击高亮 */
}

/* 防止移动端意外缩放和选择 */
body {
    font-family: 'Microsoft YaHei', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
    transition: background 0.3s;
    overflow-x: hidden;
}

/* 允许输入框选择文本 */
input, textarea, select, .config-panel, .multi-result {
    user-select: auto;
    -webkit-user-select: auto;
}

:root {
    /* 浅色模式变量 */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --container-bg: rgba(255,255,255,0.95);
    --text-primary: #333;
    --text-secondary: #666;
    --config-bg: #f5f5f5;
    --config-section-bg: #fff;
    --modal-bg: linear-gradient(135deg, #667eea, #764ba2);
    --btn-primary: #667eea;
    --btn-danger: #ff6b6b;
    --btn-success: #4ecdc4;
    --input-border: #ddd;
}

[data-theme="dark"] {
    /* 深色模式变量 */
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    --container-bg: rgba(30, 30, 50, 0.95);
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --config-bg: #1a1a2e;
    --config-section-bg: #252540;
    --modal-bg: linear-gradient(135deg, #1a1a2e, #16213e);
    --btn-primary: #4e9af1;
    --btn-danger: #e74c3c;
    --btn-success: #2ecc71;
    --input-border: #3a3a5a;
}

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex; justify-content: center; align-items: center;
    transition: background 0.3s;
}
.settings-btn {
    position: fixed; top: 20px; right: 20px;
    padding: 10px 20px; border: none; border-radius: 10px;
    background: rgba(255,255,255,0.2); color: #fff;
    font-size: 16px; cursor: pointer; backdrop-filter: blur(10px);
    transition: background 0.3s;
}
.settings-btn:hover { background: rgba(255,255,255,0.3); }

.theme-toggle-btn {
    position: fixed; top: 20px; right: 130px;
    padding: 10px 15px; border: none; border-radius: 10px;
    background: rgba(255,255,255,0.2); color: #fff;
    font-size: 18px; cursor: pointer; backdrop-filter: blur(10px);
    transition: background 0.3s, transform 0.3s;
}
.theme-toggle-btn:hover { background: rgba(255,255,255,0.3); }
.theme-toggle-btn.sun { transform: rotate(180deg); }

.container {
    text-align: center; background: var(--container-bg);
    padding: 30px; border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    transition: background 0.3s;
}
h1 { color: var(--text-primary); margin-bottom: 20px; transition: color 0.3s; }
.spin-mode-selector {
    display: flex; gap: 10px; justify-content: center; margin-bottom: 20px;
}
.mode-btn {
    padding: 10px 20px; border: 2px solid var(--btn-primary);
    background: transparent; color: var(--btn-primary);
    border-radius: 8px; cursor: pointer; font-size: 14px;
    transition: all 0.3s;
}
.mode-btn:hover { background: var(--btn-primary); color: #fff; }
.mode-btn:active { transform: scale(0.95); }
.mode-btn.active {
    background: var(--btn-primary); color: #fff;
}
.wheel-wrapper { position: relative; display: inline-block; margin: 20px 0; }
#wheel { border-radius: 50%; box-shadow: 0 5px 20px rgba(0,0,0,0.3); }
.wheel-pointer {
    position: absolute; top: -15px; left: 50%; transform: translateX(-50%);
    font-size: 24px; color: #f5576c; z-index: 10;
    text-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.spin-btn {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 70px; height: 70px; border-radius: 50%;
    background: linear-gradient(135deg, #f093fb, #f5576c);
    border: 4px solid #fff; color: #fff; font-size: 14px; font-weight: bold;
    cursor: pointer; transition: transform 0.2s, background 0.2s;
}
.spin-btn:hover { transform: translate(-50%, -50%) scale(1.1); }
.spin-btn:active { transform: translate(-50%, -50%) scale(0.95); }
.spin-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.multi-spin-options {
    display: flex; gap: 20px; justify-content: center;
    margin: 15px 0; flex-wrap: wrap;
}
.multi-spin-options label {
    display: flex; align-items: center; gap: 8px;
    color: var(--text-primary); font-size: 14px;
}
.multi-spin-options input {
    width: 60px; padding: 6px; border: 1px solid var(--input-border);
    border-radius: 5px; background: var(--config-section-bg);
    color: var(--text-primary); transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.multi-spin-options.hidden { display: none; }
.result {
    font-size: 1.4em; font-weight: bold; color: var(--btn-primary);
    min-height: 35px; margin: 15px 0;
    transition: color 0.3s;
}
.multi-result {
    max-height: 300px; overflow-y: auto; margin: 15px 0;
    padding: 15px; background: var(--config-bg);
    border-radius: 10px; transition: background 0.3s;
}
.multi-result.hidden { display: none; }
.multi-result-item {
    display: flex; justify-content: space-between;
    align-items: center; padding: 10px;
    margin-bottom: 8px; background: var(--config-section-bg);
    border-radius: 8px; transition: background 0.3s;
}
.multi-result-item:last-child { margin-bottom: 0; }
.multi-result-index {
    color: var(--text-secondary); font-size: 14px;
}
.multi-result-prize {
    font-weight: bold; color: var(--btn-primary);
}
.multi-result-icon { margin-right: 8px; }
.config-toggle {
    padding: 8px 16px; border: none; border-radius: 8px;
    background: var(--btn-primary); color: #fff; cursor: pointer;
    transition: background 0.3s;
}
.config-toggle:active { transform: scale(0.95); }
.config-panel {
    margin-top: 20px; padding: 20px; background: var(--config-bg);
    border-radius: 10px; text-align: left;
    transition: background 0.3s;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
}
.config-panel.hidden { display: none; }
.config-panel h3 { margin-bottom: 15px; color: var(--text-primary); transition: color 0.3s; }
.prize-row {
    display: flex; gap: 10px; margin-bottom: 10px; align-items: center;
    flex-wrap: wrap;
}
.prize-row input[type="text"] {
    flex: 2; min-width: 80px; padding: 8px; border: 1px solid var(--input-border);
    border-radius: 5px; background: var(--config-section-bg); color: var(--text-primary);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.prize-row input[type="number"] {
    width: 70px; min-width: 60px; padding: 8px; border: 1px solid var(--input-border);
    border-radius: 5px; background: var(--config-section-bg); color: var(--text-primary);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.prize-row input[type="color"] { width: 40px; height: 35px; border: none; cursor: pointer; }
.prize-row button {
    padding: 5px 10px; background: var(--btn-danger); color: #fff;
    border: none; border-radius: 5px; cursor: pointer;
    transition: background 0.3s; white-space: nowrap;
}
.add-prize-btn {
    padding: 8px 16px; background: var(--btn-success); color: #fff;
    border: none; border-radius: 5px; cursor: pointer;
    margin: 10px 0; transition: background 0.3s; width: 100%;
}
.config-section {
    margin: 15px 0; padding: 15px; background: var(--config-section-bg);
    border-radius: 8px; transition: background 0.3s;
}
.config-section h4 { margin-bottom: 10px; color: var(--text-secondary); transition: color 0.3s; }
.config-section label { display: block; margin: 10px 0 5px; color: var(--text-primary); transition: color 0.3s; }
.config-section select, .config-section input {
    padding: 8px; border: 1px solid var(--input-border); border-radius: 5px;
    background: var(--config-section-bg); color: var(--text-primary);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
    width: 100%; box-sizing: border-box;
}
.export-btn {
    padding: 8px 16px; background: #95a5a6; color: #fff;
    border: none; border-radius: 5px; cursor: pointer; margin-right: 10px;
}
.admin-btn {
    padding: 10px 16px; background: var(--btn-primary); color: #fff; border: none;
    border-radius: 5px; cursor: pointer; margin: 5px 0; width: 100%;
    transition: background 0.3s;
}
.admin-btn.admin-logout { background: var(--btn-danger); }
.admin-btn:hover { opacity: 0.9; }
.auth-status {
    padding: 10px; background: var(--config-bg); border-radius: 5px;
    margin: 10px 0; font-size: 14px;
    transition: background 0.3s;
}
.status-indicator {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; background: #95a5a6; margin-right: 8px;
}
.status-indicator.active { background: #2ecc71; }
.auth-input {
    width: 100%; padding: 12px; border: 1px solid var(--input-border);
    border-radius: 5px; font-size: 14px; margin: 10px 0;
    background: var(--config-section-bg); color: var(--text-primary);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.auth-input-full {
    width: 100%; padding: 10px; border: 1px solid var(--input-border);
    border-radius: 5px; font-size: 14px; margin: 8px 0;
    background: var(--config-section-bg); color: var(--text-primary);
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.auth-buttons { display: flex; gap: 10px; margin-top: 10px; }
.auth-btn-confirm {
    flex: 1; padding: 10px; background: var(--btn-primary); color: #fff;
    border: none; border-radius: 5px; cursor: pointer;
    transition: background 0.3s;
}
.auth-btn-cancel {
    flex: 1; padding: 10px; background: #95a5a6; color: #fff;
    border: none; border-radius: 5px; cursor: pointer;
}
.auth-error { color: #e74c3c; font-size: 13px; margin-top: 10px; }
.auth-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); display: flex;
    justify-content: center; align-items: center; z-index: 1000;
    padding: 20px;
}
.auth-modal-content {
    background: var(--config-section-bg); padding: 30px; border-radius: 15px;
    width: 100%; max-width: 400px; max-height: 90vh;
    overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    transition: background 0.3s;
}
.auth-modal-content h3 { margin-bottom: 20px; color: var(--text-primary); transition: color 0.3s; }
@media (max-width: 500px) {
    .container { padding: 20px 15px; }
    h1 { font-size: 1.5em; }
    #wheel { width: 280px; height: 280px; }
    .spin-btn { width: 55px; height: 55px; font-size: 11px; }
    .wheel-pointer { font-size: 20px; top: -12px; }
    .result { font-size: 1.1em; }
    .settings-btn { top: 10px; right: 10px; padding: 6px 12px; font-size: 13px; }
    .theme-toggle-btn { top: 10px; right: 65px; padding: 6px 10px; font-size: 15px; }
    .spin-mode-selector { gap: 8px; margin-bottom: 15px; }
    .mode-btn { padding: 8px 16px; font-size: 13px; }
    .config-toggle { padding: 6px 14px; font-size: 13px; }
    .multi-spin-options { gap: 15px; font-size: 13px; }
    .multi-spin-options input { width: 50px; padding: 5px; }

    /* 多轮结果适配 */
    .multi-result {
        max-height: 200px; padding: 10px;
    }
    .multi-result-item {
        padding: 8px; font-size: 13px;
    }

    /* 配置面板适配 */
    .config-panel {
        max-height: 50vh; padding: 15px;
        margin-top: 15px;
    }
    .config-panel h3 { font-size: 1.2em; }
    .config-section { margin: 10px 0; padding: 12px; }
    .config-section h4 { font-size: 0.95em; }

    /* 奖品配置适配 */
    .prize-row {
        gap: 8px; margin-bottom: 8px;
    }
    .prize-row input[type="text"] {
        flex: 1; min-width: 60px; padding: 6px; font-size: 13px;
    }
    .prize-row input[type="number"] {
        width: 55px; padding: 6px; font-size: 13px;
    }
    .prize-row input[type="color"] {
        width: 35px; height: 30px;
    }
    .prize-row button {
        padding: 4px 8px; font-size: 12px;
    }
    .add-prize-btn {
        padding: 10px; font-size: 14px;
    }

    /* 模态框适配 */
    .prize-modal-content { padding: 30px 20px; }
    .prize-modal-header { font-size: 1.5em; }
    .prize-modal-icon { font-size: 60px; }
    .prize-modal-name { font-size: 2em; }
    .prize-modal-close { padding: 10px 30px; font-size: 14px; }

    /* 登录模态框适配 */
    .auth-modal-content {
        padding: 20px; width: 95%;
    }
    .auth-modal-content h3 { font-size: 1.3em; margin-bottom: 15px; }
    .auth-input { padding: 10px; font-size: 14px; }
    .auth-btn-confirm, .auth-btn-cancel {
        padding: 12px; font-size: 14px;
    }

    /* 按钮最小触摸尺寸 */
    .config-toggle, .export-btn {
        min-height: 44px; display: inline-flex;
        align-items: center; justify-content: center;
    }
    .admin-btn {
        min-height: 44px;
    }
}

@media (max-width: 350px) {
    #wheel { width: 240px; height: 240px; }
    .spin-btn { width: 50px; height: 50px; font-size: 10px; }
    .container { padding: 15px 10px; }
    h1 { font-size: 1.3em; }

    /* 奖品配置更小屏幕适配 */
    .prize-row {
        gap: 6px;
    }
    .prize-row input[type="text"] {
        flex: 1; min-width: 50px; padding: 5px; font-size: 12px;
    }
    .prize-row input[type="number"] {
        width: 45px; padding: 5px; font-size: 12px;
    }
    .prize-row input[type="color"] {
        width: 32px; height: 28px;
    }
    .prize-row button {
        padding: 3px 6px; font-size: 11px;
    }
}

/* 平板设备 */
@media (min-width: 501px) and (max-width: 768px) {
    #wheel { width: 350px; height: 350px; }
    .spin-btn { width: 65px; height: 65px; font-size: 13px; }
}

/* 横屏适配 */
@media (max-height: 500px) and (orientation: landscape) {
    .container { padding: 15px; }
    #wheel { width: 250px; height: 250px; }
    .spin-btn { width: 50px; height: 50px; font-size: 10px; }
    h1 { font-size: 1.3em; margin-bottom: 10px; }
    .result { margin: 10px 0; min-height: 25px; }
    .wheel-wrapper { margin: 10px 0; }

    /* 配置面板横屏适配 */
    .config-panel {
        max-height: 40vh;
    }

    /* 模态框横屏适配 */
    .prize-modal-content,
    .auth-modal-content {
        padding: 20px;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    .spin-btn, .mode-btn, .config-toggle, .prize-modal-close,
    .settings-btn, .theme-toggle-btn, .admin-btn, .export-btn,
    .add-prize-btn, .prize-row button, .auth-btn-confirm, .auth-btn-cancel {
        min-height: 44px; /* iOS 推荐的最小触摸目标 */
        min-width: 44px;
        touch-action: manipulation;
    }
    .spin-btn { min-width: 60px; min-height: 60px; }

    /* 输入框触摸优化 */
    input, select {
        min-height: 44px;
        touch-action: manipulation;
    }
    input[type="color"] {
        min-height: auto;
    }
}
.prize-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: flex;
    justify-content: center; align-items: center; z-index: 2000;
    animation: fadeIn 0.3s; padding: 20px;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.prize-modal-content {
    background: var(--modal-bg);
    padding: 40px; border-radius: 20px;
    text-align: center; box-shadow: 0 15px 50px rgba(0,0,0,0.4);
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: background 0.3s;
    width: 100%; max-width: 400px; max-height: 90vh;
    overflow-y: auto;
}
@keyframes popIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.prize-modal-header {
    font-size: 2em; font-weight: bold; color: #fff;
    margin-bottom: 20px; text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.prize-modal-body { margin: 30px 0; }
.prize-modal-icon { font-size: 80px; margin-bottom: 15px; animation: bounce 1s infinite; }
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
.prize-modal-level {
    font-size: 1.5em; font-weight: bold; color: rgba(255,255,255,0.9);
    margin-bottom: 10px; text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.prize-modal-name {
    font-size: 2.8em; font-weight: bold; color: #fff;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.prize-modal-close {
    padding: 12px 40px; border: none; border-radius: 25px;
    background: #fff; color: var(--btn-primary); font-size: 16px;
    font-weight: bold; cursor: pointer; transition: transform 0.2s, color 0.3s;
}
.prize-modal-close:hover { transform: scale(1.05); }
.prize-modal-close:active { transform: scale(0.95); }

/* 特效画布样式 */
.effect-canvas {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 3000 !important;
}
