/* ========================================
   SHARED LAB STYLES — Dark Theme
   Matches: craps-lab, blackjack-lab, baccarat-lab, roulette-lab
   ======================================== */

:root {
  --bg: #0b1120;
  --bg-card: #151f32;
  --bg-card-hover: #1c2b45;
  --border: #243552;
  --border-light: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent-green: #10b981;
  --accent-green-dim: #059669;
  --accent-gold: #f59e0b;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========================================
   HEADER & NAVIGATION
   ======================================== */
.site-header {
  background: rgba(11, 17, 32, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  font-size: 1.25rem;
  white-space: nowrap;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-green), var(--accent-gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #0b1120;
}

.brand-text { letter-spacing: 0.02em; }

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--bg-card);
}

.nav-tab.active {
  color: var(--accent-green);
  border-color: var(--accent-green);
  background: rgba(16, 185, 129, 0.1);
}

.lang-switch {
  display: flex;
  gap: 0.25rem;
  background: var(--bg-card);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn.active {
  color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.15);
}

/* ========================================
   MAIN CONTENT LAYOUT
   ======================================== */
.main-content {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
}

.page-hero {
  text-align: center;
  margin-bottom: 2.5rem;
  padding: 1rem 0;
}

.page-title {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, var(--text), var(--accent-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 700px;
  margin: 0 auto;
}

/* ========================================
   SECTIONS & CARDS
   ======================================== */
.section {
  margin-bottom: 3rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.section-icon { font-size: 1.75rem; }

.section-badge {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Grid layouts */
.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: all 0.2s ease;
}

.card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.card-title.green { color: var(--accent-green); }
.card-title.gold { color: var(--accent-gold); }

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

/* ========================================
   SIMULATOR AREA
   ======================================== */
.simulator-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.simulator-header {
  background: rgba(16, 185, 129, 0.08);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.simulator-title {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.simulator-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.simulator-body {
  padding: 1.5rem;
  min-height: 400px;
}

/* ========================================
   TABLE LAYOUT (for video poker, blackjack, etc.)
   ======================================== */
.table-frame {
  background: #0a1220;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  position: relative;
}

.table-felt {
  background: 
    radial-gradient(ellipse at center, #0d2a1a 0%, #06150f 70%, #04100a 100%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 19px,
      rgba(16, 185, 129, 0.03) 20px
    );
  padding: 2rem;
  min-height: 300px;
}

.card-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.playing-card {
  width: 84px;
  height: 120px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s;
  cursor: pointer;
  user-select: none;
}

.playing-card:hover:not(.held):not(.empty) {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
  border-color: var(--accent-green);
}

.playing-card.held {
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3), 0 8px 24px rgba(0,0,0,0.3);
}

.playing-card.red .rank { color: #dc2626; }
.playing-card.black .rank { color: #111827; }

.playing-card .rank {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1;
}

.playing-card .suit {
  font-size: 2.5rem;
  line-height: 1;
  margin-top: 0.25rem;
}

.playing-card .corner {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.playing-card .corner.suit {
  top: auto;
  bottom: 6px;
  left: auto;
  right: 8px;
  transform: rotate(180deg);
}

.playing-card.empty {
  background: transparent;
  border-style: dashed;
  border-color: var(--border-light);
  cursor: default;
}

.playing-card.dealt {
  animation: dealIn 0.3s ease-out backwards;
}

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-30px) rotate(-5deg); }
  to { opacity: 1; transform: translateY(0) rotate(0); }
}

/* Hold indicators */
.hold-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: var(--accent-gold);
  color: #0b1120;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 800;
  white-space: nowrap;
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-green-dim));
  color: #0b1120;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent-green);
  color: var(--accent-green);
}

.btn-gold {
  background: linear-gradient(135deg, var(--accent-gold), #d97706);
  color: #0b1120;
}

.btn-gold:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.4);
}

.btn-danger {
  background: var(--accent-red);
  color: #fff;
}

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }

.btn-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ========================================
   BANKROLL / STATS DISPLAY
   ======================================== */
.stats-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-value.positive { color: var(--accent-green); }
.stat-value.negative { color: var(--accent-red); }
.stat-value.gold { color: var(--accent-gold); }

/* ========================================
   PAYTABLE
   ======================================== */
.paytable {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.paytable th,
.paytable td {
  padding: 0.625rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.paytable th {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.paytable tr:last-child td { border-bottom: none; }
.paytable tr:hover td { background: rgba(255,255,255,0.02); }

.paytable .hand-name { font-weight: 600; }
.paytable .payout { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent-gold); }

/* ========================================
   MONTE CARLO SIMULATOR
   ======================================== */
.simulator-config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.config-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.config-group input,
.config-group select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
}

.config-group input:focus,
.config-group select:focus {
  outline: none;
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.simulator-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.result-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.5rem;
}

.result-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.result-value.ev-positive { color: var(--accent-green); }
.result-value.ev-negative { color: var(--accent-red); }
.result-value.ev-neutral { color: var(--accent-gold); }

.result-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Progress bar for batch simulation */
.progress-wrap {
  margin: 1.5rem 0;
  display: none;
}

.progress-wrap.visible { display: block; }

.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green), var(--accent-gold));
  border-radius: 4px;
  width: 0%;
  transition: width 0.1s linear;
}

.progress-text {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ========================================
   FOOTER
   ======================================== */
.site-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  margin-top: auto;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--accent-gold); }

.footer-links .divider {
  color: var(--border);
}

.footer-copyright {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.footer-disclaimer {
  max-width: 800px;
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* ========================================
   TOOLTIPS & HELPERS
   ======================================== */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 120%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text);
  white-space: normal;
  max-width: 280px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
  z-index: 10;
  box-shadow: var(--shadow-lg);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--border);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* ========================================
   MODAL / OVERLAY
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  padding: 1.5rem;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.3s;
}

.modal-overlay.open .modal { transform: scale(1); }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1.125rem; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
}

.modal-close:hover { color: var(--accent-red); }

.modal-body { padding: 1.5rem; }

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ========================================
   ALERTS / NOTICES
   ======================================== */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid;
}

.alert-green {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--accent-green);
  color: var(--text);
}

.alert-gold {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--accent-gold);
  color: var(--text);
}

.alert-red {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--accent-red);
  color: var(--text);
}

.alert-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 0.125rem; }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
  .header-inner { padding: 0.75rem 1rem; }
  .brand-text { display: none; }
  .nav-tabs { order: 3; width: 100%; justify-content: center; margin-top: 0.75rem; }
  .main-content { padding: 1.5rem 1rem 2rem; }
  .page-title { font-size: 1.75rem; }
  .simulator-header { flex-direction: column; align-items: flex-start; }
  .card-row { gap: 0.5rem; }
  .playing-card { width: 70px; height: 100px; }
  .stats-bar { flex-direction: column; gap: 0.75rem; }
  .stat-item { min-width: auto; flex: 1; }
  .footer-links { flex-direction: column; gap: 0.5rem; }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ========================================
   FOCUS VISIBLE
   ======================================== */
:focus-visible {
  outline: 2px solid var(--accent-green);
  outline-offset: 2px;
}

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }