/* Sport Portal — referee console (coach / field referee UI) */

:root {
  --ref-bg: #eef2f7;
  --ref-surface: #ffffff;
  --ref-text: #0f172a;
  --ref-muted: #64748b;
  --ref-border: #e2e8f0;
  --ref-brand: #1f4eea;
  --ref-brand-dim: #1a3dc7;
  /* Фехтование: красный слева, зелёный справа */
  --ref-left: #dc2626;
  --ref-left-dim: #b91c1c;
  --ref-right: #16a34a;
  --ref-right-dim: #15803d;
  --ref-warn: #d97706;
  --ref-ok: #16a34a;
  --ref-shadow: 0 8px 32px rgba(15, 23, 42, 0.12);
  --ref-safe-bottom: env(safe-area-inset-bottom, 0px);
  --ref-safe-top: env(safe-area-inset-top, 0px);
  --ref-paused-opacity: 0.38;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
}

.ref-body--pult .ref-fencer-name {
  display: none;
}

.ref-body--pult .ref-apply-bar {
  display: none !important;
}

.ref-setting--pult-only.hidden {
  display: none;
}

.ref-header-action.is-on {
  background: var(--ref-brand);
  color: #fff;
  border-color: var(--ref-brand);
}

.ref-display-dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  max-width: min(92vw, 24rem);
  width: 100%;
  box-shadow: var(--ref-shadow);
}

.ref-display-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.ref-display-dialog__panel {
  padding: 1.25rem;
  display: grid;
  gap: 0.9rem;
}

.ref-display-dialog__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ref-display-dialog__title {
  margin: 0;
  font-size: 1.15rem;
}

.ref-display-close {
  border: 0;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.ref-display-hint {
  margin: 0;
  color: var(--ref-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.ref-display-qr {
  display: grid;
  place-items: center;
  padding: 0.75rem;
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  background: #fff;
  min-height: 12rem;
}

.ref-display-link-wrap {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--ref-muted);
}

.ref-display-link-wrap input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--ref-border);
  border-radius: 8px;
  font-size: 0.85rem;
}

.ref-display-viewers {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.ref-display-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.ref-body--pult .ref-setting--pult-only {
  display: flex;
}

.ref-body .site-nav + .ref-header {
  position: static;
}

.ref-body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--ref-bg);
  color: var(--ref-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
}

.ref-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: calc(0.55rem + var(--ref-safe-top)) 0.75rem 0.55rem;
  background: var(--ref-surface);
  border-bottom: 1px solid var(--ref-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.ref-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  min-width: 0;
}

.ref-back {
  color: var(--ref-brand);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 0.35rem 0;
}

.ref-header-center {
  display: flex;
  justify-content: center;
  min-width: 0;
}

.ref-timer-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.ref-timer-card {
  text-align: center;
  padding: 0.35rem 1rem;
  border-radius: 12px;
  background: rgba(31, 78, 234, 0.06);
  border: 1px solid var(--ref-border);
  min-width: 8.75rem;
  pointer-events: none;
  user-select: none;
}

.ref-timer-card.is-running {
  border-color: var(--ref-brand);
  box-shadow: 0 0 0 2px rgba(31, 78, 234, 0.2);
}

.ref-timer-card.is-low {
  border-color: var(--ref-warn);
  background: rgba(217, 119, 6, 0.12);
}

.ref-timer-card.is-final {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.1);
}

.ref-body--paused .ref-timer-card {
  opacity: 0.85;
}

.ref-time {
  font-size: clamp(1.75rem, 6vw, 2.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.ref-time--hundredths {
  letter-spacing: 0;
}

.ref-time-set {
  appearance: none;
  border: 1px solid var(--ref-border);
  background: var(--ref-surface);
  color: var(--ref-brand);
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 8px;
  min-height: 2.15rem;
  padding: 0 0.55rem;
  cursor: pointer;
  flex-shrink: 0;
}

.ref-time-set:active {
  transform: scale(0.97);
}

.ref-set-time-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 22rem;
  width: calc(100% - 1.5rem);
}

.ref-set-time-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.ref-set-time-dialog__panel {
  background: var(--ref-surface);
  border-radius: 16px;
  padding: 1rem 1rem 0.9rem;
  box-shadow: var(--ref-shadow);
}

.ref-set-time-dialog__title {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ref-text);
}

