.admin-editor {
  --admin-roster-gap: 12px;
  --admin-bench-width: 190px;
  --admin-drop-accent: #c9a25e;
  --admin-drop-surface: rgba(201, 162, 94, .09);
  --admin-chip-surface: #17110c;
}

.admin-edit-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(201, 162, 94, .4);
  border-radius: 50%;
  background: rgba(18, 12, 8, .88);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .28);
  color: #d8b46f;
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease, transform .18s ease;
}

.admin-edit-button:hover,
.admin-edit-button:focus-visible {
  border-color: rgba(236, 203, 136, .82);
  background: #711914;
  color: #fff1d6;
  outline: 0;
  transform: translateY(-1px);
}

.admin-edit-button svg { width: 16px; height: 16px; pointer-events: none; }
.admin-edit-button--small { width: 28px; height: 28px; }
.admin-edit-button--small svg { width: 13px; height: 13px; }

.admin-edit-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-edit-heading h1,
.admin-edit-heading h3 { margin-block: 0; }
.evening-record__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.evening-record__games > .admin-edit-button { margin-left: -4px; }

.admin-editor {
  width: min(780px, calc(100vw - 32px));
  max-height: min(88vh, 920px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(201, 162, 94, .52);
  border-radius: 6px;
  background: #100c09;
  box-shadow: 0 34px 110px rgba(0, 0, 0, .74);
  color: #e9ddca;
}

.admin-editor--game { width: min(1120px, calc(100vw - 24px)); }
.admin-editor::backdrop { background: rgba(3, 2, 1, .78); backdrop-filter: blur(5px); }
.admin-editor[open] { animation: admin-editor-in .18s ease-out; }

@keyframes admin-editor-in {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.admin-editor__header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 66px;
  padding: 15px 18px 15px 22px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(201, 162, 94, .22);
  background: rgba(16, 12, 9, .98);
}

.admin-editor__title {
  margin: 0;
  color: #f0dec0;
  font-family: 'Oswald', sans-serif;
  font-size: 21px;
  letter-spacing: .025em;
  text-transform: uppercase;
}

.admin-editor__close {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #bfae97;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
}

.admin-editor__close:hover,
.admin-editor__close:focus-visible { background: rgba(201, 162, 94, .1); color: #fff0d3; outline: 0; }

.admin-editor__form {
  max-height: calc(min(88vh, 920px) - 66px);
  padding: 22px;
  overflow-y: auto;
}

.admin-editor__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.admin-editor--game .admin-editor__grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.admin-editor__field {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: #d1c0aa;
  font-size: 13px;
}

.admin-editor__field--wide { grid-column: 1 / -1; }
.admin-editor__field > span { font-weight: 700; letter-spacing: .035em; }

.admin-editor input,
.admin-editor select,
.admin-editor textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid rgba(201, 162, 94, .3);
  border-radius: 3px;
  background: #0a0806;
  color: #f0e6d7;
  font: inherit;
  color-scheme: dark;
}

.admin-editor textarea { min-height: 92px; resize: vertical; }
.admin-editor input:focus,
.admin-editor select:focus,
.admin-editor textarea:focus { border-color: #c9a25e; outline: 2px solid rgba(201, 162, 94, .14); }

.admin-editor__actions {
  position: sticky;
  bottom: -22px;
  z-index: 2;
  display: flex;
  margin: 22px -22px -22px;
  padding: 16px 22px;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid rgba(201, 162, 94, .22);
  background: rgba(16, 12, 9, .98);
}

.admin-editor--game .admin-editor__actions {
  position: static;
  margin-top: 18px;
}

.admin-editor__status {
  min-height: 20px;
  margin: 18px 0 0;
  color: #cfb77f;
  font-size: 14px;
}

.admin-editor__status[data-state="error"] { color: #ff9189; }
.admin-editor__status[data-state="success"] { color: #a8d6a1; }

.admin-editor__button {
  display: inline-flex;
  min-height: 43px;
  padding: 10px 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(201, 162, 94, .44);
  border-radius: 3px;
  background: transparent;
  color: #d8c5a8;
  cursor: pointer;
  font-family: 'Oswald', sans-serif;
  font-size: 13px;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.admin-editor__button--primary { background: linear-gradient(180deg, #8c1f19, #5a110d); color: #fff0d6; }
.admin-editor__button:hover { border-color: #d8b46f; color: #fff4df; }
.admin-editor__button:disabled { cursor: wait; opacity: .55; }

.admin-roster {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 4px 0 0;
  padding: 0;
  border: 0;
}

.admin-roster > legend {
  margin-bottom: 12px;
  color: #e7d1ab;
  font-family: 'Oswald', sans-serif;
  font-size: 18px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.admin-roster__hint { margin: -6px 0 13px; color: #9f907d; font-size: 13px; }
.admin-roster__hint[data-state="error"] { color: #ff9189; }
.admin-roster__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--admin-bench-width);
  gap: var(--admin-roster-gap);
  align-items: start;
}
.admin-seat-table {
  overflow: hidden;
  border: 1px solid rgba(201, 162, 94, .18);
  border-radius: 3px;
  background: rgba(255, 255, 255, .012);
}

.admin-seat-list { display: grid; }

.admin-seat-list__header,
.admin-seat {
  display: grid;
  grid-template-columns: 46px minmax(132px, 1.25fr) minmax(98px, .72fr) 68px 58px minmax(130px, 1fr);
  gap: 7px;
  align-items: center;
}

.admin-seat-list__header {
  min-height: 34px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(201, 162, 94, .22);
  color: #aa9679;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .075em;
  text-transform: uppercase;
}

.admin-seat {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(201, 162, 94, .12);
}

.admin-seat:last-child { border-bottom: 0; }
.admin-seat:focus { outline: 1px solid rgba(201, 162, 94, .42); outline-offset: -1px; }
.admin-seat.is-dragging { opacity: .45; }
.admin-seat.is-drop-target {
  box-shadow: inset 0 2px 0 var(--admin-drop-accent);
  background: var(--admin-drop-surface);
}
.admin-seat__position { display: flex; align-items: center; justify-content: center; }
.admin-seat__number {
  width: 24px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d6ad67;
  cursor: default;
  font-family: 'Oswald', sans-serif;
  font-size: 16px;
}
.admin-roster__layout:has(.admin-bench__player.is-selected) .admin-seat__number { cursor: copy; }
.admin-seat input,
.admin-seat select {
  min-width: 0;
  min-height: 34px;
  padding: 5px 7px;
  font-size: 12px;
}

.admin-seat__player {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  color: #f0e5d3;
  cursor: grab;
  touch-action: none;
}
.admin-seat__player strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-seat__grab { color: #745f43; font-size: 15px; line-height: 1; }

.admin-seat__night {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #ae9c83;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.admin-seat__night input {
  width: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: #8c1f19;
}

.admin-seat__night:has(input:disabled) { cursor: not-allowed; opacity: .38; }
.admin-best-move {
  grid-column: 2 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 0 4px;
}

.admin-best-move[hidden] { display: none; }
.admin-best-move__label {
  display: inline-flex;
  min-width: 84px;
  align-items: baseline;
  justify-content: space-between;
  gap: 7px;
  color: #cbae7c;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.admin-best-move__label small {
  color: #806b4d;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}
.admin-best-move__grid {
  display: grid;
  width: min(100%, 330px);
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;
}
.admin-best-move__grid button {
  width: 100%;
  min-width: 0;
  min-height: 30px;
  padding: 0;
  aspect-ratio: 1;
  border: 1px solid rgba(201, 162, 94, .34);
  border-radius: 3px;
  background: #0a0806;
  color: #b99b69;
  cursor: pointer;
  font-family: "Oswald", "Arial Narrow", sans-serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.admin-best-move__grid button:hover:not(:disabled),
.admin-best-move__grid button:focus-visible {
  border-color: rgba(230, 189, 114, .8);
  color: #f0cf91;
  outline: 0;
}
.admin-best-move__grid button[aria-pressed="true"] {
  border-color: #d2a65a;
  background: linear-gradient(145deg, #9f231c, #68100d);
  color: #fff3dc;
  box-shadow: inset 0 0 0 1px rgba(255, 222, 153, .16), 0 0 12px rgba(155, 35, 28, .22);
}
.admin-best-move__grid button:disabled:not([aria-pressed="true"]) {
  cursor: not-allowed;
  opacity: .28;
}

.admin-bench {
  display: grid;
  gap: 9px;
  min-height: 86px;
  padding: 11px;
  border: 1px solid rgba(201, 162, 94, .18);
  border-radius: 3px;
  background: rgba(255, 255, 255, .012);
}
.admin-bench > strong {
  color: #aa9679;
  font-size: 10px;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.admin-bench__list { display: grid; gap: 6px; }
.admin-bench__player {
  display: flex;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(201, 162, 94, .22);
  border-radius: 3px;
  background: var(--admin-chip-surface);
  color: #e8dac5;
  cursor: grab;
  text-align: left;
  touch-action: pan-x;
}
.admin-bench__player > span { color: #806946; }
.admin-bench__player strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-bench__player:hover,
.admin-bench__player:focus-visible,
.admin-bench__player.is-selected {
  border-color: var(--admin-drop-accent);
  background: var(--admin-drop-surface);
  outline: 0;
}
.admin-bench__player.is-dragging { opacity: .45; }
.admin-bench__empty { color: #746a5d; font-size: 12px; }

.admin-editor__more {
  border: 1px solid rgba(201, 162, 94, .18);
  border-radius: 3px;
  background: rgba(255, 255, 255, .012);
}

.admin-editor__more > summary {
  padding: 10px 12px;
  color: #c8b495;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}

.admin-editor__more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 2px 12px 12px;
}

@media (max-width: 900px) {
  .admin-editor--game .admin-editor__form { overflow-x: hidden; }
  .admin-editor--game .admin-editor__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-editor--game .admin-editor__grid > .admin-editor__field:first-child { grid-column: 1 / -1; }
  .admin-seat-list__header { display: none; }
  .admin-roster__layout { grid-template-columns: 1fr; }
  .admin-bench { grid-row: 1; min-height: 0; }
  .admin-bench__list { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .admin-bench__player { width: auto; min-width: 132px; }
  .admin-seat {
    grid-template-columns: 40px minmax(0, 1fr) 98px 56px;
    grid-template-areas:
      "position player role points"
      "position comment comment night"
      "best best best best";
    gap: 5px 7px;
    padding-block: 7px;
  }
  .admin-seat__position { grid-area: position; align-self: stretch; flex-direction: column; justify-content: center; }
  .admin-seat__player { grid-area: player; }
  .admin-seat__role { grid-area: role; }
  .admin-seat__points { grid-area: points; }
  .admin-seat__night { grid-area: night; }
  .admin-seat__comment { grid-area: comment; }
  .admin-best-move { grid-area: best; }
}

@media (max-width: 620px) {
  .admin-editor { width: calc(100vw - 16px); max-height: 94vh; }
  .admin-editor__form { max-height: calc(94vh - 62px); padding: 16px; }
  .admin-editor__grid { grid-template-columns: 1fr; }
  .admin-editor--game .admin-editor__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-editor__field--wide { grid-column: auto; }
  .admin-editor--game .admin-editor__field--wide { grid-column: 1 / -1; }
  .admin-editor__actions { margin: 20px -16px -16px; padding: 13px 16px; }
  .admin-editor--game .admin-editor__actions { margin: 16px 0 0; padding: 12px 0 0; }
  .admin-edit-heading { align-items: flex-start; }
  .admin-editor__more-grid { grid-template-columns: 1fr; }
  .admin-best-move {
    flex-wrap: wrap;
  }
  .admin-best-move__label { flex: 0 0 100%; justify-content: flex-start; }
  .admin-best-move__grid {
    width: min(100%, 240px);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }
  .admin-best-move__grid button { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-editor[open] { animation: none; }
  .admin-edit-button { transition: none; }
}
