:root {
  --bg: #1a1b18;
  --panel: #f1f2ef;
  --ink: #171512;
  --muted: #171512;
  --line: rgba(212, 201, 180, 0.05);
  --primary: #0b7a43;
  --primary-dark: #064f2b;
  --dart-red: #b92722;
  --dart-red-dark: #841914;
  --dart-black: #151512;
  --wire: #b9b4aa;
  --bracket-line: rgba(0, 0, 0, 0.82);
  --blue-panel: rgba(241, 242, 239, 0.62);
  --blue-surface: rgba(247, 248, 245, 0.56);
  --blue-surface-strong: rgba(247, 248, 245, 0.78);
  --soft: #e3e7df;
  --warn: #fff7e6;
  --warn-text: #704c00;
  --loss: #fae4de;
  --loss-text: #8f1f19;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background-color: #11120f;
  background-image:
    linear-gradient(rgba(9, 10, 8, 0.12), rgba(9, 10, 8, 0.22)),
    url("assets/background.png?v=5");
  background-position: center top, center top;
  background-repeat: no-repeat, repeat-x;
  background-size: auto, auto 100%;
  background-attachment: fixed, scroll;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.secondary {
  border: 1px solid var(--line);
  background: var(--blue-surface-strong);
  color: var(--primary-dark);
}

button.danger {
  border: 1px solid rgba(185, 39, 34, 0.36);
  background: var(--loss);
  color: var(--loss-text);
}

button.player-button {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  background: var(--blue-surface-strong);
  color: var(--ink);
  font-size: 1rem;
  text-align: left;
  font-weight: 800;
  line-height: 1.25;
}

button.player-button.winner {
  border-color: rgba(11, 122, 67, 0.45);
  background: var(--soft);
  color: var(--primary-dark);
}

button.player-button.loser {
  border-color: rgba(185, 39, 34, 0.3);
  background: var(--loss);
  color: var(--loss-text);
  text-decoration: line-through;
}

button.player-button.bye {
  color: var(--muted);
  font-style: italic;
}

button:focus-visible,
input:focus,
textarea:focus {
  outline: 3px solid rgba(11, 122, 67, 0.28);
  outline-offset: 2px;
}

.app {
  width: min(100%, 1180px);
  margin: 0 auto 0 0;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
  color: #fffaf0;
}

.qr-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 18px 22px;
  align-items: center;
  width: min(100%, 860px);
  margin: 0 auto 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  padding: 16px;
}

.qr-copy {
  display: grid;
  gap: 6px;
  text-align: left;
  justify-items: start;
}

.qr-copy h2 {
  margin: 0;
  font-size: 1.15rem;
}

.qr-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.qr-code {
  display: block;
  width: 240px;
  height: 240px;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

.qr-actions {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.lod-code-text {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 160px;
  text-align: center;
}

.landing-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  width: min(100%, 720px);
  margin: 9vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  padding: 20px;
}

.landing-copy {
  display: grid;
  gap: 8px;
  max-width: 420px;
}

.landing-copy h1 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.8rem);
}

.landing-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.landing-qr {
  display: block;
  width: 256px;
  height: 256px;
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
}

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

.lod-link-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: #78c89a;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 8vw, 3.2rem);
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.panel,
.bracket-shell {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(5px);
  padding: clamp(16px, 4vw, 24px);
}

.bracket-shell {
  border-top: 4px solid var(--primary);
}

.panel {
  border-top: 4px solid var(--dart-red);
}

.panel-title,
.bracket-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.panel-title p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.step-label {
  margin: 0 0 4px;
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tools-title {
  margin: 0;
  color: #fffaf0;
  font-size: 1.15rem;
}

.panel.tool-panel {
  padding: 0;
  overflow: hidden;
}

.tool-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  color: var(--ink);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 900;
  list-style: none;
}

.tool-panel > summary::-webkit-details-marker {
  display: none;
}