.ref-set-time-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.ref-set-time-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ref-muted);
}

.ref-set-time-field input {
  width: 100%;
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  padding: 0.65rem 0.4rem;
  color: var(--ref-text);
}

.ref-set-time-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.95rem;
}

.ref-period {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ref-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.ref-priority {
  margin-top: 0.2rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ref-warn);
  text-transform: uppercase;
}

.ref-priority.hidden {
  display: none;
}

.ref-start-bar {
  display: none;
}

.ref-timer-controls {
  border: 2px solid var(--ref-brand);
  border-radius: 16px;
  padding: 0.65rem 0.75rem;
  background: var(--ref-surface);
  box-shadow: var(--ref-shadow);
  flex-shrink: 0;
  width: 100%;
  position: relative;
  z-index: 1;
}

.ref-timer-controls .ref-start-bar-btn {
  width: 100%;
  max-width: none;
}

.ref-start-bar-btn {
  width: 100%;
  max-width: 28rem;
  min-height: clamp(3.5rem, 14vw, 4.75rem);
  padding: 0.85rem 1.5rem;
  border: none;
  border-radius: 16px;
  font: inherit;
  font-size: clamp(1.35rem, 5.5vw, 1.85rem);
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, var(--ref-brand) 0%, var(--ref-brand-dim) 100%);
  box-shadow: 0 8px 28px rgba(31, 78, 234, 0.35);
}

.ref-start-bar-btn--pause {
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 8px 28px rgba(217, 119, 6, 0.35);
}

.ref-start-bar-btn:active {
  transform: scale(0.98);
}

.ref-swap-top {
  display: block;
  width: min(100%, 16rem);
  min-height: 2.35rem;
  margin: 0 auto 0.35rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--ref-border);
  border-radius: 10px;
  background: var(--ref-surface);
  color: var(--ref-text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
  flex-shrink: 0;
}

.ref-swap-top:active {
  transform: scale(0.98);
}

.ref-body--paused .ref-swap-top {
  opacity: 1;
  pointer-events: auto;
}

.ref-fencer-action {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--ref-border);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
}

.ref-fencer-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.ref-fencer-foot {
  padding: 0.45rem;
  border-radius: 12px;
  border: 2px solid var(--ref-border);
  background: var(--ref-surface);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.ref-fencer-foot--left {
  border-top: 3px solid var(--ref-left);
}

.ref-fencer-foot--right {
  border-top: 3px solid var(--ref-right);
}

.ref-fencer-foot .ref-fencer-action {
  margin-top: 0;
}

.ref-fencer-action--mutual {
  background: var(--ref-bg);
  color: var(--ref-text);
}

.ref-fencer-action--priority {
  border-color: var(--ref-warn);
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.ref-header-action {
  border: 1px solid var(--ref-brand-dim);
  background: linear-gradient(180deg, var(--ref-brand) 0%, var(--ref-brand-dim) 100%);
  color: #fff;
  min-height: 2.35rem;
  padding: 0 0.65rem;
  border-radius: 10px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.ref-header-action--rules {
  border-color: rgba(217, 119, 6, 0.55);
  background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
}

.ref-header-action__icon {
  font-size: 0.95rem;
  line-height: 1;
}

.ref-header-action__text {
  line-height: 1.1;
}

/* Penalty chart dialog */
.ref-penalty-dialog {
  margin: auto;
  padding: 0;
  border: none;
  max-width: none;
  max-height: none;
  width: 100%;
  height: 100%;
  background: transparent;
}

.ref-penalty-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.ref-penalty-dialog__panel {
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 720px);
  width: min(100%, 28rem);
  margin: max(0.75rem, var(--ref-safe-top)) auto 0.75rem;
  background: var(--ref-surface, #fff);
  border: 1px solid var(--ref-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22);
  overflow: hidden;
}

.ref-penalty-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem 0.35rem;
  border-bottom: 1px solid var(--ref-border);
}

.ref-penalty-dialog__head-main {
  min-width: 0;
  flex: 1;
}

.ref-penalty-dialog__title {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
}

.ref-penalty-back {
  display: block;
  margin: 0 0 0.15rem;
  padding: 0;
  border: none;
  background: none;
  color: var(--ref-brand);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}

.ref-penalty-back.hidden {
  display: none;
}

.ref-penalty-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--ref-border);
  border-radius: 10px;
  background: var(--ref-bg, #f8fafc);
  color: var(--ref-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.ref-penalty-disclaimer {
  margin: 0;
  padding: 0.55rem 0.85rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--ref-muted);
  background: rgba(217, 119, 6, 0.08);
  border-bottom: 1px solid rgba(217, 119, 6, 0.15);
}

.ref-penalty-search-wrap {
  padding: 0.65rem 0.85rem 0.35rem;
}

.ref-penalty-search {
  width: 100%;
  box-sizing: border-box;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--ref-border);
  border-radius: 10px;
  font: inherit;
  font-size: 0.92rem;
  background: #fff;
}

.ref-penalty-search-hint {
  margin: 0.3rem 0 0;
  font-size: 0.68rem;
}

.ref-penalty-body {
  padding: 0.35rem 0.85rem 0.85rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.ref-penalty-section-label {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ref-muted);
}

.ref-penalty-cats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.ref-penalty-cat {
  min-height: 3rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}

.ref-penalty-cat:active {
  transform: scale(0.98);
}

.ref-penalty-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ref-penalty-list--compact .ref-penalty-item {
  padding: 0.45rem 0;
}

.ref-penalty-item {
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--ref-border);
}

