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

body {
  font-family: 'Nunito', sans-serif;
  background: #1a1a2e;
  background-image: radial-gradient(circle at 30% 70%, #16213e 0%, #1a1a2e 60%);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: #fff;
  user-select: none;
  overflow-x: hidden;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.6rem 1rem;
  background: linear-gradient(135deg, #ff6b35, #e85d2a);
  color: #fff; font-family: 'Nunito', sans-serif; flex-shrink: 0;
}
.btn-back {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 0.85rem;
  background: rgba(255,255,255,0.2); padding: 0.3rem 0.7rem; border-radius: 999px;
  transition: background 0.2s; white-space: nowrap;
}
.btn-back:hover { background: rgba(255,255,255,0.35); }
.game-title { font-size: 1.1rem; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.stats { display: flex; gap: 0.8rem; font-size: 0.9rem; font-weight: 700; opacity: 0.95; white-space: nowrap; }

.controls-bar {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  padding: 0.5rem 1rem; background: rgba(0,0,0,0.3); backdrop-filter: blur(4px);
  flex-wrap: wrap; flex-shrink: 0;
}
.difficulty-selector { display: flex; gap: 0.3rem; }
.diff-btn {
  padding: 0.3rem 0.8rem; border: 2px solid rgba(255,255,255,0.25); border-radius: 999px;
  background: transparent; color: #fff; font-family: 'Nunito', sans-serif; font-weight: 700;
  font-size: 0.8rem; cursor: pointer; transition: all 0.2s;
}
.diff-btn:hover { background: rgba(255,255,255,0.15); }
.diff-btn.active { background: #e94560; border-color: #e94560; }
.control-buttons { display: flex; gap: 0.4rem; }

.btn {
  padding: 0.35rem 1rem; border: none; border-radius: 999px; font-family: 'Nunito', sans-serif;
  font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: opacity 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.96); }
.btn-new { background: #e94560; color: #fff; }
.btn-new:hover { opacity: 0.88; }
.btn-orange { background: #e94560; color: #fff; padding: 0.5rem 1.5rem; font-size: 1rem; border: none; border-radius: 999px; font-family: 'Nunito', sans-serif; font-weight: 700; cursor: pointer; }
.btn-orange:hover { opacity: 0.88; }

.game-container {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  padding: 0.8rem; overflow: auto;
}

.nonogram-wrapper { display: inline-block; max-width: 100%; overflow: auto; }

.nonogram-board {
  display: grid;
  gap: 0;
  background: #333;
  border: 2px solid #555;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.clue-cell {
  display: flex; align-items: flex-end; justify-content: center;
  background: #2a2a4a; padding: 2px; font-size: 0.65rem; font-weight: 700;
  color: rgba(255,255,255,0.8); flex-direction: column; text-align: center;
  min-width: 24px; min-height: 24px;
}
.clue-cell.row-clue {
  flex-direction: row; align-items: center; justify-content: flex-end; gap: 3px; padding-right: 4px;
}
.clue-cell.col-clue {
  flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; padding-bottom: 2px;
}
.clue-cell.corner { background: #1e1e3a; }

.game-cell {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  background: #e0e0e0; border: 1px solid #bbb; cursor: pointer;
  transition: background 0.1s; font-size: 0.9rem; font-weight: 800; color: #c00;
  -webkit-tap-highlight-color: transparent;
}
.game-cell:hover { background: #d0d0d0; }
.game-cell.filled { background: #333; border-color: #222; }
.game-cell.marked { background: #e0e0e0; color: #c00; }
.game-cell.correct-row .filled-check,
.game-cell.filled.row-done { background: #2a7a2a; border-color: #1a5a1a; }

.clue-cell.done { color: rgba(255,255,255,0.3); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }
.modal-content {
  background: #1e1e3a; border-radius: 16px; padding: 2rem 2.5rem; text-align: center;
  animation: popIn 0.3s ease; border: 2px solid rgba(255,255,255,0.1); max-width: 90vw;
}
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.modal-content h2 { font-size: 1.8rem; font-weight: 800; margin-bottom: 0.3rem; }
.modal-content p { font-size: 0.95rem; color: rgba(255,255,255,0.7); margin-bottom: 0.3rem; }
.modal-stats { font-size: 1.1rem; font-weight: 700; color: #fff; }
.modal-content .btn { margin-top: 1rem; }

@media (max-width: 480px) {
  .topbar { padding: 0.4rem 0.6rem; }
  .game-title { font-size: 0.9rem; }
  .stats { font-size: 0.8rem; gap: 0.5rem; }
  .controls-bar { padding: 0.4rem 0.5rem; gap: 0.5rem; }
  .diff-btn { padding: 0.25rem 0.6rem; font-size: 0.7rem; }
  .btn { padding: 0.3rem 0.7rem; font-size: 0.75rem; }
  .game-container { padding: 0.4rem; }
  .game-cell { width: 22px; height: 22px; font-size: 0.7rem; }
  .clue-cell { font-size: 0.55rem; min-width: 18px; min-height: 18px; }
}

/* ===== SEO GAME INFO SECTION ===== */
.game-info {
  max-width: 780px;
  margin: 1rem auto;
  padding: 1rem 1.2rem;
  background: rgba(0,0,0,0.15);
  border-radius: 12px;
  color: rgba(255,255,255,0.85);
  font-size: 0.88rem;
  line-height: 1.6;
}
.game-info h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 0.5rem; }
.game-info h3 { font-size: 0.95rem; font-weight: 700; margin: 0.8rem 0 0.3rem; }
.game-info ul { padding-left: 1.2rem; }
.game-info li { margin-bottom: 0.2rem; }
