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

:root {
  /* ALOYT brand colours */
  --brand-primary: #6366f1;
  --brand-primary-hover: #818cf8;
  --brand-dark: #4f46e5;
  --brand-accent: #06b6d4;
  --brand-accent-hover: #22d3ee;
  --brand-panel: rgba(99, 102, 241, 0.10);
  --brand-glow: rgba(99, 102, 241, 0.35);

  /* UI surface colours */
  --bg: #0f172a;
  --panel: #1e293b;
  --display: #0f172a;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --operator: #c084fc;
  --operator-hover: #d8b4fe;
  --equals: #22c55e;
  --equals-hover: #4ade80;
  --func: #64748b;
  --func-hover: #94a3b8;
  --sci: var(--brand-accent);
  --sci-hover: var(--brand-accent-hover);
  --border: #334155;
  --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3),
    0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

.calculator {
  width: 100%;
  max-width: 400px;
  padding: 24px 20px 20px;
  background: var(--panel);
  border-radius: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.calculator::before {
  content: "";
  position: absolute;
  top: -40px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, var(--brand-glow), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.brand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo svg {
  width: 28px;
  height: 28px;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: var(--brand-primary);
  filter: drop-shadow(0 1px 2px rgba(99, 102, 241, 0.35));
}

.angle-mode {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-accent);
  letter-spacing: 0.05em;
  margin-left: auto;
}

.nav-tabs {
  display: flex;
  gap: 6px;
  background: var(--display);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
}

.nav-tab {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.nav-tab:hover:not(.active) {
  background: #334155;
  color: var(--text);
}

.display {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 130px;
  padding: 18px;
  background: var(--display);
  border-radius: 16px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.previous-operand {
  color: var(--text-muted);
  font-size: 1.1rem;
  min-height: 1.5rem;
  word-break: break-all;
}

.current-operand {
  color: var(--text);
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  word-break: break-all;
}

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

.buttons.scientific {
  grid-template-columns: repeat(4, 1fr);
}

.btn {
  height: 60px;
  border: none;
  border-radius: 12px;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  background: var(--border);
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, box-shadow 0.15s;
  outline: none;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.96);
}

.btn:hover {
  background: #475569;
}

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

.btn.func {
  background: var(--func);
}

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

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

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

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

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

.btn.sci {
  background: var(--sci);
  color: #00171f;
  font-size: 1.1rem;
}

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

.hidden {
  display: none !important;
}

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

.footer a {
  color: var(--brand-primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}

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

/* AdSense ad containers */
.ads-container {
  margin: 1rem auto;
  text-align: center;
  min-height: 100px;
}

.ads-top {
  margin-bottom: 1.5rem;
}

.ads-bottom {
  margin-top: 1.5rem;
}

@media (max-width: 420px) {
  .calculator {
    padding: 16px 14px 16px;
    max-width: 100%;
  }
  .btn {
    height: 54px;
    font-size: 1.1rem;
  }
  .current-operand {
    font-size: 2.2rem;
  }
  .ads-container {
    min-height: 60px;
    margin: 0.75rem auto;
  }
}