.ref-penalty-item:last-child {
  border-bottom: none;
}

.ref-penalty-item__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
}

.ref-penalty-item__label {
  flex: 1;
  min-width: 0;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
}

.ref-penalty-item__penalty {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
  white-space: nowrap;
}

.ref-penalty-empty {
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--ref-muted);
  text-align: center;
}

.ref-bout-meta {
  margin: 0;
  padding: 0.35rem 1rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ref-muted);
}

.ref-live-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 0.75rem;
  margin: 0;
  padding: 0.35rem 1rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #15803d;
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.12), transparent);
  border-bottom: 1px solid rgba(22, 163, 74, 0.2);
}

.ref-live-badge.hidden {
  display: none;
}

.ref-live-badge__dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  animation: ref-live-pulse 1.4s ease-in-out infinite;
}

@keyframes ref-live-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
}

.ref-live-badge__link {
  color: var(--ref-brand);
  text-decoration: none;
  font-weight: 800;
}

.ref-live-badge__link:hover {
  text-decoration: underline;
}

.ref-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem 0;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.ref-fencers {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto;
  gap: 0.35rem;
  align-items: stretch;
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
}

.ref-fencer-col--left {
  grid-column: 1;
  grid-row: 1;
}

.ref-vs {
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  padding-top: 4.5rem;
  font-size: 2rem;
  font-weight: 800;
  color: var(--ref-muted);
  opacity: 0.5;
}

.ref-fencer-col--right {
  grid-column: 3;
  grid-row: 1;
}

.ref-fencer-col--left,
.ref-fencer-col--right {
  align-self: stretch;
}

.ref-fencer {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  padding: 0.65rem;
  border-radius: 16px;
  background: var(--ref-surface);
  border: 2px solid var(--ref-border);
  box-shadow: var(--ref-shadow);
  min-width: 0;
}

.ref-fencer--left {
  border-top: 4px solid var(--ref-left);
}

.ref-fencer--right {
  border-top: 4px solid var(--ref-right);
}

.ref-fencer.is-winner {
  border-color: var(--ref-ok);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.25), var(--ref-shadow);
  opacity: 1 !important;
}

.ref-fencer.is-priority {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.14);
  box-shadow:
    0 0 0 4px rgba(245, 158, 11, 0.55),
    0 0 28px rgba(245, 158, 11, 0.35),
    var(--ref-shadow);
}

.ref-score-touch.has-priority {
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.85),
    0 0 0 4px #fbbf24;
}

.ref-score-touch-priority {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  line-height: 1.1;
}

.ref-score-touch-priority.hidden {
  display: none;
}

.ref-score-touch-priority-p {
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.ref-score-touch-priority-word {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.95;
}

.ref-score-touch-label.hidden {
  display: none;
}

.ref-fencer-label {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ref-muted);
  text-align: center;
}

.ref-fencer-name {
  margin: 0;
  font-size: clamp(0.85rem, 3.2vw, 1.05rem);
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  min-height: 2.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ref-pcards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.3rem;
  min-height: 1.25rem;
}

.ref-card-ind {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
}

