:root {
  --gold: #c9a84c;
  --gold-light: #e8c96a;
  --gold-dark: #a0842a;
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface-light: #222;
  --surface-hover: #2a2a2a;
  --border: #333;
  --text: #ffffff;
  --text-secondary: #bbbbbb;
  --text-muted: #999999;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --primary: var(--gold);
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 12px rgba(0,0,0,0.5);
  --header-height: 52px;
  --footer-height: 60px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { 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;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: var(--gold); }
input, select, button, textarea { font-family: inherit; font-size: 14px; }

/* ========== Header ========== */
.ky-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-height);
  background: linear-gradient(180deg, #141414 0%, #0f0f0f 100%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
}
.ky-header .ky-back {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--text); font-size: 18px; border-radius: 50%;
}
.ky-header .ky-back:active { background: rgba(255,255,255,0.08); }
.ky-header .ky-logo {
  font-size: 18px; font-weight: 700; color: var(--gold); letter-spacing: 1px;
  display: flex; align-items: center; gap: 6px;
}
.ky-header .ky-logo-icon {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  display: flex; align-items: center; justify-content: center; font-size: 14px; color: #000; font-weight: 800;
}
.ky-header .ky-header-actions {
  display: flex; align-items: center; gap: 8px;
}
.ky-header .ky-btn-gold {
  padding: 5px 14px; border-radius: 20px; border: 1px solid var(--gold);
  background: transparent; color: var(--gold); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .2s;
}
.ky-header .ky-btn-gold:hover, .ky-header .ky-btn-gold:active { background: var(--gold); color: #000; }
.ky-header .ky-btn-gold-fill {
  background: var(--gold); color: #000; border-color: var(--gold);
}
.ky-header .ky-btn-gold-fill:hover, .ky-header .ky-btn-gold-fill:active { background: var(--gold-light); }
.ky-header .ky-balance-top {
  color: var(--gold); font-size: 13px; font-weight: 600; margin-right: 4px;
}

/* ========== Main ========== */
.ky-main {
  padding: calc(var(--header-height) + 12px) 12px calc(var(--footer-height) + 12px);
  max-width: 600px; margin: 0 auto; min-height: 100vh;
}

/* ========== Bottom Nav ========== */
.ky-footer-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--footer-height);
  background: linear-gradient(0deg, #141414 0%, #0f0f0f 100%);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
}
.ky-footer-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-muted); font-size: 10px; height: 100%; transition: color .2s;
}
.ky-footer-nav a.active, .ky-footer-nav a:active { color: var(--gold); }
.ky-footer-nav a .icon {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
}

/* ========== Cards ========== */
.ky-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 14px; margin-bottom: 12px;
}
.ky-card-title {
  font-size: 15px; font-weight: 700; margin-bottom: 12px;
  color: var(--gold); display: flex; align-items: center; gap: 8px;
}
.ky-card-title::before {
  content: ''; width: 3px; height: 16px; border-radius: 2px; background: var(--gold);
}

