/* ============================================
   Tablo — Nonogram Styles
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  min-height: 100vh;
}

.game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px 20px;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  margin-top: 24px;
}

.game-stats {
  display: flex;
  gap: 24px;
  padding: 16px 24px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 500px;
  margin: 0 auto;
  align-items: center;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 80px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: #2dd4bf;
}

.size-select {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-primary, sans-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 80px;
}

.size-select:hover {
  border-color: #2dd4bf;
}

/* Fixed: Container with controlled overflow */
.nonogram-container {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  padding: 16px;
  background: #0f172a;
  border-radius: 12px;
  border: 2px solid #334155;
  display: flex;
  justify-content: center;
}

/* Fixed: Proper layout structure */
.nonogram-grid-wrapper {
  display: inline-flex;
  flex-direction: column;
}

/* Top row: corner + column clues */
.nonogram-top-row {
  display: flex;
  flex-direction: row;
}

/* Bottom row: row clues column + grid */
.nonogram-bottom-row {
  display: flex;
  flex-direction: row;
}

/* Column clues container */
.col-clues-row {
  display: flex;
  flex-direction: row;
  gap: 1px;
}

/* Row clues container */
.row-clues-column {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* Corner cell */
.nonogram-corner {
  width: 60px;
  height: 50px;
  background: transparent;
  flex-shrink: 0;
}

/* Clue cells */
.clue-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Column clues: stack numbers vertically, align bottom */
.col-clue {
  width: 35px;
  height: 50px;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 1px;
}

.col-clue span {
  display: block;
}

/* Row clues: numbers in a row, align right */
.row-clue {
  width: 60px;
  height: 35px;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  text-align: right;
}

.row-clue span {
  display: inline;
}

/* Cell grid */
.nonogram-cell-grid {
  display: grid;
  gap: 1px;
  background: #334155;
  border: 2px solid #334155;
}

.cell {
  width: 35px;
  height: 35px;
  background: #1e293b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  flex-shrink: 0;
}

.cell:hover {
  background: #243044;
}

.cell.filled {
  background: #2dd4bf;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
}

.cell.marked {
  background: #0f172a;
}

.cell.marked::after {
  content: '✕';
  font-size: 20px;
  color: #f59e0b;
  font-weight: 700;
}

.winner-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.winner-modal.visible { display: flex; }

.winner-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
}

.winner-content {
  position: relative;
  background: #1e293b;
  border: 2px solid #2dd4bf;
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
}

.winner-icon { font-size: 48px; margin-bottom: 16px; }
.winner-title { font-size: 24px; font-weight: 700; margin-bottom: 12px; color: #e2e8f0; }
.winner-message { font-size: 16px; color: #94a3b8; margin-bottom: 24px; }
.winner-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.tablo-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 10001;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.tablo-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.game-controls {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.game-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-primary, sans-serif);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.game-btn:hover:not(:disabled) {
  background: #243044;
  border-color: #2dd4bf;
  color: #2dd4bf;
}

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

.game-btn.primary {
  background: #2dd4bf;
  border-color: #2dd4bf;
  color: #0f1923;
}

.game-btn.primary:hover:not(:disabled) {
  background: #5eead4;
}

.game-hint {
  font-size: 12px;
  color: #64748b;
  text-align: center;
  margin: 8px auto;
  max-width: 600px;
  line-height: 1.5;
}

/* Mobile responsive */
@media (max-width: 600px) {
  .cell {
    width: 28px;
    height: 28px;
  }

  .col-clue {
    width: 28px;
    height: 40px;
    font-size: 9px;
    padding: 2px 1px;
  }

  .row-clue {
    width: 45px;
    height: 28px;
    font-size: 9px;
    padding: 2px 1px;
  }

  .nonogram-corner {
    width: 45px;
    height: 40px;
  }

  .cell.marked::after {
    font-size: 14px;
  }

  .game-stats {
    gap: 12px;
    padding: 12px 16px;
    max-width: 100%;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-value {
    font-size: 14px;
  }

  .nonogram-container {
    padding: 8px;
  }
}