/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Roboto", sans-serif;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #333;
  padding: 10px;
  transition:
    background-color 0.3s,
    color 0.3s;
}

body.dark-mode {
  background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%);
  color: #e0e0e0;
}

.container {
  max-width: 700px; /* Reduced from 1000px */
  width: 100%;
  margin: 0 auto;
}

/* Header - 40% smaller */
header {
  text-align: center;
  margin-bottom: 20px; /* Reduced from 30px */
  color: white;
  padding: 15px; /* Reduced from 20px */
  border-radius: 12px; /* Reduced from 15px */
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1); /* Reduced shadow */
}

body.dark-mode header {
  background: rgba(0, 0, 0, 0.2);
}

h1 {
  font-family: "Orbitron", sans-serif;
  font-size: 2rem; /* Reduced from 2.8rem (approx 40% smaller) */
  margin-bottom: 8px; /* Reduced from 10px */
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 0.9rem; /* Reduced from 1.2rem */
  opacity: 0.9;
}

/* Calculator Container */
.calculator-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px; /* Reduced from 30px */
  margin-bottom: 30px; /* Reduced from 40px */
}

.calculator {
  flex: 1;
  min-width: 280px; /* Reduced from 350px */
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px; /* Reduced from 20px */
  padding: 20px; /* Reduced from 25px */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); /* Reduced shadow */
  transition: background-color 0.3s;
}

body.dark-mode .calculator {
  background: rgba(30, 30, 40, 0.9);
}

/* Display - 40% smaller */
.display-container {
  background-color: #1a1a2e;
  color: #00ff9d;
  border-radius: 8px; /* Reduced from 10px */
  padding: 15px; /* Reduced from 20px */
  margin-bottom: 20px; /* Reduced from 25px */
  text-align: right;
  font-family: "Orbitron", sans-serif;
  min-height: 90px; /* Reduced from 120px */
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.5); /* Reduced shadow */
  overflow: hidden;
}

.display-history {
  font-size: 0.9rem; /* Reduced from 1.2rem */
  min-height: 22px; /* Reduced from 30px */
  color: #8a8a8a;
  word-wrap: break-word;
  word-break: break-all;
}

.display {
  font-size: 2rem; /* Reduced from 2.8rem */
  font-weight: 500;
  word-wrap: break-word;
  word-break: break-all;
}

/* Buttons Grid - 40% smaller */
.buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px; /* Reduced from 15px */
  margin-bottom: 15px; /* Reduced from 20px */
}