/* ========== Buttons ========== */
.ky-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-light); color: var(--text); cursor: pointer; font-size: 14px;
  transition: all .2s; font-weight: 500;
}
.ky-btn:active { transform: scale(0.98); }
.ky-btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #000; border: none; font-weight: 600;
}
.ky-btn-primary:active { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }
.ky-btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.ky-btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.ky-btn-lg { padding: 12px 28px; font-size: 15px; border-radius: 24px; }
.ky-btn-sm { padding: 5px 12px; font-size: 12px; }
.ky-btn-block { width: 100%; }
.ky-btn-outline-gold {
  border: 1px solid var(--gold); color: var(--gold); background: transparent;
}
.ky-btn-outline-gold:active { background: var(--gold); color: #000; }

/* ========== Tabs ========== */
.ky-tabs {
  display: flex; gap: 8px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none;
}
.ky-tabs::-webkit-scrollbar { display: none; }
.ky-tab {
  flex-shrink: 0; padding: 8px 16px; border-radius: 20px; cursor: pointer; font-size: 13px;
  background: var(--surface-light); color: var(--text-secondary); border: 1px solid var(--border);
  transition: all .2s; white-space: nowrap;
}
.ky-tab.active {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #000; border-color: transparent; font-weight: 600;
}

/* ========== Sport nav ========== */
.ky-sport-nav {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px 0; margin-bottom: 12px; scrollbar-width: none;
}
.ky-sport-nav::-webkit-scrollbar { display: none; }
.ky-sport-item {
  flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 12px; border-radius: var(--radius); background: var(--surface-light); border: 1px solid var(--border);
  color: var(--text-secondary); font-size: 11px; cursor: pointer; transition: all .2s; min-width: 56px;
}
.ky-sport-item.active, .ky-sport-item:active {
  background: var(--gold); color: #000; border-color: var(--gold); font-weight: 600;
}
.ky-sport-item .icon { font-size: 20px; }

/* ========== Match cards ========== */
.ky-match-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  margin-bottom: 10px; overflow: hidden;
}
.ky-match-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface-light); border-bottom: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
}
.ky-match-header .league { color: var(--gold); font-weight: 600; }
.ky-match-body { padding: 12px; }
.ky-match-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.ky-match-row:last-child { border-bottom: none; padding-bottom: 0; }
.ky-match-row:first-child { padding-top: 0; }
.ky-match-team {
  display: flex; align-items: center; gap: 8px; flex: 1;
}
.ky-match-team .flag {
  width: 24px; height: 18px; border-radius: 2px; background: var(--surface-hover);
  display: flex; align-items: center; justify-content: center; font-size: 12px; overflow: hidden;
}
.ky-match-team .name { font-size: 13px; font-weight: 500; }
.ky-match-score {
  font-size: 16px; font-weight: 700; color: var(--text); min-width: 40px; text-align: center;
}
.ky-match-odds-row {
  display: flex; gap: 6px; margin-top: 10px;
}
.ky-odd-box {
  flex: 1; text-align: center; padding: 8px 4px; border-radius: var(--radius-sm);
  background: var(--surface-light); border: 1px solid var(--border); cursor: pointer; transition: all .2s;
}
.ky-odd-box:active, .ky-odd-box:hover {
  border-color: var(--gold); background: rgba(201,168,76,0.1);
}
.ky-odd-box .ky-odd-label { font-size: 10px; color: var(--text-muted); display: block; margin-bottom: 2px; }
.ky-odd-box .ky-odd-val { font-size: 14px; font-weight: 700; color: var(--gold); display: block; }
.ky-odd-box .ky-odd-team { font-size: 10px; color: var(--text-secondary); display: block; margin-top: 2px; }
.ky-odd-box .ky-odd-spread { font-size: 11px; color: var(--text-secondary); display: block; }

/* ========== Forms ========== */
.ky-form { max-width: 100%; }
.ky-form-group { margin-bottom: 14px; }
.ky-form-group label {
  display: block; font-size: 12px; margin-bottom: 6px; color: var(--text-secondary); font-weight: 500;
}
.ky-form-group input, .ky-form-group select, .ky-form-group textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-light); color: var(--text); font-size: 14px;
  transition: border-color .2s;
}
.ky-form-group input:focus, .ky-form-group select:focus, .ky-form-group textarea:focus {
  outline: none; border-color: var(--gold);
}
.ky-form-group input::placeholder { color: var(--text-muted); }
.ky-form-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.ky-form .ky-btn { flex: 1; min-width: 100px; }

/* ========== Tables ========== */
.ky-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ky-table th, .ky-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.ky-table th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
.ky-table tr:last-child td { border-bottom: none; }
.ky-table tr:active { background: var(--surface-hover); }
.ky-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.ky-badge-success { background: rgba(39,174,96,0.15); color: var(--success); }
.ky-badge-danger { background: rgba(231,76,60,0.15); color: var(--danger); }
.ky-badge-warn { background: rgba(243,156,18,0.15); color: var(--warning); }
.ky-badge-info { background: rgba(201,168,76,0.15); color: var(--gold); }

/* ========== Modal ========== */
.ky-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 200; }
.ky-modal-overlay.active { display: flex; }
.ky-modal {
  background: var(--surface); border-radius: var(--radius); width: 90%; max-width: 420px;
  max-height: 80vh; overflow: auto; padding: 20px; border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.ky-modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: var(--gold); }
.ky-modal-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.ky-modal-row:last-child { border-bottom: none; }
.ky-modal-row span:first-child { color: var(--text-secondary); }
.ky-modal-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-light); color: var(--text); font-size: 14px; margin-top: 8px;
}
.ky-modal-input:focus { outline: none; border-color: var(--gold); }
.ky-modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.ky-modal-actions .ky-btn { flex: 1; text-align: center; }

/* ========== Transaction list ========== */
.ky-tx-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.ky-tx-item:last-child { border-bottom: none; }
.ky-tx-left { display: flex; flex-direction: column; gap: 2px; }
.ky-tx-type { font-size: 13px; font-weight: 600; }
.ky-tx-time { font-size: 11px; color: var(--text-muted); }
.ky-tx-right { text-align: right; }
.ky-tx-amount { font-size: 14px; font-weight: 700; }
.ky-tx-amount.deposit { color: var(--success); }
.ky-tx-amount.withdraw { color: var(--danger); }

