:root {
  color: #111;
  background: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  font-size: 14px;
  line-height: normal;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: 100%;
  margin: 0;
}

h1 {
  margin: 0 0 18px;
  font-size: 30px;
  line-height: 36px;
}

p {
  margin: 0 0 14px;
}

#setup-view {
  width: 480px;
  min-height: 425px;
  margin: 0 auto;
  padding: 36px 20px 20px;
  background: #ddd;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.operation {
  margin: 14px 0;
}

.operation-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.operation-name input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.range-row {
  margin: 1px 0 0 40px;
}

.range-row input {
  width: 42px;
  height: 21px;
  padding: 1px 3px;
  border: 1px solid #888;
  border-radius: 1px;
  text-align: right;
}

.duration-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 15px 0 0;
}

select {
  padding: 1px 2px;
}

.start-button {
  display: block;
  margin: 14px 0 0 auto;
  padding: 2px 7px;
  cursor: pointer;
}

.error {
  position: fixed;
  z-index: 2;
  right: 16px;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 16px;
  margin: 0;
  color: #8b1a1a;
  text-align: center;
}

.error:empty {
  display: none;
}

.game-view {
  min-height: 100dvh;
}

.status {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 15px 0;
  font-size: 18px;
}

.status strong {
  font-weight: 400;
}

.play-area {
  display: flex;
  height: 74px;
  align-items: center;
  justify-content: center;
  margin-top: 198px;
  background: #ddd;
}

.problem-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  width: 100%;
  font-size: 36px;
  line-height: normal;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.answer {
  width: 188px;
  height: 50px;
  padding: 1px 5px;
  border: 2px solid #222;
  border-radius: 2px;
  background: #fff;
  color: #111;
  font-size: 36px;
  text-align: left;
}

.keypad {
  position: fixed;
  z-index: 1;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  width: min(320px, calc(100% - 28px));
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  justify-content: center;
  transform: translateX(-50%);
  touch-action: manipulation;
  user-select: none;
}

.keypad button {
  height: 48px;
  border: 1px solid #888;
  border-radius: 2px;
  background: #eee;
  color: #111;
  font-size: 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.keypad button:active {
  background: #ddd;
}

.keypad button:focus-visible,
.start-button:focus-visible,
.link-button:focus-visible {
  outline: 3px solid #1867c0;
  outline-offset: 2px;
}

.backspace {
  font-size: 27px !important;
}

.result {
  display: grid;
  min-height: 270px;
  place-items: center;
  text-align: center;
  align-content: center;
}

.result p {
  margin: 8px 0;
}

.final-score {
  font-size: 30px;
}

.link-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #0645ad;
  cursor: pointer;
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  #setup-view {
    width: 100%;
    min-height: 100dvh;
    padding: 26px 16px 20px;
  }

  h1 {
    font-size: 27px;
  }

  .range-row {
    margin-left: 20px;
    line-height: 1.8;
  }

  .game-view {
    min-height: 100dvh;
  }

  .status {
    font-size: 16px;
  }

  .play-area {
    height: 66px;
    margin-top: min(140px, 17dvh);
  }

  .problem-row {
    gap: 7px;
    font-size: clamp(28px, 9vw, 36px);
  }

  .answer {
    width: min(38vw, 150px);
    height: 46px;
    font-size: 32px;
  }

  .keypad button {
    height: clamp(50px, 7.5dvh, 62px);
  }
}
