:root {
    --bg-page: #f1f5f9;         
    --card-bg: #ffffff;         
    --text-main: #1e293b;       
    --text-muted: #64748b;      
    --btn-dark: #0f172a;        
    --btn-red: #ef4444;         
    --btn-green: #22c55e;       
    --panel-bg: #f8fafc;
    --border-color: #e2e8f0;    
}

/* ================ BẢNG MÀU DARK MODE ================ */
body.dark-mode {
    --bg-page: #0f172a;         
    --card-bg: #1e293b;         
    --text-main: #f8fafc;       
    --text-muted: #94a3b8;      
    --btn-dark: #334155;        
    --panel-bg: #0f172a;
    --border-color: #334155;    
}
/* ====================================================== */

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

html, body {
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    touch-action: manipulation; 
}

body {
    background: var(--bg-page);
    color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    justify-content: center;
    align-items: flex-start; 
    min-height: 100vh;
    padding: 15px;
    transition: color 0.2s ease; 
}

.sync-btn {
    position: absolute;
    top: max(15px, 2vh);
    left: max(15px, 4vw);
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
}
.sync-btn:active { transform: scale(0.95); }
.sync-icon { font-size: 1rem; }

.name-input {
    position: absolute;
    top: max(15px, 2vh);
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px dashed var(--border-color);
    padding: 8px 10px;
    border-radius: 20px;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    font-weight: 700;
    width: 90px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    z-index: 100;
    outline: none;
    transition: all 0.2s;
}
.name-input:focus {
    border: 1px solid #3b82f6;
    width: 140px; 
}

.theme-btn {
    position: absolute;
    top: max(15px, 2vh);
    right: max(15px, 4vw);
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 100;
}
.theme-btn:active { transform: scale(0.95); }
.theme-icon { font-size: 1rem; }

.app-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 550px; 
    border-radius: 28px;
    padding: 25px 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0,0,0,0.05);
    text-align: center;
    margin-top: 45px; 
    min-height: calc(100dvh - 85px); 
    display: flex;
    flex-direction: column;
    justify-content: center; 
}

.user-profile {
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 800;
    color: var(--text-main);
    margin-top: -10px; 
    margin-bottom: 16px;
    word-break: break-word;
    letter-spacing: -0.5px;
}

