@font-face {
  font-family: "GothamPro";
  src: url("/assets/gothampro_bold.ttf") format("truetype");
  font-display: swap;
  font-style: normal;
  font-weight: 700;
}

:root {
  --bg: #070809;
  --panel: #101214;
  --panel-2: #15181b;
  --line: rgba(255, 255, 255, .9);
  --line-soft: rgba(255, 255, 255, .18);
  --text: #f6f7f8;
  --muted: #a8b0b8;
  --danger: #ff4d68;
  --accent: #f6c044;
  --radius: 14px;
  --radius-lg: 24px;
  --grid-line-half: 1px;
  --grid-line-size: 2px;
  --game-cell-alpha: .64;
  --game-logo-cell-top-alpha: 0;
  --player-cell-alpha: .002;
  --total-cell-alpha: .006;
  --table-scale: 1;
  --score-cell-size: clamp(72px, 7.8vw, 104px);
  --total-cell-width: clamp(92px, 9vw, 132px);
  --player-label-width: clamp(160px, 20vw, 260px);
  --table-text-shadow: 4px 5px 0 rgba(0, 0, 0, .7), 7px 9px 18px rgba(0, 0, 0, .76);
  --number-text-shadow: 3px 4px 0 rgba(0, 0, 0, .62), 4px 5px 9px rgba(0, 0, 0, .58);
  --text-outline: rgba(0, 0, 0, .82);
  font-family: "GothamPro", "Arial Black", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  position: relative;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  isolation: isolate;
  overflow-x: hidden;
  text-shadow:
    0 2px 0 rgba(0, 0, 0, .64),
    0 5px 14px rgba(0, 0, 0, .74);
}

body::before,
body::after {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
}

body::before {
  z-index: 0;
  inset: -48px;
  background: url("/assets/background.jpg") center / cover no-repeat;
  filter: blur(22px);
  opacity: .88;
  transform: scale(1.08);
}

body::after {
  z-index: 1;
  background:
    linear-gradient(rgba(7, 8, 9, .72), rgba(7, 8, 9, .82)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .02) 0 1px, transparent 1px 8px);
}

button,
input,
a {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

button:disabled {
  cursor: default;
  opacity: .48;
  transform: none;
}

.app-shell {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px;
}

.app-shell > main:not(.admin-layout) {
  display: grid;
  flex: 1;
  width: 100%;
  place-items: center;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, .86);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, #d7083a 0 24%, #236ad5 24% 49%, #78d93f 49% 73%, #f2a900 73% 100%);
  box-shadow: 0 0 24px rgba(246, 192, 68, .16);
}

.brand-kicker,
.brand-title {
  display: block;
}

.brand-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-title {
  overflow: hidden;
  color: var(--text);
  font-size: clamp(22px, 3vw, 36px);
  font-weight: 700;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.scale-control {
  display: grid;
  grid-template-columns: auto minmax(130px, 180px) 48px;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .055);
}

.scale-control-label,
.scale-value {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.scale-control-label {
  color: var(--muted);
  text-transform: uppercase;
}

.scale-slider {
  width: 100%;
  min-width: 0;
  accent-color: var(--accent);
}

.scale-value {
  text-align: right;
}

.muted-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.status-toast {
  position: fixed;
  z-index: 20;
  top: 22px;
  left: 50%;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 18px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: var(--radius);
  color: #fff;
  background: rgba(8, 10, 12, .88);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .42);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  text-shadow: 0 2px 5px rgba(0, 0, 0, .65);
  transform: translate(-50%, -12px);
  transition: opacity .22s ease, transform .22s ease, border-color .22s ease, background .22s ease;
}

.status-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.status-toast.status-success {
  border-color: rgba(76, 236, 132, .66);
  background: rgba(10, 55, 28, .92);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .42), 0 0 30px rgba(76, 236, 132, .24);
}

