/* ===== DESIGN TOKENS ===== */
:root {
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-success: #16a34a;
  --color-success-light: #dcfce7;
  --color-error: #dc2626;
  --color-error-light: #fef2f2;
  --color-info: #2563eb;
  --color-warning: #d97706;
  --color-purple: #9333ea;
  --color-yellow: #ca8a04;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.1);
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

body {
  font-family: "Poppins", sans-serif;
  touch-action: manipulation;
}

/* ===== LAYOUT & REUSABLE UTILITIES ===== */
.game-body {
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 0.5rem;
  position: relative;
}

@media (min-width: 640px) {
  .game-body {
    padding: 1rem;
  }
}

.header-back {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.header-controls {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.header-icons {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
}

.level-display-text {
  margin: 0;
  white-space: nowrap;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  letter-spacing: 0.025em;
}

.game-card {
  width: 100%;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
  background: var(--color-surface);
  border-radius: 1.5rem;
  padding: 1rem;
  border: 1px solid rgba(229, 231, 235, 0.5);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

@media (min-width: 640px) {
  .game-card {
    padding: 1.5rem;
  }
}

.game-card-deco {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.game-card-deco--tr {
  top: 0;
  right: 0;
  width: 6rem;
  height: 6rem;
  background: linear-gradient(135deg, rgba(241, 245, 249, 0.2), rgba(243, 244, 246, 0.2));
  transform: translate(-0.75rem, -3rem);
}

.game-card-deco--bl {
  bottom: 0;
  left: 0;
  width: 5rem;
  height: 5rem;
  background: linear-gradient(315deg, rgba(241, 245, 249, 0.2), rgba(243, 244, 246, 0.2));
  transform: translate(-2.5rem, 2.5rem);
}

.status-bar {
  text-align: center;
  margin-bottom: 1.5rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(90deg, #f8fafc, #f1f5f9);
  border-radius: 1rem;
  border: 1px solid rgba(243, 244, 246, 0.5);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.status-bar-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: skewX(-12deg);
  animation: pulse 2s ease-in-out infinite;
}

.status-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  position: relative;
  z-index: 10;
  letter-spacing: 0.025em;
}

.status-text--success {
  color: var(--color-success);
  font-weight: 700;
}

.status-text--error {
  color: var(--color-error);
  font-weight: 700;
}

.status-text--info {
  color: var(--color-info);
  font-weight: 700;
}

.status-text--default {
  color: var(--color-text);
}

.status-highlight {
  color: var(--color-primary);
  font-size: 1.25rem;
  font-weight: 700;
}

.play-again-wrap {
  width: 100%;
  max-width: 32rem;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 1.5rem;
}

.play-again-wrap.hidden {
  display: none !important;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.loading-wrap .loading-spinner {
  flex-shrink: 0;
}

.loading-wrap .loading-text {
  flex-shrink: 0;
}

.game-over-title {
  font-size: clamp(0.875rem, 2vw, 1.25rem);
  font-weight: 700;
  background: linear-gradient(90deg, #22c55e, #059669);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 0.75rem;
}

.game-over-subtitle {
  color: var(--color-text-muted);
  font-size: 1.25rem;
  font-weight: 500;
}

.popup-heading {
  font-size: clamp(1.25rem, 4vw, 2.25rem);
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.popup-heading--purple {
  color: var(--color-purple);
}

.popup-heading--green {
  color: var(--color-success);
}

.popup-heading--yellow {
  color: var(--color-yellow);
}

.popup-subtitle {
  color: var(--color-text-muted);
  font-size: 1.125rem;
}

.hint-message {
  color: var(--color-text);
  text-align: center;
  font-size: 1.125rem;
  margin: 0;
  white-space: pre-line;
}

/* Start Screen Styles */
.start-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #f3f4f6; /* bg-gray-100 to match game screen */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

.start-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-screen-content {
  text-align: center;
  padding: 2rem;
  max-width: 500px;
  width: 90%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.start-screen-logo {
  margin-bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

.start-screen-logo-img {
  display: block;
  width: min(82vw, 252px);
  height: auto;
  object-fit: contain;
}

.level-card {
  background: white;
  border-radius: 14px;
  padding: 1.25rem 1rem;
  margin-bottom: 0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 3px solid #8b5cf6;
  animation: cardSlideIn 0.5s ease-out;
  width: 100px;
  height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  margin-right: auto;
}

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

.level-card-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.level-card-grid-size {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #1f2937;
  text-align: center;
}

.start-screen-buttons {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.how-to-play-button {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.how-to-play-button:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

/* Make game board smaller */
.grid-container {
  display: grid;
  gap: 2px;
  padding: 4px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 2px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  box-sizing: border-box;
  /* Dynamic grid columns set via CSS custom property */
  grid-template-columns: repeat(var(--grid-size, 3), 1fr);
  max-width: var(--grid-width, 100%);
  width: var(--grid-width, 100%);
}

/* Logo Text Styling */
.logo-text {
  font-family: "Jua", sans-serif;
  font-weight: 400;
  letter-spacing: 0.05em;
}
.cell {
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  transition: all 0.2s ease-in-out;
  user-select: none;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  position: relative;
  /* Dynamic sizing via CSS custom properties */
  font-size: var(--cell-font-size, clamp(0.875rem, 3.5vw, 1.5rem));
  min-height: var(--cell-min-height, 30px);
  min-width: var(--cell-min-width, 30px);
}

.cell-disabled {
  cursor: default;
}
.cell-clue {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #475569;
  cursor: not-allowed;
  border-color: #cbd5e1;
  font-weight: 700;
}
.cell-start {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #166534;
  border-color: #86efac;
  font-weight: 700;
}
.cell-end {
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  color: #991b1b;
  border-color: #fca5a5;
  font-weight: 700;
}
.cell-user {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1e40af;
  border-color: #93c5fd;
  font-weight: 700;
}
.cell-empty:hover {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-color: #cbd5e1;
  transform: scale(1.02);
}
.cell.highlight {
  border: 3px solid #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
  z-index: 10;
  transform: scale(1.05);
}
.cell.error {
  animation: shake 0.5s;
  background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
  border-color: #f87171;
  color: #dc2626;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
.hint-highlight {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
  color: #92400e !important;
  border: 3px solid #f59e0b !important;
  animation: pulse 1s infinite;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3) !important;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

/* Popup Styles */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #f3f4f6;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

/* Game Over Popup with opacity overlay */
.popup-overlay.game-over-overlay {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

/* Level Completion Popup with opacity overlay */
.popup-overlay.level-completion-overlay {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

/* Hint Popup with opacity overlay */
.popup-overlay.hint-overlay {
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

/* How to Play Popup with opacity overlay */
.popup-overlay.how-to-play-overlay {
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(5px);
}

.popup-content {
  background: white;
  border-radius: 20px;
  padding: 1rem;
  max-width: min(400px, 90vw);
  width: 85%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: popupSlideIn 0.3s ease-out;
  margin: 1rem;
}

@keyframes popupSlideIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.popup-header h1 {
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
}

/* Level Completion Heading - 40% smaller */
#levelCompletionHeading {
  font-size: 0.75rem !important; /* 40% of text-xl (1.25rem) */
}

@media (min-width: 640px) {
  #levelCompletionHeading {
    font-size: 0.9rem !important; /* 40% of sm:text-2xl (1.5rem) */
  }
}

@media (min-width: 768px) {
  #levelCompletionHeading {
    font-size: 1.125rem !important; /* 40% of md:text-3xl (1.875rem) */
  }
}

@media (min-width: 1024px) {
  #levelCompletionHeading {
    font-size: 1.35rem !important; /* 40% of lg:text-4xl (2.25rem) */
  }
}

.popup-body {
  margin-bottom: 0.75rem;
}

/* Beautiful How to Play Title */
.how-to-play-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #374151;
  text-align: center;
  position: relative;
  padding: 0.25rem 0;
}

.title-icon {
  font-size: 1.75rem;
  animation: icon-bounce 2s ease-in-out infinite;
}

.title-text {
  position: relative;
  letter-spacing: 0.025em;
}

@keyframes icon-bounce {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  25% {
    transform: translateY(-3px) rotate(-2deg);
  }
  75% {
    transform: translateY(-1px) rotate(2deg);
  }
}

.rules-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rule-item {
  display: flex;
  align-items: flex-start;
  padding: 0.75rem;
  background-color: #f8fafc;
  border-radius: 12px;
  border-left: 4px solid #6366f1;
}

.rule-number {
  background-color: #6366f1;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.875rem;
  margin-right: 1rem;
  flex-shrink: 0;
}

.rule-item p {
  margin: 0;
  line-height: 1.5;
  color: #374151;
}

.celebration-section {
  text-align: center;
}

.celebration-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

.popup-footer {
  text-align: center;
}

.start-button,
.next-button {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
  min-width: 150px;
}

.start-button:hover,
.next-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.start-button:active,
.next-button:active {
  transform: translateY(0);
}

.next-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.next-button:hover {
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.hidden {
  display: none !important;
}

/* Loading Spinner */
.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #6366f1;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Loading text animation */
.loading-text {
  animation: loading-pulse 1.5s ease-in-out infinite;
}

@keyframes loading-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Mobile Responsive Adjustments */

.error-highlight {
  background-color: #fecaca !important;
  border: 3px solid #dc2626 !important;
  animation: errorPulse 0.5s ease-in-out;
}

@keyframes errorPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* Top Left Controls Container - Removed, buttons now in top-center row */

/* Level Display Styles */
#levelDisplay {
  background: transparent;
  box-shadow: none;
  border: none;
  padding: 0;
  margin: 0;
  margin-left: 5px;
  position: static;
  flex-shrink: 0;
}

#levelDisplay .level-display-text {
  margin: 0;
  white-space: nowrap;
  text-shadow: none;
}

/* Back Button and Level Display Container */
.header-back {
  gap: 0;
  flex-wrap: nowrap;
}

/* Back Button Icon */
.back-button-icon {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  margin: 0;
}

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

.back-button-icon:hover::before {
  left: 100%;
}

.back-button-icon:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.back-button-icon:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.back-button-icon svg {
  transition: transform 0.2s ease;
}

.back-button-icon:hover svg {
  transform: translateX(-2px);
}

/* Mobile responsive for level selection */
@media (max-width: 640px) {
  .levels-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .level-button {
    font-size: 1rem;
    min-height: 50px;
  }

  #levelDisplay {
    padding: 0;
  }

  .level-display-text {
    font-size: 0.875rem;
  }
}

/* Beautiful Button Styles */
.beautiful-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Poppins", sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  text-decoration: none;
  min-width: 100px;
  z-index: 1;
}

.beautiful-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
  z-index: -1;
}

.beautiful-button:hover::before {
  left: 100%;
}

.beautiful-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  animation: buttonPulse 0.6s ease-in-out;
}

@keyframes buttonPulse {
  0% {
    transform: translateY(-2px) scale(1);
  }
  50% {
    transform: translateY(-2px) scale(1.05);
  }
  100% {
    transform: translateY(-2px) scale(1);
  }
}

.beautiful-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.beautiful-button:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.beautiful-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.beautiful-button:disabled:hover {
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Back Button */
.back-button {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  font-size: 1.25rem;
  padding: 0;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  min-width: auto;
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.back-button:hover::before {
  left: 100%;
}

.back-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
  transform: translateY(-1px);
}

.back-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

/* Hint Button */
.hint-button {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.hint-button:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

.hint-button:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

/* Solution Button */
.solution-button {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.solution-button:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
}

.solution-button:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

/* Reset Button */
.reset-button {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.reset-button:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
}

.reset-button:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

/* Undo Button */
.undo-button {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
}

.undo-button:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
}

.undo-button:disabled {
  background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%);
  box-shadow: 0 2px 8px rgba(209, 213, 219, 0.2);
}

/* Audio Button */
.audio-button {
  background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
  padding: 0.75rem 1.5rem;
  min-width: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.audio-button svg {
  transition: transform 0.2s ease;
}

.audio-button:hover svg {
  transform: scale(1.1);
}

.audio-button:hover {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
}

.audio-button:disabled {
  background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
  box-shadow: 0 2px 8px rgba(156, 163, 175, 0.2);
}

/* Square Icon Buttons (Top Right) */
.icon-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Poppins", sans-serif;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  width: 44px;
  height: 44px;
  padding: 0;
  flex-shrink: 0;
}

.square-icon-button {
  aspect-ratio: 1;
}

.icon-button::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
  z-index: 1;
}

.icon-button:hover::before {
  left: 100%;
}

.icon-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.icon-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.icon-button svg {
  position: relative;
  z-index: 2;
  transition: transform 0.2s ease;
}

.icon-button:hover svg {
  transform: scale(1.1);
}

/* Icon Buttons - Same color for all */
.icon-button {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.icon-button:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 8px 25px rgba(139, 92, 246, 0.4);
}

/* Popup Button Styles */
.popup-footer .start-button {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: white;
  font-size: 1rem;
  padding: 0.75rem 1.5rem;
  min-width: 150px;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3);
}

.popup-footer .start-button:hover {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 100%);
  box-shadow: 0 8px 30px rgba(99, 102, 241, 0.4);
}

.back-button {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  color: white;
  font-size: 1rem;
  padding: 0.875rem 1.75rem;
  min-width: 150px;
  box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
}

.back-button:hover {
  background: linear-gradient(135deg, #4b5563 0%, #374151 100%);
  box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
}

.play-again-button {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-size: 1.125rem;
  padding: 1rem 2rem;
  min-width: 200px;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-block;
  margin-top: 1rem;
}

.play-again-button:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 8px 25px rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}

.play-again-button:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.hint-ok-button {
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  color: white;
  font-size: 1rem;
  padding: 0.875rem 1.75rem;
  min-width: 120px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.hint-ok-button:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.next-level-button {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  font-size: 1rem;
  padding: 0.875rem 1.75rem;
  min-width: 150px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.next-level-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.back-to-home-button {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
  font-size: 1rem;
  padding: 0.875rem 1.75rem;
  min-width: 150px;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.back-to-home-button:hover {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Enhanced Game Over Popup Styles */
.game-over-popup {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border: 2px solid #10b981;
  box-shadow: 0 25px 50px -12px rgba(16, 185, 129, 0.25),
    0 0 0 1px rgba(16, 185, 129, 0.1);
}

.celebration-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  font-size: 1.5rem;
  animation: confetti-fall 3s ease-in-out infinite;
  opacity: 0.8;
}

.confetti-1 {
  top: -20px;
  left: 10%;
  animation-delay: 0s;
}

.confetti-2 {
  top: -20px;
  left: 30%;
  animation-delay: 0.5s;
}

.confetti-3 {
  top: -20px;
  left: 50%;
  animation-delay: 1s;
}

.confetti-4 {
  top: -20px;
  left: 70%;
  animation-delay: 1.5s;
}

.confetti-5 {
  top: -20px;
  left: 90%;
  animation-delay: 2s;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(360deg);
    opacity: 0;
  }
}

.success-icon-container {
  position: relative;
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}

.success-icon {
  font-size: 4rem;
  animation: success-bounce 1s ease-in-out;
  z-index: 2;
  position: relative;
}

.success-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border: 3px solid #10b981;
  border-radius: 50%;
  animation: success-pulse 2s ease-in-out infinite;
}

@keyframes success-bounce {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-10px);
  }
  60% {
    transform: translateY(-5px);
  }
}

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

.achievement-section {
  text-align: center;
  padding: 1rem 0;
}

.achievement-badge {
  display: inline-flex;
  align-items: center;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 20px;
  margin-bottom: 1.5rem;
  box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
  animation: badge-glow 2s ease-in-out infinite alternate;
}

.badge-icon {
  font-size: 2rem;
  margin-right: 0.75rem;
  animation: trophy-spin 1s ease-in-out;
}

.badge-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.badge-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}

.badge-subtitle {
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0.9;
  line-height: 1;
}

@keyframes badge-glow {
  0% {
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
  }
  100% {
    box-shadow: 0 12px 35px rgba(251, 191, 36, 0.5);
  }
}

@keyframes trophy-spin {
  0% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(10deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.celebration-message {
  font-size: 1.125rem;
  line-height: 1.6;
  color: #374151;
  max-width: 400px;
  margin: 0 auto;
  font-weight: 500;
}

.celebration-button {
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  font-size: 1.125rem;
  padding: 1rem 2rem;
  min-width: 200px;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.celebration-button:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.4);
  transform: translateY(-2px) scale(1.02);
}

.button-icon {
  font-size: 1.25rem;
  animation: rocket-bounce 1s ease-in-out infinite;
}

.button-text {
  font-weight: 600;
}

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

/* ===== COMPREHENSIVE RESPONSIVE DESIGN ===== */

/* Override min-height: 100vh for landscape mode only */
@media (orientation: landscape) {
  body {
    min-height: auto !important;
  }
}

/* Keep min-height: 100vh for web screens (desktop) */
@media (min-width: 1024px) {
  body {
    min-height: 100vh !important;
  }
}

/* Extra small screens - ensure popup never exceeds viewport */
@media (max-width: 320px) {
  .popup-content {
    width: 95%;
    max-width: min(320px, calc(100vw - 0.5rem));
    padding: 0.75rem;
    margin: 0.25rem;
  }

  .popup-header h1 {
    line-height: 1.1;
  }

  .popup-header p {
    font-size: 0.875rem;
  }
}

/* Landscape Mobile (orientation: landscape) */
@media (orientation: landscape) and (max-height: 600px) {
  body {
    padding: 0.5rem;
  }

  .popup-content {
    max-height: 90vh;
    padding: 1rem;
    margin: 0.5rem;
    max-width: min(400px, 90vw);
  }

  .popup-header h1 {
    margin-bottom: 0.5rem;
  }

  .popup-header p {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
  }

  .rules-section {
    margin-bottom: 0.5rem;
  }

  .rule-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .rule-number {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
    margin-right: 0.75rem;
  }

  .celebration-section {
    margin-bottom: 0.5rem;
  }

  .celebration-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
  }

  .start-button,
  .next-button {
    padding: 0.75rem;
    font-size: 1rem;
    min-width: 160px;
  }

  .game-over-popup {
    max-height: 85vh;
    padding: 1rem;
  }

  .success-icon {
    font-size: 2.5rem;
  }

  .achievement-badge {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
  }

  .badge-icon {
    font-size: 1.25rem;
    margin-right: 0.5rem;
  }

  .badge-title {
    font-size: 0.875rem;
  }

  .badge-subtitle {
    font-size: 0.625rem;
  }

  .celebration-message {
    font-size: 0.875rem;
    padding: 0 0.5rem;
  }

  .celebration-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.25rem;
    min-width: 140px;
  }

  .confetti {
    font-size: 1rem;
  }

  .how-to-play-title {
    font-size: 1.125rem;
    gap: 0.25rem;
    margin-bottom: 0.375rem;
  }

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

  .levels-grid {
    max-height: 20rem;
    padding: 0.5rem;
  }

  .level-button {
    font-size: 0.875rem;
    min-height: 40px;
  }
}