.btn {
  border: none;
  border-radius: 8px; /* Reduced from 12px */
  font-size: 1.1rem; /* Reduced from 1.5rem */
  font-weight: 500;
  height: 50px; /* Reduced from 70px (approx 40% smaller) */
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: "Roboto", sans-serif;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1); /* Reduced shadow */
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn:hover {
  transform: translateY(-2px); /* Reduced from -3px */
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Button Types */
.number {
  background-color: #f0f0f0;
  color: #333;
}

body.dark-mode .number {
  background-color: #3a3a4a;
  color: #e0e0e0;
}

.number:hover {
  background-color: #e0e0e0;
}

body.dark-mode .number:hover {
  background-color: #4a4a5a;
}

.zero {
  grid-column: span 2;
}

.operator {
  background-color: #4d4dff;
  color: white;
}

.operator:hover {
  background-color: #3a3aff;
}

.equals {
  background-color: #ff6b6b;
  color: white;
  grid-column: span 1;
}

.equals:hover {
  background-color: #ff5252;
}

/* Additional Functions - 40% smaller */
.additional-functions {
  display: flex;
  justify-content: space-between;
  gap: 10px; /* Reduced from 15px */
  margin-bottom: 20px; /* Reduced from 25px */
}

.func-btn {
  flex: 1;
  background-color: #50c878;
  color: white;
  border: none;
  border-radius: 8px; /* Reduced from 10px */
  padding: 10px 0; /* Reduced from 15px 0 */
  font-size: 0.9rem; /* Reduced from 1.2rem */
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px; /* Reduced from 8px */
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

.func-btn:hover {
  background-color: #40b068;
  transform: translateY(-2px); /* Reduced from -3px */
}

/* Instructions - 40% smaller */
.instructions {
  flex: 1;
  min-width: 250px; /* Reduced from 300px */
  background: rgba(255, 255, 255, 0.9);
  border-radius: 15px; /* Reduced from 20px */
  padding: 20px; /* Reduced from 25px */
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  transition: background-color 0.3s;
}

body.dark-mode .instructions {
  background: rgba(30, 30, 40, 0.9);
}

.instructions h3 {
  margin-bottom: 15px; /* Reduced from 20px */
  color: #4d4dff;
  font-size: 1.2rem; /* Reduced from 1.5rem */
  display: flex;
  align-items: center;
  gap: 8px; /* Reduced from 10px */
}

.instructions ul {
  padding-left: 18px; /* Reduced from 20px */
  margin-bottom: 20px; /* Reduced from 25px */
}

.instructions li {
  margin-bottom: 8px; /* Reduced from 10px */
  line-height: 1.5; /* Slightly reduced */
  font-size: 0.9rem; /* Slightly smaller font */
}

/* Theme Toggle - 40% smaller */
.theme-toggle {
  text-align: center;
}

#theme-switch {
  background-color: #4d4dff;
  color: white;
  border: none;
  border-radius: 8px; /* Reduced from 10px */
  padding: 10px 20px; /* Reduced from 12px 25px */
  font-size: 0.9rem; /* Reduced from 1rem */
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* Reduced from 10px */
  margin: 0 auto;
}

#theme-switch:hover {
  background-color: #3a3aff;
  transform: translateY(-2px); /* Reduced from -3px */
}

/* Keyboard Instructions - 40% smaller */
.keyboard-instructions {
  background-color: rgba(77, 77, 255, 0.1);
  border-radius: 8px; /* Reduced from 10px */
  padding: 12px; /* Reduced from 15px */
  text-align: center;
  font-size: 0.8rem; /* Reduced from 0.9rem */
  margin-top: 15px; /* Reduced from 20px */
  border-left: 3px solid #4d4dff; /* Reduced from 4px */
}

body.dark-mode .keyboard-instructions {
  background-color: rgba(77, 77, 255, 0.2);
}

.keyboard-instructions p {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* Reduced from 10px */
}

/* Footer - 40% smaller */
footer {
  text-align: center;
  padding: 15px; /* Reduced from 20px */
  color: white;
  font-size: 0.8rem; /* Reduced from 0.9rem */
  opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
  .calculator-container {
    flex-direction: column;
  }

  h1 {
    font-size: 1.6rem; /* Reduced from 2.2rem */
  }

  .display {
    font-size: 1.6rem; /* Reduced from 2.2rem */
  }

  .btn {
    height: 45px; /* Reduced from 60px */
    font-size: 1rem; /* Reduced from 1.3rem */
  }

  .calculator {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .calculator {
    padding: 15px;
  }

  h1 {
    font-size: 1.4rem; /* Reduced from 1.8rem */
  }

  .display {
    font-size: 1.4rem; /* Reduced from 1.8rem */
  }

  .display-container {
    min-height: 80px; /* Reduced from 90px */
    padding: 12px; /* Reduced from 15px */
  }

  .btn {
    height: 40px; /* Reduced from 55px */
    font-size: 0.95rem; /* Reduced from 1.2rem */
  }

  .buttons {
    gap: 8px; /* Reduced from 10px */
  }

  .instructions {
    min-width: 100%;
  }

  .instructions h3 {
    font-size: 1.1rem;
  }

  .instructions li {
    font-size: 0.85rem;
  }
}

/* For very small screens */
@media (max-width: 360px) {
  .btn {
    height: 38px;
    font-size: 0.9rem;
  }

  .display {
    font-size: 1.3rem;
  }

  .display-history {
    font-size: 0.8rem;
  }
}