/* ========== Account page ========== */
.ky-account-hero {
  background: linear-gradient(135deg, #1a1a1a, #0f0f0f);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; margin-bottom: 14px;
}
.ky-account-hero .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ky-account-hero .value { font-size: 28px; font-weight: 700; color: var(--gold); }
.ky-account-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px;
}
.ky-account-grid .ky-card { text-align: center; margin-bottom: 0; padding: 14px 8px; }
.ky-account-grid .ky-card .label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.ky-account-grid .ky-card .value { font-size: 15px; font-weight: 600; color: var(--text); }

/* ========== Utils ========== */
.ky-text-center { text-align: center; }
.ky-text-right { text-align: right; }
.ky-mt { margin-top: 12px; }
.ky-mb { margin-bottom: 12px; }
.ky-hidden { display: none; }
.ky-loading { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.ky-empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.ky-divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ========== Message ========== */
.ky-msg { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 12px; font-size: 13px; }
.ky-msg-success { background: rgba(39,174,96,0.1); color: var(--success); border: 1px solid rgba(39,174,96,0.2); }
.ky-msg-error { background: rgba(231,76,60,0.1); color: var(--danger); border: 1px solid rgba(231,76,60,0.2); }

/* ========== Match Detail Modal ========== */
#match-modal { z-index: 190; }
#bet-modal { z-index: 200; }
.ky-modal-wide { width: 95%; max-width: 600px; max-height: 90vh; }
.ky-modal-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--border); }
.ky-modal-close { background: none; border: none; color: var(--text); font-size: 24px; cursor: pointer; padding: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; }
.ky-modal-body { overflow-y: auto; max-height: calc(90vh - 60px); }
.ky-match-more-hint { text-align: center; font-size: 11px; color: var(--text-muted); padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }

/* ========== Match Detail ========== */
.ky-match-detail-hero {
  background: linear-gradient(180deg, #141414, var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 16px; text-align: center; margin-bottom: 14px;
}
.ky-detail-league { font-size: 13px; color: var(--gold); font-weight: 600; margin-bottom: 6px; }
.ky-detail-time { font-size: 12px; color: var(--text-secondary); margin-bottom: 16px; }
.ky-live-dot { color: var(--danger); font-weight: 600; }
.ky-live-dot::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); margin-right: 4px; animation: pulse 1.5s infinite; vertical-align: middle; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.ky-detail-teams { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; gap: 16px; }
.ky-detail-team { display: flex; align-items: center; gap: 8px; flex: 1; }
.ky-detail-team-right { justify-content: flex-end; flex-direction: row-reverse; }
.ky-detail-team-right .ky-detail-name { text-align: right; }
.ky-detail-flag { width: 28px; height: 20px; border-radius: 2px; background: var(--surface-hover); display: flex; align-items: center; justify-content: center; font-size: 12px; }
.ky-detail-name { font-size: 15px; font-weight: 600; text-align: left; }
.ky-detail-score { font-size: 22px; font-weight: 700; color: var(--gold); min-width: 50px; text-align: center; }
.ky-detail-vs { font-size: 12px; color: var(--text-muted); font-weight: 700; letter-spacing: 2px; flex-shrink: 0; }
.ky-detail-odds { margin-bottom: 14px; }
.ky-detail-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.ky-detail-group-title { padding: 10px 14px; background: var(--surface-light); font-size: 14px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.ky-detail-ratio { font-size: 12px; color: var(--text-secondary); font-weight: 400; }
.ky-detail-group-items { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; }
.ky-detail-odd-btn { flex: 1 1 0; min-width: 80px; text-align: center; padding: 10px 6px; border-radius: var(--radius-sm); background: var(--surface-light); border: 1px solid var(--border); cursor: pointer; transition: all .2s; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ky-detail-odd-btn:hover, .ky-detail-odd-btn:active { border-color: var(--gold); background: rgba(201,168,76,0.12); transform: scale(0.98); }
.ky-detail-odd-label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 3px; line-height: 1.2; }
.ky-detail-odd-val { font-size: 15px; font-weight: 700; color: var(--gold); display: block; line-height: 1.2; }

/* ========== Responsive PC ========== */
@media (min-width: 769px) {
  body { background: #0a0a0a; }
  .ky-main { max-width: 480px; padding-left: 16px; padding-right: 16px; }
  .ky-header { justify-content: center; }
  .ky-header .ky-logo { position: absolute; left: 50%; transform: translateX(-50%); }
  .ky-header .ky-back { position: absolute; left: 12px; }
  .ky-header .ky-header-actions { position: absolute; right: 12px; }
}

/* ========== Mobile tweaks ========== */
@media (max-width: 768px) {
  .ky-match-odds-row { gap: 4px; }
  .ky-odd-box { padding: 6px 2px; }
  .ky-odd-box .ky-odd-val { font-size: 13px; }
  .ky-account-grid { grid-template-columns: repeat(2, 1fr); }
}
