* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
}

body {
  background: #1a1a2e;
  color: white;
  padding: 20px;
  min-height: 100vh;
  overflow-x: hidden; /* Side scroll hata diya */
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 10px;
}

h1 {
  text-align: center;
  color: #00adb5;
  margin: 20px 0;
  font-size: 2.5rem;
}

/* Navigation */
.nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 30px 0;
  flex-wrap: wrap;
}

.nav a {
  padding: 12px 30px;
  background: #393e46;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-size: 1.2rem;
  transition: background 0.3s;
}

.nav a:hover {
  background: #4a4f57;
}

.nav a.active {
  background: #00adb5;
}

.nav a.active:hover {
  background: #0097a7;
}

/* Matrices Layout - Yeh major change hai */
.matrices {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 40px 0;
  padding: 20px 10px;
  flex-wrap: nowrap;
  overflow-x: auto; /* Desktop par scroll */
}

/* Box - Common for both 2x2 and 3x3 */
.box {
  background: rgba(30, 30, 46, 0.9);
  padding: 25px;
  border-radius: 15px;
  border: 2px solid #393e46;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.box h2 {
  text-align: center;
  color: #00adb5;
  margin-bottom: 20px;
  font-size: 1.5rem;
}

.box.result {
  border-color: #4caf50;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.2);
}

.box.result h2 {
  color: #4caf50;
}

/* Grids */
.grid-2x2,
.grid-3x3 {
  display: grid;
  gap: 15px;
  justify-content: center;
}

/* 2x2 Grid */
.grid-2x2 {
  grid-template-columns: repeat(2, 1fr);
}

/* 3x3 Grid */
.grid-3x3 {
  grid-template-columns: repeat(3, 1fr);
}

/* 4x4 Grid */
.grid-4x4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

/* Inputs for 2x2 */
.grid-2x2 input {
  width: 80px;
  height: 80px;
  font-size: 1.6rem;
  text-align: center;
  background: #1a1a2e;
  color: white;
  border: 2px solid #393e46;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.3s;
}

/* Inputs for 3x3 - slightly smaller */
.grid-3x3 input {
  width: 70px;
  height: 70px;
  font-size: 1.4rem;
  text-align: center;
  background: #1a1a2e;
  color: white;
  border: 2px solid #393e46;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.3s;
}

/* Inputs for 4x4 */
.grid-4x4 input {
  width: 65px;
  height: 65px;
  font-size: 1.3rem;
  text-align: center;
  background: #1a1a2e;
  color: white;
  border: 2px solid #393e46;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.3s;
}

/* Hover effect for inputs */
.grid-2x2 input:hover,
.grid-3x3 input:hover,
.grid-4x4 input:hover {
  border-color: #00adb5;
}

/* Result inputs */
.box.result input {
  border-color: #4caf50;
  color: #4caf50;
  font-weight: bold;
  background: rgba(76, 175, 80, 0.1);
}

.box.result input:hover {
  border-color: #45a049;
}

/* Symbols */
.symbol {
  font-size: 4rem;
  color: #00adb5;
  font-weight: bold;
  margin: 0 15px;
  flex-shrink: 0;
}

.equals {
  font-size: 4rem;
  color: #4caf50;
  font-weight: bold;
  margin: 0 15px;
  flex-shrink: 0;
}

/* Buttons */
.buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin: 40px 0;
  flex-wrap: wrap;
}

.buttons button {
  padding: 15px 35px;
  font-size: 1.2rem;
  background: #00adb5;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-width: 160px;
  transition: all 0.3s;
  font-weight: bold;
}

.buttons button:hover {
  background: #0097a7;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 173, 181, 0.3);
}

.buttons button:active {
  transform: translateY(0);
}

.buttons button:last-child {
  background: #ff5722;
}

.buttons button:last-child:hover {
  background: #e64a19;
  box-shadow: 0 4px 12px rgba(255, 87, 34, 0.3);
}

/* Scrollbar styling */
.matrices::-webkit-scrollbar {
  height: 8px;
}

.matrices::-webkit-scrollbar-track {
  background: rgba(57, 62, 70, 0.3);
  border-radius: 4px;
}

.matrices::-webkit-scrollbar-thumb {
  background: #00adb5;
  border-radius: 4px;
}

.matrices::-webkit-scrollbar-thumb:hover {
  background: #0097a7;
}

/* Responsive Design - YAHAN MAJOR CHANGE KIYA */
@media (max-width: 1200px) {
  .container {
    max-width: 95%;
  }

  .matrices {
    justify-content: flex-start;
    padding-bottom: 30px;
  }

  .box {
    min-width: 320px;
  }

  .grid-2x2 input {
    width: 75px;
    height: 75px;
    font-size: 1.5rem;
  }

  .grid-3x3 input {
    width: 65px;
    height: 65px;
    font-size: 1.3rem;
  }

  .grid-4x4 input {
    width: 60px;
    height: 60px;
    font-size: 1.2rem;
  }

  .symbol,
  .equals {
    font-size: 3.5rem;
    margin: 0 10px;
  }
}

@media (max-width: 992px) {
  .matrices {
    flex-wrap: wrap; /* YEH LINE ADD KI - boxes neeche aajayenge */
    justify-content: center;
    overflow-x: visible; /* Scroll hata diya */
    flex-direction: column;
    align-items: center;
    gap: 30px;
  }

  .box {
    min-width: auto;
    width: 100%;
    max-width: 500px;
  }

  .symbol,
  .equals {
    display: none; /* Mobile par symbols hide */
  }
}

@media (max-width: 768px) {
  h1 {
    font-size: 2rem;
  }

  .nav a {
    padding: 10px 20px;
    font-size: 1.1rem;
  }

  .box {
    padding: 20px;
    max-width: 400px;
  }

  .box h2 {
    font-size: 1.3rem;
    margin-bottom: 15px;
  }

  .grid-2x2 input {
    width: 65px;
    height: 65px;
    font-size: 1.3rem;
  }

  .grid-3x3 input {
    width: 55px;
    height: 55px;
    font-size: 1.1rem;
  }

  .grid-4x4 input {
    width: 50px;
    height: 50px;
    font-size: 1rem;
  }

  .grid-2x2,
  .grid-3x3,
  .grid-4x4 {
    gap: 10px;
  }

  .buttons button {
    padding: 12px 25px;
    min-width: 140px;
    font-size: 1.1rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .nav {
    gap: 10px;
  }

  .nav a {
    padding: 8px 15px;
    font-size: 1rem;
  }

  .box {
    padding: 15px;
    max-width: 350px;
  }

  .grid-2x2 input {
    width: 55px;
    height: 55px;
    font-size: 1.1rem;
  }

  .grid-3x3 input {
    width: 45px;
    height: 45px;
    font-size: 1rem;
  }

  .grid-4x4 input {
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
  }

  .buttons {
    gap: 10px;
  }

  .buttons button {
    padding: 10px 20px;
    min-width: 120px;
    font-size: 1rem;
  }
}
