/* ==========================================================================
   Woordzoeker - Dutch Language Learning Word Search Application
   Modern, Vibrant, Accessible Design System & Theme Engine
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
:root {
  /* Brand Palettes: Royal Dutch Orange + Indigo Modern */
  --primary: #f97316;
  --primary-hover: #ea580c;
  --primary-light: #ffedd5;
  --primary-glow: rgba(249, 115, 22, 0.35);

  --accent-indigo: #6366f1;
  --accent-indigo-hover: #4f46e5;
  --accent-indigo-glow: rgba(99, 102, 241, 0.3);

  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --danger: #ef4444;

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-grid: 'Outfit', 'JetBrains Mono', monospace;

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Dark Theme (Default) --- */
[data-theme="dark"] {
  --bg-app: #0b0f19;
  --bg-gradient: radial-gradient(circle at 50% -20%, #1e1b4b 0%, #0b0f19 75%);
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --bg-elevated: #1f2937;
  --bg-subtle: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(249, 115, 22, 0.6);

  --text-main: #f9fafb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --grid-cell-bg: rgba(31, 41, 55, 0.55);
  --grid-cell-hover: rgba(55, 65, 81, 0.85);
  --grid-cell-border: rgba(255, 255, 255, 0.08);
  --grid-cell-active: rgba(249, 115, 22, 0.25);
  --grid-cell-text: #f3f4f6;

  --card-border: 1px solid rgba(255, 255, 255, 0.08);
  --glass-blur: blur(16px);
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg-app: #f8fafc;
  --bg-gradient: radial-gradient(circle at 50% -20%, #fed7aa 0%, #f8fafc 65%);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-hover: rgba(248, 250, 252, 0.95);
  --bg-elevated: #ffffff;
  --bg-subtle: rgba(0, 0, 0, 0.03);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(249, 115, 22, 0.7);

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --grid-cell-bg: #ffffff;
  --grid-cell-hover: #f1f5f9;
  --grid-cell-border: rgba(0, 0, 0, 0.08);
  --grid-cell-active: rgba(249, 115, 22, 0.15);
  --grid-cell-text: #1e293b;

  --card-border: 1px solid rgba(0, 0, 0, 0.08);
  --glass-blur: blur(12px);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-app);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  user-select: none;
}

/* --- App Header --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: var(--card-border);
  box-shadow: var(--shadow-sm);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.flag-icon {
  font-size: 1.75rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.25));
}

.logo-letters {
  display: flex;
  gap: 2px;
}

.letter-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 23px;
  height: 23px;
  border-radius: 5px;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 0.78rem;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.l1 { background: #38bdf8; } /* W - Pastel Sky Blue */
.l2 { background: #fb923c; } /* O - Pastel Orange */
.l3 { background: #34d399; } /* O - Pastel Mint Green */
.l4 { background: #f472b6; } /* R - Pastel Rose/Pink */
.l5 { background: #a78bfa; } /* D - Pastel Lavender/Purple */

.brand-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.brand-subtitle em {
  font-style: normal;
  color: var(--primary);
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Buttons System --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
  box-shadow: 0 6px 16px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: var(--card-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-icon:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-subtle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-heading);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.btn-subtle:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.btn-tool {
  background: var(--bg-elevated);
  border: var(--card-border);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-family: var(--font-heading);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.btn-tool:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.78rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Main Layout --- */
.app-main {
  max-width: 1760px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

/* --- Controls Card --- */
.controls-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.custom-select, .form-input, .form-textarea {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: var(--bg-elevated);
  border: var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  outline: none;
  transition: all var(--transition-fast);
}

.custom-select:focus, .form-input:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.custom-select option {
  background: var(--bg-elevated);
  color: var(--text-main);
}

/* --- Unified Controls Toolbar (Actions Left, Status Right) --- */
.controls-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border-subtle);
}

.toolbar-actions-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.toolbar-actions-group .btn-primary {
  height: 40px;
  padding: 0 1.35rem;
}

.toolbar-actions-group .btn-tool {
  height: 40px;
  padding: 0 0.95rem;
}

.status-box {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-elevated);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  border: var(--card-border);
}

.timer-text {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  letter-spacing: 0.05em;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 200px;
  max-width: 320px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 600;
}

.progress-title {
  color: var(--text-secondary);
}

.progress-count {
  color: var(--text-main);
}

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #f97316, #10b981);
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Game Layout Split --- */
.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(580px, 1.08fr);
  gap: 1.25rem;
  align-items: stretch; /* Stretches both cards to have identical height & aligned bottoms */
}

@media (max-width: 1100px) {
  .game-layout {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.puzzle-section,
.wordlist-section {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* --- Puzzle Board Section --- */
.board-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  height: 100%;
  min-height: 600px;
  box-sizing: border-box;
}

.board-header {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  gap: 0.5rem;
}

.board-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.board-subtitle {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
}

[data-theme="dark"] .board-subtitle {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
}

.board-tip {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

/* --- Word Search Grid --- */
.grid-outer-wrapper {
  width: 100%;
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.5rem;
  overflow: visible; /* No scrollbar; grid scales adaptively */
  overflow-x: clip;
  touch-action: none;
}

.grid-container {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 12), minmax(0, 1fr));
  width: min(100%, calc(var(--grid-cols, 12) * 44px + (var(--grid-cols, 12) - 1) * 3px + 16px));
  max-width: 100%;
  gap: 3px;
  background: var(--bg-subtle);
  padding: 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  user-select: none;
  -webkit-user-select: none;
}

/* SVG Highlight Layer */
.grid-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Grid Cell */
.grid-cell {
  aspect-ratio: 1 / 1;
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grid-cell-bg);
  border: 1px solid var(--grid-cell-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-grid);
  font-size: clamp(0.68rem, calc(28vw / var(--grid-cols, 12)), 1.25rem);
  font-weight: 700;
  color: var(--grid-cell-text);
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, color 0.15s ease;
  position: relative;
  z-index: 10;
}

.grid-cell:hover {
  background: var(--grid-cell-hover);
  transform: scale(1.06);
  z-index: 15;
}

.grid-cell.cell-selected {
  background: var(--primary) !important;
  color: #ffffff !important;
  transform: scale(1.08);
  box-shadow: 0 0 10px var(--primary-glow);
  z-index: 20;
}

.grid-cell.cell-start {
  border-color: #ffffff;
}

.grid-cell.cell-hint-glow {
  animation: hintPulse 1.2s infinite alternate ease-in-out;
  background: #facc15 !important;
  color: #000000 !important;
  z-index: 25;
}

@keyframes hintPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.7); }
  100% { transform: scale(1.15); box-shadow: 0 0 16px 6px rgba(250, 204, 21, 0.5); }
}

/* --- Word List Section --- */
.wordlist-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: 100%;
  min-height: 600px;
  box-sizing: border-box;
}

