/* Dynasty Timeline - 朝代时间轴 */
* { margin: 0; padding: 0; box-sizing: border-box; }

.dt-fullscreen {
    width: 100vw;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #FFF7ED, #FDE68A 60%, #FCD34D);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Header */
.dt-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #B45309, #92400E);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 52px;
}
.back-btn-wrap { position: relative; flex-shrink: 0; }
.back-btn { display: flex; align-items: center; gap: 4px; color: #fff; text-decoration: none; font-size: 14px; padding: 4px 0; }
.back-overlay { display: none; position: absolute; top: -8px; left: -8px; right: -8px; bottom: -8px; cursor: pointer; z-index: 1; }
.back-overlay.active { display: block; }
.dt-header .title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }
.header-actions { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.points-badge { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 14px; font-size: 13px; color: #FFD700; font-weight: 600; cursor: pointer; }
.points-badge i { font-size: 12px; }
.points-badge.pulse { animation: badgePulse 0.5s ease; }
.points-badge.pulse-big { animation: badgePulseBig 0.6s ease; }
@keyframes badgePulse { 0%{transform:scale(1);} 40%{transform:scale(1.25); background:rgba(255,215,0,0.5);} 100%{transform:scale(1);} }
@keyframes badgePulseBig { 0%{transform:scale(1);} 30%{transform:scale(1.4); background:rgba(255,100,0,0.6);} 100%{transform:scale(1);} }

/* Main */
.dt-main { flex: 1; display: flex; flex-direction: column; position: relative; }
.screen { flex: 1; display: flex; flex-direction: column; padding: 16px; animation: fadeIn 0.3s ease; }
.screen.hidden { display: none; }
@keyframes fadeIn { from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:none;} }

/* ===== Menu ===== */
.menu-title { font-size: 26px; font-weight: 800; color: #78350F; text-align: center; margin-top: 16px; letter-spacing: 2px; }
.menu-desc { text-align: center; color: #92400E; font-size: 14px; margin-top: 6px; margin-bottom: 24px; }

.level-grid { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.level-card {
    background: linear-gradient(135deg, #fff, #FEF3C7);
    border: 2px solid #F59E0B;
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 10px rgba(180, 83, 9, 0.15);
}
.level-card:active { transform: scale(0.97); }
.level-card .lvl-icon {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, #F59E0B, #B45309);
    color: #fff; font-size: 20px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.level-card .lvl-body { flex: 1; }
.level-card .lvl-name { font-size: 17px; font-weight: 700; color: #78350F; }
.level-card .lvl-desc { font-size: 12px; color: #92400E; margin-top: 2px; }
.level-card .lvl-meta { font-size: 11px; color: #A16207; margin-top: 4px; }
.level-card .lvl-arrow { color: #B45309; font-size: 20px; }

.menu-stats { display: flex; gap: 12px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.stat-item { background: rgba(255,255,255,0.6); border-radius: 12px; padding: 8px 14px; text-align: center; min-width: 72px; }
.stat-value { font-size: 18px; font-weight: 700; color: #78350F; }
.stat-label { font-size: 11px; color: #92400E; margin-top: 2px; }

.lottery-entry-btn {
    margin: 8px auto 0;
    background: linear-gradient(135deg, #F59E0B, #DC2626);
    color: #fff; border: none; padding: 10px 24px;
    border-radius: 20px; font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 6px; cursor: pointer;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}
.lottery-entry-btn:active { transform: scale(0.96); }

/* ===== Game ===== */
.game-top {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.75); border-radius: 12px;
    padding: 8px 12px; margin-bottom: 12px; font-size: 13px;
    font-weight: 600; color: #78350F; position: relative;
}
.game-timer, .game-level, .game-progress { flex: 1; text-align: center; }
.game-timer i { margin-right: 4px; }
.streak-badge {
    position: absolute; top: -10px; right: -4px;
    background: linear-gradient(135deg, #DC2626, #F59E0B);
    color: #fff; padding: 3px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 700;
    animation: streakPop 0.4s ease;
    box-shadow: 0 3px 8px rgba(220, 38, 38, 0.4);
}
.streak-badge.hidden { display: none; }
@keyframes streakPop { 0%{transform:scale(0);} 60%{transform:scale(1.3);} 100%{transform:scale(1);} }

.dt-hint {
    text-align: center; font-size: 12px; color: #92400E;
    background: rgba(255,255,255,0.55); border-radius: 10px;
    padding: 6px 10px; margin-bottom: 10px;
}

/* Board */
.dt-board {
    flex: 1;
    overflow-y: auto;
    background: rgba(255,255,255,0.4);
    border-radius: 14px;
    padding: 10px 10px 4px;
    min-height: 180px;
    -webkit-overflow-scrolling: touch;
}
.dt-timeline { display: flex; flex-direction: column; gap: 6px; position: relative; }
.dt-timeline::before {
    content: '';
    position: absolute;
    left: 22px; top: 16px; bottom: 16px;
    width: 3px;
    background: linear-gradient(180deg, #FBBF24, #B45309);
    border-radius: 2px;
    opacity: 0.5;
}

.dt-slot {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,255,255,0.85);
    border: 2px dashed #D97706;
    border-radius: 12px;
    padding: 8px 10px 8px 38px;
    min-height: 52px;
    position: relative;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    cursor: grab;
    touch-action: none;
}
.dt-slot:active { cursor: grabbing; }
.dt-slot.dragging-source { opacity: 0.25; }
.dt-slot .slot-num {
    position: absolute; left: 6px; top: 50%; transform: translateY(-50%);
    width: 30px; height: 30px; border-radius: 50%;
    background: #fff; border: 2px solid #D97706;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #B45309; z-index: 2;
}
.dt-slot .slot-content {
    flex: 1; display: flex; align-items: center; justify-content: space-between;
    gap: 10px; min-height: 36px;
}
.dt-slot .slot-placeholder { color: #A16207; font-size: 13px; opacity: 0.6; }
.dt-slot.hover-target {
    border-color: #DC2626;
    background: rgba(254, 226, 226, 0.85);
    transform: scale(1.02);
}
.dt-slot.correct {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 2px solid #F59E0B;
    border-style: solid;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    animation: slotCorrectPop 0.5s ease;
}
.dt-slot.correct .slot-num {
    background: linear-gradient(135deg, #F59E0B, #B45309);
    color: #fff; border-color: #B45309;
}
.dt-slot.wrong-shake { animation: wrongShake 0.4s ease; }
@keyframes slotCorrectPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.06); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6); }
    100% { transform: scale(1); }
}
@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Card - 朝代牌（古风配色 + 楷体 + 红印）*/
.dt-card {
    --dyn-c: #78350F;
    --dyn-c2: #4A1A08;
    position: relative;
    padding: 10px 20px 10px 16px;
    border-radius: 4px;
    font-family: "STKaiti", "KaiTi", "Kaiti SC", "华文楷体", "FangSong", "仿宋", "STSong", "SimSun", "宋体", serif;
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 3px;
    color: #FEF3C7;
    background: linear-gradient(160deg, var(--dyn-c), var(--dyn-c2));
    border: 1px solid rgba(255, 215, 150, 0.35);
    box-shadow:
        0 2px 6px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255, 220, 180, 0.18),
        inset 0 0 0 3px rgba(0,0,0,0.12);
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
    transition: box-shadow 0.2s, transform 0.15s;
}
.dt-card::before {
    /* 左侧金色竖线，像古卷装饰 */
    content: '';
    position: absolute;
    left: 4px; top: 6px; bottom: 6px;
    width: 2px;
    background: linear-gradient(180deg, rgba(255,215,0,0.7), rgba(255,215,0,0.2));
    border-radius: 1px;
}
.dt-card::after {
    /* 右下小红印 */
    content: '印';
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 14px; height: 14px;
    background: #B91C1C;
    color: #FEF3C7;
    font-size: 9px;
    font-weight: 900;
    line-height: 14px;
    text-align: center;
    border-radius: 2px;
    font-family: "KaiTi", serif;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 0 0 1px rgba(255,200,150,0.3);
    transform: rotate(-4deg);
    letter-spacing: 0;
    text-shadow: none;
}
.dt-card .card-name { font-size: 20px; }

/* 朝代专属配色 */
.dt-card[data-did="xia"]      { --dyn-c: #7C2D12; --dyn-c2: #431407; }
.dt-card[data-did="shang"]    { --dyn-c: #92400E; --dyn-c2: #581C0B; }
.dt-card[data-did="zhou"]     { --dyn-c: #065F46; --dyn-c2: #022C22; }
.dt-card[data-did="xizhou"]   { --dyn-c: #047857; --dyn-c2: #064E3B; }
.dt-card[data-did="dongzhou"] { --dyn-c: #065F46; --dyn-c2: #022C22; }
.dt-card[data-did="qin"]      { --dyn-c: #1C1917; --dyn-c2: #0C0A09; }
.dt-card[data-did="han"]      { --dyn-c: #991B1B; --dyn-c2: #5C0E0E; }
.dt-card[data-did="xihan"]    { --dyn-c: #B91C1C; --dyn-c2: #7F1D1D; }
.dt-card[data-did="donghan"]  { --dyn-c: #7F1D1D; --dyn-c2: #450A0A; }
.dt-card[data-did="sanguo"]   { --dyn-c: #6B21A8; --dyn-c2: #3B0764; }
.dt-card[data-did="jin"]      { --dyn-c: #57534E; --dyn-c2: #292524; }
.dt-card[data-did="xijin"]    { --dyn-c: #78716C; --dyn-c2: #44403C; }
.dt-card[data-did="dongjin"]  { --dyn-c: #44403C; --dyn-c2: #1C1917; }
.dt-card[data-did="nanbei"]   { --dyn-c: #BE185D; --dyn-c2: #831843; }
.dt-card[data-did="sui"]      { --dyn-c: #0369A1; --dyn-c2: #0C4A6E; }
.dt-card[data-did="tang"]     { --dyn-c: #C2410C; --dyn-c2: #7C2D12; }
.dt-card[data-did="wudai"]    { --dyn-c: #78350F; --dyn-c2: #3F1703; }
.dt-card[data-did="song"]     { --dyn-c: #0F766E; --dyn-c2: #134E4A; }
.dt-card[data-did="beisong"]  { --dyn-c: #115E59; --dyn-c2: #042F2E; }
.dt-card[data-did="nansong"]  { --dyn-c: #134E4A; --dyn-c2: #042F2E; }
.dt-card[data-did="yuan"]     { --dyn-c: #A16207; --dyn-c2: #713F12; }
.dt-card[data-did="ming"]     { --dyn-c: #9F1239; --dyn-c2: #5F0D22; }
.dt-card[data-did="qing"]     { --dyn-c: #1E3A8A; --dyn-c2: #0D1E4C; }

.dt-slot.correct .dt-card {
    box-shadow:
        0 4px 12px rgba(255, 215, 0, 0.55),
        inset 0 1px 0 rgba(255, 220, 180, 0.25),
        inset 0 0 0 3px rgba(255, 215, 0, 0.5);
    border-color: rgba(255, 215, 0, 0.85);
}
.dt-slot.correct .dt-card::before {
    background: linear-gradient(180deg, #FFD700, rgba(255,215,0,0.4));
    width: 3px;
}

.dt-year {
    font-size: 11px;
    color: #92400E;
    font-weight: 600;
    margin-left: auto;
    padding: 2px 8px;
    background: rgba(255,255,255,0.5);
    border-radius: 8px;
    white-space: nowrap;
    animation: yearFlyIn 0.5s ease;
}
@keyframes yearFlyIn {
    from { opacity: 0; transform: translateY(10px) scale(0.7); }
    to { opacity: 1; transform: none; }
}

/* Drag ghost */
.dragging-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.92;
    transform: scale(1.08) rotate(3deg);
    box-shadow: 0 10px 24px rgba(0,0,0,0.35) !important;
}

/* Pool */
.dt-pool-wrap {
    margin-top: 10px;
    background: rgba(255,255,255,0.75);
    border-radius: 14px 14px 0 0;
    padding: 8px 12px 14px;
    box-shadow: 0 -4px 14px rgba(120, 53, 15, 0.1);
}
.dt-pool-label { font-size: 12px; color: #92400E; text-align: center; margin-bottom: 6px; }
.dt-pool {
    display: flex; flex-wrap: wrap; gap: 8px;
    justify-content: center; min-height: 44px;
}

/* Points popup */
.points-popup {
    position: fixed;
    left: 50%; top: 38%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #F59E0B, #DC2626);
    color: #fff;
    padding: 10px 24px;
    border-radius: 16px;
    font-size: 22px;
    font-weight: 700;
    z-index: 200;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.4);
    animation: pointsFly 1s ease forwards;
    pointer-events: none;
}
.points-popup.hidden { display: none; }
@keyframes pointsFly {
    0% { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.7); }
    30% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.1); }
    70% { opacity: 1; transform: translateX(-50%) translateY(-10px) scale(1); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-60px) scale(0.9); }
}

/* Combo flash - 屏幕边缘金光 */
.combo-flash {
    position: fixed; inset: 0; pointer-events: none; z-index: 50;
    box-shadow: inset 0 0 0 0 rgba(255, 215, 0, 0);
    transition: box-shadow 0.2s;
}
.combo-flash.on {
    box-shadow: inset 0 0 60px 10px rgba(255, 215, 0, 0.5);
}

/* Particles */
.particle {
    position: fixed;
    width: 10px; height: 10px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 150;
    animation: particleBurst 0.8s ease-out forwards;
}
@keyframes particleBurst {
    0% { opacity: 1; transform: translate(0,0) scale(1); }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0.3); }
}

/* ===== Complete Screen ===== */
.complete-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(120, 53, 15, 0.2);
    max-width: 420px;
    margin: 20px auto;
    animation: fadeIn 0.4s ease;
}
.complete-icon { font-size: 56px; margin-bottom: 10px; animation: iconBounce 0.8s ease; }
@keyframes iconBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.complete-title { font-size: 22px; font-weight: 700; color: #78350F; margin-bottom: 10px; }
.complete-stars { font-size: 26px; color: #F59E0B; margin: 8px 0 14px; letter-spacing: 4px; }
.complete-timeline {
    display: flex; flex-direction: column; gap: 4px;
    background: #FFFBEB; border-radius: 10px; padding: 10px;
    margin: 12px 0; text-align: left; max-height: 200px; overflow-y: auto;
}
.timeline-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 4px 6px; }
.timeline-row .tr-name { font-weight: 700; color: #78350F; }
.timeline-row .tr-year { font-size: 11px; color: #92400E; }
.complete-stats { display: flex; justify-content: space-around; margin: 14px 0; flex-wrap: wrap; gap: 8px; }
.complete-stats .stat-item { min-width: 80px; }
.complete-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.action-btn {
    border: none;
    background: #FEF3C7;
    color: #78350F;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.action-btn.primary {
    background: linear-gradient(135deg, #F59E0B, #B45309);
    color: #fff;
}
.action-btn:active { transform: scale(0.97); }

/* ===== Lottery ===== */
.lottery-card {
    background: #fff;
    border-radius: 20px;
    padding: 24px 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(120, 53, 15, 0.2);
    max-width: 420px;
    margin: 20px auto;
}
.lottery-title { font-size: 22px; font-weight: 700; color: #78350F; margin-bottom: 6px; }
.lottery-cost { font-size: 13px; color: #92400E; margin-bottom: 4px; }
.lottery-balance { font-size: 14px; color: #78350F; margin-bottom: 14px; }
.lottery-box {
    width: 140px; height: 140px;
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border-radius: 16px;
    margin: 10px auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 56px;
    box-shadow: inset 0 4px 12px rgba(180, 83, 9, 0.1);
}
.lottery-gift.spinning { animation: giftSpin 0.12s linear infinite; }
@keyframes giftSpin { 0%{transform:scale(1) rotate(0);} 50%{transform:scale(0.9) rotate(180deg);} 100%{transform:scale(1) rotate(360deg);} }
.lottery-result { min-height: 24px; font-size: 14px; color: #78350F; margin: 10px 0; font-weight: 600; }
.lottery-draw-btn { margin-bottom: 8px; }
.lottery-draw-btn:disabled { opacity: 0.5; cursor: not-allowed; }
