/* =====================================================
   Macau 6D Pools – v2 Modern UI
   Brand colors: #8f0222 (primary), #6d0019 (dark), #a90329 (mid)
   ===================================================== */
:root {
  --primary:       #8f0222;
  --primary-dark:  #6d0019;
  --primary-mid:   #a90329;
  --bg:            #f0f0f0;
  --card-bg:       #ffffff;
  --text:          #2c2c2c;
  --text-muted:    #888888;
  --border:        #e4e4e4;
  --shadow:        0 2px 10px rgba(0,0,0,0.07);
  --radius:        12px;

  --prize1:        #c0392b;
  --prize2:        #27ae60;
  --prize3:        #2980b9;
  --starter:       #c2185b;
  --consolation:   #7b1fa2;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===================================================
   HEADER
   =================================================== */
#site-header {
  background: linear-gradient(to bottom, #f4f4f4 0%, #e8e8e8 100%);
  color: var(--text);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  border-bottom: 1px solid #d0d0d0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  max-width: 960px;
  margin: 0 auto;
}

.header-logo-link { display: flex; align-items: center; }

.header-logo-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}

.header-logo-img {
  height: 58px;
  width: auto;
  display: block;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-nav a {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 20px;
  transition: background 0.2s, color 0.2s;
}

.header-nav a:hover { color: var(--primary-dark); text-decoration: none; background: rgba(143,2,34,0.08); }

.nav-live {
  background: var(--primary) !important;
  border: 1px solid var(--primary-dark) !important;
  color: #fff !important;
  font-weight: 700 !important;
  letter-spacing: 0.3px;
}

.nav-live:hover { background: var(--primary-dark) !important; color: #fff !important; text-decoration: none !important; }

.nav-active {
  background: rgba(143,2,34,0.1) !important;
  color: var(--primary-dark) !important;
  font-weight: 700 !important;
  border: 1px solid rgba(143,2,34,0.25) !important;
}

/* Day tabs */
.day-tabs-wrap {
  background: linear-gradient(to right, var(--primary-dark), var(--primary));
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.day-tabs-wrap::-webkit-scrollbar { display: none; }

.day-tabs {
  display: flex;
  min-width: max-content;
  padding: 0 10px;
  max-width: 960px;
  margin: 0 auto;
}

.day-tab {
  color: rgba(255,255,255,0.68);
  padding: 9px 15px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.day-tab:hover { color: rgba(255,255,255,0.9); text-decoration: none; border-bottom-color: rgba(255,255,255,0.35); }
.day-tab.active { color: #fff; border-bottom-color: #fff; }

/* ===================================================
   MAIN / CONTAINER
   =================================================== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 20px;
  background: linear-gradient(to bottom, var(--primary-mid), var(--primary-dark));
  border-radius: 3px;
}

.reload-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(143,2,34,0.3);
}

.reload-btn:hover { background: var(--primary-dark); }
.reload-btn.spinning { animation: spin 0.55s linear; }

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ===================================================
   RESULT CARDS
   =================================================== */
.result-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
  border-left: 5px solid var(--primary);
  gap: 12px;
  position: relative;
}

.result-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}

.result-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12); transform: translateY(-2px); }
.result-card:hover::after { opacity: 0.02; }
.result-card:active { transform: scale(0.99); }

.card-num {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.card-date {
  min-width: 88px;
  flex-shrink: 0;
}

.card-day {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.card-date-str {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-top: 1px;
}

.card-balls {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 4px 0;
}

.card-arrow {
  color: #ccc;
  font-size: 22px;
  flex-shrink: 0;
  line-height: 1;
  margin-left: 4px;
}

/* Loading / empty */
.loading-row {
  text-align: center;
  padding: 48px 0;
  color: var(--text-muted);
}

.loading-row img {
  display: block;
  margin: 0 auto 10px;
}

/* ===================================================
   BALL NUMBERS
   =================================================== */
.balls-wrap {
  display: inline-block;
  white-space: nowrap;
  line-height: 1;
}

.ball {
  /* All sizing via inline style from JS so border-box reset won't interfere */
  display: inline-block;
  background-image: url('/assets/images/numball.png');
  background-repeat: no-repeat;
  background-position: center center;
  color: #222;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  text-align: center;
  vertical-align: middle;
  /* Opt out of border-box for balls so padding doesn't shrink content */
  box-sizing: content-box;
  padding: 0;
  line-height: 1;
}

/* ===================================================
   DETAIL MODAL
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.58);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--card-bg);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  animation: slideUp 0.28s cubic-bezier(.22,.68,0,1.2);
  overscroll-behavior: contain;
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0.4; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* Desktop: centered modal */
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 16px; }
  .modal { border-radius: 18px; max-height: 88vh; }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 10px auto 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.modal-logo {
  height: 42px;
  width: auto;
  flex-shrink: 0;
}

.modal-date-info {
  flex: 1;
  text-align: right;
}

.modal-day-txt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
}

.modal-date-txt {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  background: #f0f0f0;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s;
}

.modal-close:hover { background: #e0e0e0; }

/* -------------------------------------------------------
   Detail-result table (v1-style coloured rows)
------------------------------------------------------- */
#modal-prizes {
  padding: 0;
}

table.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

table.detail-table td {
  padding: 6px 5px;
  text-align: center;
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.45);
  word-break: break-word;
}

