/* ==========================================================================
   DPBOSS 88 - COMPREHENSIVE MOBILE-FIRST RESPONSIVE ENGINE
   Optimized for all Smartphones (iOS Safari, Android Chrome, Foldables, Tablets)
   ========================================================================== */

/* --- 1. Global Mobile Reset & Touch Standards --- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  min-width: 320px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Eliminate iOS Safari automatic zoom-in when tapping form inputs */
@media screen and (max-width: 768px) {
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px !important;
  }
}

/* Smooth Touch Scrolling Everywhere */
.hq-bar,
.top-nav,
.tabs,
.market-table-wrap,
.tt-card,
.chart-modal-body,
.chart-table-wrap {
  -webkit-overflow-scrolling: touch;
}

/* Horizontal swipe scroll hint for tables on mobile */
.mobile-swipe-hint {
  display: none;
  font-size: 0.72rem;
  color: #64748b;
  text-align: center;
  padding: 4px 6px;
  background: #f1f5f9;
  border-radius: 6px;
  margin-bottom: 6px;
  font-weight: 700;
}
@media screen and (max-width: 768px) {
  .mobile-swipe-hint {
    display: block;
  }
}

/* --- 2. Mobile Header, Ticker & App-like Navigation Drawer --- */
@media screen and (max-width: 640px) {
  .header {
    padding: 0;
  }

  .top-bar {
    padding: 4px 6px;
  }

  .brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 0;
  }

  .logo-box {
    flex: 1;
    min-width: 0;
  }

  .logo-box a {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .header-logo-img {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    flex-shrink: 0;
  }

  .logo {
    font-size: 1.3rem;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hdr-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .hdr-res-toggle {
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 800;
    border-radius: 20px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .menu-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #1e3a8a;
    color: #fde047;
    border: 1.5px solid #ff2d8a;
    cursor: pointer;
  }

  /* Sticky live ticker inside header */
  .live-ticker {
    padding: 4px 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
  }

  .live-ticker .nm {
    font-size: 1rem;
    font-weight: 900;
  }

  /* Horizontal Marquee Ticker */
  .hq-bar {
    padding: 3px 0;
  }

  .hq-item {
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  .hq-item .n {
    font-size: 0.75rem;
    font-weight: 900;
  }

  /* Full App Drawer Style for Mobile Navigation */
  .top-nav {
    display: none;
    background: linear-gradient(180deg, #0b1329 0%, #1e293b 100%);
    border-bottom: 3px solid #f59e0b;
    box-shadow: 0 10px 25px rgba(0,0,0,0.4);
    padding: 10px;
  }

  .top-nav.open {
    display: block !important;
    animation: drawerSlideDown 0.25s ease-out;
  }

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

  .top-nav-links {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .top-nav-links a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 8px !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 8px !important;
    color: #f8fafc !important;
    font-size: 0.82rem !important;
    font-weight: 800 !important;
    text-decoration: none !important;
    min-height: 44px !important;
    text-align: center !important;
    transition: all 0.15s ease !important;
  }

  .top-nav-links a:hover,
  .top-nav-links a:active {
    background: #2563eb !important;
    color: #ffffff !important;
    transform: scale(0.98);
  }
}

@media screen and (max-width: 360px) {
  .logo {
    font-size: 1.15rem;
  }
  .header-logo-img {
    width: 30px;
    height: 30px;
  }
  .hdr-res-toggle {
    padding: 4px 8px;
    font-size: 0.7rem;
  }
}

/* --- 3. Mobile Quick Controls & Action Bars --- */
@media screen and (max-width: 640px) {
  .quick-control-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    padding: 6px 4px !important;
  }

  .status-pill {
    justify-content: center !important;
    padding: 6px 12px !important;
    font-size: 0.75rem !important;
    width: 100% !important;
  }

  .ctrl-actions {
    display: flex !important;
    width: 100% !important;
    gap: 6px !important;
  }

  .ctrl-btn {
    flex: 1 !important;
    min-height: 40px !important;
    padding: 8px 6px !important;
    font-size: 0.8rem !important;
    justify-content: center !important;
    text-align: center !important;
    border-radius: 8px !important;
  }

  .social-join-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }
}

@media screen and (max-width: 380px) {
  .social-join-grid {
    grid-template-columns: 1fr !important;
  }
  .social-join-grid a {
    min-height: 44px;
    font-size: 0.82rem !important;
  }
}

/* --- 4. Golden Ank & Lucky Numbers Board (Mobile Adaptive) --- */
@media screen and (max-width: 640px) {
  .lucky-box {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    padding: 6px !important;
  }

  .lucky-left {
    padding: 8px 6px !important;
    border-radius: 8px !important;
  }

  .lucky-left-title {
    font-size: 0.8rem !important;
    padding-bottom: 4px !important;
    margin-bottom: 6px !important;
  }

  .lucky-digits {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
    margin-bottom: 6px !important;
  }

  .lucky-digit {
    height: 38px !important;
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15) !important;
  }

  .lucky-jodis,
  .lucky-panels {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px !important;
    margin-bottom: 4px !important;
  }

  .lucky-jodi,
  .lucky-panel {
    padding: 4px 2px !important;
    font-size: 0.82rem !important;
    font-weight: 900 !important;
    text-align: center !important;
    border-radius: 6px !important;
  }

  .lucky-extra {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 4px !important;
    margin-top: 4px !important;
  }

  .lx-row {
    justify-content: center !important;
    gap: 4px !important;
    font-size: 0.7rem !important;
    padding: 3px 4px !important;
    background: rgba(255,255,255,0.15) !important;
    border-radius: 4px !important;
  }

  /* Ank Groups (Kalyan, Sridevi, Milan) */
  .lucky-codes {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
  }

  .ank-group-label {
    font-size: 0.78rem !important;
    padding: 4px !important;
  }

  .ank-group-row {
    display: flex !important;
    width: 100% !important;
  }

  .lucky-code-cell {
    flex: 1 !important;
    padding: 4px 2px 6px !important;
  }

  .lucky-code-cell .code {
    font-size: 0.68rem !important;
  }

  .lucky-code-cell .num {
    font-size: 1.25rem !important;
    font-weight: 900 !important;
    color: #1e3a8a !important;
    line-height: 1.1 !important;
  }
}

