* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #1d1d1f;
  background: #f5f5f5;
  font-family: Arial, Helvetica, sans-serif;
}

main {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.intro {
  margin: 0 0 24px;
  color: #555;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #fff;
}

label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}

input,
button {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #b8b8b8;
  border-radius: 5px;
  font: inherit;
}

input:focus,
button:focus-visible {
  outline: 2px solid #2463eb;
  outline-offset: 1px;
}

.buttons {
  display: flex;
  gap: 8px;
}

button {
  min-width: 86px;
  cursor: pointer;
  color: #fff;
  border-color: #2463eb;
  background: #2463eb;
  font-weight: 700;
}

button + button {
  color: #333;
  border-color: #b8b8b8;
  background: #fff;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.error {
  min-height: 20px;
  margin: 8px 0;
  color: #c62828;
  font-size: 14px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 16px 0;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #fff;
}

.stats div {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid #e5e5e5;
}

.stats div:last-child {
  border-right: 0;
}

.stats span,
.stats strong {
  display: block;
}

.stats span {
  margin-bottom: 6px;
  color: #666;
  font-size: 12px;
}

.stats strong {
  overflow: hidden;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  min-height: 22px;
  margin: 0 0 8px;
  font-size: 14px;
}

.chart-wrap {
  height: 420px;
  padding: 10px;
  border: 1px solid #d8d8d8;
  border-radius: 8px;
  background: #fff;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  color: #666;
  font-size: 12px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  width: 10px;
  height: 3px;
}

.legend .win {
  background: #16803c;
}

.legend .loss {
  background: #d12d2d;
}

.note {
  margin-top: 20px;
  color: #666;
  font-size: 12px;
}

.result-win {
  color: #16803c;
}

.result-loss {
  color: #d12d2d;
}

@media (max-width: 700px) {
  main {
    margin: 24px auto;
  }

  form {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .stats div:nth-child(2) {
    border-right: 0;
  }

  .stats div:nth-child(-n + 2) {
    border-bottom: 1px solid #e5e5e5;
  }

  .chart-wrap {
    height: 320px;
  }
}