/* Small Mobile (≤480px) */
@media (max-width: 480px) {
  body {
    padding: 0.5rem;
    overflow-x: hidden;
  }

  .start-screen-content {
    padding: 1rem;
    gap: 1.75rem;
  }

  .level-card {
    width: 88px;
    height: 88px;
    padding: 1rem 0.65rem;
    margin-bottom: 0;
    border-radius: 12px;
  }

  .level-card-number {
    font-size: 2.125rem;
  }

  .level-card-grid-size {
    font-size: 0.6875rem;
  }

  .start-screen-buttons {
    gap: 0.75rem;
  }

  .start-button,
  .how-to-play-button {
    width: 100%;
    max-width: 250px;
  }

  .grid-container {
    gap: 1px;
    padding: 4px;
  }

  .cell {
    font-size: clamp(0.875rem, 4vw, 1.25rem);
    border-radius: 6px;
    min-height: 25px;
    min-width: 25px;
  }


  .header-back {
    top: 0.25rem;
    left: 0.25rem;
    gap: 0;
  }

  .header-controls {
    top: 0.25rem;
    gap: 0.375rem;
  }

  .header-icons {
    top: 0.25rem;
    right: 0.25rem;
    gap: 0.375rem;
  }

  .icon-button {
    width: 36px;
    height: 36px;
  }

  .icon-button svg {
    width: 16px;
    height: 16px;
  }

  .level-display-text {
    font-size: 0.75rem;
    font-weight: 600;
  }

  .back-button-icon {
    width: 32px;
    height: 32px;
  }

  .back-button-icon svg {
    width: 16px;
    height: 16px;
  }

  .beautiful-button {
    font-size: 0.625rem;
    padding: 0.5rem 1rem;
    min-width: 70px;
    border-radius: 8px;
  }

  .popup-content {
    width: 90%;
    padding: 1rem;
    margin: 0.5rem;
    border-radius: 12px;
    max-width: min(350px, 90vw);
  }

  .popup-header h1 {
    margin-bottom: 0.5rem;
    line-height: 1.1;
  }

  .popup-header p {
    font-size: 0.875rem;
  }

  .how-to-play-title {
    font-size: 1rem;
    gap: 0.25rem;
    margin-bottom: 0.375rem;
  }

  .title-icon {
    font-size: 1.125rem;
  }

  .rule-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .rule-number {
    width: 20px;
    height: 20px;
    font-size: 0.625rem;
    margin-right: 0.5rem;
  }

  .rule-item p {
    font-size: 0.75rem;
    line-height: 1.4;
  }

  .start-button,
  .next-button {
    padding: 0.75rem;
    font-size: 0.875rem;
    min-width: 140px;
  }

  .levels-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    padding: 0.5rem;
  }

  .level-button {
    font-size: 0.75rem;
    min-height: 40px;
    border-radius: 8px;
  }

  .celebration-section {
    margin-bottom: 0.75rem;
  }

  .celebration-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
  }

  .game-over-popup {
    margin: 0.5rem;
    max-width: min(350px, calc(100vw - 1rem));
    padding: 0.75rem;
  }

  .success-icon {
    font-size: 2.5rem;
  }

  .success-ring {
    width: 50px;
    height: 50px;
  }

  .achievement-badge {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
  }

  .badge-icon {
    font-size: 1.25rem;
    margin-right: 0.375rem;
  }

  .badge-title {
    font-size: 0.875rem;
  }

  .badge-subtitle {
    font-size: 0.625rem;
  }

  .celebration-message {
    font-size: 0.875rem;
    padding: 0 0.5rem;
  }

  .celebration-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.25rem;
    min-width: 140px;
  }

  .confetti {
    font-size: 1rem;
  }
}