.wordlist-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
  gap: 0.5rem;
}

.wordlist-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.dutch-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #f97316;
  background: rgba(249, 115, 22, 0.15);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
}

.wordlist-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

.badge-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  background: var(--bg-elevated);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-full);
  border: var(--card-border);
  white-space: nowrap;
}

/* Guide for columns */
.wordlist-columns-guide {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(160px, 1.4fr) minmax(110px, 1fr) minmax(110px, 1fr);
  padding: 0.6rem 0.95rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  gap: 0.75rem;
  align-items: center;
}

.col-guide {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* List of Words */
.word-items-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

/* Individual Word Item - Spacious, perfectly centered, equal top/bottom padding */
.word-item {
  display: grid;
  grid-template-columns: minmax(135px, 1fr) minmax(160px, 1.4fr) minmax(110px, 1fr) minmax(110px, 1fr);
  align-items: center;
  padding: 0.75rem 0.95rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
  position: relative;
  overflow: visible;
  gap: 0.75rem;
  min-height: 64px;
  box-sizing: border-box;
  cursor: default;
}

.word-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateX(2px);
}

/* Dutch Word Column */
.word-col-nl {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  height: 100%;
}

.btn-speak {
  width: 30px;
  height: 30px;
  min-width: 30px;
  max-width: 30px;
  padding: 0;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.btn-speak:hover {
  background: rgba(249, 115, 22, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  transform: scale(1.08);
}

.btn-speak svg {
  width: 15px;
  height: 15px;
  display: block;
}

.word-text-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  min-width: 0;
}

.word-main-text {
  font-weight: 700;
  font-size: 0.94rem;
  color: var(--text-main);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.word-sub-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
  display: block;
  cursor: help;
}

/* Target Word Badge Column (Centered with equal top/bottom breathing room) */
.word-col-badge {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  height: 100%;
}

.word-target-badge {
  font-family: var(--font-grid);
  font-weight: 800;
  font-size: 0.82rem;
  height: 32px;
  padding: 0 0.65rem;
  background: rgba(249, 115, 22, 0.15);
  color: #f97316;
  border-radius: 6px;
  border: 1px solid rgba(249, 115, 22, 0.35);
  letter-spacing: 0.05em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.badge-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 900;
  line-height: 1;
}

/* English and Turkish Columns (Centered vertically) */
.word-col-en, .word-col-tr {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  align-self: center;
}

/* Found / Completed Word Styling */
.word-item.word-found {
  opacity: 0.75;
  background: var(--bg-subtle);
  border-left-width: 5px;
}

.word-item.word-found .word-main-text,
.word-item.word-found .word-col-en,
.word-item.word-found .word-col-tr {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  color: var(--text-muted);
}

.word-item.word-found .word-target-badge {
  opacity: 0.9;
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

/* --- Modals System --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 1;
  transition: opacity var(--transition-normal);
}

.modal-overlay.hidden {
  display: none;
  opacity: 0;
}

.modal-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: var(--card-border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: 90vh;
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-card.modal-lg {
  max-width: 860px;
}

@keyframes modalSlideUp {
  0% { transform: translateY(20px) scale(0.97); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

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

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-icon {
  font-size: 1.25rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.btn-close-modal:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

/* Modal Tabs */
.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  padding: 0 1rem;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 0.75rem 1rem;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

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

/* Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-focus);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background: var(--bg-subtle);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.drop-zone:hover, .drop-zone.dragover {
  background: var(--bg-elevated);
  border-color: var(--primary);
  transform: scale(1.01);
}

.file-input-hidden {
  display: none;
}

.drop-icon {
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.drop-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.drop-subtext {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.drop-subtext code {
  background: var(--bg-elevated);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

/* Paste Text Form */
.paste-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-main);
}

