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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0px;
  background: #17181783;
  font-family: 'Segoe UI', sans-serif;
  padding: 10px;
}

.calculator {
  border: 15px solid #191c24;
  border-radius: 10px;
  max-width: 480px;
  width: 100%;
}

.calculator_screen {
  border: 30px solid #191c24;
  background: #191c24;
  border-radius: 0px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  margin-bottom: 0px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#myCanvas {
  border: 5px solid #d7e2a5dc;
  width: 384px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 2 / 1;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #191c24;
  border-radius: 5px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* ===== 通用按键网格 ===== */
.func_pad,
.main_pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 11px;
  padding: 10px;
  background: #191c24;
  border-radius: 0px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.func_pad button,
.main_pad button {
  width: 100%;
  height: 30px;
  font-size: 16px;
  font-weight: normal;
  color: #cec5c5;
  background: #383a3b9f;
  border: 2px solid #757980;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 0 #414652, 0 6px 12px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.func_pad button {
  background: #1d1e1f9f;
}

.func_pad button:hover,
.main_pad button:hover {
  background: #515355;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #5a606d, 0 8px 16px rgba(0, 0, 0, 0.4);
}

.func_pad button:active,
.main_pad button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #414652, 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== 数字键盘区域 ===== */
.number_pad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 10px;
  background: #191c24;
  border-radius: 0px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.number_pad button {
  width: 100%;
  height: 40px;
  font-size: 28px;
  font-weight: normal;
  color: #cec5c5;
  background: #898d929f;
  border: 2px solid #757980;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 4px 0 #414652, 0 6px 12px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.number_pad button:hover {
  background: #747577;
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #414652, 0 8px 16px rgba(0, 0, 0, 0.4);
}

.number_pad button:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #414652, 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 特殊按键颜色 */
#KEY_DEL {
  background: #89eb489f;
  border-color: #8b9186;
  color: #fff;
}

#KEY_DEL:hover {
  background: #8edf58;
}

#KEY_AC {
  background: #89eb489f;
  border-color: #8b9186;
  color: #fff;
}

#KEY_AC:hover {
  background: #8edf58;
}

#KEY_EXE {
  color: #50b160;
}

/* 键盘提示 */
.hint {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  color: #131414;
  font-size: 14px;
}

.hint kbd {
  display: inline-block;
  padding: 2px 8px;
  background: #898d929f;
  border: 1px solid #757980;
  border-radius: 4px;
  color: #c5b6b6;
  font-size: 13px;
}

/* ===== 手机响应式（480px 以下） ===== */
@media (max-width: 480px) {
  body {
    padding: 5px;
  }

  .calculator {
    border-width: 8px;
  }

  .calculator_screen {
    border-width: 15px;
  }

  #myCanvas {
    border-width: 3px;
    width: 100%;
  }

  .func_pad,
  .main_pad {
    gap: 5px;
    padding: 6px;
  }

  .func_pad button,
  .main_pad button {
    height: 24px;
    font-size: 11px;
    border-width: 1.5px;
    box-shadow: 0 2px 0 #414652, 0 3px 6px rgba(0, 0, 0, 0.3);
  }

  .func_pad button:hover,
  .main_pad button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 #5a606d, 0 4px 8px rgba(0, 0, 0, 0.4);
  }

  .func_pad button:active,
  .main_pad button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #414652, 0 1px 2px rgba(0, 0, 0, 0.3);
  }

  .number_pad {
    gap: 5px;
    padding: 6px;
  }

  .number_pad button {
    height: 32px;
    font-size: 18px;
    border-width: 1.5px;
    box-shadow: 0 2px 0 #414652, 0 3px 6px rgba(0, 0, 0, 0.3);
  }

  .number_pad button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 0 #414652, 0 4px 8px rgba(0, 0, 0, 0.4);
  }

  .number_pad button:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #414652, 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

/* ===== 超小屏幕（360px 以下） ===== */
@media (max-width: 360px) {
  .calculator {
    border-width: 5px;
  }

  .calculator_screen {
    border-width: 10px;
  }

  .func_pad,
  .main_pad {
    gap: 3px;
    padding: 4px;
  }

  .func_pad button,
  .main_pad button {
    height: 20px;
    font-size: 9px;
  }

  .number_pad {
    gap: 3px;
    padding: 4px;
  }

  .number_pad button {
    height: 26px;
    font-size: 14px;
  }
}
