.calculator-page {
  max-width: 100%;
}

.calculator-page h2,
.modal h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1.1rem;
}

.period-bar,
.actions,
.calculator-page section {
  margin-bottom: 1.25rem;
}

.period-bar {
  padding: 0.7rem 0.95rem;
  background: #f5f7fa;
  border: 1px solid #d8dee6;
  border-radius: 6px;
}

table input,
table select,
table button {
  width: 100%;
  min-width: 0;
  padding: 0.35rem 0.45rem;
  font-size: 0.9rem;
  border: 1px solid #bfc7d1;
  border-radius: 4px;
  background: #fff;
}

.lookup-btn,
#calculate-btn,
#clear-btn,
#modal-close,
#error-modal-close,
.modal button {
  width: auto;
  white-space: nowrap;
  cursor: pointer;
  background: #f3f4f6;
}

.lookup-btn:hover,
#calculate-btn:hover,
#clear-btn:hover,
#modal-close:hover,
#error-modal-close:hover,
.modal button:hover {
  background: #e7eaee;
}

#calculate-btn,
#clear-btn {
  padding: 0.5rem 0.85rem;
}

#you-new-rating,
#you-new-rd,
[id$="-delta"] {
  background: #f3f5f7;
}

.calc-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calc-table-compact th,
.calc-table-compact td {
  border: 1px solid #d6dbe1;
  padding: 0.28rem 0.35rem;
  vertical-align: middle;
}

.calc-table th {
  background: #f3f4f6;
  text-align: left;
  font-weight: bold;
  font-size: 0.88rem;
}

.calc-table td input,
.calc-table td select {
  width: 100%;
}

.col-name { width: 32%; }
.col-lookup { width: 8%; }
.col-rating { width: 10%; }
.col-rd { width: 8%; }
.col-new-rating { width: 12%; }
.col-new-rd { width: 8%; }
.col-outcome { width: 12%; }
.col-delta { width: 10%; }

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.actions-top {
  margin-top: -0.1rem;
}

.opponents-table-wrap {
  max-height: 65vh;
  overflow: auto;
  border: 1px solid #d6dbe1;
  border-radius: 4px;
  background: #fff;
}

.opponents-table-wrap table {
  border: 0;
}

.opponents-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3f4f6;
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.modal-backdrop.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
}

.modal-small {
  width: min(460px, calc(100vw - 32px));
}

.modal table {
  margin-top: 0.75rem;
}

.modal-message {
  margin: 0.5rem 0 1rem;
  line-height: 1.45;
  color: #b00020;
}

@media (max-width: 900px) {
  .opponents-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .calc-table {
    font-size: 0.85rem;
  }

  .calc-table-compact th,
  .calc-table-compact td {
    padding: 0.24rem 0.28rem;
  }
}