/* --- 5. Kalyan Jackpot Live Card (Mobile Responsive) --- */
@media screen and (max-width: 640px) {
  [class~="5_minut_jackpot"] .kj-top {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    padding: 6px 8px !important;
  }

  [class~="5_minut_jackpot"] .kj-title {
    font-size: 13px !important;
  }

  [class~="5_minut_jackpot"] .kj-status {
    width: 100% !important;
    justify-content: space-between !important;
  }

  [class~="5_minut_jackpot"] .kj-main {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 8px 6px !important;
  }

  [class~="5_minut_jackpot"] .kj-latest {
    flex: 1 1 100% !important;
    text-align: center !important;
    padding: 8px 6px !important;
    border-radius: 8px !important;
  }

  [class~="5_minut_jackpot"] .kj-number {
    font-size: 1.4rem !important;
  }

  [class~="5_minut_jackpot"] .kj-suit {
    font-size: 1.25rem !important;
  }

  [class~="5_minut_jackpot"] .kj-time {
    font-size: 0.85rem !important;
  }

  [class~="5_minut_jackpot"] .kj-history-btn,
  [class~="5_minut_jackpot"] .kj-join {
    flex: 1 1 calc(50% - 4px) !important;
    min-height: 42px !important;
    padding: 8px !important;
    font-size: 0.78rem !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1) !important;
  }
}