.status-toast.status-warning {
  border-color: rgba(246, 192, 68, .72);
  background: rgba(70, 49, 10, .92);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .42), 0 0 30px rgba(246, 192, 68, .22);
}

.status-toast.status-error {
  border-color: rgba(255, 77, 104, .72);
  background: rgba(72, 14, 25, .94);
  box-shadow: 0 14px 42px rgba(0, 0, 0, .42), 0 0 30px rgba(255, 77, 104, .24);
}

.solid-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease, opacity .16s ease;
}

.solid-button,
.ghost-button,
.danger-button {
  padding: 10px 14px;
}

.solid-button {
  border-color: rgba(246, 192, 68, .8);
  color: #141006;
  background: var(--accent);
  text-shadow: 0 1px 1px rgba(255, 255, 255, .24);
}

.solid-button.has-unsaved {
  border-color: rgba(85, 255, 135, .96);
  color: #031107;
  background: #49f071;
  box-shadow:
    0 0 0 1px rgba(85, 255, 135, .34),
    0 0 18px rgba(85, 255, 135, .74),
    0 0 42px rgba(85, 255, 135, .34);
  animation: save-button-pulse 1s ease-in-out infinite;
}

@keyframes save-button-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(85, 255, 135, .28),
      0 0 14px rgba(85, 255, 135, .55),
      0 0 34px rgba(85, 255, 135, .24);
  }

  50% {
    box-shadow:
      0 0 0 1px rgba(85, 255, 135, .48),
      0 0 26px rgba(85, 255, 135, .9),
      0 0 62px rgba(85, 255, 135, .46);
  }
}

.ghost-button {
  border-color: var(--line-soft);
  color: var(--text);
  background: rgba(255, 255, 255, .055);
}

.danger-button {
  border-color: rgba(255, 77, 104, .5);
  color: #ffdfe4;
  background: rgba(255, 77, 104, .1);
}

.icon-button {
  display: inline-grid;
  width: 40px;
  min-width: 40px;
  padding: 0;
  place-items: center;
  border-color: var(--line-soft);
  color: var(--text);
  background: rgba(255, 255, 255, .055);
}

.solid-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled),
.danger-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.admin-section {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  background: rgba(11, 13, 15, .76);
  box-shadow: 0 24px 90px rgba(0, 0, 0, .45);
}

.scoreboard-surface {
  padding: 0 0 28px;
  overflow: visible;
}

h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
}

.table-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 10px 0 4px;
}

.scoreboard-grid {
  position: relative;
  isolation: isolate;
  width: max-content;
  margin: 0 auto;
  padding-bottom: 64px;
  transform-origin: top center;
  zoom: var(--table-scale);
}

.scoreboard-grid::after {
  position: absolute;
  z-index: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 64px;
  background:
    radial-gradient(ellipse 34% 62% at 50% 0%, rgba(255, 255, 255, .62) 0%, rgba(255, 255, 255, .32) 30%, rgba(255, 255, 255, .1) 55%, rgba(255, 255, 255, 0) 76%),
    radial-gradient(ellipse 72% 78% at 50% 4%, rgba(255, 255, 255, .24) 0%, rgba(255, 255, 255, .09) 46%, rgba(255, 255, 255, 0) 78%);
  mix-blend-mode: screen;
  opacity: .96;
  pointer-events: none;
  content: "";
}

.games-strip,
.scoreboard-body {
  position: relative;
  z-index: 1;
}

.games-strip {
  display: grid;
  grid-template-columns: repeat(var(--game-count), var(--score-cell-size));
  margin: 0 0 0 calc(var(--player-label-width) + var(--grid-line-half));
}

.game-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--score-cell-size);
  height: var(--score-cell-size);
  min-height: 0;
  padding: 10px;
  border: 0;
  border-radius: 0;
  background: linear-gradient(to bottom, rgba(var(--game-rgb), var(--game-logo-cell-top-alpha)), rgba(var(--game-rgb), var(--game-cell-alpha)));
  box-shadow: none;
}

