/* Shared action sizing. Keep card buttons, navigation and draw tiles independent.
   Size declarations intentionally win over older module and inline overrides. */
:root {
  --button-height:34px;
  --button-padding-y:6px;
  --button-padding-x:12px;
  --button-font-size:12px;
  --button-radius:6px;
}

body :is(button.primary,button.secondary,.lesson-actions button) {
  box-sizing:border-box;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  height:auto !important;
  min-height:var(--button-height) !important;
  min-width:34px !important;
  max-width:100%;
  padding:var(--button-padding-y) var(--button-padding-x) !important;
  border-radius:var(--button-radius) !important;
  font-family:inherit;
  font-size:var(--button-font-size) !important;
  font-weight:500;
  line-height:18px !important;
  letter-spacing:0;
  white-space:normal;
  overflow-wrap:break-word;
  text-align:center;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}

body :is(button.primary,button.secondary,.lesson-actions button)[hidden] {
  display:none !important;
}

body :is(button.primary,button.secondary,.lesson-actions button):focus-visible {
  outline:2px solid var(--orange);
  outline-offset:2px;
}

.tournament-module .tournament-tabs {
  display:grid;
  grid-template-columns:repeat(6,minmax(0,1fr));
  width:100%;
  max-width:720px;
  gap:6px;
  align-items:stretch;
}
.tournament-module .tournament-tabs button {
  width:100%;
  min-width:0 !important;
  padding-inline:6px !important;
  white-space:nowrap;
}
.tournament-module .tournament-tabs button.is-active {
  font-weight:600;
  border-color:var(--orange);
  background:var(--action-hover);
}
.tournament-library .tournament-event-open {
  padding-top:54px;
}

@media(min-width:681px) and (max-width:1100px) {
  .tournament-module .tournament-tabs {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
}

@media(max-width:680px), (max-width:950px) and (hover:none) and (pointer:coarse) {
  :root {
    --button-height:44px;
    --button-padding-y:8px;
  }
  body :is(button.primary,button.secondary,.lesson-actions button) {
    min-width:44px !important;
  }
  .tournament-module .tournament-tabs {
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:6px;
    max-width:none;
    padding-bottom:12px;
  }
  .tournament-module .tournament-tabs button {
    min-width:0 !important;
  }
  .tournament-header {
    flex-wrap:wrap;
    gap:12px;
  }
  .tournament-header>div {
    flex:1 1 190px;
    min-width:0;
  }
  .tournament-library .tournament-event-open {
    padding-top:64px;
  }
  .tournament-category-actions,.tournament-actions,.tournament-match-save {
    gap:8px;
    align-items:stretch;
  }
  .tournament-category-actions>button,.tournament-actions>button {
    align-self:stretch;
  }
  .form-actions {
    flex-wrap:wrap;
    gap:8px;
  }
  .form-actions>button:is(.primary,.secondary) {
    flex:1 1 140px;
  }
  body .tournament-module .form-actions>button,
  body .tournament-dialog .form-actions>button {
    flex:1 1 140px;
  }
  body button:is([data-replacement-plus],[data-class-plus],[data-class-minus],[data-remove-member],.tournament-dialog-head [data-close]) {
    font-size:18px !important;
    width:44px;
    flex-shrink:0;
    padding-inline:6px !important;
  }
  body button[data-replacement-minus] {
    width:auto;
    white-space:nowrap;
  }
  body .compact-replacements summary {
    grid-template-columns:8px minmax(0,1fr) auto;
    grid-template-rows:auto auto;
  }
  body .compact-replacements summary::before {
    grid-column:1;
    grid-row:1 / 3;
  }
  body .compact-replacements summary>b {
    grid-column:2;
    grid-row:1;
  }
  body .compact-replacements summary>span:nth-of-type(1) {
    grid-column:2;
    grid-row:2;
  }
  body .compact-replacements summary>span:last-child {
    grid-column:3;
    grid-row:1 / 3;
  }
  .agenda-actions {
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    align-items:stretch;
    gap:8px;
  }
  body .agenda-actions button {
    height:100% !important;
    white-space:normal;
  }
  .lesson-actions {
    gap:6px;
  }
  body .theme {
    width:44px;
    height:44px;
    min-width:44px;
    min-height:44px;
    border-radius:var(--button-radius);
    touch-action:manipulation;
  }
  body .panel-head .link {
    min-height:44px;
    padding:4px 6px;
    touch-action:manipulation;
  }
  body .bulk:has(>#tabMens)>button:is(#tabMens,#tabCosts) {
    flex:1 1 0;
  }
}
