/* SolitaireRealm - Main CSS */
/* ============================================
   CSS Custom Properties (Default/Dark Theme)
   ============================================ */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --card-bg: #ffffff;
  --card-bg-back: #0f3460;
  --card-border: rgba(255,255,255,0.15);
  --card-shadow: 0 4px 12px rgba(0,0,0,0.4);
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b8;
  --accent: #e94560;
  --accent-glow: rgba(233,69,96,0.4);
  --pile-bg: rgba(255,255,255,0.05);
  --pile-border: rgba(255,255,255,0.15);
  --header-bg: rgba(15,15,35,0.95);
  --modal-bg: #1e1e3a;
  --modal-overlay: rgba(0,0,0,0.75);
  --btn-primary-bg: #e94560;
  --btn-primary-text: #ffffff;
  --btn-secondary-bg: rgba(255,255,255,0.1);
  --btn-secondary-text: #e8e8f0;
  --sidebar-bg: #12122a;
  --action-bar-bg: rgba(15,15,35,0.9);
  --xp-bar-bg: rgba(255,255,255,0.1);
  --xp-bar-fill: #e94560;
  --hint-highlight: rgba(100,255,100,0.5);
  --valid-drop: rgba(100,255,100,0.3);
  --invalid-drop: rgba(255,100,100,0.3);
  --anim-duration: 0.3s;
  --card-width: clamp(60px, 9vw, 90px);
  --card-height: clamp(84px, 12.6vw, 126px);
  --card-radius: 8px;
  --tableau-offset-down: 28px;
  --tableau-offset-up: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Courier New', 'Consolas', monospace;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input[type="range"] {
  cursor: pointer;
}

/* ============================================
   Loading Screen
   ============================================ */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.loading-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-logo-sr {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
}