.game-card.has-title {
  align-content: center;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
}

.game-card:first-child {
  border-top-left-radius: 0;
}

.game-card:last-child {
  border-top-right-radius: 0;
}

.game-icon {
  width: min(var(--game-logo-size, 73px), calc(var(--score-cell-size) - 14px));
  height: min(var(--game-logo-size, 73px), calc(var(--score-cell-size) - 14px));
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
  transform: translateY(var(--game-logo-offset-y, 0px));
}

.game-card.has-title .game-icon {
  width: min(var(--game-logo-title-size, 62px), calc(var(--score-cell-size) - 22px));
  height: min(var(--game-logo-title-size, 62px), calc(var(--score-cell-size) - 22px));
  transform: translateY(calc(var(--game-logo-offset-y, 0px) - 3px));
}

.game-title {
  max-width: 100%;
  overflow: hidden;
  color: #fff;
  font-size: clamp(12px, 1.5vw, 18px);
  line-height: 1;
  text-align: center;
  -webkit-text-stroke: 0;
  text-overflow: ellipsis;
  text-shadow: none;
  text-stroke: 0;
  white-space: nowrap;
}

.scoreboard-body {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow: hidden;
  border: var(--grid-line-size) solid var(--line);
  border-radius: var(--radius-lg);
  background: transparent;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .1),
    0 26px 70px rgba(0, 0, 0, .65),
    0 0 38px rgba(255, 255, 255, .12);
  text-shadow: var(--table-text-shadow);
}

.player-labels {
  display: grid;
  flex: 0 0 var(--player-label-width);
  grid-auto-rows: var(--score-cell-size);
  width: var(--player-label-width);
  background: transparent;
}

.player-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--score-cell-size);
  padding: 10px 12px;
  border: 0;
  border-right: var(--grid-line-size) solid var(--line);
  border-bottom: var(--grid-line-size) solid var(--line);
  background: rgba(255, 255, 255, var(--player-cell-alpha));
  color: var(--text);
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.02;
  overflow-wrap: anywhere;
  text-align: center;
  -webkit-text-stroke: 1px var(--text-outline);
  text-shadow: var(--table-text-shadow);
  text-stroke: 1px var(--text-outline);
}

.player-label:first-child {
  border-radius: 0;
}

.player-label:last-child {
  border-bottom: 0;
  border-radius: 0;
}

.score-grid {
  display: grid;
  grid-auto-rows: var(--score-cell-size);
  grid-template-columns: repeat(var(--game-count), var(--score-cell-size)) var(--total-cell-width);
  background: transparent;
}

.score-cell,
.total-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--score-cell-size);
  height: var(--score-cell-size);
  min-height: 0;
  border-right: var(--grid-line-size) solid var(--line);
  border-bottom: var(--grid-line-size) solid var(--line);
  overflow: hidden;
}

.score-cell {
  background:
    linear-gradient(rgba(255, 255, 255, .1), rgba(0, 0, 0, .16)),
    #050607;
}

.score-cell::before {
  position: absolute;
  inset: 0;
  background: var(--game-color);
  content: "";
  opacity: var(--game-cell-alpha);
}

.total-cell {
  width: var(--total-cell-width);
  border-right: 0;
  color: #fff;
  background: rgba(255, 255, 255, var(--total-cell-alpha));
  font-size: clamp(33px, 4.5vw, 51px);
  font-weight: 700;
  text-align: center;
  -webkit-text-stroke: 1px var(--text-outline);
  text-shadow: var(--number-text-shadow);
  text-stroke: 1px var(--text-outline);
}

.player-label.is-last-row,
.score-cell.is-last-row,
.total-cell.is-last-row {
  border-bottom: 0;
}

