:root {
    --paper-bg: #f4e4c1;
    --ink-black: #2c2c2c;
    --stamp-red: #c0392b;
    --jade-green: #27ae60;
    --gold: #f1c40f;
    --border-color: #5d4037;
    --wood-color: #8d6e63;
    --disabled-gray: #9e9e9e;
    --book-page: #fffdf5;
    --purple-royal: #8e44ad;
}

body {
    font-family: "KaiTi", "STKaiti", "Baskerville", serif;
    background-color: var(--paper-bg);
    background-image: url('https://www.transparenttextures.com/patterns/aged-paper.png');
    color: var(--ink-black);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    user-select: none;
    touch-action: manipulation; 
}

.container {
    width: 90%;
    max-width: 700px;
    height: 90vh;
    max-height: 800px;
    border: 4px double var(--border-color);
    padding: 20px;
    position: relative;
    background: rgba(255, 255, 255, 0.5);
    box-shadow: 0 0 25px rgba(0,0,0,0.25);
    border-radius: 8px;
    text-align: center;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden; 
}

h1, h2, h3 { margin: 10px 0; font-weight: bold; text-shadow: 1px 1px 2px rgba(0,0,0,0.1); flex-shrink: 0; }
.decorative-line { height: 2px; background: linear-gradient(90deg, transparent, var(--ink-black), transparent); margin: 10px 0; flex-shrink: 0; }

/* --- 页面切换 --- */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden; 
    animation: fadeIn 0.4s ease;
}
.screen.active { display: flex; }

#game-screen {
    overflow: hidden; 
    justify-content: space-between; 
    padding-bottom: 5px;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- 按钮样式 --- */
.btn {
    background-color: var(--border-color); color: var(--paper-bg); border: none; padding: 10px 20px;
    font-size: 18px; cursor: pointer; font-family: inherit; border-radius: 4px; transition: all 0.2s;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3); margin: 5px; font-weight: bold;
}
.btn:active:not(:disabled) { transform: scale(0.95); }
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; background-color: #ccc !important; }