/* Mobile (≤640px) */
@media (max-width: 640px) {
  body {
    padding: 0.75rem;
    overflow-x: hidden;
  }

  .start-screen-content {
    padding: 1.5rem;
  }

  .level-card {
    width: 96px;
    height: 96px;
    padding: 1.1rem 0.85rem;
    border-radius: 13px;
  }

  .level-card-number {
    font-size: 2.35rem;
  }

  .level-card-grid-size {
    font-size: 0.75rem;
  }

  .grid-container {
    gap: 1.5px;
    padding: 5px;
  }

  .header-back {
    top: 0.5rem;
    left: 0.5rem;
    gap: 0;
  }

  .header-controls {
    top: 0.5rem;
    gap: 0.5rem;
  }

  .header-icons {
    top: 0.5rem;
    right: 0.5rem;
    gap: 0.5rem;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .icon-button svg {
    width: 18px;
    height: 18px;
  }

  .cell {
    font-size: clamp(0.875rem, 3.5vw, 1.25rem);
    border-radius: 8px;
    min-height: 28px;
    min-width: 28px;
  }

  .beautiful-button {
    font-size: 0.75rem;
    padding: 0.625rem 1.25rem;
    min-width: 80px;
  }


  .level-display-text {
    font-size: 0.875rem;
    font-weight: 600;
  }

  .back-button-icon {
    width: 36px;
    height: 36px;
  }

  .back-button-icon svg {
    width: 18px;
    height: 18px;
  }

  .start-button {
    font-size: 1rem;
    padding: 0.875rem 1.75rem;
    min-width: 180px;
  }

  .popup-footer .beautiful-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    min-width: 120px;
  }

  .levels-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .level-button {
    font-size: 1rem;
    min-height: 50px;
  }

  /* Mobile adjustments for game over popup */
  .game-over-popup {
    margin: 0.5rem;
    max-width: min(400px, calc(100vw - 1rem));
  }

  .success-icon {
    font-size: 3rem;
  }

  .success-ring {
    width: 60px;
    height: 60px;
  }

  .achievement-badge {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
  }

  .badge-icon {
    font-size: 1.5rem;
    margin-right: 0.5rem;
  }

  .badge-title {
    font-size: 1rem;
  }

  .badge-subtitle {
    font-size: 0.75rem;
  }

  .celebration-message {
    font-size: 1rem;
    padding: 0 1rem;
  }

  .celebration-button {
    font-size: 1rem;
    padding: 0.875rem 1.5rem;
    min-width: 180px;
  }

  .confetti {
    font-size: 1.25rem;
  }

  /* Mobile adjustments for How to Play title */
  .how-to-play-title {
    font-size: 1.25rem;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
    padding: 0.125rem 0;
  }

  .title-icon {
    font-size: 1.5rem;
  }
}

