/* ── RESET & BASE ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Strictly Monochrome Retro Palette */
  --bg-dark: #000000;
  --white: #ffffff;
  --gray-light: #aaaaaa;
  --gray-dark: #555555;
  --pixel: 4px;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  font-family: 'Press Start 2P', monospace;
  color: var(--white);
  image-rendering: pixelated;
  overflow-x: hidden;
  position: relative;
}

/* Retro Scanlines */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.04) 3px,
    rgba(255, 255, 255, 0.04) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* ── CALCULATOR WRAPPER ── */
.calc-wrapper {
  position: relative;
  z-index: 2;
  background: var(--bg-dark);
  border: var(--pixel) solid var(--white);
  padding: 32px 24px 20px;
  width: 420px;
  box-shadow: none; /* No shadow */
}

.calc-title {
  text-align: center;
  font-size: 14px;
  color: var(--white);
  letter-spacing: 6px;
  margin-bottom: 28px;
  font-weight: bold;
}

/* ── DISPLAY ── */
.calc-display {
  background: var(--bg-dark);
  border: var(--pixel) solid var(--white);
  padding: 16px 16px 14px;
  margin-bottom: 24px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  box-shadow: none; /* No shadow */
}

.display-expression {
  font-size: 10px;
  color: var(--gray-light);
  word-break: break-all;
  text-align: right;
  min-height: 20px;
  line-height: 1.6;
  font-weight: bold;
}

.display-result {
  font-size: 28px;
  color: var(--white);
  word-break: break-all;
  text-align: right;
  line-height: 1.2;
  font-weight: bold;
}

/* ── BUTTON GRID ── */
.calc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  border: var(--pixel) solid var(--white);
  padding: 18px 4px;
  text-align: center;
  user-select: none;
  image-rendering: pixelated;
  outline: none;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.08s ease, color 0.08s ease;
  box-shadow: none; /* No shadow */
}

.btn::after {
  display: none !important;
}

/* Hover & Active default state transition overrides */

/* Number buttons */
.btn-num {
  background: var(--bg-dark);
  color: var(--white);
}

.btn-num:hover {
  background: var(--white);
  color: var(--bg-dark);
}

.btn-num:active {
  background: var(--gray-light);
  color: var(--bg-dark);
}

/* Operator buttons (Gray background for visual hierarchy) */
.btn-operator {
  background: var(--gray-light);
  color: var(--bg-dark);
  border-color: var(--white);
}

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

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

/* Clear button (Dark gray background) */
.btn-clear {
  background: var(--gray-dark);
  color: var(--white);
}

.btn-clear:hover {
  background: var(--white);
  color: var(--bg-dark);
}

.btn-clear:active {
  background: var(--gray-light);
  color: var(--bg-dark);
}

/* Wide button spans 2 columns */
.btn-wide {
  grid-column: span 2;
}

/* Equals button (Pure white) */
.btn-equal {
  background: var(--white);
  color: var(--bg-dark);
}

.btn-equal:hover {
  background: var(--gray-light);
  color: var(--bg-dark);
}

.btn-equal:active {
  background: var(--gray-dark);
  color: var(--white);
}

/* Zero spans 2 columns */
.btn-zero {
  grid-column: span 2;
}

.calc-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 8px;
  color: var(--white);
  letter-spacing: 2px;
  font-weight: bold;
}

/* ── MODAL OVERLAY ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-dark);
  border: var(--pixel) solid var(--white);
  padding: 28px 24px 20px;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: none; /* No shadow */
}

.modal-title {
  text-align: center;
  font-size: 10px;
  color: var(--white);
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.modal-subtitle {
  text-align: center;
  font-size: 7px;
  color: var(--gray-light);
  margin-bottom: 24px;
}

/* ── ORDER SUMMARY ── */
.modal-order {
  border: var(--pixel) solid var(--white);
  padding: 12px;
  margin-bottom: 20px;
  background: var(--bg-dark);
}

.order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 7px;
  color: var(--white);
  margin-bottom: 8px;
  gap: 8px;
}

.order-row:last-child {
  margin-bottom: 0;
}

