:root {
    --bg-color: #f1f5f9;
    --sidebar-bg: #ffffff;
    --panel-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --success-bg: #d1fae5;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --number-bg: #f8fafc;
    --number-border: #cbd5e1;
    --hover-bg: #f8fafc;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.dashboard-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand span {
    color: var(--primary);
    font-weight: 300;
}

.status-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--success-bg);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--success);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
}

.status-indicator.live {
    animation: pulse 2s infinite;
}

.timer-box {
    text-align: center;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.timer-box p {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 1rem;
}

.countdown-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.2);
}

.latest-draw-info {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
}

.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.top-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1000px) {
    .grid-layout {
        grid-template-columns: 1fr 1fr;
    }
    .list-panel {
        grid-column: span 2;
    }
}

.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    margin-bottom: 1.5rem;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Inputs */
.input-group {
    display: flex;
    gap: 0.75rem;
}

input {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0 1.25rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.error-text {
    color: var(--danger);
    font-size: 0.85rem;
    margin-top: 0.5rem;
    min-height: 20px;
}

/* Number Grid */
.number-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.number-ball {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--number-bg);
    border: 1px solid var(--number-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: all 0.3s ease;
}

.number-ball.matched {
    background: var(--success);
    color: white;
    border-color: var(--success);
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.empty-state {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
    padding: 1rem 0;
}

/* Tickets Portfolio */
.tickets-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ticket-wrapper {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-color);
}

.ticket-header {
    background: white;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ticket-header:hover {
    background: var(--hover-bg);
}

.ticket-numbers {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ticket-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
}

.delete-btn:hover {
    background: var(--danger-hover);
    color: white;
}

/* History Table */
.ticket-history {
    display: none;
    padding: 0;
    background: white;
    border-top: 1px solid var(--border-color);
}

.ticket-history.open {
    display: block;
    animation: slideDown 0.3s ease-out;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-table th, .history-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.history-table th {
    background: var(--bg-color);
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tr:hover {
    background: var(--hover-bg);
}

.match-count {
    font-weight: 600;
    color: var(--success);
    background: var(--success-bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
}

.match-count.zero {
    color: var(--text-muted);
    background: var(--bg-color);
}

.mini-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--number-bg);
    border: 1px solid var(--number-border);
    font-size: 0.7rem;
    margin-right: 2px;
    margin-bottom: 2px;
    color: var(--text-muted);
}

.mini-ball.matched {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: white;
    border-left: 4px solid var(--success);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    transform: translateX(120%);
    animation: slideInRight 0.3s forwards, fadeOut 0.3s forwards 4s;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Animations */
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes slideInRight {
    to { transform: translateX(0); }
}

@keyframes fadeOut {
    to { opacity: 0; pointer-events: none; }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.prize-text {
    font-weight: 700;
    color: var(--success);
    font-size: 0.95rem;
    margin-right: 0.5rem;
}

.form-select {
    flex: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
}

.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.suggestion-result {
    border-top: 1px dashed var(--border-color);
    padding-top: 1rem;
}

/* Mix Panel Styles */
.heads-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.head-tag {
    cursor: pointer;
    user-select: none;
}

.head-tag input {
    display: none;
}

.head-tag span {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: all 0.2s;
}

.head-tag input:checked + span {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.head-tag:hover span {
    border-color: var(--primary);
}

/* Big Winners Styles */
.big-winners-panel {
    background: linear-gradient(135deg, #fff9c4, #fff);
    border: 1px solid #f1c40f;
    box-shadow: 0 4px 15px rgba(241, 196, 15, 0.2);
}

.big-winners-panel .panel-header h3 {
    color: #c0392b;
    font-size: 1.25rem;
}

.big-winners-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.big-winner-card {
    background: white;
    border: 1px solid #f39c12;
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.big-winner-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.big-winner-tier {
    font-weight: 700;
    color: #2c3e50;
    font-size: 1rem;
}

.big-winner-value {
    color: #e74c3c;
    font-weight: 800;
    font-size: 1.1rem;
}

.big-winner-count {
    background: #e74c3c;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.btn-detail {
    background: #f8fafc;
    color: var(--primary);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 1rem;
    transition: all 0.2s;
}

.btn-detail:hover {
    background: var(--primary);
    color: white;
}

/* Dark Mode Variables */
body.dark {
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --panel-bg: #1e293b;
    --border-color: #334155;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --success-bg: rgba(5, 150, 105, 0.2);
    --number-bg: #334155;
    --number-border: #475569;
    --hover-bg: #334155;
}

body.dark .big-winners-panel {
    background: linear-gradient(135deg, #1e293b, #0f172a);
    border: 1px solid #334155;
}

body.dark .ticket-header {
    background: #1e293b;
}

body.dark .history-table th {
    background: #0f172a;
}

/* News Grid CSS */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}
.news-card {
    background: var(--panel-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
}
.news-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}
.news-img {
    position: relative;
    height: 180px;
    background: #f8f9fa;
}
.news-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.news-badge {
    position: absolute;
    bottom: 10px;
    left: 10px;
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
}
.news-content {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.news-date {
    font-size: 0.8rem;
    color: #95a5a6;
    margin-bottom: 0.5rem;
}
.news-title {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-main);
    margin: 0;
}

/* History Table Balls */
.history-ball {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 0.95rem;
    border: 1px solid rgba(255,255,255,0.25);
    margin: 0 3px;
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(0,0,0,0.15);
    transition: transform 0.2s;
}
.history-ball:hover {
    transform: scale(1.1);
}
.history-ball-mega {
    background: radial-gradient(circle at 30% 30%, #ff4b2b, #c0392b);
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(231, 76, 60, 0.35);
}
.history-ball-power {
    background: radial-gradient(circle at 30% 30%, #ff4b2b, #c0392b);
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(231, 76, 60, 0.35);
}
.history-ball-lotto {
    background: radial-gradient(circle at 30% 30%, #2ecc71, #27ae60);
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(46, 204, 113, 0.35);
}
.history-ball-special {
    background: radial-gradient(circle at 30% 30%, #f1c40f, #d35400);
    box-shadow: inset -2px -2px 5px rgba(0,0,0,0.2), 0 2px 5px rgba(243, 156, 18, 0.35);
}

/* Mobile Header Style (Hidden on desktop) */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    align-items: center;
    padding: 0 1rem;
    justify-content: space-between;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: var(--hover-bg);
}

.mobile-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.1;
}

.mobile-brand-title {
    color: #e74c3c;
    font-weight: 900;
    font-size: 1.15rem;
    letter-spacing: 0.5px;
}

.mobile-brand-subtitle {
    color: #f39c12;
    font-weight: 800;
    font-size: 0.7rem;
    letter-spacing: 2.5px;
    margin-top: 1px;
}

/* Sidebar Overlay Scrim */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}
/* Card & Ticket Card Styles for Lotto, Mega, Power, Max 3D */
.card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}
.ticket-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    background: var(--panel-bg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 280px;
    flex: 1;
    transition: transform 0.2s, box-shadow 0.2s;
}
.ticket-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.ticket-card.win {
    border-color: #2ecc71;
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.05) 0%, var(--panel-bg) 100%);
}
.ticket-card .ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    background: transparent !important;
}
.ticket-card .remove-btn {
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}
.ticket-card .remove-btn:hover {
    background: rgba(220, 38, 38, 0.1);
}

/* Responsive Overrides */
@media (max-width: 1024px) {
    .mobile-header {
        display: flex;
    }

    .dashboard-container {
        flex-direction: column !important;
        height: 100vh !important;
        overflow: hidden !important;
        padding-top: 60px !important; /* Offset for sticky mobile header */
    }

    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -260px !important; /* Hidden off-screen by default */
        bottom: 0 !important;
        height: 100vh !important;
        width: 260px !important;
        z-index: 999 !important;
        visibility: hidden !important;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s !important;
        box-shadow: 5px 0 25px rgba(0,0,0,0.15) !important;
        display: flex !important; /* Force display flex for overlay */
        padding-top: 60px !important; /* Push content down to prevent mobile header overlap */
    }

    .sidebar.active {
        left: 0 !important;
        visibility: visible !important;
    }

    .main-content {
        padding: 1rem !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        height: calc(100vh - 60px) !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 !important;
    }

    /* Stack top header actions on mobile */
    .top-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        margin-bottom: 1.5rem !important;
    }

    .top-header h2 {
        font-size: 1.5rem !important;
    }

    .top-header .actions {
        width: 100% !important;
    }

    .top-header .actions button {
        width: 100% !important;
    }

    /* Pinned Keno stream on mobile */
    .live-stream-sticky-wrapper {
        position: sticky !important;
        top: -1rem !important; /* Pin precisely to the top of scrollable .main-content */
        z-index: 997 !important; /* Above page content but below sidebar/menu overlay */
        background: var(--bg-color) !important;
        margin-left: -1rem !important;
        margin-right: -1rem !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
        border-bottom: 1px solid var(--border-color) !important;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08) !important;
    }

    .live-stream-panel {
        padding: 0.75rem !important;
    }

    .live-stream-panel > div {
        flex-direction: column !important;
    }

    .mobile-header {
        z-index: 10000 !important;
    }

    .stream-container {
        height: 200px !important;
        min-width: 100% !important;
    }

    #twitch-embed {
        height: 100% !important;
    }

    .chat-container {
        height: 280px !important;
        min-width: 100% !important;
        transition: height 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .chat-container.collapsed {
        height: 40px !important; /* height of header only */
    }

    .chat-container.collapsed #chat-messages,
    .chat-container.collapsed .chat-input-area {
        display: none !important;
    }

    .chat-container.collapsed .chat-toggle-icon {
        transform: rotate(-90deg) !important;
    }

    #chat-messages {
        flex: 1 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }

    /* Prevent mobile zoom on focus */
    input, select, textarea, button {
        font-size: 16px !important;
    }

    /* Vietlott Result Cards & Balls mobile overrides */
    .premium-card {
        padding: 1rem !important;
    }
    .premium-title {
        font-size: 1.35rem !important;
    }
    #vietlott-result-balls {
        display: flex !important;
        flex-wrap: nowrap !important; /* Force all balls on single line */
        justify-content: center !important;
        align-items: center !important;
        gap: 4px !important;
    }
    .premium-ball {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.15rem !important;
        margin: 0 !important;
        box-shadow: inset -2px -2px 4px rgba(0,0,0,0.2), 0 3px 6px rgba(231,76,60,0.25) !important;
    }
    .premium-ball-special {
        box-shadow: inset -2px -2px 4px rgba(0,0,0,0.2), 0 3px 6px rgba(242,153,74,0.25) !important;
    }
    #vietlott-result-balls > div[style*="width: 2px"] {
        height: 30px !important;
        margin: 0 4px !important;
        background: #cbd5e1 !important;
    }
    .jackpot-box {
        min-width: 100% !important;
        padding: 1.25rem 1rem !important; /* Reduce padding on mobile */
    }
    .jackpot-value {
        font-size: 1.6rem !important;
    }
    .premium-table {
        min-width: 100% !important; /* Allow the table to resize down if cell padding is smaller */
    }
    .premium-table th, .premium-table td {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.85rem !important;
    }

    /* History table balls mobile overrides */
    .history-ball {
        width: 24px !important;
        height: 24px !important;
        font-size: 0.75rem !important;
        margin: 0 1px !important;
        box-shadow: inset -1px -1px 3px rgba(0,0,0,0.2), 0 1px 3px rgba(0,0,0,0.15) !important;
    }
    .history-table th, .history-table td {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.8rem !important;
    }
    #history-tbody td div[style*="inline-flex"],
    tbody td div[style*="display: inline-flex"],
    #history-tbody td div[style*="display: flex"] {
        flex-wrap: nowrap !important;
    }
    
    /* Tickets container and numpad mobile overrides */
    .tickets-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 1rem !important;
    }
    .ticket-wrapper {
        width: 100% !important;
    }
    #numpad-container {
        max-width: 100% !important;
        padding: 0.5rem !important;
    }
    #numpad-ball-list {
        max-width: 100% !important;
        gap: 4px !important;
    }
    .numpad-ball-btn {
        width: 28px !important;
        height: 28px !important;
        min-width: 28px !important;
        min-height: 28px !important;
        font-size: 0.75rem !important;
    }
    #hot-numbers-list, #cold-numbers-list {
        justify-content: space-between !important;
        gap: 4px !important;
    }
    
    @media (max-width: 360px) {
        .premium-ball {
            width: 32px !important;
            height: 32px !important;
            font-size: 1rem !important;
        }
        #vietlott-result-balls {
            gap: 2px !important;
        }
        #vietlott-result-balls > div[style*="width: 2px"] {
            margin: 0 2px !important;
        }
        .jackpot-value {
            font-size: 1.4rem !important;
        }
    }

    /* General responsive layouts */
    #print-top-header, #print-header, .top-header, .panel-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    #header-buttons, .actions {
        width: 100% !important;
        display: flex !important;
        gap: 8px !important;
    }
    #header-buttons button, .actions button {
        flex: 1 !important;
        padding: 0.6rem 0.5rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }
    #region-date-selectors {
        flex-direction: column !important;
        padding: 1rem !important;
    }
    #region-date-selectors > div {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }
    .region-selector {
        width: 100% !important;
        gap: 0.5rem !important;
    }
    .region-btn {
        padding: 0.6rem 0.4rem !important;
        font-size: 0.82rem !important;
    }

    /* Live modal mobile adjustments */
    #live-modal > div {
        width: 95% !important;
        height: 90% !important;
    }
    #live-content-container {
        padding: 0.75rem !important;
    }
    #live-xskt-table-container {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    .xskt-table th, .xskt-table td {
        padding: 0.6rem 0.4rem !important;
        font-size: 0.9rem !important;
    }
    .xskt-table td.prize-name {
        width: 70px !important;
        font-size: 0.85rem !important;
    }
    .xskt-table td:not(.prize-name) {
        font-size: 0.95rem !important;
    }
    .xskt-table tr.prize-db td:not(.prize-name) {
        font-size: 1.2rem !important;
    }
    .num-item {
        min-width: 36px !important;
        padding: 0.25rem 0.4rem !important;
        font-size: 0.85rem !important;
    }
    .num-item.db-num {
        padding: 0.35rem 0.6rem !important;
        font-size: 1.1rem !important;
    }

    /* Tabs wrapping style for touch friendliness */
    .tabs-container {
        display: flex !important;
        flex-wrap: wrap !important;
        overflow-x: visible !important;
        gap: 8px 4px !important;
        padding-bottom: 4px !important;
        border-bottom: 1px solid var(--border-color) !important;
    }

    .tab-btn {
        flex: 1 1 auto !important;
        padding: 0.5rem 0.8rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    /* Grid stack */
    .grid-layout {
        grid-template-columns: 1fr !important;
    }

    /* Table responsiveness */
    .ticket-history, #xskt-table-container, .xskt-table-container, .table-responsive, #prize-table-container {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .chat-container.mobile-chat-mode {
        margin-bottom: 1.5rem !important;
    }

    /* Fix draw row header stretching the screen in Keno */
    .draw-row > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 6px !important;
    }
    .draw-row > div:first-child > div {
        width: 100% !important;
        flex-wrap: wrap !important;
    }
    .draw-row > div:first-child > span {
        align-self: flex-start !important;
        margin-top: 2px !important;
    }

    /* Fix ticket-header stretching in Keno and other pages */
    .ticket-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    .ticket-numbers {
        width: 100% !important;
    }
    .ticket-summary {
        width: 100% !important;
        justify-content: flex-end !important;
    }

    /* Fix investment row wrapping and options squishing */
    .investment-config-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }
    .investment-config-row > div {
        width: 100% !important;
        justify-content: space-between !important;
    }
    .investment-config-row select {
        flex: 1 !important;
        max-width: none !important;
    }
    .investment-config-row input[type="number"] {
        flex: 0 0 80px !important;
        margin-left: 5px !important;
    }

    /* Stack last draw analysis boxes vertically */
    .keno-stats-panel > div > div:last-child {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Center and wrap hot/cold numbers list */
    #hot-numbers-list, #cold-numbers-list {
        justify-content: center !important;
        gap: 12px !important;
        flex-wrap: wrap !important;
    }

    /* Global Table responsiveness for all tables inside panels and cards */
    .card table, .panel table {
        display: table !important;
        width: 100% !important;
    }

    .table-responsive, #prize-table-container, #xskt-table-container, .xskt-table-container, #xskt-table-container-loto {
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Ensure tables inside scrollable wrappers don't squish excessively on mobile */
    .table-responsive table:not(.history-table), #prize-table-container table, #xskt-table-container table, .xskt-table-container table, #xskt-table-container-loto table {
        min-width: 580px !important;
    }
    .table-responsive table.history-table {
        min-width: auto !important;
        width: 100% !important;
    }

    /* Prevent word wrapping inside cells for better scrollability */
    .table-responsive th, .table-responsive td,
    #prize-table-container th, #prize-table-container td,
    #xskt-table-container th, #xskt-table-container td,
    .xskt-table-container th, .xskt-table-container td,
    #xskt-table-container-loto th, #xskt-table-container-loto td {
        white-space: nowrap !important;
    }

    /* Reduce paddings on mobile for better horizontal space */
    .panel, .card {
        padding: 1rem !important;
        min-width: 0 !important;
    }
    #xskt-container, #ticket-checker-panel, #ticket-checker-panel-loto {
        padding: 1rem !important;
    }
    .content-body {
        padding: 1rem !important;
    }

    /* Max 3D Pro / Max 3D+ Mobile Header and Banner fixes */
    .main-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        padding: 1rem !important;
        display: flex !important;
    }
    .header-left, .header-right {
        width: 100% !important;
    }
    .header-right button {
        width: 100% !important;
        padding: 0.6rem 0.5rem !important;
        font-size: 0.85rem !important;
    }
    .jackpot-banner {
        padding: 1.5rem 1rem !important;
        border-radius: 12px !important;
    }
    .jackpot-banner div {
        font-size: 2.2rem !important;
    }
    .jackpot-banner h3 {
        font-size: 1rem !important;
    }

    /* Ticket cards stack vertically on mobile (Mega/Power/Lotto/Max3D) */
    .ticket-card {
        width: 100% !important;
        min-width: 100% !important;
    }
    #ticket-list {
        flex-direction: column !important;
        width: 100% !important;
    }
}