.tool-panel > summary::after {
  content: "+";
  color: var(--primary-dark);
  font-size: 1.35rem;
  line-height: 1;
}

.tool-panel[open] > summary {
  border-bottom: 1px solid var(--line);
}

.tool-panel[open] > summary::after {
  content: "-";
}

.tool-body {
  padding: clamp(14px, 3vw, 20px);
}

.top-workspace {
  display: grid;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
  width: calc(100vw - 36px);
}

.setup-stack {
  display: grid;
  gap: 36px;
}

.setup-stack .panel,
.top-side-stack {
  display: grid;
  gap: 18px;
}

.top-workspace .out-shot-panel,
.top-side-stack .panel {
  margin-bottom: 0;
}

.bracket-workspace {
  display: grid;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
  width: calc(100vw - 36px);
}

.bracket-workspace .bracket-shell,
.bracket-workspace .out-shot-panel,
.bracket-workspace .mystery-out-card {
  margin-bottom: 0;
}

.bracket-side-stack {
  display: grid;
  gap: 18px;
}

.redraw-warning {
  margin-bottom: 14px;
  border: 1px solid #e3b44a;
  border-radius: 8px;
  background: var(--warn);
  color: var(--warn-text);
  padding: 12px;
  font-weight: 900;
  line-height: 1.35;
}

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

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  padding: 12px;
}

input {
  min-height: 48px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.45;
}

.player-list-label {
  margin-top: 14px;
}

.team-draw-warning {
  display: block;
  border: 2px solid #d59600;
  border-radius: 8px;
  background: var(--warn);
  color: var(--warn-text);
  padding: 14px;
  font-size: clamp(1.15rem, 4vw, 1.7rem);
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
}

.name-editor {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 14px;
}

.name-editor-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.name-editor-title h3 {
  margin: 0;
  font-size: 1rem;
}

.name-editor-title button {
  min-height: 40px;
}

.name-list {
  display: grid;
  gap: 9px;
  max-height: 340px;
  overflow: auto;
  padding-right: 4px;
}

.name-row {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 9px;
  align-items: center;
}

.name-row span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.name-row input {
  min-height: 42px;
}

.empty-names {
  margin: 0;
  color: var(--muted);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.single-action {
  grid-template-columns: 1fr;
}

.message {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--warn-text);
  font-weight: 800;
}

.groups {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.groups.empty,
.bracket.empty {
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.group-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 14px;
}

.group-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.team-members {
  margin: 0;
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.4;
}

.champion {
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--dart-black);
  color: #fffaf0;
  padding: 8px 12px;
  font-weight: 900;
}

.bracket {
  display: grid;
  gap: 32px;
}

.bracket-section {
  min-width: 0;
  border-radius: 8px;
  background: rgba(16, 17, 14, 0.18);
  padding: 14px;
}

.bracket-section h3 {
  margin: 0 0 12px;
  color: #fffaf0;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rounds {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 290px;
  gap: 46px;
  overflow-x: auto;
  padding: 8px 18px 20px 0;
  align-items: start;
}

.round {
  position: relative;
  display: grid;
  align-content: start;
  gap: 20px;
  padding-top: 12px;
}

.round:nth-of-type(2) {
  padding-top: 46px;
}

.round:nth-of-type(3) {
  padding-top: 104px;
}

.round:nth-of-type(4) {
  padding-top: 172px;
}

.round:not(:last-child)::after {
  display: none;
}

.round-title {
  margin: 0 0 2px;
  border-bottom: 1px solid rgba(255, 250, 240, 0.22);
  color: #fffaf0;
  font-size: 0.98rem;
  font-weight: 900;
  padding-bottom: 7px;
  text-transform: uppercase;
}

.final-section .round {
  width: min(100%, 280px);
}

.final-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

.final-match-block {
  display: grid;
  gap: 10px;
}