.order-row span:last-child {
  text-align: right;
  word-break: break-all;
  max-width: 55%;
}

.order-divider {
  border-top: var(--pixel) dashed var(--white);
  margin: 10px 0;
}

.order-total {
  font-size: 9px;
  color: var(--white);
}

/* ── CARD INPUTS ── */
.modal-card {
  margin-bottom: 16px;
}

.card-label {
  font-size: 7px;
  color: var(--white);
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.card-input {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: var(--bg-dark);
  color: var(--white);
  border: 3px solid var(--white);
  padding: 10px 8px;
  width: 100%;
  outline: none;
  margin-bottom: 12px;
  letter-spacing: 1px;
}

.card-input::placeholder {
  color: var(--gray-dark);
}

.card-input:focus {
  background: var(--white);
  color: var(--bg-dark);
}

.card-input:focus::placeholder {
  color: var(--gray-light);
}

.card-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.card-field .card-input {
  margin-bottom: 0;
}

/* ── MODAL ERROR ── */
.modal-error {
  font-size: 7px;
  color: var(--white);
  text-align: center;
  min-height: 16px;
  margin-bottom: 12px;
  letter-spacing: 1px;
  animation: blink 0.5s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ── MODAL BUTTONS ── */
.modal-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.btn-modal {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  padding: 12px 8px;
  border: 3px solid var(--white);
  cursor: pointer;
  text-align: center;
  outline: none;
  transition: background-color 0.08s ease, color 0.08s ease;
  box-shadow: none; /* No shadow */
}

.btn-modal::after {
  display: none !important;
}

.btn-modal:hover {
  background: var(--white);
  color: var(--bg-dark);
}

.btn-modal:active {
  background: var(--gray-light);
  color: var(--bg-dark);
}

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

.btn-pay:hover {
  background: var(--gray-light);
}

.btn-pay:active {
  background: var(--gray-dark);
  color: var(--white);
}

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

.modal-note {
  text-align: center;
  font-size: 5px;
  color: var(--gray-light);
  letter-spacing: 1px;
  line-height: 1.8;
}

/* ── SUCCESS FLASH ── */
.success-flash {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-dark);
  z-index: 200;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.success-flash.active {
  display: flex;
}

.success-inner {
  text-align: center;
}

.success-icon {
  font-size: 48px;
  color: var(--white);
  animation: pulse 0.3s step-end infinite;
  margin-bottom: 16px;
  display: block;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.success-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 16px;
  color: var(--white);
  letter-spacing: 3px;
  margin-bottom: 10px;
}

.success-sub {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: var(--gray-light);
  letter-spacing: 2px;
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  .calc-wrapper {
    width: 90vw;
    padding: 20px 16px 16px;
    box-shadow: none; /* No shadow */
  }

  .calc-title {
    font-size: 12px;
    letter-spacing: 3px;
    margin-bottom: 20px;
  }

  .calc-display {
    min-height: 90px;
    padding: 12px 12px 10px;
    margin-bottom: 16px;
  }

  .display-result {
    font-size: 20px;
  }

  .display-expression {
    font-size: 8px;
  }

  .btn {
    font-size: 9px;
    padding: 14px 2px;
    min-height: 48px;
    box-shadow: none; /* No shadow */
  }

  .calc-grid {
    gap: 10px;
  }
  
  .modal {
    padding: 20px 16px;
    box-shadow: none; /* No shadow */
  }
}

/* ── INFO BUTTON ── */
.info-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  position: relative;
  z-index: 5;
}

.info-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  font-weight: bold;
  background: var(--bg-dark);
  color: var(--white);
  border: 3px solid var(--white);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: background-color 0.08s ease, color 0.08s ease;
}

.info-btn:hover {
  background: var(--white);
  color: var(--bg-dark);
}

.info-btn:active {
  background: var(--gray-light);
  color: var(--bg-dark);
}

.info-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: var(--white);
  border: 3px solid var(--white);
  padding: 8px 12px;
  background: var(--bg-dark);
  line-height: 1.4;
  letter-spacing: 1px;
}
