:root {
  --bg: #df181d;
  --surface: #1c1c20;
  --surface-2: #26262c;
  --text: #f2f2f4;
  --text-dim: #9a9aa2;
  --border: #34343c;
  --red: #d3212a;
  --red-dim: #7a1418;
  --green: #339841;
  --yellow: #ffc80f;
  --blue: #0561ab;
  --card-black: #000000;
  --radius: 10px;
  --btn-radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  padding: 16px;
  padding-bottom: 48px;
  max-width: 640px;
  margin: 0 auto;
}

.app-header {
  text-align: center;
  padding: 8px 0 20px;
}

.app-header h1 {
  margin: 0;
  font-size: 4.5rem;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--yellow);
  -webkit-text-stroke: 1px #ffffff;
  paint-order: stroke fill;
  text-shadow:
    -2px 2px 0 #000,
    -4px 4px 0 #000,
    -6px 6px 0 #000;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: var(--btn-radius);
  border: 8px solid #fff;
  background: var(--surface-2);
  color: #fff;
  font-weight: 700;
  text-shadow: 2px 2px 0 #000;
  padding: 10px 16px;
  transition: opacity 0.15s ease, transform 0.05s ease;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.65;
  filter: grayscale(35%);
  cursor: not-allowed;
}

button.primary {
  background: var(--yellow);
}

button.btn-green {
  background: var(--green);
}

button.btn-blue {
  background: var(--blue);
}

button.btn-red {
  background: var(--red);
}

button.btn-black {
  background: var(--card-black);
}

input[type="text"],
input[type="number"] {
  font: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
}

input[type="text"]:focus,
input[type="number"]:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

section {
  margin-bottom: 20px;
}

.add-player form {
  display: flex;
  gap: 8px;
}

.add-player input {
  flex: 1;
  min-width: 0;
  border: 8px solid #fff;
}

table#players-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
}

#players-table th,
#players-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

#players-table th {
  color: var(--text-dim);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

#players-table tbody tr:last-child td {
  border-bottom: none;
}

#players-table td.score {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.1rem;
}

#players-table tr.leader td.score {
  color: var(--green);
}

.remove-player-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 4px 8px;
  font-size: 1.1rem;
  line-height: 1;
}

.remove-player-btn:hover {
  color: var(--red);
}

.empty-state {
  color: var(--text-dim);
  text-align: center;
  padding: 16px;
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions button {
  flex: 1;
  min-width: 120px;
}

.history-section h2 {
  font-size: 1rem;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--yellow);
  -webkit-text-stroke: 1px #ffffff;
  paint-order: stroke fill;
  text-shadow:
    -1px 1px 0 #000,
    -2px 2px 0 #000,
    -3px 3px 0 #000;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  border: 8px solid #fff;
  border-radius: var(--btn-radius);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.history-item.color-green {
  background: var(--green);
}

.history-item.color-yellow {
  background: var(--yellow);
}

.history-item.color-blue {
  background: var(--blue);
}

.history-item.color-red {
  background: var(--red);
}

.history-item.color-black {
  background: var(--card-black);
}

.history-item .round-label {
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.history-item .round-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.history-item .round-scores span {
  white-space: nowrap;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

@media (min-width: 480px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: var(--green);
  border: 8px solid #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

@media (min-width: 480px) {
  .modal {
    border-radius: var(--radius);
  }
}

.modal h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.round-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.round-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.round-input-row label {
  flex: 1;
  font-weight: 500;
  color: #fff;
  text-shadow: 2px 2px 0 #000;
}

.round-input-row input {
  width: 100px;
  text-align: right;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.update-toast {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface-2);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 200;
}