.format-help {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: normal;
}

.form-textarea {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  resize: vertical;
}

/* Preview Table */
.upload-preview-area {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.preview-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.preview-badge {
  font-size: 0.75rem;
  background: var(--primary-light);
  color: #ea580c;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  font-weight: 600;
}

[data-theme="dark"] .preview-badge {
  background: rgba(249, 115, 22, 0.2);
  color: #fb923c;
}

.preview-table-wrapper {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.preview-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
  text-align: left;
}

.preview-table th {
  background: #182234;
  padding: 0.5rem 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 5;
}

[data-theme="light"] .preview-table th {
  background: #f1f5f9;
}

.preview-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
}

/* Saved Lists Tab */
.saved-lists-container {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.saved-list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: var(--card-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.saved-list-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.saved-list-info h4 {
  font-family: var(--font-heading);
  font-size: 0.92rem;
  color: var(--text-main);
}

.saved-list-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.saved-list-actions {
  display: flex;
  gap: 0.4rem;
}

/* Manual Word Picker Modal */
.picker-toolbar {
  padding: 0.85rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.picker-search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-elevated);
  border: var(--card-border);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.75rem;
  flex: 1;
  max-width: 380px;
}

.search-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main);
  font-size: 0.85rem;
  width: 100%;
}

.picker-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.picker-selected-stat {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.picker-selected-stat strong {
  color: var(--primary);
}

.picker-words-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.65rem;
}