.stats-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stat-badge {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: clamp(0.85rem, 3vw, 1rem);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-gray { background: #e2e8f0; color: #334155; }
.badge-blue { background: #e0f2fe; color: #0369a1; }

.countdown-wrapper { 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 25px 0 0px 0; 
}

.cd {
    font-family: "Inter", "Segoe UI", Arial, sans-serif; /* Đổi font sang Inter y chang T3 */
    font-size: 6rem; /* Đồng bộ kích thước font to y chang T3 */
    font-weight: 800; /* Đồng bộ độ đậm (weight 800) */
    color: var(--text-main);
    line-height: 1; 
    letter-spacing: 1px; 
    white-space: nowrap;
    font-variant-numeric: tabular-nums; 
    margin: 0; 
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); /* Bổ sung hiệu ứng bóng đổ giống T3 */
}

.info-row {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 35px; 
}

/* NÚT ĐỀ XUẤT */
.suggest-btn {
    background: linear-gradient(135deg, #8b5cf6, #6366f1);
    color: white;
    border: none;
    padding: 14px 30px; 
    border-radius: 12px;
    font-size: 1.05rem; 
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.suggest-btn:active { transform: scale(0.92); }
.suggest-btn.is-original {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.ping-info {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    color: var(--text-muted);
    font-weight: 700;
    transition: color 0.2s ease;
    white-space: nowrap; 
}

.time-info {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: var(--text-muted);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

#endTimeDisplay {
    display: inline-block;
    min-width: 65px;
    text-align: center;
}

.controls-panel {
    background: transparent;
    border: none;
    padding: 0; 
    display: flex;
    justify-content: space-between; 
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    margin-top: 40px;
}

/* ĐÃ ĐẢO NGƯỢC LOGIC: Đẩy 2 nút ngoài ra xa, để 2 nút trong xích lại gần tâm 0.00 */
.controls-panel > button:nth-of-type(1) { margin-right: clamp(14px, 4vw, 24px); } 
.controls-panel > button:nth-of-type(2) { margin-right: clamp(4px, 1vw, 8px); } 
.controls-panel > button:nth-of-type(3) { margin-left: clamp(4px, 1vw, 8px); }  
.controls-panel > button:nth-of-type(4) { margin-left: clamp(14px, 4vw, 24px); }  

.db {
    border: none;
    border-radius: 8px; 
    padding: clamp(8px, 2vw, 12px) 0; 
    font-size: clamp(0.72rem, 3vw, 0.85rem); 
    font-weight: 700;
    color: white;
    cursor: pointer;
    flex: 1; 
    min-width: 0; 
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
    transition: transform 0.1s, opacity 0.2s;
    white-space: nowrap;
    letter-spacing: -0.2px;
}

.db:active { transform: scale(0.92); }
.db:hover { opacity: 0.9; }

.btn-red { background-color: var(--btn-red); }
.btn-green { background-color: var(--btn-green); }

/* ĐÓNG BĂNG CHIỀU RỘNG CHỐNG GIẬT NÚT LÊN XUỐNG */
.offset-display {
    flex: 0 0 80px; 
    width: 80px;
    min-width: 80px; 
    text-align: center;
}

.d-t {
    font-size: clamp(1.1rem, 3.5vw, 1.5rem);
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.cb {
    background: var(--btn-dark);
    color: white;
    border: none;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s, opacity 0.2s;
}
.cb:hover { opacity: 0.9; }
.cb:active { transform: scale(0.95); }

.main-btn {
    flex: 1;
    max-width: 250px;
    padding: 16px 20px;
    border-radius: 18px;
    font-size: clamp(1.1rem, 3.5vw, 1.25rem);
    letter-spacing: 0.5px;
}

.square-btn {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.active-viewers-box {
    background: var(--panel-bg);
    border: 1px dashed var(--border-color);
    padding: 10px 15px;
    border-radius: 16px;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.active-viewers-box b {
    color: var(--text-main);
    font-weight: 800;
}

.color-btn {
    background: transparent;
    color: var(--text-muted);
    border: 2px dashed var(--border-color);
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}
.color-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
    background: var(--panel-bg);
}

.active-config {
    display: flex; 
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 15px;
    padding: 12px 16px;
    background: var(--panel-bg); 
    border: 1px solid var(--border-color); 
    border-radius: 14px; 
    transition: all 0.2s;
    width: 100%; 
}

.config-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2); 
    border: 1px solid var(--border-color);
}

.config-text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main); 
    letter-spacing: 0;
}

.config-del-btn {
    background: #fee2e2; 
    border: none;
    color: #ef4444; 
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s;
    margin-left: 5px; 
}
.config-del-btn:active { transform: scale(0.9); }

.modal-overlay, .modal { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); justify-content: center; align-items: center; z-index: 9999; padding: 15px;}
.modal-content, .modal-confirm { background: var(--card-bg); padding: 28px; border-radius: 24px; width: 100%; max-width: 380px; text-align: center; box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25); transition: background-color 0.2s ease;}
.modal-title { font-size: 1.4rem; margin-bottom: 24px; font-weight: 800; color: var(--text-main);}
.form-group { margin-bottom: 18px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-muted); font-size: 0.95rem;}
.form-group input[type="text"], .form-group input[type="number"] { width: 100%; padding: 12px 16px; border-radius: 12px; background: var(--bg-page); border: 2px solid var(--border-color); font-size: 1.05rem; font-weight: 600; color: var(--text-main); outline: none; transition: border 0.2s;}
.form-group input[type="text"]:focus, .form-group input[type="number"]:focus { border-color: #3b82f6; }
.color-input { width: 100%; height: 48px; border: none; border-radius: 12px; cursor: pointer; padding: 0; overflow: hidden;}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 12px; }
.modal-actions { display: flex; gap: 12px; margin-top: 28px; }
.modal-btn { flex: 1; padding: 14px; border-radius: 14px; border: none; font-weight: 700; font-size: 1rem; cursor: pointer; transition: transform 0.1s; }
.modal-btn:active { transform: scale(0.95); }
.mbc, .modal-btn-cancel { background: var(--panel-bg); color: var(--text-main); border: 1px solid var(--border-color); }
.mbs, .modal-btn-ok { background: var(--btn-dark); color: white; }

