/* Admin panel — builds on the game's tokens and buttons in style.css */
body.admin {
  position: static;
  overflow: auto;
  min-height: 100%;
  -webkit-user-select: auto;
  user-select: auto;
}

.ad-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(12px + var(--safe-t)) 16px calc(32px + var(--safe-b));
}

.ad-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-bottom: 14px; }
.ad-head .g-brand { font-size: 28px; }
.ad-tag {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 2px 9px;
}
.ad-live { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-left: auto; }
.ad-live i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.ad-live.on { color: var(--mint-t); }
.ad-live.on i { background: var(--mint); box-shadow: 0 0 0 3px rgba(41, 201, 153, 0.25); animation: pulse 1.6s infinite; }
.ad-logout { width: auto; font-size: 14px; padding: 6px 12px; }

/* ------------------------------------------------------------------ login */
.ad-login { max-width: 420px; margin: 40px auto; padding: 22px; }
.ad-login h2 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; font-size: 24px; }
.ad-login p { margin: 0 0 14px; color: var(--ink-soft); font-size: 14px; }
.ad-login form { display: flex; flex-direction: column; gap: 10px; }
.ad-err { color: var(--coral-t) !important; font-weight: 900; min-height: 1em; margin: 10px 0 0 !important; }

/* ------------------------------------------------------------------ stats */
.ad-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 12px; }
.ad-stat {
  background: var(--card);
  border: var(--bw) solid var(--edge);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 3px 3px 0 var(--edge);
}
.ad-stat b { display: block; font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.ad-stat span { font-size: 12px; color: var(--muted); font-weight: 900; text-transform: uppercase; letter-spacing: 0.6px; }

.ad-toolbar { margin-bottom: 12px; }
.ad-toolbar .input { font-size: 15px; padding: 9px 12px; }

.ad-rooms { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 1100px) { .ad-rooms { grid-template-columns: 1fr 1fr; } }

.ad-empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.ad-empty h3 { font-family: var(--font-display); font-weight: 600; margin: 0 0 4px; color: var(--ink); }

/* ------------------------------------------------------------------- room */
.ad-room { padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.ad-room-head { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.ad-room-title { flex: 1; min-width: 0; }
.ad-room-title h3 { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 20px; }
.ad-room-title code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; background: var(--paper); border: 2px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: 16px; }
.ad-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pill { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: 0.5px; border: 2px solid var(--edge); border-radius: 999px; padding: 1px 8px; background: var(--raised); }
.pill.private { background: var(--grape-l); color: var(--grape-t); }
.pill.public { background: var(--sky); color: var(--on-accent); }
.pill.live { background: var(--mint); color: var(--on-accent); }
.pill.idle { background: var(--paper-2); }
.ad-timer { font-family: var(--font-display); font-weight: 700; font-size: 26px; min-width: 64px; text-align: right; }
.ad-timer.urgent { color: var(--coral-t); }
.ad-timer small { display: block; font-family: var(--font-body); font-size: 11px; color: var(--muted); font-weight: 900; text-transform: uppercase; }

.ad-meta { font-size: 14px; line-height: 1.5; color: var(--ink-soft); background: var(--paper); border-radius: 10px; padding: 8px 10px; }
.ad-meta b { color: var(--ink); }
.ad-meta .ad-word { color: var(--grape-t); font-family: var(--font-display); font-size: 16px; }

.ad-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.ad-btn {
  border: 2px solid var(--edge);
  border-radius: 10px;
  background: var(--raised);
  padding: 6px 10px;
  font-weight: 900;
  font-size: 13px;
  box-shadow: 0 2px 0 var(--edge);
}
.ad-btn:active { transform: translateY(2px); box-shadow: none; }
.ad-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.ad-btn.go { background: var(--mint); color: var(--on-accent); }
.ad-btn.warn { background: var(--sun); color: var(--on-accent); }
.ad-btn.danger { background: var(--rose-l); color: var(--coral-t); }
.ad-btn.sm { padding: 3px 7px; font-size: 12px; }

.ad-settings { border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; }
.ad-settings summary { cursor: pointer; font-weight: 900; font-size: 14px; }
.ad-settings .set-grid { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); margin: 8px 0 4px; }

.ad-announce { display: flex; gap: 6px; }
.ad-announce .input { font-size: 14px; padding: 7px 10px; }

/* ---------------------------------------------------------------- players */
.ad-players { display: flex; flex-direction: column; gap: 4px; }
.ad-player {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 92px auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 10px;
  background: var(--zebra);
}
.ad-player.guessed { background: var(--mint-l); }
.ad-player.drawing { background: var(--sun-l); }
.ad-player.away { opacity: 0.55; }
.ad-player .pl-av { width: 38px; height: 38px; }
.ad-pname { font-weight: 900; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-pflags { font-size: 11px; color: var(--muted); font-weight: 800; }
.ad-score {
  width: 100%;
  border: 2px solid var(--edge);
  border-radius: 8px;
  padding: 5px 6px;
  font-weight: 900;
  font-size: 15px;
  text-align: right;
  color: var(--ink);
  background: var(--field);
}
.ad-score:focus { outline: none; box-shadow: 0 0 0 3px rgba(77, 141, 255, 0.3); }
.ad-pacts { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.ad-noplayers { font-size: 13px; color: var(--muted); padding: 4px; }

@media (max-width: 560px) {
  .ad-player { grid-template-columns: 34px minmax(0, 1fr) 80px; }
  .ad-pacts { grid-column: 1 / -1; justify-content: flex-start; }
}

.ad-theme { flex: none; }

/* ------------------------------------------------------------- statistics */
body.admin { --c1: #3f7ef0; --c2: #e2593f; }
:root[data-theme='dark'] body.admin { --c1: #4784f2; --c2: #e2593f; }
.ad-tabs { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; padding: 2px 2px 5px; }
.ad-tabs button, .st-chips button {
  flex: none;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--raised);
  color: var(--ink);
  font-weight: 900;
  font-size: 14px;
  padding: 8px 14px;
  min-height: 40px;
  box-shadow: 0 2px 0 var(--edge);
}
.ad-tabs button { font-family: var(--font-display); font-weight: 600; font-size: 17px; }
.ad-tabs button[aria-selected='true'], .st-chips button[aria-pressed='true'] { background: var(--sun); color: var(--on-accent); }
.ad-tabs button:focus-visible, .st-chips button:focus-visible, .st-game > button:focus-visible, .st-scroll:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.st-bar-top { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 12px; }
.st-bar-top .ad-btn { min-height: 40px; }
.st-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.st-chips button { font-size: 13px; padding: 6px 11px; }
.st-when { color: var(--ink-soft); font-size: 14px; margin: 0; min-height: 1.4em; flex: 1 1 160px; }
#st-body { transition: opacity 0.15s; }
#st-body.busy { opacity: 0.5; }
#st-body > .st-chips { margin-bottom: 12px; }
.st-tiles .ad-stat span { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 800; color: var(--ink-soft); display: block; line-height: 1.3; }
.st-tiles { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.st-ch { font-style: normal; display: block; margin-top: 4px; font-size: 12px; font-weight: 900; color: var(--ink); }
.ad-stat .st-ch span, .st-ch span { display: inline; font-weight: 700; color: var(--muted); font-size: 12px; }
.st-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
@media (min-width: 780px) { .st-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.st-card { padding: 14px 16px; min-width: 0; }
#st-body > .st-card { margin-bottom: 14px; }
.st-card h3 { margin: 0 0 8px; font-family: var(--font-display); font-weight: 600; font-size: 19px; }
.st-card h3 + p { margin: -4px 0 10px; font-size: 13px; color: var(--ink-soft); line-height: 1.45; }
.st-card h4 { margin: 0 0 6px; font-size: 14px; }
.st-none { color: var(--muted); font-size: 14px; margin: 4px 0; }
.st-legend { display: flex; gap: 14px; font-size: 13px; margin-bottom: 8px; color: var(--ink-soft); }
.st-legend span { display: flex; align-items: center; gap: 6px; }
.st-legend i { width: 12px; height: 12px; border-radius: 3px; }
i.c1 { background: var(--c1); }
i.c2 { background: var(--c2); }
/* columns */
.st-cols { display: flex; gap: 8px; padding-bottom: 22px; }
.st-axis { display: flex; flex-direction: column; justify-content: space-between; height: 160px; font-size: 11px; color: var(--muted); text-align: right; min-width: 18px; }
.st-axis b { font-weight: 700; line-height: 1; }
.st-axis b:first-child { margin-top: -5px; }
.st-axis b:last-child { margin-bottom: -5px; }
.st-plot { position: relative; flex: 1; height: 160px; min-width: 0; }
.st-plot > u { position: absolute; left: 0; right: 0; height: 1px; background: var(--line); }
.st-plot > u:nth-child(1) { top: 0; }
.st-plot > u:nth-child(2) { top: 50%; }
.st-plot > u:nth-child(3) { bottom: 0; background: var(--muted); }
.st-bars { position: absolute; inset: 0; display: flex; }
.st-col { position: relative; flex: 1; min-width: 0; height: 100%; display: flex; justify-content: center; }
.st-col:hover, .st-col:focus-visible { background: var(--zebra); outline: none; }
.st-col:focus-visible { box-shadow: inset 0 0 0 2px var(--sky); }
.st-col > div { width: min(24px, calc(100% - 2px)); height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.st-cols.tight .st-col > div { width: calc(100% - 1px); }
.st-col i { display: block; min-height: 2px; flex: none; }
.st-col i:first-child { border-radius: 4px 4px 0 0; }
.st-col s { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); text-decoration: none; font-size: 11px; color: var(--muted); white-space: nowrap; }
.st-col:nth-last-child(-n + 2):not(:first-child) s { transform: none; left: auto; right: 0; }
/* ranked lists */
.st-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.st-list li { display: grid; grid-template-columns: minmax(90px, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.st-list li > span { overflow-wrap: anywhere; line-height: 1.25; }
.st-list li > div, .st-bar { display: block; height: 12px; min-width: 0; }
.st-list li i, .st-bar i { display: block; height: 100%; background: var(--c1); border-radius: 0 4px 4px 0; }
.st-list b { font-weight: 900; min-width: 74px; text-align: right; font-variant-numeric: tabular-nums; }
.st-list small { display: inline-block; min-width: 42px; color: var(--muted); font-weight: 700; font-size: 13px; }
/* games */
.st-games { list-style: none; margin: 0; padding: 0; }
.st-game { border-top: 2px solid var(--line); }
.st-game:first-child { border-top: 0; }
.st-game > button { display: grid; grid-template-columns: 26px minmax(130px, 1.2fr) minmax(60px, 1fr) auto; gap: 4px 12px; align-items: center; width: 100%; padding: 10px 4px; border: 0; background: none; color: var(--ink); text-align: left; font-size: 14px; border-radius: 8px; }
.st-game > button:hover { background: var(--zebra); }
.st-rank { font-family: var(--font-display); font-size: 18px; color: var(--muted); text-align: center; }
.st-name { font-weight: 900; font-size: 15px; }
.st-nums { display: grid; grid-template-columns: repeat(5, 84px); gap: 4px; font-size: 12px; color: var(--ink-soft); }
.st-nums b { display: block; font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .st-game > button { grid-template-columns: 26px minmax(0, 1fr) minmax(60px, 34%); }
  .st-nums { grid-column: 1 / -1; grid-template-columns: repeat(5, minmax(0, 1fr)); padding-left: 38px; }
}
@media (max-width: 520px) { .st-nums { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 4px; } }
.st-detail { padding: 4px 4px 16px; }
.st-detail > p { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); }
.st-tags { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0; font-size: 14px; }
/* device tables */
.st-scroll { overflow-x: auto; margin: 0 -4px; }
.st-scroll table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 14px; font-variant-numeric: tabular-nums; }
.st-scroll th, .st-scroll td { padding: 7px 8px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.st-scroll th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.st-scroll thead th { border-top: 0; color: var(--muted); font-size: 12px; }
.st-scroll .few td, .st-scroll .few th { color: var(--muted); font-weight: 600; }
.st-scroll td.bad { color: var(--coral-t); font-weight: 900; }
.st-tip { position: fixed; z-index: 50; left: 0; top: 0; max-width: min(280px, calc(100vw - 16px)); background: var(--inverse); color: var(--on-inverse); border-radius: 9px; padding: 6px 10px; font-size: 13px; font-weight: 800; pointer-events: none; opacity: 0; visibility: hidden; }
.st-tip.show { opacity: 1; visibility: visible; }
@media (max-width: 560px) {
  .ad-tabs { gap: 4px; }
  .ad-tabs button { flex: 1 1 auto; font-size: 15px; padding: 8px 4px; }
  #st-ranges { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; gap: 4px; }
  #st-ranges button { padding: 6px 1px; font-size: 12px; white-space: nowrap; }
  .st-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ----------------------------------------------------------- live checks */
.ad-checks { display: grid; gap: 8px; margin-bottom: 12px; }
.ad-check {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  align-items: baseline;
  padding: 8px 12px;
  border: 2px solid var(--edge);
  border-radius: 12px;
  background: var(--card);
  font-size: 14px;
}
.ad-check b { font-weight: 900; }
.ad-check span { color: var(--ink-soft); font-size: 13px; }
.ad-check.warn { background: var(--rose-l); }
.ad-check.info { background: var(--sky-l); }
.ad-check.ok { border-style: dashed; border-color: var(--line); }
.ad-check.ok b { color: var(--mint-t); }

/* --------------------------------------------------------------- line-up */
#lineup-view .st-card { margin-bottom: 14px; }
.ad-lineup { list-style: none; margin: 0; padding: 0; }
.ad-lineup li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  gap: 4px 12px;
  align-items: center;
  padding: 8px 4px;
  border-top: 2px solid var(--line);
  font-size: 15px;
}
.ad-lineup li:first-child { border-top: 0; }
.ad-lineup li.off .lu-name, .ad-lineup li.off .lu-rank { opacity: 0.55; }
.lu-rank { font-family: var(--font-display); font-size: 18px; color: var(--muted); text-align: center; }
.lu-name { font-weight: 900; min-width: 0; overflow-wrap: anywhere; }
.lu-plays { font-size: 13px; color: var(--ink-soft); font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.lu-new {
  font-style: normal;
  display: inline-block;
  margin-left: 4px;
  padding: 0 7px;
  border: 1.5px solid var(--edge);
  border-radius: 999px;
  background: var(--sun);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  vertical-align: 2px;
}
.ad-switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: var(--raised);
  cursor: pointer;
  transition: background 0.15s;
}
.ad-switch i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s;
}
.ad-switch[aria-checked='true'] { background: var(--mint); }
.ad-switch[aria-checked='true'] i { transform: translateX(22px); background: #fff; }
.ad-switch:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.ad-switch:disabled { opacity: 0.6; cursor: wait; }
.ad-lu-foot { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-top: 10px; }
.ad-lu-foot p { margin: 0; font-size: 13px; color: var(--ink-soft); flex: 1 1 220px; }
.ad-log { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.ad-log li { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 0 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.ad-log li:first-child { border-top: 0; }
.ad-log time { color: var(--muted); font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.ad-log small { grid-column: 2; color: var(--ink-soft); font-size: 12px; font-weight: 700; }
.ad-log li.ad-noplayers { display: block; }
.st-kind { display: inline-block; margin-right: 4px; padding: 0 6px; border-radius: 6px; background: var(--chip); font-size: 11px; font-weight: 900; color: var(--ink-soft); }
@media (max-width: 560px) {
  .ad-lineup li { grid-template-columns: 24px minmax(0, 1fr) auto; }
  .lu-plays { grid-column: 2; grid-row: 2; text-align: left; }
  .ad-switch { grid-column: 3; grid-row: 1 / span 2; }
}