.final-match-block + .final-match-block {
  margin-top: 14px;
}

.champion-box {
  min-width: 0;
  border: 2px solid rgba(11, 122, 67, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(127, 195, 255, 0.72), rgba(165, 216, 255, 0.58));
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.14);
  padding: 16px;
}

.champion-box.winner {
  border-color: rgba(11, 122, 67, 0.72);
  background:
    linear-gradient(180deg, rgba(216, 239, 224, 0.96), rgba(227, 244, 233, 0.88));
}

.champion-box.winner .champion-box-name,
.champion-box.winner .champion-box-title {
  color: var(--primary-dark);
}

.champion-box-title {
  margin: 0 0 10px;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.champion-box-game {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.champion-box-name {
  color: var(--ink);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1.1;
  word-break: break-word;
}

.champion-box-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.match {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  padding: 12px;
  margin-bottom: 10px;
}

.match::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -28px;
  width: 28px;
  border-top: 2px solid rgba(0, 0, 0, 0.45);
  transform: translateY(-50%);
}

.round:last-child .match::after {
  display: none;
}

.match-advance {
  animation: match-advance 850ms ease-out;
}

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

.match-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.board-assignment-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.board-assignment-select {
  min-width: 124px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-weight: 900;
}

.match-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
}

.match-meta {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.3;
}

.pdf-visual-section {
  border: 1px solid #d7d2c8;
  background: #f7f4ee;
  overflow: hidden;
  padding: 12px;
}

.pdf-visual-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  border-bottom: 2px solid #111;
  background: #ffffff;
  margin-bottom: 0;
  padding: 10px 14px 8px;
  color: #111;
}

.pdf-visual-heading h3 {
  margin: 0 0 2px;
  color: #111;
  font-size: 1.25rem;
  letter-spacing: 0;
  text-transform: none;
}

.pdf-visual-heading p,
.pdf-visual-heading span {
  margin: 0;
  color: #222;
  font-size: 0.84rem;
  font-weight: 900;
}

.pdf-visual-scroll {
  border: 1px solid #111;
  border-top: 0;
  background: #ffffff;
  overflow-x: auto;
}

.pdf-visual-grid {
  display: grid;
  grid-template-rows: minmax(460px, auto) minmax(430px, auto) auto;
  gap: 0;
  min-width: max(100%, calc(var(--pdf-columns, 6) * 315px + 340px));
  background: #ffffff;
  color: #111;
  padding: 10px;
}

.pdf-visual-band {
  display: grid;
  gap: 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.winner-band {
  border-bottom: 2px solid #111;
  padding-bottom: 28px;
}

.loser-band {
  padding-top: 28px;
  padding-bottom: 24px;
}

.pdf-band-title {
  margin: 0;
  color: #111;
  font-size: 0.9rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: none;
}

.pdf-visual-columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 290px;
  gap: 48px;
  align-items: stretch;
}

.pdf-visual-column {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 260px;
}

.pdf-column-matches {
  display: grid;
  align-content: space-around;
  gap: clamp(28px, calc(220px / var(--match-count, 1)), 82px);
  min-height: max(290px, calc(var(--match-count, 1) * 132px));
}

.winner-column {
  padding-top: calc(var(--column-index, 0) * 34px);
}

.loser-column {
  padding-top: calc(var(--column-index, 0) * 20px);
}

.pdf-visual-column.grey-column {
  border: 1px solid #b8b8b8;
  background: repeating-linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.08),
    rgba(0, 0, 0, 0.08) 8px,
    rgba(0, 0, 0, 0.03) 8px,
    rgba(0, 0, 0, 0.03) 16px
  );
  padding-inline: 8px;
}

.pdf-visual-column.grey-column .round-title {
  color: #555;
}

.pdf-visual-section .round-title {
  color: #111;
  border-bottom-color: #111;
  font-size: 0.82rem;
}

.final-band .pdf-visual-columns {
  grid-auto-columns: 320px;
}