/* --- 6. Live Result Cards & Market Grid (Mobile Touch Experience) --- */
@media screen and (max-width: 640px) {
  .live-update-row {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .lu-card {
    margin: 0 !important;
    padding: 8px 10px !important;
    border-radius: 10px !important;
  }

  .lu-name {
    font-size: 0.82rem !important;
  }

  .lu-num {
    font-size: 1.15rem !important;
    font-weight: 900 !important;
  }

  .lu-status-box {
    display: none !important; /* Hide redundant check text on small screens */
  }

  /* Market Result Cards */
  .market-card {
    border-radius: 12px !important;
    margin-bottom: 8px !important;
    padding: 10px 12px 12px !important;
    border: 1.5px solid rgba(0, 9, 77, 0.12) !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06) !important;
  }

  .mkt-days {
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
    border-radius: 8px !important;
  }

  .market-name {
    font-size: 1.05rem !important;
    font-weight: 900 !important;
    margin: 4px 0 6px !important;
    letter-spacing: 0.3px !important;
  }

  .result-nums {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    margin: 6px 0 10px !important;
    font-size: 1.25rem !important;
  }

  .result-nums .open,
  .result-nums .close {
    font-size: 1.15rem !important;
    font-weight: 800 !important;
    color: #1e3a8a !important;
    letter-spacing: 1px !important;
  }

  .result-nums .jodi {
    font-size: 1.45rem !important;
    font-weight: 900 !important;
    color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.08) !important;
    padding: 2px 8px !important;
    border-radius: 6px !important;
    min-width: 36px !important;
    text-align: center !important;
  }

  /* Chart Links Bar */
  .chart-links {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 6px !important;
    width: 100% !important;
  }

  .chart-links a {
    flex: 1 0 auto !important;
    min-width: 72px !important;
    height: 38px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.78rem !important;
    font-weight: 900 !important;
    border-radius: 8px !important;
    text-decoration: none !important;
  }

  .chart-links .time-mid {
    flex: 2 !important;
    font-size: 0.72rem !important;
    font-weight: 800 !important;
    color: #1e3a8a !important;
    text-align: center !important;
    padding: 6px 4px !important;
    background: rgba(255, 255, 255, 0.7) !important;
    border-radius: 6px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }
}

@media screen and (max-width: 360px) {
  .live-update-row {
    grid-template-columns: 1fr !important;
  }
  .chart-links a {
    min-width: 60px !important;
    padding: 4px 6px !important;
    font-size: 0.72rem !important;
  }
  .chart-links .time-mid {
    font-size: 0.65rem !important;
  }
}

/* --- 7. Search Bar & Interactive VIP Games on Mobile --- */
@media screen and (max-width: 640px) {
  .search-container {
    padding: 0 4px !important;
    margin: 8px auto !important;
  }

  .search-box-wrap {
    padding: 6px 12px !important;
    border-radius: 24px !important;
    height: 48px !important;
  }

  .search-input {
    font-size: 16px !important;
  }

  .search-icon {
    font-size: 1.2rem !important;
  }

  /* Scratch to Win Cards */
  .sc-card {
    height: 140px !important;
    border-radius: 12px !important;
    margin-bottom: 8px !important;
  }

  .sc-title {
    font-size: 0.75rem !important;
  }

  .sc-ank {
    font-size: 1.6rem !important;
  }

  .sc-nums {
    flex-wrap: wrap !important;
    justify-content: center !important;
    gap: 4px !important;
  }

  .sc-nums span {
    padding: 3px 8px !important;
    font-size: 0.72rem !important;
  }

  /* Digit Trend Analyzer */
  .dt2-wrap {
    border-radius: 12px !important;
    margin: 4px 0 !important;
  }

  .dt2-filters {
    padding: 6px !important;
    gap: 6px !important;
  }

  .dt2-filters select {
    font-size: 16px !important;
    padding: 10px 8px !important;
    min-height: 44px !important;
    border-radius: 8px !important;
  }

  .dt2-row {
    gap: 6px !important;
    font-size: 0.8rem !important;
  }

  .dt2-pct {
    font-size: 0.75rem !important;
    width: 32px !important;
  }
}

