/* ==========================================================================
   VARIABLES & RESET
   ========================================================================== */
:root {
  --cell-size: 28px;
  --primary: #2c3e50;
  --accent: #3498db;
  --bg-color: #f4f4f4;
  --text-dark: #333;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  padding: 20px;
  display: flex;
  gap: 20px;
  height: 100vh;
  margin: 0;
}

/* ==========================================================================
   SIDEBAR (CONTROLS)
   ========================================================================== */
.controls {
  width: 300px;
  height: fit-content;
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.controls h3 {
  margin-top: 0;
  color: var(--primary);
}

label {
  font-size: 0.9rem;
  font-weight: bold;
  color: #555;
  display: block;
  margin-bottom: 5px;
}

select,
input[type="number"],
textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

textarea {
  height: 120px;
  font-family: monospace;
  resize: vertical;
}

button {
  padding: 12px;
  border: none;
  cursor: pointer;
  font-weight: bold;
  border-radius: 4px;
  font-size: 0.95rem;
  transition: background 0.2s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: #34495e;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}
.btn-secondary:hover {
  background: #d0d0d0;
}

.input-section {
  display: none;
}
.input-section.active {
  display: block;
  animation: fadeIn 0.3s;
}

.batch-panel {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.batch-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.stats {
  font-size: 0.85em;
  color: #666;
  margin-top: 10px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

/* ==========================================================================
   GAME AREA (PREVIEW)
   ========================================================================== */
.print-area {
  flex: 1;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  overflow: auto;
}

.print-header {
  font-size: 1.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--primary);
  border-bottom: 2px solid #eee;
  width: 100%;
  text-align: center;
  padding-bottom: 10px;
}

.game-container {
  display: flex;
  gap: 40px;
  justify-content: center;
  width: 100%;
}

/* --- Grid --- */
#grid {
  border-collapse: collapse;
  user-select: none;
}

#grid td {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 1px solid #000;
  text-align: center;
  font-weight: bold;
  font-size: 14px;
  padding: 0;
  cursor: default;
}

#grid td.empty {
  background-color: #000;
}

#grid td.filled {
  background-color: #fff;
  color: transparent;
  transition: color 0.1s;
}

#grid td.revealed {
  color: #000 !important;
  background-color: #e8f0fe;
}

/* --- Word List --- */
.word-list {
  column-count: 2;
  column-gap: 30px;
  min-width: 200px;
  font-size: 13px;
}

.word-group {
  break-inside: avoid;
  margin-bottom: 10px;
}
.group-title {
  border-bottom: 2px solid #000;
  font-weight: bold;
  margin-bottom: 4px;
}

.word-item {
  cursor: pointer;
  padding: 1px 4px;
  text-transform: uppercase;
}
.word-item:hover {
  background-color: #eee;
}
.word-item.active {
  text-decoration: line-through;
  color: #aaa;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   PRINT MEDIA (NATIVE CTRL+P)
   ========================================================================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 0;
  }

  body,
  html {
    background: white;
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
  }

  .controls {
    display: none !important;
  }

  .print-area {
    display: block;
    border: none;
    box-shadow: none;
    padding: 10mm;
    width: 100%;
    height: 100%;
  }

  .print-header {
    font-size: 24pt;
    color: #000;
    border-bottom: 3px solid #000;
  }

  .game-container {
    justify-content: space-between;
    gap: 30px;
  }

  #grid {
    flex: 2;
    width: 100% !important;
  }
  #grid td {
    border: 1px solid #000 !important;
  }
  #grid td.empty {
    background-color: #000 !important;
    -webkit-print-color-adjust: exact;
  }
  #grid td.filled.revealed {
    background-color: #ddd !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
  }

  .word-list {
    flex: 1;
    column-count: 3;
    font-size: 10pt;
  }
  .word-item.active {
    color: #000 !important;
    text-decoration: line-through;
  }
}
