:root {
  --primary-color: #4a90e2;
  --secondary-color: #50e3c2;
  --error-color: #ff6b6b;
  --background-color: #f0f4f8;
  --text-color: #333333;
  --cell-background: #ffffff;
  --border-radius: 16px;
  --cell-size: min(70px, 14vw);
  --grid-gap: min(10px, 2vw);
}

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

body {
  font-family: 'Poppins', sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--background-color);
  color: var(--text-color);
  padding: 1rem;
  box-sizing: border-box;
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: white;
  width: min(95%, 450px);
  max-width: 100%;
  padding: clamp(0.8rem, 3vw, 1.5rem);
  border-radius: var(--border-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  margin: auto;
}

header {
  width: 100%;
  text-align: center;
  margin-bottom: min(0.5rem, 2vw);
}

h1 {
  color: var(--primary-color);
  margin-bottom: min(1rem, 4vw);
  font-size: clamp(1.2rem, 6vw, 2rem);
  word-wrap: break-word;
  font-weight: 700;
}

.game-info {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  width: 100%;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.info-item {
  background-color: var(--primary-color);
  color: white;
  padding: clamp(0.3rem, 2vw, 0.5rem) clamp(0.6rem, 3vw, 1rem);
  border-radius: 49px;
  font-size: clamp(0.8rem, 3.5vw, 1rem);
  font-weight: 600;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.info-label {
  opacity: 0.9;
}

.info-value {
  font-weight: 700;
}

.instructions {
  background-color: #f9f9f9;
  border-radius: var(--border-radius);
  font-size: clamp(0.9rem, 4vw, 1.1rem);
  padding: clamp(0.8rem, 4vw, 1.2rem);
  margin-bottom: min(1rem, 3vw);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  width: 100%;
  box-sizing: border-box;
}

.instructions h2 {
  color: var(--primary-color);
  margin-bottom: min(1rem, 3vw);
  font-size: clamp(1.2rem, 6vw, 1.6rem);
  font-weight: 700;
}

.instructions ol {
  padding-left: clamp(1.2rem, 5vw, 1.8rem);
  margin-bottom: min(1.5rem, 4vw);
}

.instructions li {
  margin-bottom: min(0.8rem, 2.5vw);
  font-size: clamp(0.9rem, 4vw, 1.1rem);
  line-height: 1.5;
}

.button-container {
  display: flex;
  justify-content: center;
  margin-top: min(0.8rem, 2vw);
}

.start-button {
  padding: clamp(0.7rem, 4vw, 1.2rem) clamp(1.2rem, 6vw, 2rem);
  font-size: clamp(0.9rem, 4vw, 1.1rem);
  font-weight: 600;
  border-radius: 49px;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  max-width: 100%;
}

.start-button:hover {
  background-color: #3a7bc8;
  transform: translateY(-2px);
  box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, var(--cell-size));
  gap: var(--grid-gap);
  margin: 0 auto;
  max-width: 100%;
  justify-content: center;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: min(2px, 0.5vw) solid #e0e0e0;
  border-radius: min(12px, 3vw);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: bold;
  background-color: var(--cell-background);
  transform-origin: center;
  transition:
    transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1),
    box-shadow 0.3s ease,
    background-color 0.3s ease,
    border-color 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cell:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.cell:focus-visible {
  outline: 3px solid var(--primary-color);
  outline-offset: 2px;
}

.cell.right {
  background-color: var(--secondary-color);
  animation: pulse-success 0.5s;
  border-color: var(--secondary-color);
}

.cell.wrong {
  background-color: var(--error-color);
  animation: shake 0.5s;
  border-color: var(--error-color);
}

.cell.highlight {
  background-color: var(--primary-color);
  animation: fade-highlight 0.5s ease, grow 0.5s ease;
  border-color: var(--primary-color);
  transform: scale(1.05);
}

.cell.current-row {
  background-color: #e6f2ff;
  animation: fade-highlight 0.5s;
  border-color: var(--primary-color);
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes fade-highlight {
  0% { opacity: 0.6; }
  100% { opacity: 1; }
}

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