/* --- 8. Chart Modal Viewer (Full Screen on Mobile) --- */
@media screen and (max-width: 768px) {
  .chart-modal-overlay {
    padding: 6px !important;
    align-items: flex-end !important; /* Slide up bottom sheet on mobile */
  }

  .chart-modal-content {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 94vh !important;
    height: 94vh !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .chart-modal-header {
    padding: 10px 14px !important;
  }

  .chart-modal-title {
    font-size: 0.95rem !important;
  }

  .chart-modal-close {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.4rem !important;
  }

  .chart-modal-body {
    padding: 8px !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Historical Tables Horizontal Scroll */
  .panel-chart,
  .chart-table {
    min-width: 580px !important;
    font-size: 0.75rem !important;
  }

  .panel-chart th,
  .chart-table th {
    padding: 6px 3px !important;
    font-size: 0.72rem !important;
  }

  .panel-chart td,
  .chart-table td {
    padding: 4px 2px !important;
    font-size: 0.75rem !important;
    line-height: 1.15 !important;
  }

  .chart-modal-actions {
    padding: 8px 12px !important;
  }

  .chart-modal-actions .ctrl-btn {
    min-height: 40px !important;
    padding: 8px 14px !important;
  }
}

/* --- 9. Admin Control Panel (Mobile App Experience) --- */
@media screen and (max-width: 768px) {
  body.admin-body {
    padding: 8px !important;
  }

  .admin-container {
    padding: 0 !important;
  }

  .admin-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 8px !important;
    padding-bottom: 10px !important;
    margin-bottom: 12px !important;
  }

  .brand-title {
    font-size: 1.25rem !important;
  }

  .nav-links {
    display: flex !important;
    width: 100% !important;
    justify-content: space-between !important;
    gap: 6px !important;
    overflow-x: auto !important;
    padding-bottom: 4px !important;
  }

  .nav-links a {
    margin-left: 0 !important;
    padding: 6px 10px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 6px !important;
    font-size: 0.78rem !important;
    white-space: nowrap !important;
  }

  /* Horizontal swipeable tab bar */
  .tabs {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 6px !important;
    padding-bottom: 6px !important;
    margin-bottom: 14px !important;
    scrollbar-width: none !important;
  }

  .tabs::-webkit-scrollbar {
    display: none !important;
  }

  .tab-btn {
    flex-shrink: 0 !important;
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    white-space: nowrap !important;
    border-radius: 20px !important;
  }

  .card {
    padding: 14px 12px !important;
    border-radius: 10px !important;
    margin-bottom: 14px !important;
  }

  .card-title {
    font-size: 1rem !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  /* Admin form grids */
  .grid-2 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 6px !important;
  }

  /* Golden Ank inputs grid stays in 4 clean columns on phone */
  .grid-4 {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 6px !important;
  }

  .form-control {
    font-size: 16px !important;
    padding: 10px 8px !important;
  }

  .btn {
    width: 100% !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.95rem !important;
  }

  /* Security Modal on Mobile */
  .security-modal {
    padding: 20px 16px !important;
    border-radius: 12px !important;
  }

  .security-icon {
    font-size: 2.2rem !important;
  }

  .security-title {
    font-size: 1.15rem !important;
  }

  .sec-input {
    font-size: 16px !important;
    padding: 12px !important;
  }

  .sec-btn {
    min-height: 46px !important;
  }

  /* Admin Table Horizontal Scroll */
  .market-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .market-table-wrap table {
    min-width: 540px !important;
  }
}

/* --- 10. Timetable & Forum Responsive Upgrades --- */
@media screen and (max-width: 640px) {
  .tt-container,
  .forum-container {
    padding: 8px 6px !important;
  }

  .tt-header,
  .forum-hero {
    padding: 15px 10px !important;
    border-radius: 10px !important;
  }

  .tt-header h1,
  .forum-hero h1 {
    font-size: 1.15rem !important;
  }

  .tt-card {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  .tt-table {
    min-width: 500px !important;
  }

  .leaderboard-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .lb-card {
    padding: 8px !important;
  }

  .lb-name {
    font-size: 0.88rem !important;
  }

  .lb-stat {
    font-size: 0.72rem !important;
  }

  .post-form-card {
    padding: 14px 10px !important;
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .f-input {
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
}