/* Tablet Portrait (641px-768px) */
@media (min-width: 641px) and (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .grid-container {
    gap: 2px;
    padding: 6px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .icon-button svg {
    width: 19px;
    height: 19px;
  }

  .cell {
    font-size: 1.1rem;
  }

  .beautiful-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    min-width: 90px;
  }


  .level-display-text {
    font-size: 1rem;
  }

  .back-button-icon {
    width: 38px;
    height: 38px;
  }

  .back-button-icon svg {
    width: 19px;
    height: 19px;
  }

  .popup-content {
    max-width: 480px;
    padding: 1.5rem;
  }

  .levels-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }

  .level-button {
    font-size: 1.125rem;
    min-height: 55px;
  }

  .how-to-play-title {
    font-size: 1.375rem;
  }

  .rule-item {
    padding: 0.75rem;
  }

  .rule-number {
    width: 26px;
    height: 26px;
    font-size: 0.8rem;
  }

  .start-button,
  .next-button {
    padding: 1rem;
    font-size: 1.125rem;
    min-width: 190px;
  }

  .celebration-icon {
    font-size: 3.5rem;
  }

  .success-icon {
    font-size: 3.5rem;
  }

  .achievement-badge {
    padding: 1rem 1.25rem;
  }

  .badge-icon {
    font-size: 1.75rem;
  }

  .badge-title {
    font-size: 1.125rem;
  }

  .celebration-message {
    font-size: 1.125rem;
  }

  .celebration-button {
    font-size: 1.125rem;
    padding: 1rem 1.75rem;
    min-width: 190px;
  }
}

