:root {
  --bg-color: #0f172a; /* Slate 900 */
  --calc-bg: rgba(30, 41, 59, 0.7); /* Slate 800 */
  --calc-border: rgba(255, 255, 255, 0.1);
  --calc-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 40px rgba(56, 189, 248, 0.08);
  
  --display-bg: rgba(15, 23, 42, 0.6);
  
  --btn-bg: rgba(255, 255, 255, 0.04);
  --btn-hover: rgba(255, 255, 255, 0.1);
  --btn-active: rgba(255, 255, 255, 0.15);
  
  --btn-num-bg: rgba(255, 255, 255, 0.08);
  --btn-num-hover: rgba(255, 255, 255, 0.12);
  
  --btn-op-bg: rgba(99, 102, 241, 0.2); /* Indigo */
  --btn-op-hover: rgba(99, 102, 241, 0.3);
  --btn-op-text: #a5b4fc;
  
  --btn-eq-bg: linear-gradient(135deg, #4f46e5, #3b82f6);
  --btn-eq-hover: linear-gradient(135deg, #6366f1, #60a5fa);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-func: #38bdf8; /* Sky blue */
  --text-error: #fb7185; /* Rose */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  user-select: none;
}

body {
  background: var(--bg-color);
  background-image: 
    radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.2) 0px, transparent 60%),
    radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.2) 0px, transparent 60%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-main);
  overflow: hidden;
}

/* Glassmorphism dots effect behind */
body::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  z-index: -1;
}

.calculator-container {
  padding: 1rem;
  width: 100%;
  max-width: 440px;
}

.calculator {
  background: var(--calc-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--calc-border);
  border-radius: 28px;
  padding: 1.5rem;
  box-shadow: var(--calc-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.display-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modes {
  display: flex;
  justify-content: flex-start;
  padding: 0 0.5rem;
}

.toggle-container {
  display: flex;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

.toggle-option {
  padding: 4px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.25s ease;
}

.toggle-option.active {
  background: rgba(255,255,255,0.12);
  color: var(--text-main);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.display {
  background: var(--display-bg);
  border-radius: 20px;
  padding: 1.5rem;
  text-align: right;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 4px 12px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history {
  font-size: 0.95rem;
  color: var(--text-muted);
  min-height: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.5px;
  font-weight: 400;
}

.current {
  font-size: 2.75rem;
  font-weight: 300;
  letter-spacing: -1px;
  overflow-x: auto;
  overflow-y: hidden;
  text-overflow: clip;
  white-space: nowrap;
  transition: all 0.2s ease;
  scrollbar-width: none;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.current::-webkit-scrollbar {
  display: none;
}

.current.error {
  color: var(--text-error);
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: 0;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: 3.25rem;
  gap: 0.6rem;
}

.btn {
  border: none;
  outline: none;
  background: var(--btn-bg);
  color: var(--text-main);
  font-size: 1.05rem;
  font-weight: 400;
  border-radius: 14px;
  cursor: pointer;
  height: 100%;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn:hover {
  background: var(--btn-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 8px -1px rgba(0, 0, 0, 0.2);
}

.btn:active {
  background: var(--btn-active);
  transform: translateY(1px);
  box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
}

.btn.num {
  background: var(--btn-num-bg);
  font-size: 1.35rem;
  font-weight: 500;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

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

.btn.func {
  color: var(--text-func);
  font-size: 0.95rem;
  font-weight: 500;
}

.btn.op {
  background: var(--btn-op-bg);
  color: var(--btn-op-text);
  font-size: 1.5rem;
  font-weight: 400;
}

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

.btn.action {
  color: var(--text-error);
  font-weight: 600;
}

.btn.equals {
  grid-row: span 2;
  grid-column: 5;
  height: 100%;
  background: var(--btn-eq-bg);
  color: white;
  font-size: 2rem;
  font-weight: 300;
  box-shadow: 0 8px 15px rgba(79, 70, 229, 0.3);
  border: none;
}

.btn.equals:hover {
  background: var(--btn-eq-hover);
  box-shadow: 0 12px 20px rgba(79, 70, 229, 0.4);
}