.final-band {
  border-top: 2px solid #111;
  padding-top: 12px;
}

.final-column {
  display: grid;
  gap: 18px;
  min-height: 0;
}

.pdf-visual-section .match {
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
  margin-bottom: 0;
  padding: 0;
}

.pdf-visual-section .match-header {
  min-height: 20px;
  margin-bottom: 6px;
}

.pdf-visual-section .match-title {
  color: #111;
  font-size: 0.68rem;
}

.pdf-visual-section .match-meta {
  display: none;
}

.pdf-visual-section .match-tools {
  display: none;
}

.pdf-visual-section .slots {
  gap: 0;
}

.pdf-visual-section button.player-button {
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid #111;
  border-radius: 0;
  background: #ffffff;
  color: #111;
  padding: 0 4px;
  font-size: 0.86rem;
  opacity: 1;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.pdf-visual-section button.player-button + button.player-button {
  margin-top: 6px;
}

.pdf-visual-section button.player-button:not(:disabled):hover,
.pdf-visual-section button.player-button:not(:disabled):focus-visible {
  border-bottom-color: var(--primary);
  background: #e9f4ee;
  color: var(--primary-dark);
}

.pdf-visual-section button.player-button.winner {
  border-bottom-color: var(--primary-dark);
  background: #dfeee5;
  color: var(--primary-dark);
}

.pdf-visual-section button.player-button.loser {
  border-bottom-color: var(--dart-red);
  background: #f7e8e5;
  color: var(--loss-text);
}

.pdf-visual-section .reset-match {
  min-height: 24px;
  border: 1px solid #111;
  border-radius: 0;
  background: #ffffff;
  color: #111;
  padding: 0 7px;
  font-size: 0.68rem;
}

.pdf-visual-section .match::after {
  right: -18px;
  width: 18px;
  border-color: #111;
}

.pdf-visual-section .final-column .match::after,
.pdf-visual-column:last-child .match::after {
  display: none;
}

.pdf-visual-section .champion-box {
  border: 2px solid #111;
  background: #ffffff;
  box-shadow: none;
}

.pdf-visual-section .champion-box.winner {
  border-color: rgba(11, 122, 67, 0.72);
  background: #dfeee5;
}

.pdf-mirror-panel {
  border-top-color: var(--primary);
}

.pdf-layout-select {
  min-width: 132px;
  color: var(--ink);
  font-size: 0.84rem;
}

.pdf-layout-select select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
  font-weight: 900;
}

.pdf-column-mirror {
  display: grid;
  gap: 14px;
}

.pdf-mirror-meta,
.pdf-final-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 12px;
}

.pdf-mirror-meta strong,
.pdf-final-row span {
  font-weight: 900;
}

.pdf-mirror-meta span {
  color: var(--muted);
  font-weight: 800;
}

.pdf-mirror-grid {
  display: grid;
  gap: 14px;
}

.pdf-column-group {
  min-width: 0;
  border-radius: 8px;
  background: rgba(16, 17, 14, 0.15);
  padding: 12px;
}

