:root {
  --bg-top: #f4efe4;
  --bg-bottom: #d9e5d2;
  --card: rgba(255, 250, 242, 0.88);
  --ink: #21312b;
  --muted: #5d6d65;
  --line: rgba(33, 49, 43, 0.14);
  --green: #24553f;
  --green-soft: #dfeccc;
  --red-soft: #f3c9c9;
  --white-soft: #e3e7eb;
  --win-soft: #dcebbf;
  --lose-soft: #d9e2f2;
  --white-win-soft: #ece7dc;
  --shadow: 0 18px 60px rgba(34, 50, 41, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Zen Kaku Gothic New", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.9),
      transparent 30%
    ),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

button,
input,
select {
  font: inherit;
}

textarea {
  font: inherit;
}

.page-shell {
  width: min(1100px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.hero-card,
.toolbar-card,
.board-card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 20px;
  padding: 28px;
}

.eyebrow,
.toolbar-label,
.status-label {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
}

.hero-card h1,
.toolbar-card h2,
.board-header h2 {
  margin: 0;
  line-height: 1.2;
}

.hero-card h1 {
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.hero-description,
.hero-status p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.hero-status {
  padding: 20px;
  border-radius: 22px;
  background: linear-gradient(
    135deg,
    rgba(36, 85, 63, 0.96),
    rgba(63, 121, 94, 0.85)
  );
  color: #f7f5ef;
  align-self: stretch;
}

.hero-status .status-label {
  color: rgba(255, 255, 255, 0.72);
}

.hero-status strong {
  display: block;
  font-size: 1.5rem;
}

.toolbar-card,
.board-card {
  margin-top: 18px;
  padding: 22px;
}

.toolbar-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.event-title-input {
  width: min(100%, 520px);
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: clamp(1.15rem, 3vw, 1.9rem);
  font-weight: 700;
  line-height: 1.2;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(33, 49, 43, 0.08);
}

.event-title-input:focus {
  box-shadow:
    inset 0 0 0 2px rgba(36, 85, 63, 0.25),
    0 0 0 4px rgba(36, 85, 63, 0.08);
}

.toolbar-actions {
  display: flex;
  gap: 12px;
}

.primary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}

.primary-button {
  background: var(--green);
  color: #fffdf6;
}

.ghost-button {
  background: rgba(36, 85, 63, 0.08);
  color: var(--green);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.score-pills {
  display: flex;
  gap: 12px;
}

.score-pill {
  min-width: 92px;
  padding: 10px 14px;
  border-radius: 18px;
  text-align: center;
}

.score-pill span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.score-pill strong {
  display: block;
  font-size: 1.6rem;
}

.score-pill.red {
  background: rgba(243, 201, 201, 0.72);
}

.score-pill.white {
  background: rgba(227, 231, 235, 0.95);
}

.table-wrap {
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.match-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.7);
}

.match-table th,
.match-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.actions-header,
.actions-cell {
  width: 84px;
  min-width: 84px;
  text-align: center;
}

.winner-header,
.result-cell {
  width: 112px;
  min-width: 112px;
}

.match-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #2f6f57, #285844);
  color: #fffdf8;
  font-size: 0.95rem;
  text-align: left;
  white-space: nowrap;
}

.rule-header,
.rule-cell {
  width: 72px;
  min-width: 72px;
  font-weight: 700;
}

.rule-cell {
  white-space: nowrap;
}

.actions-cell {
  background: rgba(255, 255, 255, 0.58);
}

.actions-cell.muted,
.team-cell.muted {
  background: rgba(255, 255, 255, 0.42);
}

.row-action-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease;
}

.row-action-button + .row-action-button {
  margin-left: 6px;
}

.row-action-button.plus {
  background: rgba(36, 85, 63, 0.14);
  color: var(--green);
}

.row-action-button.minus {
  background: rgba(182, 70, 70, 0.14);
  color: #9c3d3d;
}

.row-action-button:hover {
  transform: translateY(-1px);
}

.row-action-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.team-cell {
  min-width: 148px;
}

.team-red {
  background: rgba(243, 201, 201, 0.65);
}

.team-white {
  background: rgba(227, 231, 235, 0.94);
}

.player-input,
.result-select {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  outline: none;
}

.player-pair {
  display: grid;
  gap: 8px;
}

.player-split-input {
  border-radius: 18px;
}

.player-input[readonly] {
  background: transparent;
  text-align: center;
  font-weight: 700;
}

.result-select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(33, 49, 43, 0.7) 50%),
    linear-gradient(135deg, rgba(33, 49, 43, 0.7) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) calc(50% - 1px),
    calc(100% - 11px) calc(50% - 1px);
  background-size:
    5px 5px,
    5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}

.result-select.is-red {
  background-color: rgba(243, 201, 201, 0.9);
}

.result-select.is-white {
  background-color: rgba(227, 231, 235, 0.95);
}

.summary-chip {
  border-radius: 999px;
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  background: rgba(36, 85, 63, 0.1);
}

.summary-chip.white {
  background: rgba(34, 77, 140, 0.12);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  background: rgba(33, 49, 43, 0.9);
  color: #fff;
  box-shadow: var(--shadow);
  animation: fade-slide 2.4s ease forwards;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes fade-slide {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  12%,
  80% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (max-width: 900px) {
  .hero-card,
  .toolbar-card,
  .board-header {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions,
  .score-pills {
    width: 100%;
  }

  .toolbar-actions button,
  .score-pills .score-pill {
    flex: 1;
  }

  .event-title-input {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 8px, 100%);
    padding-top: 16px;
  }

  .hero-card,
  .toolbar-card,
  .board-card {
    padding: 8px;
    border-radius: 24px;
  }

  .match-table {
    min-width: 0;
    table-layout: fixed;
    font-size: 0.78rem;
  }

  .table-wrap {
    overflow: hidden;
  }

  .match-table th,
  .match-table td {
    padding: 2px;
  }

  .match-table th {
    font-size: 0.72rem;
  }

  .actions-header,
  .actions-cell {
    width: 40px;
    min-width: 40px;
    text-align: center;
  }

  .rule-header,
  .rule-cell {
    width: 50px;
    min-width: 50px;
    font-size: 0.7rem;
    line-height: 1.2;
  }

  .rule-cell {
    white-space: normal;
    word-break: break-word;
  }

  .winner-header,
  .result-cell {
    width: 68px;
    min-width: 68px;
  }

  .team-cell {
    min-width: 96px;
  }

  .row-action-button {
    width: 18px;
    height: 18px;
    font-size: 0.72rem;
  }

  .row-action-button + .row-action-button {
    margin-left: 2px;
  }

  .player-input,
  .result-select {
    padding: 7px 8px;
    font-size: 0.76rem;
  }

  .result-select {
    padding-right: 22px;
    background-position:
      calc(100% - 12px) calc(50% - 1px),
      calc(100% - 8px) calc(50% - 1px);
    background-size:
      4px 4px,
      4px 4px;
  }

  .player-pair {
    gap: 5px;
  }

  .player-split-input {
    border-radius: 14px;
  }

  .player-input {
    text-overflow: ellipsis;
  }

  .summary-chip {
    padding: 8px 6px;
    font-size: 0.74rem;
  }

  .score-pills {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
