/* ============================================================
   Texas Hold'em Poker Equity Calculator — Design System
   Dual Theme: Light (Poker Felt) + Dark (Night Casino)
   ============================================================ */

/* --- Google Fonts ------------------------------------------ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================
   1. CUSTOM PROPERTIES — LIGHT THEME (default)
   ============================================================ */
:root {
  /* ---- Typography ---- */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* ---- Surface & Background ---- */
  --bg-primary: #2E7D32;
  --bg-secondary: #256D29;
  --bg-body: linear-gradient(145deg, #2E7D32 0%, #1B5E20 40%, #2E7D32 100%);
  --bg-card: rgba(255, 253, 245, 0.95);
  --bg-card-hover: rgba(255, 253, 245, 1);
  --bg-header: rgba(27, 94, 32, 0.85);
  --bg-footer: rgba(27, 94, 32, 0.6);
  --bg-input: rgba(255, 255, 255, 0.9);
  --bg-overlay: rgba(0, 0, 0, 0.25);

  /* ---- Text ---- */
  --text-primary: #1a1a1a;
  --text-secondary: #4a5a4a;
  --text-muted: #7a8a7a;
  --text-on-primary: #ffffff;
  --text-heading: #1B5E20;

  /* ---- Accent & Brand ---- */
  --accent-gold: #FFD700;
  --accent-gold-dim: #D4A800;
  --accent-green: #2E7D32;
  --accent-green-light: #4CAF50;
  --accent-green-glow: rgba(76, 175, 80, 0.4);

  /* ---- Card Suits ---- */
  --suit-red: #C62828;
  --suit-black: #212121;

  /* ---- Results ---- */
  --result-win: linear-gradient(90deg, #43A047, #66BB6A);
  --result-tie: linear-gradient(90deg, #9E9E9E, #BDBDBD);
  --result-lose: linear-gradient(90deg, #E53935, #EF5350);
  --result-win-color: #43A047;
  --result-lose-color: #E53935;

  /* ---- Borders & Dividers ---- */
  --border-color: rgba(0, 0, 0, 0.12);
  --border-card: rgba(0, 0, 0, 0.08);
  --border-focus: #4CAF50;
  --border-dashed: #9E9E9E;

  /* ---- Shadows ---- */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.2);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 6px 20px rgba(0, 0, 0, 0.18);
  --shadow-glow: 0 0 15px rgba(76, 175, 80, 0.3);
  --shadow-glow-accent: 0 0 20px rgba(255, 215, 0, 0.3);

  /* ---- Radii ---- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-pill: 9999px;

  /* ---- Spacing ---- */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* ---- Transitions ---- */
  --transition-fast: 0.15s ease;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;

  /* ---- Layout ---- */
  --sidebar-width: 320px;
  --max-width: 1200px;
  --header-height: 64px;

  /* ---- Ad Slots ---- */
  --ad-border: 1px dashed rgba(0, 0, 0, 0.15);
  --ad-bg: rgba(0, 0, 0, 0.03);
  --ad-text: rgba(0, 0, 0, 0.2);

  /* ---- Felt texture overlay ---- */
  --felt-texture: radial-gradient(ellipse at 30% 20%, rgba(255,255,255,0.06) 0%, transparent 60%),
                  radial-gradient(ellipse at 70% 80%, rgba(0,0,0,0.08) 0%, transparent 50%);
}

/* ============================================================
   2. CUSTOM PROPERTIES — DARK THEME
   ============================================================ */
[data-theme="dark"] {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-body: linear-gradient(145deg, #1a1a2e 0%, #0f0f23 40%, #16213e 100%);
  --bg-card: rgba(30, 35, 55, 0.92);
  --bg-card-hover: rgba(35, 42, 65, 0.96);
  --bg-header: rgba(22, 33, 62, 0.9);
  --bg-footer: rgba(15, 15, 35, 0.8);
  --bg-input: rgba(255, 255, 255, 0.06);
  --bg-overlay: rgba(0, 0, 0, 0.5);

  --text-primary: #e8e8f0;
  --text-secondary: #a0a4b8;
  --text-muted: #6b6f85;
  --text-on-primary: #ffffff;
  --text-heading: #00ff88;

  --accent-gold: #ffd700;
  --accent-gold-dim: #b8960a;
  --accent-green: #00ff88;
  --accent-green-light: #33ffaa;
  --accent-green-glow: rgba(0, 255, 136, 0.35);

  --suit-red: #ff5252;
  --suit-black: #e0e0e0;

  --result-win: linear-gradient(90deg, #00c853, #00e676);
  --result-tie: linear-gradient(90deg, #546E7A, #78909C);
  --result-lose: linear-gradient(90deg, #d32f2f, #ff5252);
  --result-win-color: #00e676;
  --result-lose-color: #ff5252;

  --border-color: rgba(255, 255, 255, 0.08);
  --border-card: rgba(255, 255, 255, 0.06);
  --border-focus: #00ff88;
  --border-dashed: #4a4e68;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.25), 0 0 1px rgba(0, 255, 136, 0.1);
  --shadow-card-hover: 0 6px 24px rgba(0, 0, 0, 0.35), 0 0 8px rgba(0, 255, 136, 0.15);
  --shadow-glow: 0 0 20px rgba(0, 255, 136, 0.25), 0 0 40px rgba(0, 255, 136, 0.1);
  --shadow-glow-accent: 0 0 20px rgba(255, 215, 0, 0.25);

  --ad-border: 1px dashed rgba(255, 255, 255, 0.1);
  --ad-bg: rgba(255, 255, 255, 0.02);
  --ad-text: rgba(255, 255, 255, 0.12);

  --felt-texture: radial-gradient(ellipse at 30% 20%, rgba(0, 255, 136, 0.03) 0%, transparent 60%),
                  radial-gradient(ellipse at 80% 70%, rgba(100, 100, 255, 0.03) 0%, transparent 50%);
}

/* ============================================================
   3. RESET & BASE
   ============================================================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  color: var(--text-primary);
  background: var(--bg-body);
  min-height: 100vh;
  line-height: 1.6;
  transition: background var(--transition-slow),
              color var(--transition-base);
  position: relative;
}

/* Felt texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--felt-texture);
  pointer-events: none;
  z-index: 0;
}

/* ============================================================
   4. APP CONTAINER
   ============================================================ */
.app-container {
  position: relative;
  z-index: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-md);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   5. HEADER
   ============================================================ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-md);
  transition: background var(--transition-base),
              box-shadow var(--transition-base);
}

.header h1 {
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  font-weight: 700;
  color: var(--text-on-primary);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.header h1::before {
  font-size: 1.3em;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 8px 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-base),
              box-shadow var(--transition-base);
  outline: none;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  box-shadow: var(--shadow-glow);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

/* ============================================================
   6. LAYOUT — CSS Grid
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-width);
  gap: var(--space-lg);
  flex: 1;
  align-items: start;
}

/* ============================================================
   7. MAIN CONTENT
   ============================================================ */
.main-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ============================================================
   8. CARDS — sections
   ============================================================ */
.card-section,
.controls,
.results,
.top-losses {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: background var(--transition-base),
              border-color var(--transition-base),
              box-shadow var(--transition-base);
}

.card-section:hover,
.controls:hover {
  box-shadow: var(--shadow-card-hover);
}

/* ---- Section Labels ---- */
.section-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  transition: color var(--transition-base);
}

.section-hint {
  display: inline-block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  font-style: italic;
  transition: color var(--transition-base);
}

/* ============================================================
   9. CARD SLOTS
   ============================================================ */
.card-slots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.card-slot {
  width: 56px;
  height: 78px;
  border-radius: var(--radius-md);
  border: 2px dashed var(--border-dashed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-base);
  background: var(--bg-input);
  position: relative;
  overflow: hidden;
}

.card-slot::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.card-slot:hover {
  border-color: var(--accent-green-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Filled card slot */
.card-slot.filled {
  border-style: solid;
  border-color: var(--border-card);
  background: var(--bg-card);
  box-shadow: var(--shadow-card),
              inset 0 -2px 4px rgba(0, 0, 0, 0.06);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  transform: translateY(-2px);
  animation: cardFlip 0.3s ease;
}

[data-theme="dark"] .card-slot.filled {
  border-color: rgba(0, 255, 136, 0.2);
  box-shadow: var(--shadow-card),
              0 0 6px rgba(0, 255, 136, 0.1),
              inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

/* Active card slot (currently being filled) */
.card-slot.active {
  border-style: solid;
  border-color: var(--accent-green-light);
  box-shadow: 0 0 0 3px var(--accent-green-glow),
              var(--shadow-sm);
  animation: pulse 1.5s infinite;
}

[data-theme="dark"] .card-slot.active {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px var(--accent-green-glow),
              0 0 15px rgba(0, 255, 136, 0.2);
}

/* Red suit color */
.card-slot .suit-red {
  color: var(--suit-red);
}

/* ============================================================
   10. CARD PICKER
   ============================================================ */
.card-picker {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 4px;
}

.card-btn {
  aspect-ratio: 3/4;
  min-width: 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--suit-black);
  font-size: clamp(0.65rem, 1.5vw, 0.8rem);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  position: relative;
  line-height: 1.1;
  padding: 2px;
}

.card-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-green-light);
  z-index: 1;
}

.card-btn:active {
  transform: translateY(0px) scale(0.95);
}

.card-btn.red {
  color: var(--suit-red);
}

.card-btn.used {
  opacity: 0.2;
  pointer-events: none;
  filter: grayscale(0.5);
}

[data-theme="dark"] .card-btn:hover {
  box-shadow: var(--shadow-md),
              0 0 8px rgba(0, 255, 136, 0.15);
  border-color: var(--accent-green);
}

/* ============================================================
   11. CONTROLS
   ============================================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
}

.controls label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color var(--transition-base);
}

.controls input[type="number"],
.controls input[type="text"],
.controls select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-base);
  width: 100px;
}

.controls input:focus,
.controls select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-green-glow);
}

[data-theme="dark"] .controls input:focus,
[data-theme="dark"] .controls select:focus {
  box-shadow: 0 0 0 3px var(--accent-green-glow),
              0 0 12px rgba(0, 255, 136, 0.1);
}

/* ============================================================
   12. ACTION BUTTONS
   ============================================================ */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base);
  outline: none;
  position: relative;
  overflow: hidden;
  text-decoration: none;
}

.btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn:hover::before {
  opacity: 1;
}

.btn:focus-visible {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.btn:active {
  transform: scale(0.97);
}

/* Primary Button */
.btn-primary {
  background: linear-gradient(135deg, #43A047, #2E7D32);
  color: var(--text-on-primary);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4CAF50, #388E3C);
  box-shadow: var(--shadow-md),
              0 0 15px rgba(76, 175, 80, 0.3);
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, #00e676, #00c853);
  color: #1a1a2e;
}

[data-theme="dark"] .btn-primary:hover {
  box-shadow: var(--shadow-md),
              0 0 20px rgba(0, 255, 136, 0.35);
}

/* Secondary Button */
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

/* Small Button */
.btn-small {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* ============================================================
   13. RESULTS
   ============================================================ */
.results {
  animation: slideIn 0.4s ease;
}

.result-bar {
  height: 40px;
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  position: relative;
}

.result-bar > * {
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.result-win {
  background: var(--result-win);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  min-width: fit-content;
  padding: 0 var(--space-sm);
}

.result-tie {
  background: var(--result-tie);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  min-width: fit-content;
  padding: 0 var(--space-xs);
}

.result-lose {
  background: var(--result-lose);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  min-width: fit-content;
  padding: 0 var(--space-sm);
}

[data-theme="dark"] .result-bar {
  box-shadow: var(--shadow-md),
              0 0 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .result-win {
  text-shadow: 0 0 8px rgba(0, 230, 118, 0.4);
}

[data-theme="dark"] .result-lose {
  text-shadow: 0 0 8px rgba(255, 82, 82, 0.4);
}

.result-info {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition-base);
}

.result-info span {
  animation: countUp 0.5s ease;
}

/* ============================================================
   14. TOP LOSSES
   ============================================================ */
.top-losses {
  animation: slideIn 0.5s ease;
}

.top-losses h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: color var(--transition-base);
}

/* ---- Loss Category Items ---- */
.loss-categories {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.loss-category-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-input);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.loss-category-item:hover {
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-sm);
}

.loss-category-item .rank-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
  min-width: 120px;
  transition: color var(--transition-base);
}

.loss-category-item .pct-bar {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
  position: relative;
}

[data-theme="dark"] .loss-category-item .pct-bar {
  background: rgba(255, 255, 255, 0.06);
}

.loss-category-item .pct-bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--result-lose);
  transition: width 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.loss-category-item .pct-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--result-lose-color);
  min-width: 42px;
  text-align: right;
  transition: color var(--transition-base);
}

/* ---- Loss Hand Items ---- */
.loss-hands {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.loss-hand-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  transition: all var(--transition-base);
}

.loss-hand-item:hover {
  background: var(--bg-input);
}

.loss-hand-item .opp-cards {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 60px;
}

.loss-hand-item .category-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(229, 57, 53, 0.1);
  color: var(--result-lose-color);
  border: 1px solid rgba(229, 57, 53, 0.2);
  transition: all var(--transition-base);
}