/* Label column — slightly darker tint */
table.detail-table td.dt-label {
  font-family: inherit;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  width: 66px;
  background: rgba(0,0,0,0.18);
  vertical-align: middle;
}

/* 1st/2nd/3rd value cell — bigger number */
table.detail-table td.dt-val-main {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 5px;
}

/* Row colours — high specificity via #modal-prizes */
#modal-prizes .dt-first  td { background: #c0392b; }
#modal-prizes .dt-second td { background: #27ae60; }
#modal-prizes .dt-third  td { background: #2980b9; }
#modal-prizes .dt-starter  td { background: #ad1457; }
#modal-prizes .dt-consol   td { background: #6a1fa2; }

/* Darker shade for label column */
#modal-prizes .dt-first  td.dt-label { background: #922b21; }
#modal-prizes .dt-second td.dt-label { background: #1e8449; }
#modal-prizes .dt-third  td.dt-label { background: #1f618d; }
#modal-prizes .dt-starter  td.dt-label { background: #880e4f; }
#modal-prizes .dt-consol   td.dt-label { background: #4a148c; }

.no-value {
  color: #ccc;
  font-size: 16px;
}

/* ===================================================
   MARQUEE & XIANGGANG
   =================================================== */
.header-marquee {
  background: var(--primary);
  padding: 6px 16px;
  font-size: 11px;
  color: rgba(255,255,255,0.88);
}

.header-marquee a { color: #fff; font-weight: 600; }

.xianggang-img {
  height: 18px;
  width: auto;
  display: block;
  margin-left: 58px;
  opacity: 0.88;
  margin-top: -10px;
}

/* ===================================================
   LOAD MORE
   =================================================== */
#loadmore-wrap {
  text-align: center;
  padding: 16px 0 24px;
}

.loadmore-btn {
  display: inline-block;
  background: #fff;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
  border-radius: 24px;
  padding: 10px 32px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.2s, color 0.2s;
}

.loadmore-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
}

.loadmore-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ===================================================
   FOOTER
   =================================================== */
footer {
  text-align: center;
  padding: 16px;
  background: var(--primary-dark);
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  margin-top: 8px;
}

/* ===================================================
   RESPONSIVE TWEAKS
   =================================================== */
@media (max-width: 480px) {
  .card-num { display: none; }
  .card-date { min-width: 72px; }
  .card-date-str { font-size: 11px; }
  .card-day { font-size: 9px; }
  .result-card { padding: 11px 12px; gap: 9px; }
}

@media (min-width: 768px) {
  .result-card { padding: 14px 22px; }
  .card-date { min-width: 110px; }
  .card-date-str { font-size: 13px; }
}