.ref-card-ind--y {
  background: #eab308;
  border: 1px solid #ca8a04;
}

.ref-card-ind--r {
  background: #ef4444;
  border: 1px solid #dc2626;
}

.ref-score-touch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  width: 100%;
  min-height: clamp(5rem, 28vw, 7.5rem);
  padding: 0.5rem 0.35rem;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: #fff;
  touch-action: manipulation;
}

.ref-score-touch--left {
  background: linear-gradient(180deg, var(--ref-left) 0%, var(--ref-left-dim) 100%);
}

.ref-score-touch--right {
  background: linear-gradient(180deg, var(--ref-right) 0%, var(--ref-right-dim) 100%);
}

.ref-score-touch-num {
  font-size: clamp(3.25rem, 17vw, 5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ref-score-touch-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.92;
}

.ref-adj {
  width: 100%;
  min-height: 2.5rem;
  border-radius: 10px;
  border: 1px solid var(--ref-border);
  background: var(--ref-bg);
  color: var(--ref-text);
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
}

.ref-adj--minus {
  margin-top: 0.4rem;
}

.ref-score-touch:active:not(:disabled),
.ref-adj:active:not(:disabled),
.ref-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.ref-body--paused .ref-score-touch {
  opacity: 0.48;
  filter: grayscale(1);
}

.ref-body--paused .ref-score-correct {
  opacity: 1;
  pointer-events: auto;
}

.ref-card-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.35rem;
}

.ref-card-btn {
  min-height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--ref-border);
  font-weight: 800;
  font-size: 0.78rem;
  cursor: pointer;
  background: var(--ref-bg);
  color: var(--ref-text);
}

.ref-card-btn:disabled,
.ref-card-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ref-card-btn--y {
  border-color: #eab308;
  color: #a16207;
  background: rgba(234, 179, 8, 0.12);
}

.ref-card-btn--y:disabled,
.ref-card-btn--y.is-disabled {
  background: rgba(234, 179, 8, 0.28);
}

.ref-card-btn--r {
  border-color: #ef4444;
  color: #b91c1c;
  background: rgba(239, 68, 68, 0.1);
}

.ref-card-btn--k {
  border-color: #0f172a;
  color: #f8fafc;
  background: #0f172a;
}

.ref-card-ind--k {
  background: #0f172a;
  border: 1px solid #334155;
}

.ref-reset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
}

.ref-reset-bar .ref-btn {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.8rem;
  padding: 0 0.45rem;
}