.pdf-column-group h3 {
  margin: 0 0 10px;
  color: #fffaf0;
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pdf-columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(132px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.pdf-column {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 10px;
}

.pdf-column p {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.pdf-games {
  display: grid;
  gap: 7px;
}

.pdf-games span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  font-weight: 900;
}

.reset-match {
  min-height: 32px;
  border: 1px solid var(--line);
  background: var(--blue-surface-strong);
  color: var(--primary-dark);
  padding: 0 10px;
  font-size: 0.78rem;
}

.slots {
  display: grid;
  gap: 7px;
}

.waiting {
  color: var(--muted);
}

button.player-button.source-slot {
  font-style: italic;
}

button.player-button.winner-source {
  color: var(--dart-red) !important;
  font-weight: 900 !important;
}

button.player-button.winner-source:disabled {
  opacity: 1;
}

button.player-button .winner-source-text {
  color: var(--dart-red) !important;
  font-weight: 900 !important;
}

button.player-button.loser-source:disabled {
  opacity: 1;
}

button.player-button .loser-source-text {
  color: #00548b !important;
  font-weight: 900 !important;
}

.out-shot-sheet {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.out-shot-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 74px 84px;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 8px;
}

.out-shot-row.out-shot-winner {
  border-color: rgba(17, 126, 67, 0.72);
  background: rgba(216, 239, 224, 0.92);
}

.out-shot-number {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--primary-dark);
  font-weight: 900;
}

.out-shot-row label {
  font-size: 0.86rem;
}

.out-shot-row input {
  min-height: 38px;
  padding: 8px;
}

.out-shot-status {
  min-height: 38px;
  display: grid;
  place-items: center;
  color: #117e43;
  font-size: 0.8rem;
  font-weight: 950;
  text-transform: uppercase;
}

.out-shot-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.dice-roller {
  display: grid;
  gap: 14px;
}

.dice-roller-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dice-roller-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.dice-total {
  border-radius: 999px;
  background: var(--soft);
  color: var(--primary-dark);
  padding: 7px 10px;
  font-weight: 900;
}

.dice-tray {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: center;
}

.die-button {
  display: grid;
  gap: 8px;
  place-items: center;
  justify-self: center;
  width: 100%;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  padding: 18px;
  transition: transform 160ms ease, filter 160ms ease;
}

.die-button:hover {
  filter: brightness(1.04);
  transform: translateY(-2px);
}

.die-steel {
  border-color: rgba(20, 20, 18, 0.32);
  background:
    linear-gradient(135deg, rgba(255, 245, 210, 0.86), rgba(37, 36, 32, 0.16)),
    repeating-linear-gradient(28deg, rgba(37, 36, 32, 0.08) 0 1px, transparent 1px 7px),
    rgba(239, 223, 178, 0.82);
  color: #171512;
}

.die-soft {
  border-color: rgba(0, 84, 139, 0.34);
  background:
    radial-gradient(circle, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 8px),
    linear-gradient(135deg, rgba(0, 92, 166, 0.78), rgba(11, 122, 67, 0.66)),
    rgba(18, 26, 32, 0.86);
  background-size: 12px 12px, auto, auto;
  color: #f7fbff;
}

.die-button.rolling {
  animation: d20-roll 620ms cubic-bezier(0.22, 0.8, 0.28, 1);
}

.die-label {
  color: currentColor;
  opacity: 0.72;
  font-size: 0.88rem;
  font-weight: 900;
  text-transform: uppercase;
}

.die-value {
  font-size: 3.25rem;
  line-height: 1;
  font-weight: 900;
}

.mystery-out-card {
  display: grid;
  gap: 14px;
  text-align: center;
}

.mystery-out-heading h3 {
  margin: 0;
  font-size: 1rem;
}

.mystery-out-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mystery-out-mode {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.mystery-out-mode input {
  width: auto;
  min-height: 0;
}

.mystery-out-value {
  display: grid;
  place-items: center;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(185, 39, 34, 0.24), rgba(11, 122, 67, 0.22)),
    var(--blue-surface);
  color: var(--dart-black);
  font-size: 3.4rem;
  font-weight: 900;
  line-height: 1;
}

.mystery-out-actions {
  display: grid;
  gap: 10px;
}

.mystery-out-winner {
  display: grid;
  gap: 8px;
  min-height: 92px;
  border: 1px solid rgba(11, 122, 67, 0.34);
  border-radius: 8px;
  background: rgba(225, 242, 230, 0.9);
  padding: 12px;
  text-align: left;
}

.mystery-out-winner.no-winner {
  border-color: rgba(185, 39, 34, 0.34);
  background: rgba(248, 230, 228, 0.94);
}

.mystery-out-winner-title {
  color: var(--primary-dark);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.1;
  text-transform: uppercase;
}

.mystery-out-winner.no-winner .mystery-out-winner-title {
  color: var(--loss-text);
}

.mystery-out-winner-body {
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 800;
  line-height: 1.35;
}

.payout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.payout-grid label:last-child {
  grid-column: 1 / -1;
}

.payout-grid select {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
  font-weight: 900;
}

#clearPayout {
  width: 100%;
  margin-top: 10px;
}