/* Hide clear data button globally */
#clear-data-btn {
    display: none !important;
}

/* Responsive Checker Form Row Stacking */
.checker-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}
input[type="date"] {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}
input[type="date"]::-webkit-date-and-time-value {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}
@media (max-width: 768px) {
    .checker-form-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .checker-form-row > div {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        min-width: 0 !important;
    }
    .input-group {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }
    .input-group > * {
        max-width: 100% !important;
        width: 100% !important;
    }
    .input-group .btn-primary {
        padding: 0.75rem 1rem !important;
    }
    input[type="date"], select, .form-input, .form-select {
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        font-size: 0.82rem !important;
        padding: 0.6rem 0.5rem !important;
    }
}

/* Fix iOS Safari Date input width/overflow bug by resetting webkit appearance and defining a clean calendar indicator overlay */
input[type="date"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    position: relative !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%237f8c8d" viewBox="0 0 24 24"><path d="M9 11H7v2h2v-2zm4 0h-2v2h2v-2zm4 0h-2v2h2v-2zm2-7h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V9h14v11z"/></svg>') !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 16px !important;
    padding-right: 32px !important;
}

input[type="date"]::-webkit-date-and-time-value {
    text-overflow: ellipsis !important;
    overflow: hidden !important;
    white-space: nowrap !important;
    min-height: 1.5em !important;
    margin: 0 !important;
    text-align: left !important;
    display: block !important;
    width: 100% !important;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: auto !important;
    height: auto !important;
    color: transparent !important;
    background: transparent !important;
    cursor: pointer !important;
    z-index: 2 !important;
}

