/* Nonograms Junior - Gaming Styles */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700;800&display=swap");

:root {
  --primary: #52a7c1;
  --primary-dark: #3d8a9d;
  --secondary: #b4ddd3;
  --accent: #7dd3c0;
  --success: #28c76f;
  --danger: #ea5455;
  --warning: #ff9f43;
  --bg-gradient-start: #e0f2f7;
  --bg-gradient-end: #b4ddd3;
  --card-bg: rgba(255, 255, 255, 0.98);
  --text-dark: #2d3748;
  --text-light: #718096;
  --grid-bg: #ffffff;
  --grid-border: #cbd5e0;
  --cell-filled: #2d3748;
  --cell-marked: #e2e8f0;
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 30px 80px rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Poppins", "Segoe UI", sans-serif;
  background: linear-gradient(
    135deg,
    var(--bg-gradient-start) 0%,
    var(--bg-gradient-end) 100%
  );
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(82, 167, 193, 0.1) 0%,
    transparent 50%
  );
  animation: pulse-bg 20s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse-bg {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
}

/* Container */
#game-container {
  background: var(--card-bg);
  border-radius: 32px;
  padding: 40px;
  max-width: 1400px;
  width: 100%;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

/* Header */
.game-header {
  text-align: center;
  margin-bottom: 40px;
}

.game-icon {
  font-size: 100px;
  animation: think 3s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 10px 20px rgba(82, 167, 193, 0.3));
}

@keyframes think {
  0%,
  100% {
    transform: rotate(-5deg);
  }
  50% {
    transform: rotate(5deg);
  }
}

.game-title {
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 20px 0 10px;
  letter-spacing: -1px;
}

.game-subtitle {
  font-size: 1.3rem;
  color: var(--text-light);
  font-weight: 500;
}

/* Skills */
.skills-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 25px 0;
}

.skill-badge {
  background: linear-gradient(
    135deg,
    rgba(82, 167, 193, 0.2) 0%,
    rgba(180, 221, 211, 0.2) 100%
  );
  color: var(--primary);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--primary);
  text-transform: capitalize;
  transition: all 0.3s ease;
}

.skill-badge:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(82, 167, 193, 0.3);
}

/* Buttons */
.btn {
  padding: 18px 40px;
  font-size: 1.2rem;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.btn::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  box-shadow: 0 8px 25px rgba(82, 167, 193, 0.4);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(82, 167, 193, 0.5);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--accent) 100%);
  color: var(--text-dark);
  box-shadow: 0 8px 25px rgba(180, 221, 211, 0.4);
}

.btn-secondary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 35px rgba(180, 221, 211, 0.5);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent) 0%, #5dbfa8 100%);
  color: white;
  box-shadow: 0 8px 25px rgba(125, 211, 192, 0.4);
}

.btn-accent:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 35px rgba(125, 211, 192, 0.5);
}

/* Game Screens */
.game-screen {
  display: none;
}

#welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
}

.welcome-content {
  text-align: center;
  max-width: 700px;
}

.welcome-text {
  font-size: 1.2rem;
  color: var(--text-dark);
  line-height: 1.8;
  margin-bottom: 30px;
}

.mode-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Puzzle Select Screen */
#puzzle-select-screen {
  display: none;
}

#difficulty-title {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  margin-bottom: 40px;
}

#puzzles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 25px;
  margin-bottom: 30px;
}

.puzzle-card {
  background: white;
  border-radius: 20px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  border: 3px solid transparent;
}

.puzzle-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 35px rgba(82, 167, 193, 0.3);
  border-color: var(--primary);
}

.puzzle-preview {
  width: 100%;
  margin-bottom: 15px;
}

.preview-grid {
  display: grid;
  gap: 2px;
  background: var(--grid-border);
  padding: 2px;
  border-radius: 8px;
}

.preview-cell {
  aspect-ratio: 1;
  background: white;
}

.preview-cell.filled {
  background: var(--cell-filled);
}

.puzzle-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 8px;
}

.puzzle-info {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* Game Screen */
#game-screen {
  display: none;
}

.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: linear-gradient(
    135deg,
    rgba(82, 167, 193, 0.1) 0%,
    rgba(180, 221, 211, 0.1) 100%
  );
  border-radius: 20px;
}

.puzzle-info-bar {
  display: flex;
  align-items: center;
  gap: 20px;
}

#puzzle-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}

#puzzle-size {
  font-size: 1.2rem;
  color: var(--text-light);
}

#timer {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--secondary);
  font-family: "Courier New", monospace;
}

/* Tools */
.tools-section {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 30px;
}