.loading-logo-title {
  font-size: 20px;
  letter-spacing: 4px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.loading-cards {
  display: flex;
  gap: 12px;
}

.loading-card {
  width: 48px;
  height: 64px;
  background: var(--card-bg);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  will-change: transform, opacity;
}

.loading-card-1 { color: #111; animation: loadingCard 1.2s ease-in-out infinite 0s; }
.loading-card-2 { color: #e94560; animation: loadingCard 1.2s ease-in-out infinite 0.15s; }
.loading-card-3 { color: #e94560; animation: loadingCard 1.2s ease-in-out infinite 0.3s; }
.loading-card-4 { color: #111; animation: loadingCard 1.2s ease-in-out infinite 0.45s; }

.loading-bar-container {
  width: 240px;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

.loading-text {
  color: var(--text-secondary);
  font-size: 14px;
  letter-spacing: 1px;
}

/* ============================================
   Ambient Canvas
   ============================================ */
.ambient-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* ============================================
   App Layout
   ============================================ */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

/* ============================================
   Header
   ============================================ */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.logo-sr {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 10px var(--accent-glow);
}

.logo-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

@media (max-width: 480px) {
  .logo-text { display: none; }
}

.header-stats {
  display: flex;
  gap: 12px;
  flex: 1;
  justify-content: center;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  white-space: nowrap;
}

.stat-icon { font-size: 12px; opacity: 0.7; }
.stat-value { font-weight: 600; font-variant-numeric: tabular-nums; }

.header-xp {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.header-level {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.xp-bar-mini {
  width: 60px;
  height: 6px;
  background: var(--xp-bar-bg);
  border-radius: 3px;
  overflow: hidden;
}

.xp-bar-mini-fill {
  height: 100%;
  background: var(--xp-bar-fill);
  border-radius: 3px;
  transition: width 0.6s ease;
  box-shadow: 0 0 6px var(--accent-glow);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.1s, opacity 0.2s, background 0.2s;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
  background: color-mix(in srgb, var(--btn-primary-bg) 85%, white);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--btn-secondary-text);
  border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.2);
}

.btn-danger {
  background: rgba(220,50,50,0.2);
  color: #ff6b6b;
  border: 1px solid rgba(220,50,50,0.3);
  width: 100%;
  justify-content: center;
}

.btn-danger:hover { background: rgba(220,50,50,0.35); }

.btn-option {
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-option.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-option:hover:not(.active) {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: background 0.2s, transform 0.1s;
  background: rgba(255,255,255,0.05);
}

.btn-icon:hover { background: rgba(255,255,255,0.12); }
.btn-icon:active { transform: scale(0.92); }

.btn-icon-inner { font-size: 16px; }

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-group-wrap { flex-wrap: wrap; }

/* Hamburger menu button */
.menu-btn { background: none; }
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 20px;
}
.hamburger span {
  display: block;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  transition: all 0.2s;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.08);
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-close {
  float: right;
  background: none;
  font-size: 16px;
  color: var(--text-secondary);
}

.sidebar-player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 12px;
}

.player-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 12px var(--accent-glow);
}

.player-name {
  font-weight: 700;
  font-size: 16px;
}

.player-rank {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
}

.sidebar-xp {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-level {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

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

.xp-bar-fill {
  height: 100%;
  background: var(--xp-bar-fill);
  border-radius: 4px;
  transition: width 0.6s ease;
  box-shadow: 0 0 8px var(--accent-glow);
}

.xp-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-align: right;
}

.sidebar-nav {
  padding: 8px;
  flex: 1;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 12px;
  border-radius: 8px;
  font-size: 15px;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
  position: relative;
}

.sidebar-nav-item:hover,
.sidebar-nav-item.active {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: rgba(233,69,96,0.15);
  color: var(--accent);
}

.nav-icon { font-size: 18px; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-streak {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.streak-value {
  font-weight: 700;
  color: #ff9500;
  font-size: 18px;
}

/* ============================================
   Main Game Area
   ============================================ */
.game-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================
   Game Board
   ============================================ */
.game-board {
  flex: 1;
  padding: 8px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* Top Row */
.top-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex-shrink: 0;
}

.top-row-gap { flex: 1; }

/* Tableau */
.tableau {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 4px;
}

/* ============================================
   Card Piles
   ============================================ */
.pile {
  width: var(--card-width);
  min-height: var(--card-height);
  flex-shrink: 0;
  position: relative;
  border-radius: var(--card-radius);
}

.pile-tableau {
  flex: 1;
  min-width: 0;
  width: auto;
}

.pile-placeholder {
  width: 100%;
  height: var(--card-height);
  border: 2px dashed var(--pile-border);
  border-radius: var(--card-radius);
  background: var(--pile-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.pile-placeholder-icon {
  font-size: 20px;
  color: var(--pile-border);
  opacity: 0.6;
}

.pile-placeholder-suit {
  font-size: 24px;
  color: var(--pile-border);
  opacity: 0.5;
}

.pile-placeholder-suit.red { color: rgba(200,80,80,0.5); }

/* Valid drop target */
.pile.valid-drop .pile-placeholder,
.pile.valid-drop-target {
  border-color: rgba(100,255,100,0.7);
  background: var(--valid-drop);
  box-shadow: 0 0 12px rgba(100,255,100,0.4);
}

/* Invalid drop target */
.pile.invalid-drop {
  border-color: rgba(255,100,100,0.7);
  background: var(--invalid-drop);
}

/* Pile stock cursor */
.pile-stock { cursor: pointer; }

/* Waste - show top 3 cards fanned */
.pile-waste {
  position: relative;
}

/* ============================================
   Cards
   ============================================ */
.card {
  width: 100%;
  height: var(--card-height);
  border-radius: var(--card-radius);
  position: absolute;
  left: 0;
  will-change: transform, opacity;
  cursor: pointer;
  backface-visibility: hidden;
  transform-style: preserve-3d;
  box-shadow: var(--card-shadow);
  transition: box-shadow 0.2s;
}

.card:hover { box-shadow: 0 8px 20px rgba(0,0,0,0.5); }

.card.selected {
  box-shadow: 0 0 0 3px var(--accent), 0 8px 24px var(--accent-glow);
  z-index: 50 !important;
}

.card.hint-source {
  animation: hintPulse 1s ease-in-out 3;
}

.card.hint-target {
  animation: hintPulseGreen 1s ease-in-out 3;
}

/* Face-down card */
.card-back {
  position: absolute;
  inset: 0;
  background: var(--card-bg-back);
  border-radius: var(--card-radius);
  border: 1px solid var(--card-border);
  overflow: hidden;
}

.card-back::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: calc(var(--card-radius) - 2px);
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 1px,
    transparent 1px,
    transparent 8px
  );
}

/* Face-up card */
.card-face {
  position: absolute;
  inset: 0;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  border: 1px solid rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
  padding: 3px 5px;
}

.card.face-up .card-back { display: none; }
.card.face-down .card-face { display: none; }

/* Card corner labels */
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 1px;
}

.card-corner-top {
  align-self: flex-start;
}

.card-corner-bottom {
  align-self: flex-end;
  transform: rotate(180deg);
  margin-top: auto;
}

.card-rank {
  font-size: clamp(10px, 1.4vw, 14px);
  font-weight: 800;
  line-height: 1;
}

.card-suit-small {
  font-size: clamp(8px, 1.1vw, 11px);
  line-height: 1;
}

/* Card center suit */
.card-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(20px, 3vw, 32px);
  line-height: 1;
  pointer-events: none;
  opacity: 0.15;
}

/* Card color classes */
.card.red .card-rank,
.card.red .card-suit-small,
.card.red .card-center {
  color: #d32f2f;
}

.card.black .card-rank,
.card.black .card-suit-small,
.card.black .card-center {
  color: #1a1a1a;
}

/* Card dragging state */
.card.dragging {
  opacity: 0.6;
  transform: scale(0.98) !important;
  pointer-events: none;
}

/* ============================================
   Waste Pile Fan
   ============================================ */
.waste-fan-card {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

/* ============================================
   Action Bar
   ============================================ */
.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 8px;
  background: var(--action-bar-bg);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,0.06);
  justify-content: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

@media (max-width: 380px) {
  .action-bar { gap: 4px; padding: 6px 4px; }
  .btn { padding: 7px 10px; font-size: 12px; }
}

/* ============================================
   AI Coach Panel
   ============================================ */
.ai-coach {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.ai-coach-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.ai-coach-toggle:hover { color: var(--text-primary); }

.ai-icon { font-size: 16px; }

.ai-toggle-arrow {
  margin-left: auto;
  transition: transform 0.2s;
  font-size: 10px;
}

.ai-coach-toggle[aria-expanded="true"] .ai-toggle-arrow {
  transform: rotate(180deg);
}

.ai-coach-body {
  padding: 0 16px 12px;
}

.ai-message {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.ai-stats { display: flex; flex-direction: column; gap: 6px; }

.ai-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.ai-stat-label { color: var(--text-secondary); width: 70px; }

.ai-efficiency-bar {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.ai-efficiency-fill {
  height: 100%;
  background: linear-gradient(90deg, #e94560, #f4a261);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.ai-stat-value { font-weight: 600; color: var(--text-primary); width: 30px; text-align: right; }

.ai-deadlock-warning {
  color: #ffa500;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================
   Modals
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--modal-bg);
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 24px 48px rgba(0,0,0,0.6);
  width: 100%;
  max-width: 440px;
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  background: var(--modal-bg);
  z-index: 1;
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  background: rgba(255,255,255,0.06) !important;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Win Modal */
.win-modal {
  text-align: center;
  padding: 32px 24px;
  position: relative;
  overflow: hidden;
}

.win-celebration {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.win-title {
  font-size: 36px;
  font-weight: 800;
  margin-bottom: 24px;
  animation: bounceIn 0.5s cubic-bezier(0.34,1.56,0.64,1);
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.win-stat {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.win-stat-icon { font-size: 20px; }
.win-stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.win-stat-value { font-size: 22px; font-weight: 800; color: var(--accent); }

.win-level-up {
  background: rgba(233,69,96,0.15);
  border: 1px solid rgba(233,69,96,0.3);
  border-radius: 10px;
  padding: 10px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.level-up-text { font-size: 14px; font-weight: 600; }
.level-up-new { font-size: 16px; font-weight: 800; color: var(--accent); }

.win-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Theme Modal */
.theme-modal .modal-header { padding-bottom: 12px; }

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px;
}

.theme-card {
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theme-card:hover { transform: scale(1.03); }
.theme-card.active { border-color: var(--accent) !important; }

.theme-card-name {
  font-size: 13px;
  font-weight: 700;
}

.theme-card-desc {
  font-size: 11px;
  opacity: 0.7;
}

.theme-card-emoji { font-size: 22px; margin-bottom: 2px; }

/* Settings Modal */
.settings-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.setting-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.setting-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-slider {
  width: 44px;
  height: 24px;
  background: rgba(255,255,255,0.1);
  border-radius: 12px;
  transition: background 0.2s;
  position: relative;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-switch input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* Volume Slider */
.volume-slider {
  flex: 1;
  min-width: 100px;
  accent-color: var(--accent);
  height: 6px;
}

/* Stats Modal */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 16px;
}

.stats-item {
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-item-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stats-item-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Achievements Modal */
.achievements-modal { max-width: 480px; }

.achievements-list {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
}

.achievement-item.unlocked {
  background: rgba(233,69,96,0.08);
  border-color: rgba(233,69,96,0.2);
}

.achievement-icon {
  font-size: 28px;
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.achievement-locked-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  opacity: 0.3;
  flex-shrink: 0;
}

.achievement-info { flex: 1; }
.achievement-name { font-size: 13px; font-weight: 700; }
.achievement-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }

.achievement-xp {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* Daily Modal */
.daily-body {
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.daily-date {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.daily-status {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Keyboard Modal */
.keyboard-modal { max-width: 400px; }

.shortcuts-list {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.shortcut-item span { color: var(--text-secondary); }

kbd {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  padding: 3px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
}

/* ============================================
   Achievement Toast
   ============================================ */
.achievement-toast {
  position: fixed;
  bottom: 80px;
  right: 16px;
  z-index: 1000;
  animation: slideInRight 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

.achievement-toast[hidden] { display: none; }

.achievement-toast.hiding {
  animation: slideOutRight 0.3s ease forwards;
}

.achievement-toast-inner {
  background: var(--modal-bg);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  max-width: 300px;
}

.achievement-toast-icon { font-size: 28px; }

.achievement-toast-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
}

.achievement-toast-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* ============================================
   Drag Ghost
   ============================================ */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9000;
  opacity: 0;
  transition: none;
  transform-origin: 50% 50%;
}

.drag-ghost.active {
  opacity: 1;
}

/* ============================================
   Left-Handed Mode
   ============================================ */
body.left-handed .top-row {
  flex-direction: row-reverse;
}

body.left-handed .top-row-gap {
  order: -1;
}

/* ============================================
   Keyframe Animations
   ============================================ */
@keyframes loadingCard {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.7; }
  50% { transform: translateY(-12px) rotate(5deg); opacity: 1; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

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

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

@keyframes slideInRight {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120px); opacity: 0; }
}

@keyframes bounceIn {
  from { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.15); }
  to { transform: scale(1); opacity: 1; }
}

@keyframes cardFlip {
  0% { transform: rotateY(0deg); }
  50% { transform: rotateY(90deg); }
  100% { transform: rotateY(0deg); }
}

@keyframes cardSlide {
  from { transform: translate(var(--slide-x, 0), var(--slide-y, -20px)); opacity: 0.7; }
  to { transform: translate(0, 0); opacity: 1; }
}

@keyframes hintPulse {
  0%, 100% { box-shadow: var(--card-shadow); }
  50% { box-shadow: 0 0 0 3px var(--accent), 0 8px 24px var(--accent-glow); }
}

@keyframes hintPulseGreen {
  0%, 100% { box-shadow: var(--card-shadow); }
  50% { box-shadow: 0 0 0 3px #64ff64, 0 8px 24px rgba(100,255,100,0.4); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes celebration {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-300px) rotate(720deg); opacity: 0; }
}

@keyframes winParticle {
  0% { transform: translate(0, 0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--px), var(--py)) rotate(var(--pr)) scale(0); opacity: 0; }
}

/* ============================================
   Responsive
   ============================================ */
@media (min-width: 600px) {
  :root {
    --card-width: 80px;
    --card-height: 112px;
    --tableau-offset-down: 32px;
  }
  .game-board { padding: 12px 12px 8px; gap: 10px; }
  .tableau, .top-row { gap: 8px; }
}

@media (min-width: 900px) {
  :root {
    --card-width: 90px;
    --card-height: 126px;
    --tableau-offset-down: 36px;
  }
  .game-board { padding: 16px; gap: 12px; }
  .tableau, .top-row { gap: 10px; }
}

@media (min-width: 1400px) {
  :root {
    --card-width: 100px;
    --card-height: 140px;
    --tableau-offset-down: 38px;
  }
}

/* Short screens - reduce card offsets */
@media (max-height: 680px) {
  :root { --tableau-offset-down: 22px; --tableau-offset-up: 16px; }
  .header { height: 48px; padding: 6px 10px; }
  .action-bar { padding: 6px 8px; }
}

/* ============================================
   Print
   ============================================ */
@media print {
  .header, .action-bar, .ai-coach, .sidebar, .sidebar-overlay,
  .achievement-toast, .drag-ghost, .ambient-canvas { display: none !important; }
  .game-area { display: block; }
}

/* ============================================
   Accessibility - Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================
   Arcade Feel
   ============================================ */

/* Score popup that floats upward on card moves */
.score-popup {
  position: fixed;
  font-size: 1.1rem;
  font-weight: 800;
  pointer-events: none;
  z-index: 9000;
  will-change: transform, opacity;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  animation: scorePopupFloat 1.1s cubic-bezier(0.22, 0.68, 0, 1.2) forwards;
  letter-spacing: 0.04em;
}
.score-popup.positive { color: #78d830; }
.score-popup.bonus    { color: #ffd700; font-size: 1.4rem; }
.score-popup.negative { color: #e94560; }

@keyframes scorePopupFloat {
  0%   { transform: translateY(0) scale(1);    opacity: 1; }
  30%  { transform: translateY(-18px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-60px) scale(0.9); opacity: 0; }
}

/* Combo banner */
.combo-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  font-size: 2.2rem;
  font-weight: 900;
  color: #ffd700;
  text-shadow:
    0 0 20px rgba(255,215,0,0.9),
    0 0 40px rgba(255,215,0,0.5),
    0 4px 12px rgba(0,0,0,0.8);
  pointer-events: none;
  z-index: 9001;
  opacity: 0;
  will-change: transform, opacity;
  animation: comboBurst 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  white-space: nowrap;
}

@keyframes comboBurst {
  0%   { transform: translate(-50%,-50%) scale(0.4); opacity: 0; }
  20%  { transform: translate(-50%,-50%) scale(1.15); opacity: 1; }
  60%  { transform: translate(-50%,-50%) scale(1);    opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.8);  opacity: 0; }
}

/* Snap-target pulse on valid drop */
.snap-target {
  animation: snapPulse 0.5s ease infinite alternate !important;
}

@keyframes snapPulse {
  from { box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 2px var(--accent); }
  to   { box-shadow: 0 0 0 4px var(--accent), inset 0 0 0 2px var(--accent), 0 0 18px var(--accent-glow); }
}

/* Valid drop highlight upgrade */
.valid-drop-target,
.valid-drop {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px;
  background: rgba(120,216,48,0.08) !important;
  transition: background 0.15s, outline 0.15s;
}

/* Card "land" flash on placement */
@keyframes cardLand {
  0%   { box-shadow: 0 0 0 0 transparent; }
  30%  { box-shadow: 0 0 0 6px rgba(120,216,48,0.6); }
  100% { box-shadow: var(--card-shadow); }
}
.card-just-placed {
  animation: cardLand 0.4s ease-out forwards;
}

/* Arcade score number spin */
@keyframes scoreSpin {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.score-value-update {
  display: inline-block;
  animation: scoreSpin 0.25s ease-out forwards;
}

/* Games hub nav link in sidebar */
.sidebar-nav-item.games-hub-link {
  background: linear-gradient(135deg, rgba(233,69,96,0.15), rgba(180,100,255,0.15));
  border: 1px solid rgba(233,69,96,0.3);
  margin-top: 8px;
}

/* Games Hub Modal */
.games-modal { max-width: 560px; }
.games-modal-sub {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: -8px 0 16px;
}
.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 480px) {
  .games-grid { grid-template-columns: repeat(2, 1fr); }
}
.game-card-link {
  text-decoration: none;
  display: block;
}
.game-card-hub {
  background: var(--pile-bg);
  border: 1px solid var(--pile-border);
  border-radius: 12px;
  padding: 18px 10px 14px;
  text-align: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  cursor: pointer;
}
.game-card-hub:hover {
  background: rgba(233,69,96,0.12);
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.game-card-icon { font-size: 2.2rem; margin-bottom: 8px; }
.game-card-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.game-card-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}
