:root {
  --bg-color: #000000;
  --btn-dark: #333333;
  --btn-gray: #a5a5a5;
  --btn-orange: #ff9f0a;
  --text-white: #ffffff;
  --text-black: #000000;
  --gap: 12px;
  --btn-size: 80px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: var(--text-white);
}

#app {
  width: 100%;
  max-width: 400px;
  /* Default to basic mode width */
  padding: 20px;
  transition: max-width 0.3s ease;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding: 0 10px;
}

.nav-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-white);
}

.nav-title {
  font-size: 1.2rem;
  font-weight: 600;
}

.calculator {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.display {
  height: 120px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  padding: 0 20px;
  overflow: hidden;
}

.display-text {
  color: var(--text-white);
  font-size: 5rem;
  font-weight: 300;
  line-height: 1;
  word-break: break-all;
  text-align: right;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}

.keypad.scientific-mode {
  grid-template-columns: repeat(10, 1fr);
}

.btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: none;
  font-size: 1.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: filter 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-dark {
  background-color: var(--btn-dark);
  color: var(--text-white);
}

.btn-dark.secondary {
  background-color: #212121;
  font-size: 1rem;
  display: none;
  /* Hidden by default */
}

.btn-gray {
  background-color: var(--btn-gray);
  color: var(--text-black);
}

.btn-orange {
  background-color: var(--btn-orange);
  color: var(--text-white);
  font-size: 1.5rem;
  padding-bottom: 3px;
}

.btn-zero {
  grid-column: span 2;
  aspect-ratio: auto;
  border-radius: 40px;
  justify-content: flex-start;
  padding-left: 30px;
}

/* Active States */
.btn:active {
  filter: brightness(1.3);
}

.btn-gray:active {
  filter: brightness(1.3);
}

.btn-orange:active {
  filter: brightness(0.8);
}

/* Responsive adjustments */
@media (max-width: 800px) {
  .keypad {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  .secondary {
    display: none !important;
  }

  #app {
    max-width: 400px !important;
  }

  .keypad.scientific-mode {
    /* On mobile, scientific mode might need a different layout or just stay hidden/modal */
    /* For now, we enforce basic layout on small screens */
    grid-template-columns: repeat(4, 1fr);
  }
}