[data-theme="dark"] .loss-hand-item .category-badge {
  background: rgba(255, 82, 82, 0.12);
  border-color: rgba(255, 82, 82, 0.25);
}

/* ============================================================
   15. SIDEBAR
   ============================================================ */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* ============================================================
   16. HISTORY PANEL
   ============================================================ */
.history-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition-base);
}

.history-panel h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  transition: color var(--transition-base);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
  padding-right: var(--space-xs);

  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--border-dashed) transparent;
}

.history-list::-webkit-scrollbar {
  width: 5px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--border-dashed);
  border-radius: var(--radius-pill);
}

.history-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.history-item:hover {
  background: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.history-item .cards {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 0.85rem;
  min-width: 50px;
  transition: color var(--transition-base);
}

.history-item .win-pct {
  font-weight: 600;
  color: var(--result-win-color);
  font-size: 0.82rem;
  transition: color var(--transition-base);
}

.history-item .timestamp {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: color var(--transition-base);
}

/* ============================================================
   17. AD SLOTS
   ============================================================ */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border: var(--ad-border);
  background: var(--ad-bg);
  border-radius: var(--radius-md);
  color: var(--ad-text);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  overflow: hidden;
  transition: all var(--transition-base);
}

/* When no ad is loaded, show placeholder text */
.ad-slot:empty::after {
  content: 'AD';
  font-size: 0.8rem;
  letter-spacing: 0.15em;
}

