:root {
  --green-dark: #063d20;
  --green: #0a5c2f;
  --green-light: #147443;
  --cream: #f5f0df;
  --white: #ffffff;
  --red: #cb241d;
  --red-dark: #981915;
  --ink: #1a1a1a;
  --line: rgba(255, 255, 255, 0.2);
  --round-column-width: 52px;
  --side-control-space: 28px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  background:
    radial-gradient(circle at top, rgba(52, 139, 80, 0.55), transparent 45%),
    linear-gradient(160deg, var(--green-dark), #031e10);
  color: var(--white);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    12px
    max(24px, env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 3px;
  color: #d9efdb;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 7vw, 2.7rem);
  line-height: 0.95;
}

.new-game-button {
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

.new-game-button:active,
.side-add-button:active,
.action-button:active,
.player-name-button:active,
.round-name-button:active {
  transform: scale(0.95);
}

.score-workspace {
  position: relative;
  padding-left: var(--side-control-space);
  padding-right: var(--side-control-space);
}

.table-scroller {
  position: relative;
  overflow: auto;
  max-height: calc(100vh - 155px);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.16);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

.score-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.score-table th,
.score-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.score-table tr > *:last-child {
  border-right: 0;
}

.score-table thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #0a5c2f;
  color: var(--white);
  padding: 9px 3px;
}

.score-table thead th:first-child {
  z-index: 9;
}

.round-heading,
.round-cell,
.total-label {
  position: sticky;
  left: 0;
  width: var(--round-column-width);
  min-width: var(--round-column-width);
  max-width: var(--round-column-width);
}

.round-heading {
  background: #084624 !important;
}

.round-heading,
.total-label {
  font-size: 0.72rem !important;
  font-weight: 700 !important;
}

.round-cell {
  z-index: 4;
  background: #073d20;
  padding: 0;
}

.total-label {
  z-index: 9;
  background: var(--red-dark) !important;
  color: var(--white);
}

.player-name-button,
.round-name-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  font-weight: 900;
}

.player-name-button {
  min-height: 35px;
  padding: 4px 2px;
  font-size: 0.8rem;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-name-button {
  min-height: 60px;
  padding: 8px 2px;
  color: #d9efdb;
  font-size: 0.82rem;
}

.score-cell {
  background: rgba(255, 255, 255, 0.96);
  padding: 0;
}

.score-input {
  width: 100%;
  min-height: 60px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  padding: 8px 3px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
}

.score-input::placeholder {
  color: #aaa;
}

.score-input:focus {
  background: #fff5bb;
}

.score-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 7;
  background: var(--red);
  color: var(--white);
  padding: 10px 4px;
  font-size: 0.92rem;
  font-weight: 900;
}

.score-table tfoot td.total-label {
  z-index: 10;
}

.side-add-button {
  position: absolute;
  display: block;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--red);
  color: transparent;
  font-size: 0;
  line-height: 0;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.24);
  z-index: 20;
}

.side-add-button::before,
.side-add-button::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--white);
  transform: translate(-50%, -50%);
}

.side-add-button::after {
  transform: translate(-50%, -50%) rotate(90deg);
}

.add-player-button {
  top: 24px;
  right: 2px;
}

.add-round-button {
  left: 2px;
  top: 100px;
}

.action-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: end center;
}

.action-modal.hidden {
  display: none;
}

.action-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.action-dialog {
  position: relative;
  width: min(100%, 440px);
  border-radius: 22px 22px 0 0;
  background: #f8f8f8;
  color: #171717;
  padding: 20px 16px max(20px, env(safe-area-inset-bottom));
  box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.25);
}

.action-modal-type {
  margin: 0 0 4px;
  color: #666;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.action-dialog h2 {
  margin: 0 0 16px;
  font-size: 1.3rem;
}

.action-button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 12px;
  margin-top: 10px;
  padding: 13px;
  background: #e7e7e7;
  color: #171717;
  font-weight: 800;
}

.delete-action {
  background: #c82720;
  color: #ffffff;
}

.cancel-action {
  background: #ffffff;
  border: 1px solid #d2d2d2;
}

@media (min-width: 520px) {
  .app-shell {
    padding-left: 22px;
    padding-right: 22px;
  }

  .score-workspace {
    --side-control-space: 32px;
  }

  .side-add-button {
    width: 22px;
    height: 22px;
  }
}