.payout-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.payout-percent-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 10px;
}

.payout-percent-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.payout-percent-title strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.payout-percent-title span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-align: right;
}

.payout-percent-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.payout-percent-inputs label {
  gap: 4px;
  font-size: 0.78rem;
}

.payout-percent-inputs input {
  min-height: 38px;
  padding: 8px;
}

.payout-summary div,
.payout-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 10px;
}

.payout-summary span,
.payout-row span,
.payout-row small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.payout-summary strong {
  display: block;
  color: var(--primary-dark);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1.1;
}

.payout-results {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.payout-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.payout-row strong {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 900;
}

.payout-empty {
  margin: 0;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 12px;
  text-align: center;
  font-weight: 900;
}

@keyframes d20-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }

  24% {
    transform: rotate(46deg) scale(1.08);
  }

  52% {
    transform: rotate(-28deg) scale(0.96);
  }

  78% {
    transform: rotate(19deg) scale(1.04);
  }

  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes match-advance {
  0% {
    border-color: rgba(11, 122, 67, 0.35);
    box-shadow: 0 0 0 rgba(11, 122, 67, 0);
    transform: scale(1);
  }

  38% {
    border-color: rgba(11, 122, 67, 0.9);
    box-shadow: 0 0 0 7px rgba(11, 122, 67, 0.18);
    transform: scale(1.025);
  }

  100% {
    border-color: var(--line);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
    transform: scale(1);
  }
}

.backup-list {
  display: grid;
  gap: 10px;
}

.backup-history {
  margin-top: 12px;
}

.backup-history summary,
.name-backup-history summary {
  cursor: pointer;
  color: var(--primary-dark);
  font-weight: 900;
}

.backup-history .backup-list,
.name-backup-history .backup-list {
  margin-top: 12px;
}

.name-backup-history {
  margin-top: 12px;
}

.backup-actions {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.paper-backup {
  max-height: 280px;
  overflow: auto;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface-strong);
  color: var(--ink);
  padding: 12px;
  font: 0.92rem/1.45 "Courier New", monospace;
  white-space: pre-wrap;
}

.backup-list.empty {
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  padding: 16px;
  text-align: center;
}

.backup-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--blue-surface);
  padding: 12px;
}

.backup-item strong,
.backup-item span,
.backup-item small {
  display: block;
}

.backup-item span,
.backup-item small {
  color: var(--muted);
  line-height: 1.35;
}

.backup-item-actions {
  display: grid;
  gap: 8px;
}

.backup-item button {
  min-height: 40px;
}