.ad-banner {
  width: 100%;
  height: 90px;
  max-width: 728px;
  margin: var(--space-md) auto;
}

.ad-sidebar {
  width: 300px;
  height: 250px;
  max-width: 100%;
}

.ad-sidebar-tall {
  width: 300px;
  height: 600px;
  max-width: 100%;
}

.ad-infeed {
  display: none;
  width: 100%;
  height: 250px;
  margin: var(--space-md) 0;
}

/* ============================================================
   18. FOOTER
   ============================================================ */
.footer {
  margin-top: auto;
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-on-primary);
  opacity: 0.6;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  transition: all var(--transition-base);
}

.footer a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer a:hover {
  color: var(--accent-gold-dim);
  text-decoration: underline;
}

/* ============================================================
   19. KEYFRAME ANIMATIONS
   ============================================================ */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardFlip {
  0% {
    transform: translateY(-2px) rotateY(90deg) scale(0.8);
    opacity: 0;
  }
  50% {
    transform: translateY(-2px) rotateY(45deg) scale(0.9);
    opacity: 0.6;
  }
  100% {
    transform: translateY(-2px) rotateY(0deg) scale(1);
    opacity: 1;
  }
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 3px var(--accent-green-glow),
                var(--shadow-sm);
  }
  50% {
    box-shadow: 0 0 0 6px var(--accent-green-glow),
                0 0 15px var(--accent-green-glow);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Loading state shimmer effect */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 25%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* ============================================================
   20. UTILITY CLASSES
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-muted {
  color: var(--text-muted);
}

.text-win {
  color: var(--result-win-color);
}

.text-lose {
  color: var(--result-lose-color);
}

/* ============================================================
   21. RESPONSIVE — Tablet (768–1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }

  .layout {
    gap: var(--space-md);
  }

  .card-picker {
    gap: 3px;
  }

  .header {
    padding: var(--space-sm) var(--space-md);
  }

  .ad-sidebar-tall {
    height: 400px;
  }
}

/* ============================================================
   22. RESPONSIVE — Mobile (<768px)
   ============================================================ */
@media (max-width: 767px) {
  .app-container {
    padding: 0 var(--space-sm);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 1;
  }

  .main-content {
    order: 0;
  }

  .header {
    border-radius: 0;
    margin-bottom: var(--space-md);
    padding: var(--space-sm) var(--space-md);
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .card-section,
  .controls,
  .results,
  .top-losses,
  .history-panel {
    padding: var(--space-md);
    border-radius: var(--radius-md);
  }

  .card-picker {
    grid-template-columns: repeat(13, 1fr);
    gap: 2px;
  }

  .card-slot {
    width: 48px;
    height: 66px;
  }

  .card-btn {
    font-size: 0.6rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn {
    width: 100%;
  }

  /* Ad adjustments */
  .ad-banner {
    height: 60px;
    max-width: 100%;
  }

  .ad-sidebar,
  .ad-sidebar-tall {
    width: 100%;
    height: 250px;
  }

  .ad-infeed {
    display: flex;
  }

  .result-bar {
    height: 32px;
  }

  .result-win,
  .result-tie,
  .result-lose {
    font-size: 0.7rem;
  }

  .history-list {
    max-height: 250px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls input[type="number"],
  .controls input[type="text"],
  .controls select {
    width: 100%;
  }
}

/* ============================================================
   23. RESPONSIVE — Small phones (<400px)
   ============================================================ */
@media (max-width: 400px) {
  .card-picker {
    grid-template-columns: repeat(7, 1fr);
  }

  .card-slot {
    width: 42px;
    height: 58px;
    font-size: 0.75rem;
  }

  .loss-category-item {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .loss-category-item .rank-name {
    min-width: auto;
  }

  .loss-category-item .pct-bar {
    width: 100%;
  }
}

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

/* ============================================================
   25. PRINT STYLES
   ============================================================ */
@media print {
  .header,
  .footer,
  .sidebar,
  .ad-slot,
  .theme-toggle,
  .action-buttons,
  .card-picker {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .app-container {
    max-width: 100%;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .card-section,
  .controls,
  .results,
  .top-losses {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}