.tool-btn {
  padding: 15px 30px;
  font-size: 1.1rem;
  font-weight: 600;
  background: white;
  color: var(--text-dark);
  border: 3px solid var(--grid-border);
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tool-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.tool-btn.active {
  background: linear-gradient(
    135deg,
    var(--primary) 0%,
    var(--primary-dark) 100%
  );
  color: white;
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(82, 167, 193, 0.4);
}

/* Game Grid */
.grid-container {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

#game-grid {
  display: grid;
  gap: 0;
  background: var(--grid-border);
  padding: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.grid-corner {
  background: var(--secondary);
}

.clue {
  background: var(--secondary);
  color: var(--text-dark);
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-width: 40px;
  min-height: 40px;
  transition: all 0.3s ease;
}

.clue.highlight {
  background: var(--accent);
  color: white;
  transform: scale(1.05);
}

.clue.complete {
  text-decoration: line-through;
  opacity: 0.5;
}

.col-clue {
  flex-direction: column;
  font-size: 0.85rem;
  line-height: 1.2;
}

.row-clue {
  white-space: nowrap;
}

.grid-cell {
  width: 40px;
  height: 40px;
  background: var(--grid-bg);
  border: 1px solid var(--grid-border);
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.grid-cell:hover {
  background: rgba(82, 167, 193, 0.1);
  transform: scale(1.05);
  z-index: 10;
}

.grid-cell.filled {
  background: var(--cell-filled);
}

.grid-cell.marked::before {
  content: "✕";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 24px;
  color: var(--danger);
  font-weight: 700;
}

.grid-cell.error {
  animation: errorShake 0.5s ease;
  background: rgba(234, 84, 85, 0.3) !important;
}

@keyframes errorShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Game Actions */
.game-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 24px;
  font-size: 1rem;
  font-weight: 600;
  background: white;
  color: var(--text-dark);
  border: 2px solid var(--grid-border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.action-btn:hover {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(82, 167, 193, 0.3);
}

/* Game Messages */
.game-message {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  padding: 20px 40px;
  border-radius: 16px;
  font-size: 1.2rem;
  font-weight: 700;
  z-index: 1000;
  animation: slideDown 0.4s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.game-message.success {
  background: linear-gradient(135deg, var(--success) 0%, #22a55d 100%);
  color: white;
}

.game-message.error {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
}

@keyframes slideDown {
  from {
    transform: translate(-50%, -50px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

/* Results Screen */
#results-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 35px;
  text-align: center;
}

.results-icon {
  font-size: 120px;
  animation: bounce 1s ease infinite;
}

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

.results-title {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#puzzle-complete-name {
  font-size: 2rem;
  color: var(--text-dark);
  font-weight: 700;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 25px;
  width: 100%;
  margin: 30px 0;
}

.stat-card {
  background: linear-gradient(
    135deg,
    rgba(82, 167, 193, 0.1) 0%,
    rgba(180, 221, 211, 0.1) 100%
  );
  padding: 30px;
  border-radius: 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.12);
}

.stat-value {
  font-size: 3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 1rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 10px;
}

.performance-message {
  font-size: 1.5rem;
  font-weight: 700;
  padding: 20px 40px;
  border-radius: 16px;
  margin: 20px 0;
}

.performance-message.perfect {
  background: linear-gradient(
    135deg,
    rgba(40, 199, 111, 0.2) 0%,
    rgba(40, 199, 111, 0.1) 100%
  );
  color: #1f9d57;
}

.performance-message.excellent {
  background: linear-gradient(
    135deg,
    rgba(82, 167, 193, 0.2) 0%,
    rgba(82, 167, 193, 0.1) 100%
  );
  color: #3d8a9d;
}

.performance-message.good {
  background: linear-gradient(
    135deg,
    rgba(255, 159, 67, 0.2) 0%,
    rgba(255, 159, 67, 0.1) 100%
  );
  color: #c05621;
}

.performance-message.try-again {
  background: linear-gradient(
    135deg,
    rgba(234, 84, 85, 0.2) 0%,
    rgba(234, 84, 85, 0.1) 100%
  );
  color: #c53030;
}

.results-actions {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
  #game-container {
    padding: 25px;
  }

  .game-title {
    font-size: 2.5rem;
  }

  .game-icon {
    font-size: 70px;
  }

  #puzzles-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
  }

  .grid-cell,
  .clue,
  .grid-corner {
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
  }

  .clue {
    font-size: 0.8rem;
  }

  .btn {
    width: 100%;
  }

  .mode-buttons,
  .game-actions,
  .results-actions {
    flex-direction: column;
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .game-top-bar {
    flex-direction: column;
    gap: 15px;
  }
}