.btn-danger { background-color: var(--stamp-red); color: white; font-size: 14px; padding: 5px 10px;}
.btn-mistake { background-color: var(--wood-color); color: white; }
.btn-setting { background-color: #607d8b; color: white; grid-column: 1 / -1; }

/* 难度选择大按钮 */
.difficulty-btn {
    width: 80%; padding: 20px; margin: 15px 0; font-size: 24px; border-radius: 10px; cursor: pointer;
    border: 3px double var(--paper-bg); transition: transform 0.2s, box-shadow 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.btn-easy { background-color: var(--jade-green); color: white; }
.btn-hard { background-color: var(--stamp-red); color: white; }
.difficulty-btn:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.diff-desc { font-size: 14px; margin-top: 5px; opacity: 0.9; font-weight: normal; }

.home-actions { display: flex; justify-content: center; gap: 10px; width: 100%; max-width: 300px; margin-top: 10px; }
.btn-start { width: 100%; background-color: var(--ink-black); color: var(--gold); font-size: 22px; padding: 15px; }

.id-selection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px; width: 100%; padding: 10px 5px; box-sizing: border-box; overflow-y: auto; flex-grow: 1; }

/* --- 科目选择 --- */
.category-grid { 
    display: flex; justify-content: center; gap: 12px; margin-top: 20px; 
    width: 100%; height: 340px; flex-wrap: nowrap; overflow-x: auto; 
    align-items: center; padding: 20px 10px; box-sizing: border-box;
}
.category-btn {
    min-width: 55px; width: 60px; height: 90%; border: 2px solid var(--border-color); border-radius: 50px;
    display: flex; align-items: center; justify-content: center; writing-mode: vertical-rl; text-orientation: upright;
    font-size: 22px; font-weight: bold; cursor: pointer; letter-spacing: 8px; transition: all 0.3s;
    background-color: #fff; box-shadow: 3px 3px 6px rgba(0,0,0,0.2); position: relative; flex-shrink: 0; 
}
.category-btn.active { background-color: var(--stamp-red); color: var(--gold); border-color: var(--stamp-red); }
.category-btn.active:hover { transform: scale(1.05); box-shadow: 0 0 15px var(--stamp-red); z-index: 10; }
.category-btn.hidden { display: none; }

/* --- 考生须知 --- */
.instruction-box {
    background: rgba(255,255,255,0.7); border: 1px solid var(--border-color); padding: 15px;
    border-radius: 5px; text-align: left; margin: 5px 0 15px 0;
    font-size: 15px; line-height: 1.5;
}

.instruction-box p {
    margin: 8px 0;
}

/* --- 倒计时页 --- */
#countdown-display { font-size: 120px; color: var(--stamp-red); font-weight: bold; animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* --- 答题核心区 --- */
.status-bar { display: flex; justify-content: space-between; width: 100%; font-size: 18px; margin-bottom: 5px; font-weight: bold; flex-shrink: 0; }

/* 连对贴纸样式 */
.streak-sticker {
    position: absolute; top: 10px; left: 10px;
    padding: 8px 16px; border-radius: 20px; font-size: 16px; font-weight: bold;
    z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: rotate(0deg); transition: all 0.3s ease;
    border: 1px solid #ccc;
    white-space: nowrap;
    background: #fdfbf7; 
    color: #666;
}
.streak-sticker.streak-pulse {
    animation: streakPulse 0.6s ease-in-out;
}
@keyframes streakPulse {
    0%, 100% { transform: rotate(-5deg) scale(1); }
    50% { transform: rotate(-5deg) scale(1.15); }
}

.streak-sticker.level-1 {
    background: linear-gradient(135deg, var(--jade-green), #2ecc71);
    color: white; border-color: var(--jade-green);
    padding: 8px 24px;
}
.streak-sticker.level-2 {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white; border-color: #3498db;
    padding: 8px 28px;
}
.streak-sticker.level-3 {
    background: linear-gradient(135deg, var(--gold), #f39c12);
    color: white; border-color: var(--gold);
    padding: 8px 32px;
}
.timer-container {
    width: 100%; height: 24px; background: #ddd; margin-bottom: 10px; border-radius: 12px; 
    overflow: hidden; flex-shrink: 0; border:1px solid #999; position: relative;
}
.timer-fill { height: 100%; background: var(--stamp-red); width: 100%; transition: width 0s linear; }
.timer-text {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: bold; color: white;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
    z-index: 2; pointer-events: none;
}
.question-box {
    font-size: 28px; font-weight: bold; padding: 10px 15px;
    border-top: 2px solid var(--border-color); border-bottom: 2px solid var(--border-color);
    background: rgba(255,255,255,0.3); width: 100%; flex-grow: 1; max-height: 35%; min-height: 80px;
    display: flex; align-items: center; justify-content: center; margin: 5px 0; box-sizing: border-box;
}
.options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; flex-shrink: 0; margin-bottom: 5px; }
.option-btn {
    background: white; border: 2px solid var(--border-color); padding: 12px 5px;
    font-size: 18px; cursor: pointer; font-family: inherit; transition: transform 0.1s;
    position: relative; border-radius: 6px; font-weight: bold; box-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    display: flex; align-items: center; justify-content: center;
}
.option-btn.correct-fast { background-color: var(--jade-green) !important; color: white; border-color: var(--jade-green); }
.option-btn.wrong { background-color: var(--stamp-red); color: white; border-color: var(--stamp-red); animation: shakeError 0.4s ease-in-out; }

@keyframes shakeError { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.game-footer { width: 100%; flex-shrink: 0; display: flex; justify-content: center; align-items: center; margin-top: 15px; }
.btn-mini-back {
    background: transparent; color: var(--ink-black); border: 1px solid var(--border-color);
    padding: 8px 20px; font-size: 16px; border-radius: 20px; cursor: pointer; opacity: 0.8; transition: all 0.3s;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-mini-back:hover { background: var(--stamp-red); color: white; border-color: var(--stamp-red); opacity: 1; transform: translateY(-2px); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }

/* 称号印章 */
.title-seal {
    position: absolute; top: 10px; right: 10px; width: 70px; height: 70px;
    border: 3px solid var(--stamp-red); border-radius: 5px; color: var(--stamp-red);
    display: none; justify-content: center; align-items: center; font-size: 20px;
    transform: rotate(15deg); opacity: 0; background: rgba(255,255,255,0.9); z-index: 10; font-weight: bold; pointer-events: none;
}
.title-seal.show { opacity: 1; animation: stampIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes stampIn { from { transform: scale(1.5) rotate(15deg); opacity: 0; } to { transform: scale(1) rotate(15deg); opacity: 1; } }

/* --- 错题与弹窗 --- */
.id-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; padding: 10px; box-sizing: border-box;}
.id-card { background: #fff; border: 1px solid var(--border-color); padding: 15px 0; cursor: pointer; border-radius: 4px; box-shadow: 2px 2px 3px rgba(0,0,0,0.1); transition: all 0.2s; }
.id-card:hover { background: var(--border-color); color: white; transform: translateY(-3px); }

.mistake-list { width: 100%; text-align: left; }
.mistake-item { background: rgba(255,255,255,0.6); border-left: 5px solid var(--stamp-red); margin-bottom: 10px; padding: 10px 12px; border-radius: 0 6px 6px 0; display: flex; justify-content: space-between; align-items: center; }
.mistake-q { font-weight: bold; font-size: 17px; margin-bottom: 3px; }
.mistake-a { font-size: 14px; color: var(--jade-green); font-weight: bold; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; background-color: #ccc !important; }

#flash-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; opacity: 0; z-index: 999; }
.flash-red { animation: flashRed 0.4s ease-in-out; }
@keyframes flashRed { 0% { background-color: rgba(255, 0, 0, 0.6); opacity: 1; } 100% { background-color: transparent; opacity: 0; } }

.modal-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s;
}
.modal-content {
    background: var(--book-page); padding: 20px; border-radius: 8px;
    border: 2px solid var(--border-color); text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4); width: 85%; max-width: 320px;
}
.modal-actions { display: flex; justify-content: space-around; margin-top: 20px; gap: 10px; }

.setting-item { width: 100%; background: rgba(255,255,255,0.6); padding: 15px; margin-bottom: 10px; border-radius: 5px; display: flex; flex-direction: column; box-sizing: border-box; border: 1px solid #ccc; }

/* --- 登录/注册界面样式 --- */
.auth-tabs { display: flex; justify-content: center; margin-bottom: 20px; border-bottom: 2px solid var(--border-color); }
.auth-tab { padding: 10px 20px; cursor: pointer; font-weight: bold; opacity: 0.6; transition: 0.3s; border-radius: 5px 5px 0 0; }
.auth-tab.active { opacity: 1; background: rgba(255,255,255,0.6); border: 2px solid var(--border-color); border-bottom: none; color: var(--stamp-red); }
.auth-form { display: none; flex-direction: column; align-items: center; gap: 15px; width: 100%; }
.auth-form.active { display: flex; animation: fadeIn 0.3s; }
.auth-input { 
    width: 260px; 
    height: 48px;
    padding: 10px 12px; 
    font-size: 18px; 
    border: 2px solid var(--border-color); 
    border-radius: 6px; 
    background: rgba(255,255,255,0.8); 
    outline: none; 
    text-align: center; 
    box-sizing: border-box;
}
select.auth-input { text-align-last: center; }

/* 隐藏 number input 的上下箭头 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