.next-box-wrapper { 
    position: absolute; 
    right: 0; 
    top: 50%;
    transform: translateY(-50%);
    bottom: auto; 
    display: flex !important;
    flex-direction: column !important; 
    align-items: flex-end !important; 
    gap: 10px !important;
    z-index: 50; 
}

.btn-next-box, .btn-prev-box { 
    color: white; 
    border: none; 
    border-radius: 12px !important; 
    font-size: 1.15rem !important; 
    font-weight: 800; 
    cursor: pointer; 
    display: flex !important; 
    align-items: center; 
    justify-content: center; 
    gap: 5px; 
    transition: transform 0.1s;
    width: 90px !important; 
    height: 40px !important; 
    padding: 0 !important; 
    visibility: visible !important; 
}

.btn-next-box { background: linear-gradient(135deg, #3b82f6, #2563eb); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.4); }
.btn-prev-box { background: linear-gradient(135deg, #64748b, #475569); box-shadow: 0 4px 10px rgba(100, 116, 139, 0.4);}

.btn-next-box:active, .btn-prev-box:active { 
    opacity: 0.7; 
}

@keyframes pulseNext {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

@media screen and (max-width: 480px) {
    body { padding: 4px; }
    .app-card { padding: 20px 6px; border-radius: 18px; margin-top: 40px; min-height: calc(100dvh - 55px); }
    
    .controls-panel { padding: 0; }
    /* ĐÃ ĐẢO NGƯỢC LẠI CHO MOBILE ĐỂ NÚT KHÔNG KẸT LẠI NHAU */
    .controls-panel > button:nth-of-type(1) { margin-right: 18px; } 
    .controls-panel > button:nth-of-type(2) { margin-right: 4px; }  
    .controls-panel > button:nth-of-type(3) { margin-left: 4px; }   
    .controls-panel > button:nth-of-type(4) { margin-left: 18px; }  
    
    .db { padding: 10px 0; font-size: 0.8rem; }
    .offset-display { min-width: 45px; margin: 0 1px; }
    .d-t { font-size: 1.15rem; }
}

/* ========================================================================= */
/* ======================== CSS DÀNH RIÊNG CHO T3 ========================== */
/* ========================================================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

.t3-body {
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: linear-gradient(135deg, #f8fafc, #eef2f7, #e2e8f0);
    color: #1f2937;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
}

.t3-top-bar {
    width: 100%;
    max-width: 500px;
    display: flex;
    justify-content: flex-end; 
    align-items: center;
    margin-bottom: 20px;
}

.t3-switch-btn {
    background: rgba(255, 255, 255, 0.96);
    color: #1f2937;
    border: 1px solid rgba(0,0,0,0.06);
    padding: 6px 14px; 
    border-radius: 999px; 
    font-weight: 600; 
    font-size: 13px;
    cursor: pointer; 
    box-shadow: 0 8px 22px rgba(0,0,0,0.12); 
    transition: all 0.25s ease;
}
.t3-switch-btn:active { transform: scale(0.95); }

.t3-app-card {
    width: 100%;
    max-width: 500px;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.t3-header { text-align: center; margin-bottom: 6px; opacity: 0.9; line-height: 1.7; }
.t3-username { font-size: 1.6rem; font-weight: 800; margin-bottom: 5px; }
.t3-stats { font-size: 1.1rem; font-weight: 600; }

.t3-countdown-area {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin: 10px 0;
}

.t3-cd {
    font-size: 6rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.t3-time-info { 
    text-align: center; 
    margin-bottom: 18px; 
    opacity: 0.8;
    line-height: 1.6;
    min-height: 50px;
}
.t3-time-range { font-size: 1.1rem; font-weight: 500; font-variant-numeric: tabular-nums; }
.t3-ping { font-size: 1.1rem; font-weight: 500; }
#serverTimeDisplay, #endTimeDisplay { display: inline-block; min-width: 70px; text-align: center; }

.t3-controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between; 
    gap: 10px; 
    width: 100%;
    margin: 18px 0;
    padding: 0;
}

.t3-btn-red, .t3-btn-green {
    border: none; 
    border-radius: 8px; 
    padding: 10px 0; 
    font-size: 14px; 
    font-weight: 600; 
    color: white; 
    flex: 1; 
    cursor: pointer; 
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.t3-btn-red { background: #d84a4a; } 
.t3-btn-green { background: #16a34a; } 
.t3-btn-red:active, .t3-btn-green:active { transform: scale(0.95); }

.t3-offset-value { 
    font-size: 1.1rem; 
    font-weight: 800; 
    min-width: 90px; 
    flex-shrink: 0;
    text-align: center; 
    font-variant-numeric: tabular-nums;
}

.t3-actions-row {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 30px;
}

.t3-btn-copy, .t3-btn-plus {
    background: linear-gradient(135deg, #475569, #1e293b);
    color: #ffffff;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.t3-btn-copy:active, .t3-btn-plus:active { 
    transform: scale(0.97); 
}

.t3-btn-copy {
    border-radius: 999px; 
    padding: 14px 38px;
    font-size: 1.1rem;
    min-width: 140px;
}

.t3-btn-plus {
    border-radius: 50%; 
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 2px;
}

.t3-firebase-box {
    width: 100%;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid #cbd5e1;
    border-radius: 16px;
    padding: 20px 15px;
}

.t3-firebase-content {
    background: transparent;
    font-size: 1rem;
    color: #475569;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.t3-firebase-content b { color: #1e293b; font-weight: 800; }

.t3-chain-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 25px; 
}

/* ================= OVERLAY MÀN HÌNH KHÓA VIP ================= */
.vip-lock-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 99999;
    display: none; flex-direction: column; justify-content: center; align-items: center;
    color: white; text-align: center; padding: 20px;
}
.vip-lock-overlay h2 { font-size: 1.8rem; margin-bottom: 10px; color: #ef4444; font-weight: 800; letter-spacing: -0.5px;}
.vip-lock-overlay p { font-size: 1.05rem; margin-bottom: 20px; color: #cbd5e1; max-width: 400px; line-height: 1.5; }
.device-id-box {
    background: #1e293b; border: 2px dashed #3b82f6; padding: 15px 25px; border-radius: 12px;
    font-size: 1.6rem; font-family: monospace; font-weight: 800; color: #60a5fa;
    margin-bottom: 20px; letter-spacing: 2px;
}
.btn-copy-id {
    background: #3b82f6; color: white; border: none; padding: 14px 28px;
    font-size: 1.1rem; font-weight: 800; border-radius: 14px; cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4); transition: 0.2s;
}
.btn-copy-id:active { transform: scale(0.95); }

input:disabled {
    background-color: #e2e8f0 !important;
    color: #64748b !important;
    border-color: #cbd5e1 !important;
    cursor: not-allowed;
    opacity: 0.8;
}

/* ================= NÚT LÙI (PREV) NHỊP TIM ĐỎ KHI CÒN GIỜ ================= */
.btn-prev-active-red {
    animation: pulseRed 1.5s infinite !important;
}
@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.8); }
    70% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ================= NÚT TIẾN (NEXT) NHỊP TIM XANH KHI CÒN GIỜ ================= */
.btn-next-active-blue {
    animation: pulseNext 1.5s infinite !important;
}


