.app-page {
  --builder-roster-gap: 12px;
  --builder-bench-width: 190px;
  --builder-drop-accent: #c9a25e;
  --builder-drop-surface: rgba(201, 162, 94, .09);
  --builder-chip-surface: #17110c;
  min-height: 100vh;
  padding: 132px 20px 72px;
  background:
    radial-gradient(circle at 20% 0%, rgba(126, 28, 20, .22), transparent 35rem),
    #0b0907;
}

.app-page [hidden] { display: none !important; }

.app-shell { width: min(1120px, 100%); margin: 0 auto; }
.app-shell--narrow { width: min(680px, 100%); }
.app-heading { margin-bottom: 28px; }
.app-heading h1 { margin: 8px 0 10px; font-size: clamp(2.1rem, 5vw, 4.2rem); }
.app-heading p { max-width: 68ch; color: var(--color-text-muted, #b9aa98); }
.app-panel {
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid rgba(201, 162, 94, .28);
  background: rgba(20, 16, 12, .9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.app-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.app-stack { display: grid; gap: 18px; }
.app-form { display: grid; gap: 16px; }
.app-form label, .builder-row label { display: grid; min-width: 0; gap: 7px; color: #d6c7b2; font-size: .82rem; letter-spacing: .04em; }
.app-form input, .app-form textarea, .app-form select,
.builder-row input, .builder-row select {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid rgba(201, 162, 94, .32);
  border-radius: 2px;
  color: #f2e8d7;
  background: #100d0a;
  font: inherit;
}
.app-form textarea { min-height: 110px; resize: vertical; }
.app-form label small { color: #8f806d; font-size: .72rem; font-weight: 400; letter-spacing: 0; line-height: 1.45; }
.app-status { min-height: 24px; margin: 16px 0; color: #d8bd89; }
.app-status[data-kind="error"] { color: #ff8c83; }
.app-status[data-kind="success"] { color: #a8d6a1; }
.app-list { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.app-list-card { display: grid; gap: 5px; padding: 14px 16px; border: 1px solid rgba(201, 162, 94, .2); background: rgba(255,255,255,.015); }
.app-list-card span { color: #b9aa98; }
.app-chip { justify-self: start; padding: 3px 8px; border: 1px solid rgba(201, 162, 94, .32); font-size: .74rem; text-transform: uppercase; }
.app-table-wrap { overflow-x: auto; }
.app-table { width: 100%; border-collapse: collapse; }
.app-table th, .app-table td { padding: 11px 12px; border-bottom: 1px solid rgba(201, 162, 94, .18); text-align: left; }
.app-table th { color: #c9a25e; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; }
.app-credentials { white-space: pre-wrap; overflow-wrap: anywhere; padding: 16px; border: 1px solid #c9a25e; color: #f2e8d7; background: #171006; }
.admin-sections { display: grid; gap: 28px; }
.admin-section h2 { margin-top: 0; }
.admin-section__heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-section__heading h2 { margin: 5px 0 0; }
.approval-list { display: grid; gap: 8px; }
.approval-card {
  display: flex;
  min-height: 62px;
  padding: 10px 12px 10px 15px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(201, 162, 94, .2);
  background: rgba(255, 255, 255, .015);
}
.approval-card__identity { display: grid; min-width: 0; gap: 3px; }
.approval-card__identity strong { color: #f0e5d3; }
.approval-card__identity span { overflow: hidden; color: #9e8e78; font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.approval-empty { margin: 12px 0 0; color: #8f806d; }
.auth-switch {
  display: grid;
  margin: -10px -10px 26px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid rgba(201, 162, 94, .22);
}
.auth-switch button {
  min-height: 48px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #94836d;
  font-family: 'Oswald', sans-serif;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.auth-switch button:hover,
.auth-switch button:focus-visible { color: #f0cf8e; outline: none; }
.auth-switch button[aria-selected='true'] { border-bottom-color: #c9a25e; color: #f2e8d7; }
.auth-form { animation: auth-panel-in .2s ease both; }
.auth-note { margin: 0; color: #9f907c; font-size: .82rem; line-height: 1.55; }
.account-nickname-note { margin-top: 6px; color: #8f806d !important; font-size: .82rem; }
.join-heading { max-width: 760px; }
.join-flow { display: grid; gap: 20px; }
.join-step { padding: clamp(20px, 3vw, 32px); }
.join-step__heading {
  display: grid;
  margin-bottom: 22px;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.join-step__heading h2 { margin: 0 0 4px; color: #f2e8d7; font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
.join-step__heading p { margin: 0; color: #9f907c; }
.join-step__number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid rgba(201, 162, 94, .48);
  color: #e5bd73;
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
}
.join-evening-list { display: grid; gap: 8px; }
.join-evening {
  display: grid;
  width: 100%;
  min-height: 86px;
  padding: 12px 16px 12px 12px;
  grid-template-columns: 66px minmax(0, 1fr) 24px;
  gap: 16px;
  align-items: center;
  border: 1px solid rgba(201, 162, 94, .2);
  background: rgba(255, 255, 255, .012);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color .18s ease, background-color .18s ease, transform .18s ease;
}
.join-evening:hover,
.join-evening:focus-visible {
  border-color: rgba(201, 162, 94, .58);
  background: rgba(201, 162, 94, .055);
  outline: none;
  transform: translateX(3px);
}
.join-evening[aria-pressed='true'] {
  border-color: #c9a25e;
  background: linear-gradient(90deg, rgba(122, 26, 23, .24), rgba(201, 162, 94, .045));
  box-shadow: inset 3px 0 0 #9f2b22;
}
.join-evening__date {
  display: grid;
  min-height: 58px;
  padding: 5px;
  place-items: center;
  border-right: 1px solid rgba(201, 162, 94, .22);
  color: #d9b56e;
  font-family: 'Oswald', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-align: center;
  text-transform: uppercase;
}
.join-evening__body { display: grid; min-width: 0; gap: 4px; }
.join-evening__body strong { overflow: hidden; color: #f2e8d7; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.join-evening__meta { color: #b8a68d; font-size: .84rem; }
.join-evening__format { color: #806f59; font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; }
.join-evening__arrow { color: #c9a25e; font-family: 'Oswald', sans-serif; font-size: 1.8rem; text-align: right; }
.join-loading,
.join-empty { margin: 0; padding: 20px; border: 1px dashed rgba(201, 162, 94, .25); color: #9f907c; text-align: center; }
.join-choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.join-choice {
  display: flex;
  min-width: 0;
  padding: clamp(20px, 3vw, 28px);
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid rgba(201, 162, 94, .2);
  background: rgba(255, 255, 255, .012);
}
.join-choice--telegram { background: linear-gradient(145deg, rgba(27, 20, 13, .8), rgba(12, 10, 8, .96)); }
.join-choice__icon { margin-bottom: 16px; color: #c9a25e; font-size: 1.45rem; }
.join-choice h3 { margin: 0 0 8px; color: #f2e8d7; font-family: 'Oswald', sans-serif; font-size: 1.2rem; text-transform: uppercase; }
.join-choice > p { margin: 0 0 20px; color: #9f907c; }
.join-choice .app-form { width: 100%; }
.join-choice > .button,
.join-choice .app-form > .button { width: 100%; margin-top: auto; }
.join-choice .auth-note { margin: 16px 0 0; }
.join-choice .auth-note a { color: #dcb970; }
.join-status { margin: 0; text-align: center; }
@keyframes auth-panel-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.evening-editor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.evening-editor-grid__title { grid-column: span 2; }
.evening-editor-grid__description { grid-column: 1 / -1; }
.evening-editor-grid__description textarea { min-height: 74px; }
.builder-roster {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--builder-bench-width);
  gap: var(--builder-roster-gap);
  align-items: start;
}
.builder-seats {
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(201, 162, 94, .2);
  border-radius: 2px;
}

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

.builder-head {
  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;
}

.builder-row {
  margin: 0;
  padding: 5px 8px;
  border-bottom: 1px solid rgba(201, 162, 94, .12);
  background: #0f0c09;
}
.builder-row:last-child { border-bottom: 0; }
.builder-row.is-dragging { opacity: .45; }
.builder-row.is-drop-target {
  box-shadow: inset 0 2px 0 var(--builder-drop-accent);
  background: var(--builder-drop-surface);
}
.builder-row input,
.builder-row select { min-width: 0; min-height: 34px; padding: 5px 7px; font-size: 12px; }
.builder-position { display: flex; align-items: center; justify-content: center; color: #d6ad67; font-family: 'Oswald', sans-serif; }
.builder-position > button {
  width: 24px;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: default;
  font: inherit;
}
.builder-roster:has(.builder-bench__player.is-selected) .builder-position > button { cursor: copy; }
.builder-player {
  display: flex;
  min-width: 0;
  min-height: 34px;
  align-items: center;
  gap: 7px;
  color: #f0e5d3;
  cursor: grab;
  touch-action: none;
}
.builder-player > span { color: #745f43; font-size: 15px; line-height: 1; }
.builder-player strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-night { display: inline-flex !important; min-height: 34px; align-items: center; justify-content: center; gap: 4px !important; cursor: pointer; font-size: 10px !important; font-weight: 700; }
.builder-night input { width: 16px; min-height: 16px; padding: 0; accent-color: #8c1f19; }
.builder-night:has(input:disabled) { cursor: not-allowed; opacity: .38; }
.builder-best-move {
  grid-column: 2 / -1;
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 0 4px;
}
.builder-best-move[hidden] { display: none; }
.builder-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;
}
.builder-best-move__label small {
  color: #806b4d;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}
.builder-best-move__grid {
  display: grid;
  width: min(100%, 330px);
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;
}
.builder-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;
}
.builder-best-move__grid button:hover:not(:disabled),
.builder-best-move__grid button:focus-visible {
  border-color: rgba(230, 189, 114, .8);
  color: #f0cf91;
  outline: 0;
}
.builder-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);
}
.builder-best-move__grid button:disabled:not([aria-pressed="true"]) {
  cursor: not-allowed;
  opacity: .28;
}
.builder-bench {
  display: grid;
  gap: 9px;
  min-height: 86px;
  padding: 11px;
  border: 1px solid rgba(201, 162, 94, .2);
  border-radius: 2px;
  background: rgba(255, 255, 255, .012);
}
.builder-bench > strong {
  color: #aa9679;
  font-size: 10px;
  letter-spacing: .075em;
  text-transform: uppercase;
}
.builder-bench__list { display: grid; gap: 6px; }
.builder-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: 2px;
  background: var(--builder-chip-surface);
  color: #e8dac5;
  cursor: grab;
  text-align: left;
  touch-action: pan-x;
}
.builder-bench__player > span { color: #806946; }
.builder-bench__player strong {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.builder-bench__player:hover,
.builder-bench__player:focus-visible,
.builder-bench__player.is-selected {
  border-color: var(--builder-drop-accent);
  background: var(--builder-drop-surface);
  outline: 0;
}
.builder-bench__player.is-dragging { opacity: .45; }
.builder-bench__empty { color: #746a5d; font-size: 12px; }
.app-more { border: 1px solid rgba(201, 162, 94, .2); background: rgba(255,255,255,.012); }
.app-more > summary { padding: 11px 13px; color: #c8b495; cursor: pointer; font-size: .82rem; font-weight: 700; }
.app-more > .app-grid { padding: 4px 13px 13px; }
.game-meta-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.game-meta-grid > label:first-child { grid-column: span 2; }
.app-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.app-brandbar {
  position: fixed; z-index: 50; inset: 0 0 auto; height: 88px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 max(20px, calc((100vw - 1440px) / 2));
  border-bottom: 1px solid rgba(201, 162, 94, .25);
  background: rgba(8, 7, 5, .96);
}
.app-brandbar a { color: #d9c7aa; text-decoration: none; }
.app-brandbar__links { display: flex; align-items: center; gap: 18px; }
.admin-nav { align-self: stretch; gap: 0; }
.admin-nav a {
  position: relative;
  display: inline-flex;
  min-height: 100%;
  padding: 0 15px;
  align-items: center;
  color: #a99679;
  font-family: 'Oswald', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  transition: background-color .16s ease, color .16s ease;
}
.admin-nav a::after {
  position: absolute;
  right: 15px;
  bottom: 0;
  left: 15px;
  height: 2px;
  background: #c9a25e;
  content: '';
  opacity: 0;
  transform: scaleX(.5);
  transition: opacity .16s ease, transform .16s ease;
}
.admin-nav a:hover,
.admin-nav a:focus-visible {
  background: rgba(201, 162, 94, .07);
  color: #f0cf8e;
  outline: none;
}
.admin-nav a[aria-current='page'] {
  background: rgba(122, 26, 23, .2);
  color: #f2e8d7;
}
.admin-nav a[aria-current='page']::after { opacity: 1; transform: scaleX(1); }

@media (max-width: 760px) {
  .app-page { padding-top: 112px; }
  .app-grid { grid-template-columns: 1fr; }
  .join-choice-grid { grid-template-columns: 1fr; }
  .join-evening { grid-template-columns: 54px minmax(0, 1fr) 18px; gap: 10px; padding-inline: 8px 12px; }
  .join-evening__date { font-size: .9rem; }
  .join-evening__meta { font-size: .78rem; }
  .join-step__heading { grid-template-columns: 32px minmax(0, 1fr); gap: 10px; }
  .join-step__number { width: 30px; height: 30px; }
  .app-brandbar { height: 72px; }
  .app-brandbar__links a:not(:last-child) { display: none; }
  .app-brandbar--admin {
    height: auto;
    min-height: 118px;
    padding: 8px 16px 0;
    align-content: start;
    flex-wrap: wrap;
  }
  .app-brandbar--admin .footer-brand img { width: 44px; height: 44px; }
  .app-brandbar--admin .footer-brand span { font-size: .88rem; }
  .app-brandbar--admin .admin-nav {
    width: calc(100% + 32px);
    min-height: 54px;
    margin: 0 -16px;
    padding: 0 8px;
    order: 3;
    overflow-x: auto;
    border-top: 1px solid rgba(201, 162, 94, .16);
    scrollbar-width: none;
  }
  .app-brandbar--admin .admin-nav::-webkit-scrollbar { display: none; }
  .app-brandbar--admin .admin-nav a {
    display: inline-flex !important;
    min-height: 54px;
    padding: 0 12px;
    flex: 0 0 auto;
  }
  .app-brandbar--admin .admin-nav a::after { right: 12px; left: 12px; }
  .app-brandbar--admin + .app-page { padding-top: 154px; }
  .approval-card { align-items: stretch; flex-direction: column; }
  .approval-card .button { width: 100%; }
  .game-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .evening-editor-grid { grid-template-columns: 1fr; }
  .evening-editor-grid__title,
  .evening-editor-grid__description { grid-column: auto; }
  .builder-roster { grid-template-columns: 1fr; }
  .builder-bench { grid-row: 1; min-height: 0; }
  .builder-bench__list { display: flex; overflow-x: auto; padding-bottom: 2px; }
  .builder-bench__player { width: auto; min-width: 132px; }
  .builder-head { display: none; }
  .builder-row {
    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;
  }
  .builder-position { grid-area: position; align-self: stretch; flex-direction: column; justify-content: center; }
  .builder-player { grid-area: player; }
  .builder-role { grid-area: role; }
  .builder-points { grid-area: points; }
  .builder-night { grid-area: night; }
  .builder-comment { grid-area: comment; }
  .builder-best-move { grid-area: best; flex-wrap: wrap; }
  .builder-best-move__label { flex: 0 0 100%; justify-content: flex-start; }
  .builder-best-move__grid {
    width: min(100%, 240px);
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 4px;
  }
  .builder-best-move__grid button { min-height: 42px; }
}
