:root {
  --retro-black: #000000;
  --retro-white: #ffffff;
  --neon-cyan: #00ffff;
  --neon-green: #32ff32;
  --neon-green-btn: #16a34a;
  --pink-600: #dc2626; /* operators */
  --blue-600: #2563eb; /* numbers */
  --blue-700: #1d4ed8; /* hover */
  --blue-800: #1e40af; /* active */
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
}

* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  background: var(--retro-black);
  color: var(--retro-white);
}
.pixel-font {
  font-family: "Press Start 2P", monospace;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
}

/* Title */
.retro-heading {
  margin: 32px 0 16px;
  padding: 12px 32px;
  border: 2px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-size: 14px;
  text-align: center;
  letter-spacing: 1px;
  background: rgba(0, 0, 0, 0.4);
}
@media (min-width: 640px) {
  .retro-heading {
    font-size: 16px;
  }
}

/* Background helpers */
.app-background {
  min-height: 100vh;
  display: flex;
  justify-content: center;
}
.pixel-grid-bg {
  background-image: linear-gradient(rgba(0, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Calculator container */
.calculator-container {
  width: 100%;
  max-width: 384px;
  background: var(--retro-black);
  border: 2px solid var(--neon-cyan);
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.calculator-header {
  background: var(--gray-900);
  padding: 16px;
  border-bottom: 1px solid var(--neon-cyan);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-title,
.header-tag {
  font-size: 10px;
}
.header-title {
  color: var(--neon-cyan);
}
.header-tag {
  color: var(--gray-400);
  opacity: 0.6;
}

/* Display */
.calculator-display-container {
  background: var(--gray-900);
  padding: 24px;
  border-bottom: 2px solid var(--neon-cyan);
}
.calculator-display {
  background: var(--retro-black);
  border: 1px solid var(--neon-green);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.operation-display {
  font-size: 10px;
  color: var(--neon-green);
  opacity: 0.5;
  height: 16px;
  text-align: right;
  overflow: hidden;
}
.main-display {
  font-size: 16px;
  color: var(--neon-green);
  text-align: right;
  overflow: hidden;
}
@media (min-width: 640px) {
  .main-display {
    font-size: 18px;
  }
}

/* Scanlines */
.crt-scanlines {
  position: relative;
  overflow: hidden;
}
.crt-scanlines::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(transparent 50%, rgba(0, 255, 255, 0.02) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 1;
}

/* Buttons */
.button-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 16px;
}
.button-zero {
  grid-column: span 2;
}
.button {
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  padding: 16px;
  border: none;
  cursor: pointer;
  transition: background 75ms;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.button:focus {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}
.button-number {
  background: var(--blue-600);
  color: var(--retro-white);
  box-shadow:
    0 0 3px rgba(0, 255, 255, 0.6),
    0 0 6px rgba(0, 255, 255, 0.3);
  border: 1px solid rgba(0, 255, 255, 0.8);
}
.button-number:hover {
  background: var(--blue-700);
}
.button-number:active {
  background: var(--blue-800);
}
.button-operator {
  background: var(--pink-600);
  color: var(--retro-white);
  box-shadow:
    0 0 3px rgba(255, 20, 147, 0.6),
    0 0 6px rgba(255, 20, 147, 0.3);
  border: 1px solid rgba(255, 20, 147, 0.8);
}
.button-operator:hover {
  filter: brightness(0.9);
}
.button-operator:active {
  filter: brightness(0.8);
}
.button-equals {
  background: var(--neon-green-btn);
  color: var(--retro-black);
  box-shadow:
    0 0 3px rgba(50, 255, 50, 0.6),
    0 0 6px rgba(50, 255, 50, 0.3);
  border: 1px solid rgba(50, 255, 50, 0.8);
}
.button-equals:hover {
  filter: brightness(1.05);
}
.button-equals:active {
  filter: brightness(0.9);
}
.button-clear {
  background: var(--gray-800);
  color: var(--retro-white);
  border: 2px solid var(--gray-600);
}
.button-clear:hover {
  background: var(--gray-700);
}
.button-clear:active {
  background: var(--gray-600);
}
button {
  border-radius: 0;
}

/* Clock */
.calculator-clock-container {
  background: var(--gray-900);
  padding: 12px;
  border-top: 1px solid var(--neon-cyan);
}
.calculator-clock {
  font-size: 10px;
  color: var(--gray-500);
  opacity: 0.7;
  text-align: center;
}

/* Tiny screen tweak */
@media (max-width: 360px) {
  .button {
    padding: 12px;
    font-size: 10px;
  }
  .calculator-display-container {
    padding: 16px;
  }
  .main-display {
    font-size: 14px;
  }
}
