:root {
  --bg-gradient-start: #1a0a2e;
  --bg-gradient-mid: #16213e;
  --bg-gradient-end: #0f0f23;
  --calc-bg: linear-gradient(145deg, #2d1b4e 0%, #1a1a3e 50%, #0d1b2a 100%);
  --display-bg: rgba(0, 0, 0, 0.4);
  --btn-number: #3d3d5c;
  --btn-number-hover: #4a4a6a;
  --btn-special: #505070;
  --btn-special-hover: #606085;
  --btn-operator: #ff6b4a;
  --btn-operator-hover: #ff8566;
  --btn-equals: #ff4d6d;
  --btn-equals-hover: #ff6b85;
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.6);
  --text-muted: rgba(255, 255, 255, 0.4);
  --glow-operator: rgba(255, 107, 74, 0.4);
  --glow-equals: rgba(255, 77, 109, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-mid) 50%, var(--bg-gradient-end) 100%);
  min-height: 100vh;
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(139, 69, 255, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(255, 107, 74, 0.1) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#root {
  position: relative;
  z-index: 1;
}

.calculator {
  width: 100%;
  max-width: 320px;
  background: var(--calc-bg);
  border-radius: 24px;
  padding: 20px;
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  animation: float-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.display {
  background: var(--display-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-end;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.expression {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  min-height: 18px;
  word-break: break-all;
  text-align: right;
}

.result-container {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: flex-end;
}

.result {
  font-family: 'JetBrains Mono', monospace;
  font-size: 42px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
  line-height: 1.1;
  transition: transform 0.15s ease;
}

.easter-egg {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 11px;
  color: var(--btn-equals);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.easter-egg span:first-child {
  font-size: 18px;
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-20deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.calc-btn {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 600;
  border: none;
  border-radius: 14px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.12s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.calc-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12) 0%, transparent 50%);
  border-radius: 14px;
  pointer-events: none;
}

.calc-btn:active,
.calc-btn.pressed {
  transform: scale(0.92);
}

.btn-number {
  background: var(--btn-number);
  color: var(--text-primary);
}

.btn-number:hover {
  background: var(--btn-number-hover);
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.btn-special {
  background: var(--btn-special);
  color: var(--text-primary);
}

.btn-special:hover {
  background: var(--btn-special-hover);
}

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

.btn-operator:hover {
  background: var(--btn-operator-hover);
  box-shadow: 0 0 25px var(--glow-operator);
}

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

.btn-equals:hover {
  background: var(--btn-equals-hover);
  box-shadow: 0 0 30px var(--glow-equals);
}

.col-span-2 {
  grid-column: span 2;
}

.footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

.footer a {
  color: var(--btn-equals);
  text-decoration: none;
  transition: color 0.2s;
}

.footer a:hover {
  color: var(--btn-equals-hover);
  text-decoration: underline;
}

@media (max-width: 360px) {
  .calculator {
    padding: 14px;
    border-radius: 20px;
  }
  
  .calc-btn {
    padding: 14px;
    font-size: 20px;
    border-radius: 12px;
  }
  
  .result {
    font-size: 36px;
  }
  
  .button-grid {
    gap: 8px;
  }
}

@media (hover: none) {
  .calc-btn:hover {
    transform: none;
    box-shadow: none;
  }
  
  .btn-number:hover {
    background: var(--btn-number);
  }
  
  .btn-special:hover {
    background: var(--btn-special);
  }
  
  .btn-operator:hover {
    background: var(--btn-operator);
  }
  
  .btn-equals:hover {
    background: var(--btn-equals);
  }
}