/* ---- Tema: Blue (default) ---- */
[data-theme="blue"] {
  --color-primary:       #3b82f6;
  --color-primary-hover: #2563eb;
  --color-primary-soft:  #eff6ff;
  --color-primary-text:  #1d4ed8;
}

/* ---- Tema: Green ---- */
[data-theme="green"] {
  --color-primary:       #16a34a;
  --color-primary-hover: #15803d;
  --color-primary-soft:  #f0fdf4;
  --color-primary-text:  #166534;
}

/* ---- Tema: Purple ---- */
[data-theme="purple"] {
  --color-primary:       #7c3aed;
  --color-primary-hover: #6d28d9;
  --color-primary-soft:  #f5f3ff;
  --color-primary-text:  #5b21b6;
}

/* ---- Tema: Gold ---- */
[data-theme="gold"] {
  --color-primary:       #d97706;
  --color-primary-hover: #b45309;
  --color-primary-soft:  #fffbeb;
  --color-primary-text:  #92400e;
}

/* ---- Base Variables ---- */
:root {
  --color-bg:             #f8fafc;
  --color-surface:        #ffffff;
  --color-surface-2:      #f1f5f9;
  --color-border:         #e2e8f0;
  --color-border-strong:  #cbd5e1;
  --color-text:           #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted:     #94a3b8;
  --color-success:        #16a34a;
  --color-success-soft:   #f0fdf4;
  --color-danger:         #dc2626;
  --color-danger-soft:    #fef2f2;
  --color-warning:        #d97706;
  --color-warning-soft:   #fffbeb;
  --radius-sm:            6px;
  --radius:               10px;
  --radius-lg:            16px;
  --shadow-sm:            0 1px 3px rgba(0,0,0,.08);
  --shadow:               0 4px 12px rgba(0,0,0,.10);
  --nav-height:           60px;
  --topbar-height:        52px;
  --font:                 'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* ---- Override Bootstrap primary dengan CSS var ---- */
.btn-primary {
  background-color: var(--color-primary) !important;
  border-color:     var(--color-primary) !important;
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--color-primary-hover) !important;
  border-color:     var(--color-primary-hover) !important;
}
.nav-pills .nav-link.active {
  background-color: var(--color-primary) !important;
}
.form-control:focus, .form-select:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,.15) !important;
}
.text-primary { color: var(--color-primary) !important; }
.bg-primary   { background-color: var(--color-primary) !important; }

/* ============================================================
   AUTH PAGE
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 1rem;
}

.auth-wrapper {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: .5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.auth-logo i {
  font-size: 2rem;
  color: var(--color-primary);
}

.auth-logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -.02em;
}

.auth-tabs {
  background: var(--color-surface-2);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 1.5rem;
  gap: 3px;
}

.auth-tabs .nav-link {
  color: var(--color-text-secondary);
  border-radius: calc(var(--radius) - 2px);
  font-size: .85rem;
  font-weight: 500;
  padding: .4rem .75rem;
  transition: all .15s;
}

.auth-tabs .nav-link.active {
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.auth-form .form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: .35rem;
}

.auth-form .form-control,
.auth-form .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--color-border);
  font-size: .875rem;
  padding: .55rem .75rem;
}

.input-password-wrap { position: relative; }

.input-password-wrap .form-control { padding-right: 2.5rem; }

.btn-toggle-pw {
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.btn-auth {
  margin-top: .25rem;
  padding: .6rem;
  font-size: .875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
}

.ch-error {
  font-size: .8rem;
  color: var(--color-danger);
  background: var(--color-danger-soft);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  margin-bottom: .75rem;
}

.ch-success {
  font-size: .8rem;
  color: var(--color-success);
  background: var(--color-success-soft);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  margin-bottom: .75rem;
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-surface);
  position: relative;
  overflow: hidden;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
  z-index: 10;
}

.topbar-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s;
}

.topbar-btn:hover { background: var(--color-surface-2); }
.topbar-btn i { font-size: 1.2rem; }

/* Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  padding-bottom: calc(var(--nav-height) + 1rem);
  -webkit-overflow-scrolling: touch;
}

/* Bottom Nav */
.bottom-nav {
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  z-index: 10;
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  font-size: .65rem;
  font-weight: 500;
  cursor: pointer;
  transition: color .15s;
  padding: .4rem 0;
}