.picker-word-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  background: var(--bg-elevated);
  border: var(--card-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.picker-word-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

.picker-word-card.selected {
  border-color: var(--primary);
  background: rgba(249, 115, 22, 0.12);
}

.picker-checkbox {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.picker-word-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.picker-word-nl {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
}

.picker-word-trans {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.footer-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.footer-buttons {
  display: flex;
  gap: 0.5rem;
}

/* Celebration Modal */
.modal-celebration-card {
  text-align: center;
  width: 95%;
  max-width: 780px;
  padding: 2.25rem 2.5rem;
  align-items: center;
}

.celebration-trophy {
  font-size: 3.5rem;
  animation: bounceTrophy 1s ease infinite alternate;
}

@keyframes bounceTrophy {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.08); }
}

.celebration-title {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 0.5rem;
}

.celebration-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.celebration-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  width: 100%;
  margin: 1.25rem 0;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-elevated);
  border: var(--card-border);
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius-md);
}

.stat-icon {
  font-size: 1.15rem;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.stat-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  color: var(--primary);
  font-weight: 700;
}

.celebration-review-container {
  width: 100%;
  text-align: left;
  margin-top: 0.5rem;
}

.review-title {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.review-table-wrap {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.review-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

.review-table th {
  background: #182234;
  padding: 0.65rem 0.95rem;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 2px solid var(--border-subtle);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
  text-align: left;
}

[data-theme="light"] .review-table th {
  background: #f1f5f9;
  border-bottom-color: rgba(0, 0, 0, 0.12);
}

.review-table td {
  padding: 0.55rem 0.95rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.review-table tr:hover td {
  background: rgba(249, 115, 22, 0.06);
}

.review-table th.col-badge,
.review-table td.review-col-badge {
  width: 25%;
  min-width: 135px;
}

.review-table th.col-nl,
.review-table td.review-col-nl {
  width: 37%;
  min-width: 180px;
}

.review-table th.col-en,
.review-table td.review-col-en {
  width: 19%;
  color: var(--text-secondary);
  font-size: 0.83rem;
}

.review-table th.col-tr,
.review-table td.review-col-tr {
  width: 19%;
  color: var(--text-secondary);
  font-size: 0.83rem;
}

.review-table td.review-col-nl .word-col-nl {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.review-table td.review-col-badge .word-target-badge {
  display: inline-flex;
}

.celebration-footer {
  width: 100%;
  justify-content: center;
  border-top: none;
  background: transparent;
  padding: 1.25rem 0 0;
}

/* Confetti Canvas */
.confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* --- Print Stylesheet (@media print) --- */
.print-sheet {
  display: none;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .app-header, .controls-card, .game-toolbar, .game-actions, .modal-overlay, .board-tip {
    display: none !important;
  }

  .print-sheet {
    display: block !important;
    padding: 20px;
    font-family: Arial, sans-serif;
  }

  .print-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #000;
    padding-bottom: 10px;
  }

  .print-header h1 {
    font-size: 24pt;
    margin-bottom: 5px;
  }

  .print-grid-box {
    display: flex;
    justify-content: center;
    margin: 20px 0;
  }

  .print-grid-table {
    border-collapse: collapse;
    margin: 0 auto;
  }

  .print-grid-table td {
    width: 32px;
    height: 32px;
    text-align: center;
    font-size: 14pt;
    font-weight: bold;
    border: 1px solid #999;
  }

  .print-words-box {
    margin-top: 30px;
    page-break-inside: avoid;
  }

  .print-words-box h2 {
    font-size: 16pt;
    border-bottom: 1px solid #000;
    margin-bottom: 10px;
    padding-bottom: 5px;
  }

  .print-words-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    font-size: 11pt;
  }

  .print-word-item {
    margin-bottom: 6px;
    line-height: 1.3;
  }
}