.ref-btn--priority {
  border-color: var(--ref-warn);
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.ref-body--paused .ref-reset-bar {
  opacity: 1;
  pointer-events: auto;
}

.ref-always-active,
.ref-body--paused .ref-always-active {
  opacity: 1;
  pointer-events: auto;
}

.ref-body--paused .ref-settings,
.ref-body--paused .ref-apply-bar {
  opacity: 1;
  pointer-events: auto;
}

.ref-btn {
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: 12px;
  border: 1px solid var(--ref-border);
  background: var(--ref-surface);
  color: var(--ref-text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.ref-btn--pause {
  min-width: 8rem;
  font-size: 1.05rem;
}

.ref-btn--primary {
  background: linear-gradient(180deg, #d97706 0%, #b45309 100%);
  border-color: #b45309;
  color: #fff;
}

.ref-btn--muted {
  background: var(--ref-bg);
}

.ref-btn--apply {
  width: 100%;
  min-height: 3.25rem;
  font-size: 1.05rem;
  background: linear-gradient(180deg, var(--ref-ok) 0%, #15803d 100%);
  border-color: #15803d;
  color: #fff;
}

.ref-btn--apply:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ref-body--paused .ref-btn--apply {
  opacity: 1;
  pointer-events: auto;
}

.ref-settings {
  border: 1px solid var(--ref-border);
  border-radius: 12px;
  background: var(--ref-surface);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.ref-settings summary {
  cursor: pointer;
  font-weight: 700;
  padding: 0.25rem 0;
}

.ref-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0;
  border-top: 1px solid var(--ref-border);
}

.ref-setting:first-of-type {
  border-top: none;
}

.ref-setting select {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--ref-border);
  background: var(--ref-bg);
  color: var(--ref-text);
}

.ref-period-ctrl {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ref-period-ctrl .ref-adj {
  min-height: 2rem;
  min-width: 2rem;
  font-size: 1rem;
}

.ref-period-ctrl span {
  font-weight: 800;
  min-width: 1.25rem;
  text-align: center;
}

.ref-apply-bar {
  flex-shrink: 0;
  padding: 0.35rem 0.75rem calc(0.55rem + var(--ref-safe-bottom));
  background: var(--ref-surface);
  border-top: 1px solid var(--ref-border);
  box-shadow: 0 -2px 14px rgba(15, 23, 42, 0.06);
  z-index: 12;
}

.ref-winner {
  text-align: center;
  margin: 0 0 0.45rem;
  font-weight: 700;
  color: var(--ref-ok);
}

.ref-winner.hidden {
  display: none;
}

.ref-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1rem + var(--ref-safe-bottom));
  transform: translateX(-50%);
  max-width: min(92vw, 24rem);
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  z-index: 100;
  pointer-events: none;
}

.ref-toast.hidden {
  display: none;
}

.hint {
  color: var(--ref-muted);
}

@media (orientation: landscape) and (max-height: 520px) {
  .ref-main {
    gap: 0.35rem;
    padding-top: 0.25rem;
  }

  .ref-fencers {
    gap: 0.5rem;
  }

  .ref-fencer {
    padding: 0.45rem;
    gap: 0.3rem;
  }

  .ref-score-touch {
    min-height: clamp(3.5rem, 18vh, 5rem);
  }

  .ref-score-touch-num {
    font-size: clamp(2.25rem, 12vh, 3.25rem);
  }

  .ref-settings {
    display: none;
  }

  .ref-vs {
    padding-top: 0;
  }
}

@media (min-width: 521px) {
  .ref-main {
    gap: 0.75rem;
    max-width: 720px;
  }

  .ref-fencers {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
  }

  .ref-vs {
    display: none;
  }

  .ref-fencer-col--left {
    grid-column: 1;
  }

  .ref-fencer-col--right {
    grid-column: 2;
  }

  .ref-timer-controls {
    margin-top: 0.15rem;
  }

  .ref-start-bar-btn {
    min-height: 3.5rem;
    font-size: 1.45rem;
  }
}

@media (min-width: 720px) {
  .ref-fencers {
    gap: 1rem;
  }

  .ref-fencer {
    padding: 1rem;
  }
}

/* На пульте на телефоне убираем верхнее меню — есть «← Пулькa» */
@media (max-width: 700px) {
  .ref-body .site-nav {
    display: none;
  }
}

/* Телефон: компактнее и всё влезает без лишней прокрутки */
@media (max-width: 520px) {
  .ref-body .site-nav__inner {
    height: 48px;
    padding: 0 0.65rem;
    gap: 0.35rem;
  }

  .ref-body .site-nav__brand {
    font-size: 0.92rem;
    gap: 0.4rem;
  }

  .ref-body .site-nav__logo {
    width: 30px;
    height: 30px;
  }

  .ref-body .site-nav__actions {
    gap: 0.35rem;
  }

  .ref-body .site-nav__link {
    font-size: 0.72rem;
  }

  .ref-header {
    grid-template-columns: minmax(0, auto) 1fr minmax(0, auto);
    grid-template-rows: auto;
    gap: 0.35rem;
    padding: calc(0.45rem + var(--ref-safe-top)) 0.65rem 0.45rem;
  }

  .ref-header-actions {
    gap: 0.25rem;
  }

  .ref-back {
    grid-column: auto;
    grid-row: auto;
    font-size: 0.82rem;
    min-width: 0;
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .ref-header-action {
    grid-column: auto;
    grid-row: auto;
    justify-self: end;
    align-self: center;
    min-height: 2rem;
    padding: 0 0.45rem;
    font-size: 0.72rem;
  }

  .ref-header-action__text {
    display: none;
  }

  .ref-header-action--rules .ref-header-action__text {
    display: none;
  }

  .ref-penalty-dialog__panel {
    width: calc(100% - 1rem);
    max-height: 90vh;
  }

  .ref-penalty-cats {
    grid-template-columns: 1fr;
  }

  .ref-header-center {
    grid-column: auto;
    grid-row: auto;
    justify-self: center;
  }

  .ref-timer-wrap {
    gap: 0.25rem;
  }

  .ref-timer-card {
    min-width: 0;
    width: auto;
    max-width: none;
    padding: 0.2rem 0.65rem;
  }

  .ref-time-set {
    min-height: 1.9rem;
    font-size: 0.68rem;
    padding: 0 0.4rem;
  }

  .ref-time {
    font-size: clamp(1.55rem, 8vw, 2rem);
  }

  .ref-bout-meta,
  .ref-live-badge {
    padding: 0.15rem 0.65rem;
    font-size: 0.7rem;
    line-height: 1.25;
  }

  .ref-live-badge {
    padding-bottom: 0.35rem;
  }

  .ref-main {
    gap: 0.35rem;
    padding: 0.3rem 0.55rem 0.25rem;
  }

  .ref-fencers {
    gap: 0.2rem;
    flex: 0 0 auto;
    min-height: 0;
  }

  .ref-swap-top {
    min-height: 2rem;
    margin-bottom: 0;
    padding: 0.3rem 0.65rem;
    font-size: 0.76rem;
  }

  .ref-fencer-label {
    font-size: 0.58rem;
    letter-spacing: 0.05em;
  }

  .ref-fencer {
    padding: 0.45rem;
    gap: 0.3rem;
    border-radius: 12px;
  }

  .ref-fencer-name {
    min-height: 1.6em;
    font-size: 0.8rem;
  }

  .ref-vs {
    align-self: center;
    padding-top: 0;
    font-size: 1.25rem;
  }

  .ref-score-touch {
    min-height: clamp(3.35rem, 20vw, 4.75rem);
    border-radius: 12px;
    padding: 0.35rem 0.25rem;
  }

  .ref-score-touch-num {
    font-size: clamp(2.25rem, 13vw, 3.15rem);
  }

  .ref-adj {
    min-height: 1.9rem;
    margin-top: 0.3rem;
    font-size: 1.05rem;
  }

  .ref-card-btn {
    min-height: 1.75rem;
    font-size: 0.78rem;
  }

  .ref-timer-controls {
    padding: 0.35rem 0.5rem;
    border-radius: 12px;
  }

  .ref-start-bar-btn {
    min-height: 2.75rem;
    font-size: 1.05rem;
    padding: 0.45rem 0.85rem;
    border-radius: 12px;
  }

  .ref-reset-bar {
    gap: 0.25rem;
  }

  .ref-reset-bar .ref-btn {
    min-height: 2.15rem;
    font-size: 0.68rem;
    padding: 0 0.3rem;
  }

  .ref-settings {
    padding: 0.28rem 0.5rem;
    font-size: 0.74rem;
  }

  .ref-btn--apply {
    min-height: 2.65rem;
    font-size: 0.9rem;
  }

  .ref-apply-bar {
    padding: 0.3rem 0.55rem calc(0.45rem + var(--ref-safe-bottom));
  }
}

/* Низкий экран телефона — ещё компактнее */
@media (max-width: 520px) and (max-height: 820px) {
  .ref-fencer-name {
    min-height: 1.1em;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .ref-fencer {
    padding: 0.35rem;
    gap: 0.22rem;
  }

  .ref-score-touch {
    min-height: clamp(3rem, 18vw, 4.15rem);
  }

  .ref-score-touch-num {
    font-size: clamp(2rem, 11.5vw, 2.75rem);
  }

  .ref-score-touch-label {
    font-size: 0.62rem;
  }

  .ref-start-bar-btn {
    min-height: 2.5rem;
    font-size: 1rem;
  }
}

/* Очень низкий экран (iPhone SE, ландшафт) — ещё компактнее */
@media (max-width: 520px) and (max-height: 740px) {
  .ref-fencer-name {
    min-height: 1.15em;
    font-size: 0.72rem;
    line-height: 1.15;
  }

  .ref-vs {
    padding-top: 0;
  }

  .ref-score-touch {
    min-height: clamp(2.85rem, 17vw, 3.85rem);
  }

  .ref-score-touch-num {
    font-size: clamp(1.85rem, 10.5vw, 2.65rem);
  }

  .ref-settings {
    display: none;
  }
}

.ref-tournament-queue {
  margin: 0 0.75rem 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: rgba(31, 78, 234, 0.08);
  border: 1px solid rgba(31, 78, 234, 0.18);
}

.ref-tournament-queue__now {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.35;
}

.ref-tournament-queue__next {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
}
