:root {
  --bg: #f6f1e6;
  --ink: #1f1b16;
  --muted: #6f6256;
  --accent: #d47532;
  --panel: #fffaf2;
  --border: #d7c8b8;
  --grid: #b7a594;
  --chip: #f1e1cf;
  --chip-active: #1f1b16;
  --chip-active-text: #fffaf2;
  --shadow: 0 8px 24px rgba(31, 27, 22, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 600px at 20% -10%, #f1e5d4 0%, transparent 60%),
              radial-gradient(1200px 600px at 90% -20%, #edd4c1 0%, transparent 55%),
              var(--bg);
  color: var(--ink);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  position: sticky;
  top: 0;
  background: rgba(246, 241, 230, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.logo {
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.3px;
}

nav {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-weight: 600;
  color: var(--muted);
}

nav a {
  text-decoration: none;
  color: inherit;
  padding: 6px 10px;
  border-radius: 8px;
}

nav a.active {
  color: var(--ink);
  background: var(--chip);
}

main {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

.submenu {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: #efe4d4;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 14px;
  align-items: center;
  justify-content: center;
}

.submenu-item {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font: inherit;
}

.submenu-item.active {
  background: var(--chip);
  color: var(--ink);
  border-color: var(--border);
}

.submenu-item:focus-visible {
  outline: none;
  border-color: var(--ink);
}

.filters {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.filters-label {
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.3px;
}

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

.chip {
  padding: 8px 14px;
  background: var(--chip);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  font: inherit;
  width: 62px;
  text-align: center;
}

.chip.active {
  background: var(--chip-active);
  color: var(--chip-active-text);
  border-color: var(--chip-active);
}

.section-title {
  margin: 24px 0 12px;
  font-family: "Fraunces", serif;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.groups {
  display: grid;
  gap: 18px;
}

.hidden {
  display: none;
}

.group-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.date {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.date-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.group-title {
  font-weight: 700;
  margin-bottom: 12px;
  font-size: 16px;
  letter-spacing: 0.3px;
}

.match-row {
  font-size: 13px;
}

.match-title {
  font-weight: 600;
}

.match-field {
  display: grid;
  grid-template-columns: 30px 1fr 30px;/*28px 1fr 28px;*/
  align-items: center;
  gap: 8px;
  /*background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;*/
}

.match-field .date-value,
.match-field .time-value,
.match-field .court-value {
  text-align: center;
  font-weight: 700;
}

.schedule-grid {
  display: grid;
  gap: 12px;
}

.schedule-field {
  display: grid;
  gap: 6px;
}

.schedule-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
}

.match-table .match-title {
  text-align: left;
}

.ctrl-btn {
  border: 1px solid var(--border);
  background: #fffaf2;
  border-radius: 8px;
  height: 28px;
  cursor: pointer;
  font-weight: 700;
}

.ctrl-btn:hover,
.ctrl-btn:focus-visible {
  background: var(--chip);
  outline: none;
}

.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.matrix th,
.matrix td {
  border: 1px solid var(--grid);
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

.matrix thead th {
  background: #f2e7d7;
  font-weight: 600;
}

.matrix tbody th {
  text-align: left;
  background: #f6ebdb;
  font-weight: 600;
}

.matrix td.diag {
  background: #d9c8b6;
  color: #6d5d4f;
  font-weight: 600;
}

.matrix td:not(.diag),
.match-row {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.context-menu {
  position: fixed;
  min-width: 180px;
  background: #fffaf2;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 6px;
  display: none;
  z-index: 100;
}

.context-menu.visible {
  display: grid;
  gap: 4px;
}

.context-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: var(--chip);
  outline: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal.visible {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 27, 22, 0.35);
}

.modal-card {
  position: relative;
  width: min(720px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(31, 27, 22, 0.18);
  padding: 18px;
  display: grid;
  gap: 14px;
  z-index: 1;
}

.modal-title {
  margin: 0 34px 0 0;
  font-family: "Fraunces", serif;
  font-size: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 0;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: var(--chip);
  outline: none;
}

.modal-body {
  overflow-x: auto;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.score-table th,
.score-table td {
  border: 1px solid var(--grid);
  padding: 8px;
  text-align: center;
}

.score-table thead th {
  background: #f2e7d7;
  font-weight: 600;
}

.score-table tbody th {
  text-align: left;
  background: #f6ebdb;
  font-weight: 600;
}

.score-cell {
  display: grid;
  grid-template-columns: 28px 1fr 28px;
  align-items: center;
  gap: 8px;
}

.score-btn {
  border: 1px solid var(--border);
  background: #fffaf2;
  border-radius: 8px;
  height: 28px;
  cursor: pointer;
  font-weight: 700;
}

.score-btn:hover,
.score-btn:focus-visible {
  background: var(--chip);
  outline: none;
}

.score-val {
  font-weight: 700;
}

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

.btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  background: #fffaf2;
}

.btn.secondary:hover,
.btn.secondary:focus-visible {
  background: var(--chip);
  outline: none;
}

.btn.primary {
  background: var(--ink);
  color: #fffaf2;
  border-color: var(--ink);
}

.btn.primary:hover,
.btn.primary:focus-visible {
  background: #2a241e;
  outline: none;
}

@media (min-width: 900px) {
  .groups {
    grid-template-columns: 1fr 1fr;
  }
}
