/* Shared by the game masters' site and the staff site (web/build.sh copies it into each). */

:root {
  color-scheme: light;
  --ink: #172b3a;
  --muted: #5f707c;
  --muted-light: #84939d;
  --line: #dce3e8;
  --line-strong: #c3ced5;
  --canvas: #f2f5f6;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --blue: #0878c9;
  --blue-dark: #075b96;
  --blue-soft: #e9f4fb;
  --green: #21865b;
  --green-soft: #e8f5ee;
  --amber: #a96408;
  --amber-soft: #fff4dc;
  --red: #b84439;
  --red-soft: #fff0ee;
  --navy: #12314a;
  --gold: #f0c75e;
  --shadow: 0 14px 40px rgba(21, 43, 58, 0.16);
  font-family: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Tahoma, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 14px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
a { color: var(--blue-dark); }
code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .92em; background: #eef2f4; padding: 1px 4px; border-radius: 3px; }
[hidden] { display: none !important; }

/* Shell */
.app-shell { min-height: 100vh; }
.shellbar { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; background: var(--navy); color: #fff; box-shadow: 0 2px 8px rgba(8, 32, 49, .18); position: sticky; top: 0; z-index: 50; }
.shellbar.staff { background: #3b1f2b; }
.brand { display: inline-flex; align-items: center; border: 0; background: none; color: inherit; cursor: pointer; padding: 0; gap: 10px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; color: var(--navy); background: var(--gold); font-weight: 800; font-size: 17px; border-radius: 6px; }
.brand-name { font-size: 18px; font-weight: 700; }
.brand-area { color: #cad8e2; font-size: 13px; border-left: 1px solid rgba(255,255,255,.3); padding-left: 10px; }
.shell-actions { display: flex; align-items: center; gap: 10px; }
.icon-button { border: 0; background: transparent; color: inherit; cursor: pointer; display: inline-grid; place-items: center; min-width: 36px; min-height: 36px; border-radius: 6px; font-size: 18px; }
.icon-button:hover { background: rgba(127,127,127,.14); }
.user-chip { text-decoration: none; border: 1px solid rgba(255,255,255,.25); border-radius: 6px; background: rgba(255,255,255,.07); display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 5px; color: #fff; cursor: pointer; min-height: 38px; max-width: 280px; }
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-initial { width: 28px; height: 28px; border-radius: 5px; background: #d8eaf5; color: var(--navy); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.workspace { min-height: calc(100vh - 58px); display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 20px 10px 14px; position: sticky; top: 58px; height: calc(100vh - 58px); overflow: auto; }
.nav-group-label { color: #788994; font-size: 11px; font-weight: 700; letter-spacing: .08em; padding: 0 12px 8px; }
.side-nav { display: grid; gap: 2px; margin-bottom: 22px; }
.nav-item { width: 100%; min-height: 40px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 6px; background: transparent; color: #405560; cursor: pointer; text-align: left; padding: 0 12px; font-size: 14px; text-decoration: none; }
.nav-item:hover { background: #f2f6f8; }
.nav-item.active { color: var(--blue-dark); background: #eaf4fa; font-weight: 600; }
.nav-icon { width: 18px; text-align: center; font-size: 16px; color: #657a87; }
.nav-item.active .nav-icon { color: var(--blue); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 10px; background: var(--red); color: #fff; font-size: 12px; text-align: center; }
.content-area { min-width: 0; padding: 24px 28px 48px; }
.page-content { max-width: 1400px; margin: 0 auto; }

/* Page structure */
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 0 0 20px; flex-wrap: wrap; }
.page-heading h1 { margin: 2px 0 0; font-size: 26px; line-height: 1.2; font-weight: 650; }
.page-subtitle { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { color: #6c7d88; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.back-link { display: inline-flex; gap: 6px; color: var(--muted); font-size: 13px; text-decoration: none; margin-bottom: 8px; }
.back-link:hover { color: var(--blue-dark); }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-main-side { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; align-content: start; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; }
.wrap-anywhere { overflow-wrap: anywhere; }

/* Panels and cards */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel.flush .panel-heading { padding: 16px 18px 0; }
.panel-heading h2 { font-size: 17px; line-height: 1.25; margin: 0; font-weight: 650; }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px 18px; border-left: 4px solid var(--metric-color, var(--blue)); }
.metric-label { color: var(--muted); font-size: 13px; }
.metric-value { margin-top: 6px; font-size: 28px; line-height: 1.1; font-weight: 650; }
.metric-foot { margin-top: 6px; color: var(--muted-light); font-size: 12px; }
.empty-state { display: grid; place-items: center; text-align: center; padding: 34px 16px; color: var(--muted); }
.empty-state strong { color: #334b59; font-size: 15px; }
.empty-state p { max-width: 420px; margin: 6px 0 14px; }
.note { border-left: 3px solid #65a7cf; background: #eff7fb; color: #3f5e6e; padding: 11px 14px; margin: 0 0 14px; border-radius: 0 6px 6px 0; }
.note.warn { border-color: #d39a35; background: var(--amber-soft); color: #6d4a12; }
.note.danger { border-color: var(--red); background: var(--red-soft); color: #7a2a23; }
.note.ok { border-color: var(--green); background: var(--green-soft); color: #1f5a3e; }
.note p:last-child { margin-bottom: 0; }

/* Buttons */
.button { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 38px; border-radius: 6px; border: 1px solid transparent; padding: 0 14px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button.secondary { color: #2f4655; border-color: var(--line-strong); background: #fff; }
.button.secondary:hover { background: #f2f6f8; border-color: #879ba9; }
.button.danger { color: #fff; background: var(--red); border-color: var(--red); }
.button.danger-outline { color: var(--red); background: #fff; border-color: #e3b5b0; }
.button.danger-outline:hover { background: var(--red-soft); }
.button.compact { min-height: 32px; padding: 0 10px; font-size: 13px; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.text-button { border: 0; background: none; color: var(--blue-dark); cursor: pointer; padding: 4px 2px; font-size: 14px; font-weight: 600; text-decoration: none; }
.text-button:hover { text-decoration: underline; }
.text-button.danger { color: var(--red); }

/* Forms */
input, select, textarea { width: 100%; min-height: 38px; border: 1px solid #b8c5cc; border-radius: 6px; padding: 8px 10px; color: var(--ink); background: #fff; outline: none; font-size: 14px; }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; }
input[type="range"] { padding: 0; border: 0; }
input[type="file"] { padding: 6px; background: var(--surface-soft); }
textarea { resize: vertical; min-height: 76px; }
input:focus, select:focus, textarea:focus { border-color: #1984c7; box-shadow: 0 0 0 3px rgba(8, 120, 201, .15); }
input:disabled, select:disabled, textarea:disabled { background: #f1f4f5; color: var(--muted); }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #3a505d; }
label .hint, .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
label.check { display: flex; align-items: flex-start; gap: 9px; font-weight: 500; }
label.check input { margin-top: 3px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px 14px; margin: 0; min-width: 0; }
legend { font-size: 13px; font-weight: 650; padding: 0 6px; color: #3a505d; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-all { grid-column: 1 / -1; }
.inline-error { color: #a23830; font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { max-width: 360px; }
.toolbar select { width: auto; min-width: 160px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; background: #fff; }
.segmented button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 600; color: #4b606c; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--blue-soft); color: var(--blue-dark); }

/* Tables */
.table-wrap { overflow-x: auto; }
.panel .table-wrap { margin: 0 -20px -6px; }
.panel.flush .table-wrap { margin: 0; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { color: #607380; background: #f7f9fa; font-size: 12px; font-weight: 650; padding: 10px 14px; border-top: 1px solid #edf0f2; border-bottom: 1px solid #e4e9ec; white-space: nowrap; }
td { color: #33495a; font-size: 14px; padding: 11px 14px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover, tbody tr.selected { background: #f4f9fc; }
.row-title { color: var(--ink); font-weight: 600; }
.row-meta { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.cell-actions { text-align: right; white-space: nowrap; }

/* Pills and tags */
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; background: #edf1f3; color: #536671; border-radius: 12px; font-size: 12px; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.status-pill:before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #8796a1; }
.status-pill.live, .status-pill.passed { background: var(--green-soft); color: #226947; }
.status-pill.live:before, .status-pill.passed:before { background: #299362; }
.status-pill.lobby, .status-pill.starting, .status-pill.pending, .status-pill.open { background: var(--amber-soft); color: #88560e; }
.status-pill.lobby:before, .status-pill.starting:before, .status-pill.pending:before, .status-pill.open:before { background: #d88c19; }
.status-pill.failed { background: var(--red-soft); color: #8e3229; }
.status-pill.failed:before { background: var(--red); }
.tag { display: inline-block; color: #4f6572; background: #eef3f5; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.tag.paid { background: var(--amber-soft); color: #7d520e; }
.tag.blue { background: var(--blue-soft); color: var(--blue-dark); }
.tag.red { background: var(--red-soft); color: #8e3229; }
.tag.green { background: var(--green-soft); color: #226947; }
.tag-list { display: flex; gap: 6px; flex-wrap: wrap; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--dot, #888); vertical-align: middle; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.15); }

/* Cards in grids */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 16px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.card h3 { margin: 0; font-size: 15px; line-height: 1.35; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.card .card-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid #edf0f2; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card.selectable { cursor: pointer; }
.card.selectable:hover, .card.selected { border-color: #8cc0e0; background: #f7fbfe; }
.big-emoji { font-size: 26px; line-height: 1; }

/* Media */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.media-tile { position: relative; border-radius: 8px; overflow: hidden; background: #e9eef1; aspect-ratio: 1; border: 1px solid var(--line); }
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile button { position: absolute; inset: 0; border: 0; background: transparent; cursor: zoom-in; }
.media-caption { font-size: 12px; color: var(--muted); margin-top: 4px; }
.media-full { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 6px; }

/* Messages */
.message-log { max-height: 320px; overflow: auto; display: grid; gap: 8px; align-content: start; }
.message-item { padding: 9px 12px; border: 1px solid #e9eef1; border-radius: 8px; background: var(--surface-soft); }
.message-item p { margin: 0; overflow-wrap: anywhere; }
.message-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* Progress */
.progress-track { height: 8px; border-radius: 5px; background: #e9eef1; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 5px; background: var(--team-color, var(--blue)); }

/* Dialogs */
.dialog { width: min(100% - 24px, 520px); max-width: none; max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 10px; box-shadow: var(--shadow); color: var(--ink); }
.dialog::backdrop { background: rgba(12, 30, 43, .45); }
.dialog-wide { width: min(100% - 24px, 820px); }
.dialog-card { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.dialog-heading h2 { font-size: 20px; margin: 2px 0 0; font-weight: 650; }
.dialog-heading .icon-button { color: #60727d; font-size: 22px; }
.dialog-body { display: grid; gap: 14px; }
.dialog-copy { color: var(--muted); margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* Sign-in */
.auth-page { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(100%, 440px); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: 0 8px 30px rgba(21, 43, 58, .08); }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }
.auth-card form { display: grid; gap: 14px; margin-top: 18px; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.auth-divider:before, .auth-divider:after { content: ""; height: 1px; background: #e7ecef; flex: 1; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* Maps */
.map { width: 100%; height: 420px; background: #e8eef1; border-radius: 8px; border: 1px solid var(--line); z-index: 0; }
.map.tall { height: calc(100vh - 220px); min-height: 420px; }
.map-fallback { display: grid; place-items: center; height: 100%; padding: 16px; color: #526a78; text-align: center; }
.leaflet-container { font: inherit; }
.pin-icon { display: grid; place-items: center; border: 0; background: transparent; }
.pin-icon span { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid #fff; border-radius: 50%; background: var(--pin, var(--blue)); color: #fff; box-shadow: 0 1px 4px rgba(20, 45, 60, .45); font-size: 12px; font-weight: 700; }
.pin-icon.selected span { background: #d14b1f; transform: scale(1.15); }
.player-icon span { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: var(--pin, #555); color: #fff; box-shadow: 0 1px 4px rgba(20, 45, 60, .45); font-size: 9px; font-weight: 700; }

/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 100; max-width: min(460px, calc(100% - 32px)); padding: 12px 16px; color: #fff; background: #243f51; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a63d35; }
.skeleton { min-height: 120px; border-radius: 8px; background: linear-gradient(90deg, #e8edef 25%, #f4f6f7 45%, #e8edef 65%); background-size: 300% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -150% 0; } }

/* Definition lists */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-main-side, .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shellbar { padding: 0 12px; }
  .brand-area { display: none; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 58px; z-index: 40; height: auto; padding: 0; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; display: flex; }
  .sidebar .nav-group-label { display: none; }
  .side-nav { display: flex; gap: 0; margin: 0; padding: 0 6px; }
  .nav-item { width: auto; min-height: 50px; flex-direction: column; justify-content: center; gap: 0; padding: 4px 12px; font-size: 12px; white-space: nowrap; border-radius: 0; }
  .nav-item.active { box-shadow: inset 0 -2px var(--blue); }
  .nav-badge { margin: 0; }
  .content-area { padding: 16px 16px 40px; }
  .page-heading h1 { font-size: 22px; }
  .form-grid.two, .form-grid.three { grid-template-columns: minmax(0, 1fr); }
  .map { height: 300px; }
  .map.tall { height: 340px; min-height: 0; }
  .dialog-card { padding: 18px; }
  .user-chip span:last-child { display: none; }
}
