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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2d3a;
  --text: #e4e4e7;
  --text-dim: #8b8d98;
  --accent: #6366f1;
  --accent-dim: #4f46e5;
  --red: #ef4444;
  --yellow: #eab308;
  --green: #22c55e;
  --input-bg: #22252f;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* Presets */
.presets {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.presets label {
  font-size: 0.8125rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.presets select {
  min-width: 12rem;
}

/* Form table */
.form-section {
  margin-top: 1.5rem;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  white-space: nowrap;
}

th {
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  padding: 0.625rem 0.5rem;
  text-align: center;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.25rem 0.25rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

tbody tr.front-nine {
  background: rgba(255, 255, 255, 0.01);
}

td:first-child {
  font-weight: 600;
  color: var(--text-dim);
  width: 3rem;
}

tfoot td {
  font-size: 0.8125rem;
  padding: 0.5rem;
  border-bottom: none;
  border-top: 2px solid var(--border);
}

/* Inputs */
input[type="number"],
select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 0.3rem 0.25rem;
  text-align: center;
  font-size: 0.8125rem;
  width: 100%;
  min-width: 2.5rem;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

input[type="number"]::-webkit-inner-spin-button {
  opacity: 0.3;
}

select {
  min-width: 4rem;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

input:disabled,
select:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Actions */
.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  justify-content: center;
}

button {
  padding: 0.625rem 2rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

#score-btn {
  background: var(--accent);
  color: white;
}

#score-btn:hover:not(:disabled) {
  background: var(--accent-dim);
}

#score-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#reset-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}

#reset-btn:hover {
  border-color: var(--text-dim);
  color: var(--text);
}

.error {
  color: var(--red);
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.8125rem;
}

/* Results */
.results-section {
  margin-top: 2.5rem;
}

.results-section h2 {
  text-align: center;
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
}

.charts {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.chart-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.chart-item svg {
  filter: drop-shadow(0 0 8px rgba(0, 0, 0, 0.3));
}

.chart-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* Breakdown */
.breakdown {
  margin-top: 2rem;
}

.breakdown h3 {
  text-align: center;
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text-dim);
}

.breakdown-table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
}

#breakdown-table td {
  font-variant-numeric: tabular-nums;
}

/* Score color cells */
.score-cell {
  font-weight: 600;
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
  display: inline-block;
  min-width: 2.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  header h1 {
    font-size: 1.5rem;
  }

  .charts {
    gap: 1rem;
  }

  .chart-item svg {
    width: 100px;
    height: 100px;
  }

  table {
    font-size: 0.75rem;
  }

  input[type="number"],
  select {
    font-size: 0.75rem;
    padding: 0.2rem 0.15rem;
  }
}
