@import url('https://fonts.googleapis.com/css2?family=MS+Sans+Serif:wght@400;700&display=swap');

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  background: linear-gradient(135deg, #008080 0%, #20b2aa 100%);
  font-family: 'MS Sans Serif', sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calculator-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.calculator-window {
  background: #c0c0c0;
  border: 2px outset #c0c0c0;
  width: 280px;
  box-shadow: 4px 4px 8px rgba(0,0,0,0.3);
}

.title-bar {
  background: linear-gradient(90deg, #0080ff 0%, #0060df 100%);
  color: white;
  padding: 4px 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: bold;
}

.title-text {
  font-size: 11px;
}

.window-controls {
  display: flex;
  gap: 2px;
}

.control-button {
  background: #c0c0c0;
  border: 1px outset #c0c0c0;
  width: 16px;
  height: 14px;
  font-size: 8px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-button:hover {
  background: #d4d4d4;
}

.control-button:active,
.control-button.pressed {
  border: 1px inset #c0c0c0;
}

.control-button.close:hover {
  background: #ff6b6b;
  color: white;
}

.calculator-body {
  padding: 8px;
}

.display {
  background: #000;
  color: #00ff00;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: bold;
  padding: 8px 12px;
  text-align: right;
  border: 2px inset #c0c0c0;
  margin-bottom: 8px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  grid-template-rows: repeat(5, 1fr);
  gap: 2px;
}

.calc-button {
  background: #c0c0c0;
  border: 2px outset #c0c0c0;
  font-size: 12px;
  font-weight: bold;
  height: 32px;
  cursor: pointer;
  font-family: 'MS Sans Serif', sans-serif;
  transition: none;
  user-select: none;
}

.calc-button:hover {
  background: #d4d4d4;
}

.calc-button:active,
.calc-button.pressed {
  border: 2px inset #c0c0c0;
  background: #a0a0a0;
}

.calc-button.wide-button {
  grid-column: span 2;
}

.calc-button.operation {
  background: #d0d0d0;
  color: #000;
}

.calc-button.equals {
  background: #e0e0e0;
  font-weight: bold;
}

/* Specific button positioning */
.button-grid .calc-button:nth-child(1) { grid-column: 1 / 3; } /* Backspace */
.button-grid .calc-button:nth-child(2) { grid-column: 3; } /* CE */
.button-grid .calc-button:nth-child(3) { grid-column: 4; } /* C */
.button-grid .calc-button:nth-child(4) { grid-column: 1; grid-row: 2; } /* ± */

.button-grid .calc-button:nth-child(5) { grid-column: 1; grid-row: 3; } /* ÷ */
.button-grid .calc-button:nth-child(9) { grid-column: 1; grid-row: 4; } /* × */
.button-grid .calc-button:nth-child(13) { grid-column: 1; grid-row: 5; } /* - */
.button-grid .calc-button:nth-child(17) { grid-column: 1; grid-row: 6; } /* + */

.button-grid .calc-button:nth-child(18) { grid-column: 2 / 4; grid-row: 6; } /* 0 */
.button-grid .calc-button:nth-child(19) { grid-column: 4; grid-row: 6; } /* . */
.button-grid .calc-button:nth-child(20) { grid-column: 4; grid-row: 5; } /* = */

.settings {
  background: #c0c0c0;
  border: 1px inset #c0c0c0;
  padding: 8px;
  border-radius: 2px;
  font-size: 11px;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.sound-toggle input {
  margin: 0;
}

.footer {
  font-size: 11px;
  color: #666;
  text-align: center;
  background: #f0f0f0;
  padding: 8px;
  border: 1px inset #c0c0c0;
  border-radius: 2px;
}

.footer a {
  color: #0060df;
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

/* Responsive design */
@media (max-width: 320px) {
  .calculator-window {
    width: 100%;
    max-width: 280px;
  }
  
  body {
    padding: 10px;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .display {
    background: #000;
    color: #fff;
    border: 2px solid #fff;
  }
  
  .calc-button {
    border-width: 3px;
  }
}