@media (min-width: 680px) {
  .top-workspace {
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 28px;
  }

  .setup-stack {
    grid-template-columns: minmax(0, 0.95fr) minmax(280px, 0.9fr) minmax(280px, 0.9fr);
    column-gap: 56px;
    row-gap: 36px;
    align-items: start;
    margin-top: 42px;
  }

  .setup-grid {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .actions {
    grid-template-columns: 1fr 1fr;
  }

  .single-action {
    grid-template-columns: 1fr;
  }

  .groups {
    grid-template-columns: repeat(2, 1fr);
  }

  .name-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .backup-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .pdf-mirror-grid {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

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

  .out-shot-actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1040px) {
  .bracket-workspace {
    grid-template-columns: minmax(0, 1fr) 440px;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 10px;
  }

  .topbar,
  .panel-title,
  .bracket-heading {
    display: grid;
  }

  .panel,
  .bracket-shell {
    box-shadow: none;
  }

  .champion {
    width: fit-content;
  }

  .backup-item {
    grid-template-columns: 1fr;
  }

  .backup-item button {
    width: 100%;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  body * {
    visibility: hidden;
  }

  #paperBackup,
  #paperBackup * {
    visibility: visible;
  }

  #paperBackup {
    position: absolute;
    inset: 0;
    max-height: none;
    overflow: visible;
    border: 0;
    padding: 0;
    font-size: 11pt;
  }
}

@media (max-width: 900px) {
  .app {
    width: 100%;
    padding: 12px;
    display: grid;
    gap: 18px;
  }

  .topbar,
  .panel-title,
  .bracket-heading,
  .dice-roller-heading,
  .name-editor-title {
    grid-template-columns: 1fr;
    display: grid;
    gap: 10px;
    align-items: start;
  }

  .champion {
    justify-self: start;
  }

  .top-workspace,
  .bracket-workspace,
  .setup-stack,
  .top-side-stack {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .lod-link-group {
    justify-content: flex-start;
  }

  .qr-panel {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    width: min(100%, 720px);
  }

  .qr-copy {
    justify-items: center;
    text-align: center;
  }

  .qr-actions {
    width: 100%;
  }

  .qr-actions button {
    width: min(100%, 240px);
  }

  .lod-code-text {
    width: min(100%, 240px);
  }

  .landing-panel {
    display: grid;
    justify-content: center;
    width: 100%;
    margin-top: 18px;
  }

  .landing-qr {
    width: 272px;
    height: 272px;
  }

  .qr-code {
    width: 280px;
    height: 280px;
  }

  .top-workspace,
  .bracket-workspace {
    display: contents;
  }

  .setup-stack {
    order: 1;
  }

  .bracket-shell {
    order: 2;
  }

  .bracket-side-stack {
    order: 3;
  }

  .tools-stack {
    order: 4;
  }

  .backups-panel {
    order: 5;
  }

  .bracket-workspace {
    width: 100%;
  }

  .top-workspace {
    width: 100%;
  }

  .setup-grid,
  .actions,
  .out-shot-actions,
  .backup-actions,
  .mystery-out-actions {
    grid-template-columns: 1fr;
  }

  .rounds {
    grid-auto-columns: 220px;
    gap: 18px;
    padding-bottom: 10px;
  }

  .qr-panel {
    width: 100%;
  }

  .bracket-section {
    padding: 10px;
  }

  .match {
    padding: 8px;
  }

  .match-header {
    grid-template-columns: 1fr;
    display: grid;
    gap: 6px;
    align-items: start;
  }

  .reset-match {
    justify-self: start;
  }

  .out-shot-row {
    grid-template-columns: 30px 1fr;
  }

  .out-shot-row label:nth-of-type(2),
  .out-shot-status {
    grid-column: 1 / -1;
  }

  .dice-tray,
  .mystery-out-modes {
    grid-template-columns: 1fr;
  }

  .die-button {
    min-height: 96px;
  }

  .mystery-out-value {
    min-height: 78px;
    font-size: 2.6rem;
  }
}

@media (max-width: 600px) {
  h1 {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
  }

  h2 {
    font-size: 1.05rem;
  }

  .panel,
  .bracket-shell {
    padding: 12px;
    border-radius: 6px;
  }

  .rounds {
    grid-auto-columns: 200px;
    gap: 14px;
  }

  .round-title {
    font-size: 0.78rem;
  }

  .match-title,
  .match-meta {
    font-size: 0.74rem;
  }

  button,
  input,
  textarea {
    font-size: 16px;
  }

  .team-members {
    font-size: 1rem;
  }

  .die-value {
    font-size: 2.5rem;
  }

  .champion {
    padding: 7px 10px;
    font-size: 0.9rem;
  }
}