.score-input {
  position: relative;
  z-index: 1;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  color: #fff;
  background: rgba(0, 0, 0, .14);
  font-size: clamp(33px, 4.5vw, 51px);
  font-weight: 700;
  text-align: center;
  -webkit-text-stroke: 1px var(--text-outline);
  text-shadow: var(--number-text-shadow);
  text-stroke: 1px var(--text-outline);
  outline: 2px solid transparent;
}

.score-input:focus {
  background: rgba(0, 0, 0, .24);
  outline-color: rgba(255, 255, 255, .82);
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.score-input[type="number"] {
  appearance: textfield;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 160px;
  padding: 24px;
  border: 1px dashed var(--line-soft);
  border-radius: var(--radius-lg);
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, .78fr) minmax(520px, 1.22fr);
  gap: 20px;
}

.admin-section {
  min-width: 0;
  padding: 20px;
}

.inline-form,
.game-form {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.inline-form {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.game-form {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  align-items: end;
}

.game-form .color-field,
.game-form .scale-field,
.game-form .offset-field {
  min-width: 92px;
}

.game-form .solid-button {
  align-self: end;
}

.field {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.row-input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  outline: 2px solid transparent;
}

.field input[type="file"],
.compact-file {
  color: transparent;
  font-size: 0;
}

.field input[type="file"]::file-selector-button,
.compact-file::file-selector-button {
  min-height: 30px;
  margin-right: 0;
  border: 0;
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, .22);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.field input {
  padding: 9px 10px;
}

.checkbox-field {
  align-self: stretch;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .04);
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.field input:focus,
.row-input:focus {
  border-color: rgba(246, 192, 68, .8);
  outline-color: rgba(246, 192, 68, .28);
}

.color-field input,
.compact-color,
.scale-field input,
.compact-scale,
.offset-field input,
.compact-offset {
  padding: 2px;
}

.rows-list {
  display: grid;
  gap: 0;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
}

.list-row,
.empty-row {
  display: grid;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .035);
}

.list-row:last-child,
.empty-row:last-child {
  border-bottom: 0;
}

.list-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.game-row {
  grid-template-columns: auto 52px minmax(180px, 1fr) 54px minmax(130px, .7fr) minmax(112px, .55fr) 74px 74px auto auto;
  min-width: 1020px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.order-actions {
  justify-content: flex-start;
}

.row-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.row-checkbox input {
  width: 18px;
  height: 18px;
}

.row-input {
  padding: 8px 10px;
}

.row-game-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  object-fit: contain;
  background: rgba(0, 0, 0, .24);
}

.compact-color {
  width: 54px;
  min-height: 40px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .06);
}

.compact-scale,
.compact-offset {
  width: 74px;
  min-height: 40px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(255, 255, 255, .06);
  text-align: center;
}

.compact-file {
  min-width: 0;
  color: var(--muted);
}

.compact-action {
  min-width: 74px;
}

.empty-row {
  color: var(--muted);
}

@media (max-width: 980px) {
  :root {
    --score-cell-size: 78px;
    --total-cell-width: 104px;
    --player-label-width: 180px;
  }

  .app-shell {
    padding: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .scale-control {
    grid-template-columns: auto minmax(120px, 1fr) 48px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .game-form,
  .game-row {
    grid-template-columns: 1fr;
  }

  .game-row {
    min-width: 0;
  }

  .row-actions {
    flex-wrap: wrap;
  }

  .row-game-icon {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 640px) {
  :root {
    --score-cell-size: 68px;
    --total-cell-width: 94px;
    --player-label-width: 150px;
  }

  .app-shell {
    padding: 14px;
  }

  .brand-title {
    max-width: 240px;
    font-size: 24px;
  }

  .scale-control {
    width: 100%;
  }

  .admin-section {
    padding: 14px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .inline-form .solid-button,
  .game-form .solid-button,
  .danger-button,
  .compact-action {
    width: 100%;
  }

  .empty-state {
    align-items: flex-start;
    flex-direction: column;
  }
}