/* Tablet Landscape (769px-1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  body {
    padding: 1.5rem;
  }

  .grid-container {
    gap: 2px;
    padding: 7px;
  }

  .cell {
    font-size: 1.2rem;
  }

  .beautiful-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    min-width: 100px;
  }


  .level-display-text {
    font-size: 1.125rem;
  }

  .back-button-icon {
    width: 40px;
    height: 40px;
  }

  .popup-content {
    max-width: 550px;
    padding: 1.5rem;
  }

  .levels-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
  }

  .level-button {
    font-size: 1.25rem;
    min-height: 60px;
  }

  .how-to-play-title {
    font-size: 1.5rem;
  }

  .rule-item {
    padding: 0.75rem;
  }

  .rule-number {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }

  .start-button,
  .next-button {
    padding: 1rem;
    font-size: 1.125rem;
    min-width: 200px;
  }

  .celebration-icon {
    font-size: 4rem;
  }

  .success-icon {
    font-size: 4rem;
  }

  .achievement-badge {
    padding: 1rem 1.5rem;
  }

  .badge-icon {
    font-size: 2rem;
  }

  .badge-title {
    font-size: 1.25rem;
  }

  .celebration-message {
    font-size: 1.125rem;
  }

  .celebration-button {
    font-size: 1.125rem;
    padding: 1rem 2rem;
    min-width: 200px;
  }
}

/* Desktop (≥1025px) */
@media (min-width: 1025px) {
  body {
    padding: 2rem;
  }

  .grid-container {
    gap: 2px;
    padding: 6px;
  }

  .icon-button {
    width: 44px;
    height: 44px;
  }

  .icon-button svg {
    width: 20px;
    height: 20px;
  }

  .cell {
    font-size: 1.1rem;
  }

  .beautiful-button {
    font-size: 0.875rem;
    padding: 0.75rem 1.5rem;
    min-width: 100px;
  }


  #levelDisplay p {
    font-size: 1.125rem;
  }

  .popup-content {
    max-width: 400px;
    padding: 1.5rem;
  }

  .levels-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
  }

  .level-button {
    font-size: 1.25rem;
    min-height: 60px;
  }

  .how-to-play-title {
    font-size: 1.5rem;
  }

  .rule-item {
    padding: 0.75rem;
  }

  .rule-number {
    width: 28px;
    height: 28px;
    font-size: 0.875rem;
  }

  .start-button,
  .next-button {
    padding: 1rem;
    font-size: 1.125rem;
    min-width: 200px;
  }

  .celebration-icon {
    font-size: 4rem;
  }

  .success-icon {
    font-size: 4rem;
  }

  .achievement-badge {
    padding: 1rem 1.5rem;
  }

  .badge-icon {
    font-size: 2rem;
  }

  .badge-title {
    font-size: 1.25rem;
  }

  .celebration-message {
    font-size: 1.125rem;
  }

  .celebration-button {
    font-size: 1.125rem;
    padding: 1rem 2rem;
    min-width: 200px;
  }
}

/* Large Desktop (≥1440px) */
@media (min-width: 1440px) {
  body {
    padding: 3rem;
  }

  .popup-content {
    max-width: 480px;
    padding: 1.5rem;
  }

  .levels-grid {
    max-width: 800px;
    margin: 0 auto;
  }

  .level-button {
    font-size: 1.375rem;
    min-height: 70px;
  }

  .how-to-play-title {
    font-size: 1.75rem;
  }

  .rule-item {
    padding: 1rem;
  }

  .rule-number {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }

  .start-button,
  .next-button {
    padding: 1.25rem;
    font-size: 1.25rem;
    min-width: 220px;
  }

  .celebration-icon {
    font-size: 5rem;
  }

  .success-icon {
    font-size: 5rem;
  }

  .achievement-badge {
    padding: 1.25rem 2rem;
  }

  .badge-icon {
    font-size: 2.5rem;
  }

  .badge-title {
    font-size: 1.5rem;
  }

  .celebration-message {
    font-size: 1.25rem;
  }

  .celebration-button {
    font-size: 1.25rem;
    padding: 1.25rem 2.5rem;
    min-width: 220px;
  }
}