.nav-tab i      { font-size: 1.3rem; line-height: 1; }
.nav-tab.active { color: var(--color-primary); }
.nav-tab span   { white-space: nowrap; }

/* ============================================================
   CARDS & STAT BOXES
   ============================================================ */
.ch-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
  margin-bottom: .75rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-bottom: .75rem;
}

.stat-box {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .625rem .75rem;
}

.stat-val {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-lbl {
  font-size: .7rem;
  color: var(--color-text-muted);
  margin-top: 1px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge-status {
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 2px 8px;
  font-size: .7rem;
  font-weight: 500;
}

.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-soft);  color: var(--color-danger);  }
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary-text); }

/* ============================================================
   SECTION LABEL
   ============================================================ */
.section-label {
  font-size: .7rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: .5rem;
}

/* ============================================================
   PLAYER CHIP
   ============================================================ */
.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--color-primary-soft);
  color: var(--color-primary-text);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: .75rem;
  font-weight: 500;
  margin: 2px;
}

.player-chip .chip-remove {
  background: none;
  border: none;
  color: var(--color-primary-text);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  opacity: .6;
  font-size: .8rem;
}

.player-chip .chip-remove:hover { opacity: 1; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  color: var(--color-primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: .7rem;
}

/* ============================================================
   DIVIDER
   ============================================================ */
.ch-divider {
  height: 1px;
  background: var(--color-border);
  margin: .75rem 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-ch-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background .15s;
}

.btn-ch-primary:hover    { background: var(--color-primary-hover); }
.btn-ch-primary:disabled { opacity: .55; cursor: not-allowed; }

.btn-ch-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  padding: .6rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: all .15s;
}

.btn-ch-outline:hover { background: var(--color-primary-soft); }

.btn-ch-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: .65rem 1rem;
  font-size: .875rem;
  font-weight: 500;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  transition: background .15s;
}

.btn-ch-danger:hover { background: #fee2e2; }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}

.loading-overlay .spinner-border {
  width: 2rem;
  height: 2rem;
  color: var(--color-primary);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state i   { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }
.empty-state p   { font-size: .875rem; }

/* ============================================================
   BOTTOM SHEET (popup statistik ringkas, settings, dll.)
   ============================================================ */
.ch-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.ch-sheet {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--color-border);
  padding: 1rem 1rem 2rem;
  width: 100%;
  max-width: 480px;
  animation: slideUp .2s ease;
}

.ch-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--color-border-strong);
  border-radius: 2px;
  margin: 0 auto .75rem;
}

.ch-sheet-title {
  font-size: .95rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: .75rem;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ============================================================
   MODE ROW (pilih game mode)
   ============================================================ */
.mode-row {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .5rem;
  gap: .75rem;
}

.mode-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mode-icon i { font-size: 1.2rem; color: var(--color-primary); }

.mode-info   { flex: 1; }
.mode-name   { font-size: .875rem; font-weight: 500; color: var(--color-text); }
.mode-desc   { font-size: .75rem; color: var(--color-text-muted); margin-top: 1px; }

.mode-start {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: .4rem .85rem;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}

.mode-start:hover { background: var(--color-primary-hover); }

/* ============================================================
   PLAY PAGE — score row
   ============================================================ */
.play-row {
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem;
  margin-bottom: .5rem;
  gap: .75rem;
}

.play-row.is-winner {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.play-name {
  flex: 1;
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text);
}

.play-score {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
  min-width: 32px;
  text-align: right;
}

/* ============================================================
   RESPONSIVE — laptop / TV
   ============================================================ */
@media (min-width: 480px) {
  .app-shell {
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
    box-shadow: var(--shadow);
  }

  body { background: var(--color-surface-2); }
}