/* ==========================================================================
   Battlesnake Arena design system — "Direction E: Two-Toggle Themes"
   Minimal editorial: warm paper, hairline rules, mono data, pink accent.

   Two theme axes, resolved onto html[data-app-theme="light|dark"]:
     - site theme    (system | light | dark)  — every page
     - game theater  (match | dark | light)   — pages marked data-theater-page
   Resolution happens in the inline head script (no-FOUC) + theme.js.
   ========================================================================== */

:root {
  --paper: #FCFBF8;
  --ink: #17141A;
  --muted: #6F6876;
  --hairline: #E8E3DB;
  --hairline-dark: #D8D2C8;
  --pink: #E8256D;
  --pink-deep: #C11655;
  --pink-wash: #FDF0F5;
  --card: #FFFFFF;
  --hover: #FAF7F1;
  --pill: #F1EDE5;
  --up: #148A5C;
  --down: #C0392B;
  --display: "Bricolage Grotesque", sans-serif;
  --body: "Instrument Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
}
html[data-app-theme="dark"] {
  --paper: #171117;
  --ink: #F4EFEA;
  --muted: #9C8F99;
  --hairline: #2A232A;
  --hairline-dark: #362E35;
  --pink: #FF3D8A;
  --pink-deep: #FF5C9E;
  --pink-wash: rgba(255, 61, 138, .10);
  --card: #1E181D;
  --hover: #201A20;
  --pill: #2A232A;
  --up: #3DDBA0;
  --down: #FF6B6B;
}

/* --- base ------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { color-scheme: light; }
html[data-app-theme="dark"] { color-scheme: dark; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--pink); color: #fff; }

h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; }
h1 { font-weight: 800; letter-spacing: -.03em; font-size: clamp(36px, 4vw, 52px); line-height: 1.05; }
h2 { font-weight: 700; font-size: 24px; }
h3 { font-weight: 700; font-size: 16px; }

/* --- nav ---------------------------------------------------------------- */
.site-nav {
  display: flex;
  align-items: center;
  gap: 28px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 32px;
}
.wordmark {
  font-family: var(--display);
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -.02em;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.wordmark .glyph { width: 22px; height: 22px; flex-shrink: 0; }
.site-nav .links { display: flex; gap: 26px; font-size: 14.5px; font-weight: 500; color: var(--muted); }
.site-nav .links a { white-space: nowrap; }
.site-nav .links a:hover { color: var(--ink); }
.site-nav .links a.active { color: var(--pink); }
.site-nav .spacer { flex: 1; }

.btn {
  display: inline-block;
  font-family: var(--body);
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: all .15s ease;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.solid { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn.solid:hover { background: var(--pink-deep); border-color: var(--pink-deep); }
.btn.danger:hover { background: var(--down); border-color: var(--down); color: #fff; }

.nav-user { display: flex; align-items: center; gap: 10px; font-size: 14.5px; font-weight: 600; }
.nav-avatar { width: 34px; height: 34px; border: 1.5px solid var(--hairline-dark); }
.nav-user:hover .nav-avatar { border-color: var(--pink); }

.user-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.user-avatar > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}
.avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pill);
  color: var(--ink);
  font-family: var(--body);
  font-weight: 700;
  text-transform: uppercase;
}

/* theme controls */
.theme-ctl { display: flex; gap: 10px; align-items: center; }
.theme-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-dark);
  background: none;
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .15s;
}
.theme-btn:hover { border-color: var(--ink); }
.theme-btn svg { width: 16px; height: 16px; }
html[data-app-theme="light"] .ic-sun { display: none; }
html[data-app-theme="dark"] .ic-moon { display: none; }

/* appearance popover */
.appearance {
  position: fixed;
  top: 74px;
  right: 32px;
  z-index: 98;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px 22px;
  width: 250px;
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .35);
  font-size: 13.5px;
}
.appearance h4 { font-family: var(--display); font-size: 14px; margin-bottom: 2px; }
.appearance fieldset { border: none; margin-top: 14px; }
.appearance legend {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 6px;
}
.appearance label { display: flex; gap: 8px; align-items: center; padding: 3px 0; cursor: pointer; color: var(--ink); }
.appearance input { accent-color: var(--pink); }
.appearance .hint { margin-top: 14px; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* mobile menu (CSS-only disclosure) */
.mobile-menu { display: none; position: relative; }
.mobile-menu summary {
  list-style: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--hairline-dark);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.mobile-menu summary::-webkit-details-marker { display: none; }
.mobile-menu summary svg { width: 18px; height: 18px; }
.mobile-menu[open] summary { border-color: var(--ink); }
.mobile-menu .sheet {
  position: absolute;
  top: 52px;
  right: 0;
  z-index: 97;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 10px;
  width: 220px;
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
}
.mobile-menu .sheet a {
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
}
.mobile-menu .sheet a:hover { background: var(--hover); }
.mobile-menu .sheet a.active { color: var(--pink); }
.mobile-menu .sheet a.cta { color: var(--pink); font-weight: 600; border-top: 1px solid var(--hairline); border-radius: 0 0 10px 10px; margin-top: 4px; padding-top: 14px; }

/* --- page scaffold ------------------------------------------------------ */
main { flex: 1; width: 100%; }
.page { max-width: 1200px; margin: 0 auto; padding: 44px 32px 96px; }

.crumb { font-family: var(--mono); font-size: 12.5px; color: var(--muted); letter-spacing: .06em; }
.crumb a:hover { color: var(--pink); }
.page-head { display: flex; align-items: flex-end; gap: 24px; margin-top: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 15.5px; padding-bottom: 9px; max-width: 52ch; }
/* Long names and 39-character logins wrap instead of widening the page. */
.page-head h1, .page-head .sub { overflow-wrap: anywhere; }

/* mode tabs */
.modes { display: flex; gap: 6px; margin: 34px 0 0; border-bottom: 1px solid var(--hairline); }
.mode {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--muted);
  padding: 10px 18px 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.mode:hover { color: var(--ink); }
.mode.on { color: var(--ink); border-bottom-color: var(--pink); }
.mode .n {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  background: var(--pill);
  padding: 1px 7px;
  border-radius: 999px;
}

/* stat band */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--hairline); }
.stat { padding: 26px 28px 24px 0; }
.stat + .stat { border-left: 1px solid var(--hairline); padding-left: 28px; }
.stat .label {
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.stat .value { font-family: var(--display); font-weight: 700; font-size: 30px; letter-spacing: -.02em; margin-top: 6px; }
.stat .value small { font-size: 15px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.stat .value .live { color: var(--pink); }

/* hairline data tables */
/* Tables too wide for a phone scroll sideways rather than dropping columns.
   The `local` paper gradients ride along with the content and cover the fixed
   edge shadows, so a shadow only shows on a side with more to scroll to. */
.table-scroll {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--paper) 40%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 40%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, color-mix(in srgb, var(--ink) 16%, transparent), transparent) left / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, color-mix(in srgb, var(--ink) 16%, transparent), transparent) right / 12px 100% no-repeat scroll;
}
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 500;
  text-align: left;
  padding: 0 14px 12px;
  border-bottom: 1px solid var(--hairline-dark);
}
table.data th.r, table.data td.r { text-align: right; }
table.data td { padding: 13px 14px; border-bottom: 1px solid var(--hairline); font-size: 15px; vertical-align: middle; }
table.data tr:hover td { background: var(--hover); }
table.data tr.you td { background: var(--pink-wash); }
table.data td.rank { font-family: var(--mono); color: var(--muted); font-size: 13.5px; width: 48px; }
table.data tr.top td.rank { color: var(--pink-deep); font-weight: 600; }
table.data td.num { font-family: var(--mono); font-size: 14px; }
table.data td.rating { font-family: var(--mono); font-weight: 600; font-size: 15px; }
.global-rankings { table-layout: fixed; }
.global-rankings th:nth-child(1) { width: 10%; }
.global-rankings th:nth-child(2) { width: 48%; }
.global-rankings th:nth-child(3) { width: 18%; }
.global-rankings th:nth-child(4) { width: 24%; }
.global-rankings .ranking-heading-short { display: none; }
.global-rankings .player, .global-rankings .snake-cell { min-width: 0; }
.global-rankings .name { min-width: 0; overflow-wrap: anywhere; }
.global-rankings a.name, .profile-rating a { display: inline-flex; align-items: center; min-height: 44px; }
.global-rankings .ranking-avatar { width: 38px; height: 38px; flex: none; }
.global-rankings .board-suffix { display: inline; }
.profile-rating strong { font-family: var(--mono); font-size: 25px; }
.global-rankings td.rating .total, .global-rankings td.rating .avg { display: block; }
.global-rankings td.rating .avg { color: var(--muted); font-weight: 400; }
.profile-rating .rating-note { color: var(--muted); max-width: 52ch; }
@media (max-width: 640px) {
  table.data.global-rankings th, table.data.global-rankings td { padding: 8px 5px; }
  table.data.global-rankings tbody td { font-size: 16px; }
  .global-rankings th:nth-child(2) { width: 42%; }
  .global-rankings th:nth-child(3) { width: 24%; }
  .global-rankings th { letter-spacing: 0; }
  .global-rankings .ranking-avatar { width: 24px; height: 24px; }
  .global-rankings .snake-cell { gap: 5px; }
}
@media (max-width: 420px) {
  .global-rankings .ranking-heading-full { display: none; }
  .global-rankings .ranking-heading-short { display: inline; }
  .global-rankings th:nth-child(1) { width: 9%; }
  .global-rankings th:nth-child(2) { width: 46%; }
  .global-rankings th:nth-child(3) { width: 29%; }
  .global-rankings th:nth-child(4) { width: 16%; }
  table.data.global-rankings th, table.data.global-rankings td { padding-left: 2px; padding-right: 2px; }
  .global-rankings .ranking-avatar, .global-rankings .board-suffix { display: none; }
}

.snake-cell { display: flex; align-items: center; gap: 12px; }
.chip {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16), 0 0 0 1px rgba(0, 0, 0, .06);
  width: 34px;
  height: 22px;
  border-radius: 6px 12px 12px 6px;
  position: relative;
  flex-shrink: 0;
}
.chip::after {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  right: 6px;
  top: 6px;
}
.snake-cell .name { font-weight: 600; letter-spacing: -.01em; }
.snake-cell .name:hover { color: var(--pink); }
.snake-cell .owner { font-size: 12.5px; color: var(--muted); display: block; margin-top: -2px; }
/* A long unbroken name or 39-character GitHub login wraps rather than widening
   a table that has to fit a phone. No effect inside .table-scroll's nowrap. */
table.data .snake-cell .name, table.data .snake-cell .owner { overflow-wrap: anywhere; }
.snake-details { min-width: 0; }
.snake-tags { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 4px; }
/* No text-transform/letter-spacing here on purpose: tag names are mixed case ("Fly.io", "C#"). */
.snake-tag { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 11px; background: var(--pill); color: var(--muted); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }

.delta { font-family: var(--mono); font-size: 12px; margin-left: 8px; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }

/* pager */
.pager { display: flex; gap: 8px; margin-top: 26px; font-family: var(--mono); font-size: 13px; color: var(--muted); align-items: center; flex-wrap: wrap; }
.pager a { padding: 6px 12px; border: 1px solid var(--hairline); border-radius: 8px; }
.pager a:hover { border-color: var(--ink); color: var(--ink); }
.pager .cur { padding: 6px 12px; background: var(--ink); color: var(--paper); border-radius: 8px; }
.pager .spacer { flex: 1; }

/* side rail */
.rail h3 { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.rail .block { padding: 26px 0; border-bottom: 1px solid var(--hairline); }
.rail .block:first-child { padding-top: 6px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pink); }
.feed { list-style: none; margin-top: 14px; }
.feed li { display: flex; gap: 12px; padding: 9px 0; font-size: 13.5px; align-items: baseline; }
.feed .t { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; width: 52px; flex-shrink: 0; }
.feed b { font-weight: 600; }
.feed .place { font-family: var(--mono); font-size: 12px; }
.feed .p1 { color: var(--pink-deep); font-weight: 600; }
.feed .p4 { color: var(--muted); }
.meta-list { margin-top: 14px; font-size: 14px; }
.meta-list div { display: flex; justify-content: space-between; padding: 7px 0; }
.meta-list dt { color: var(--muted); }
.meta-list dd { font-family: var(--mono); font-size: 13px; }

/* table + rail layout */
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 56px; margin-top: 44px; align-items: start; }

/* small variants & badges */
.stat .value.sm { font-family: var(--mono); font-weight: 500; font-size: 17px; padding-top: 9px; }

/* Public stats: the chart and its full data table are both server-rendered. */
.public-stats { max-width: 100%; min-width: 0; }
.public-stats .page-head { align-items: baseline; }
.public-stats .page-head .sub { font-size: 16px; }
.public-stats .stats-period { color: var(--muted); font-size: 16px; margin: 12px 0 20px; }
.public-stats-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--hairline); }
.public-stats-tiles .stat { min-width: 0; border-bottom: 1px solid var(--hairline); }
.public-stats-tiles .stat:nth-child(4n + 1) { border-left: 0; padding-left: 0; }
.public-stats-tiles .stat .label, .public-stats-tiles .stat .detail { font-size: 16px; letter-spacing: 0; line-height: 1.4; }
.public-stats-tiles .stat .detail { color: var(--muted); margin-top: 7px; }
.public-stats-tiles .stat .value { overflow-wrap: anywhere; }
.public-stats-note { margin: 32px 0 50px; padding: 18px 22px; border-left: 3px solid var(--pink); background: var(--surface, transparent); line-height: 1.55; font-size: 16px; }
.public-stats-note p { margin: 0 0 10px; }
.public-stats-note p:last-child { margin-bottom: 0; }
.public-stats-section { min-width: 0; margin: 48px 0 64px; }
.public-stats-section h2 { margin-bottom: 16px; }
.public-stats-chart { display: block; width: 100%; height: auto; max-height: 240px; overflow: visible; }
.public-stats-chart .chart-axis { stroke: var(--hairline); stroke-width: 2; }
.public-stats-chart .chart-label { fill: var(--ink); font-family: var(--mono); font-size: 14px; }
.public-stats-chart .chart-series-0, .public-stats-legend .series-0 { fill: var(--pink); background: var(--pink); }
.public-stats-chart .chart-series-1, .public-stats-legend .series-1 { fill: #3ca7a0; background: #3ca7a0; }
.public-stats-chart .chart-series-2, .public-stats-legend .series-2 { fill: #db9d40; background: #db9d40; }
.public-stats-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 16px; margin: 10px 0 18px; }
.public-stats-legend .key { display: inline-block; width: 13px; height: 13px; margin-right: -8px; border-radius: 2px; }
.public-stats-table-wrap { max-width: 100%; max-height: 320px; overflow: auto; border: 1px solid var(--hairline); margin-top: 18px; }
.public-stats-table { border-collapse: collapse; width: 100%; font-size: 16px; text-align: left; }
.public-stats-table:has(thead th:nth-child(4)) { min-width: 460px; }
.public-stats-table caption { text-align: left; padding: 12px; font-size: 16px; font-weight: 600; }
.public-stats-table th, .public-stats-table td { padding: 8px 12px; border-top: 1px solid var(--hairline); white-space: nowrap; }
.public-stats-table thead th { position: sticky; top: 0; background: var(--bg, #fff); white-space: normal; }
.public-stats-table td { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 760px) {
  .public-stats-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-stats-tiles .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
}
@media (max-width: 480px) {
  .public-stats-tiles { grid-template-columns: minmax(0, 1fr); }
  .public-stats-tiles .stat { border-left: 0; padding: 18px 0; }
  .public-stats-note { padding: 16px; }
}
.btn.sm { padding: 5px 14px; font-size: 13px; }
.badge { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; background: var(--pill); color: var(--muted); padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--up); }
.badge.warn { color: var(--down); }
.section { margin-top: 48px; }
.section h2 { margin-bottom: 4px; }
.section table.data { margin-top: 16px; }
p.empty { color: var(--muted); font-size: 14.5px; margin: 18px 0; }

/* sort bar above data tables */
.sortbar { display: flex; gap: 14px; align-items: baseline; margin-bottom: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.sortbar span:first-child { text-transform: uppercase; letter-spacing: .12em; font-size: 10.5px; }
.sortbar a:hover { color: var(--ink); }
.sortbar .on { color: var(--pink-deep); font-weight: 600; }

/* rail: user snake rows + join form */
.rail .mine { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.rail .mine .mname { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail .mine form { display: inline; }
.rail .mstats { font-family: var(--mono); font-size: 12px; color: var(--muted); margin: 4px 0 0 44px; }
.rail .railp { font-size: 14px; color: var(--muted); margin-top: 10px; }
.owner-inline { color: var(--muted); font-size: 12.5px; }
.join-form { display: flex; gap: 8px; margin-top: 16px; }
.join-form select { flex: 1; min-width: 0; font-family: var(--body); font-size: 14px; padding: 8px 10px; border: 1px solid var(--hairline-dark); border-radius: 10px; background: var(--card); color: var(--ink); }

/* --- flash message ------------------------------------------------------ */
.flash-message {
  max-width: 1200px;
  margin: 0 auto;
  width: calc(100% - 64px);
  background: var(--pink-wash);
  border: 1px solid var(--pink);
  color: var(--ink);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14.5px;
  animation: flash-in .4s ease, flash-out .5s 6s forwards;
}
@keyframes flash-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flash-out { from { opacity: 1; } to { opacity: 0; visibility: hidden; } }

.live-refresh-expired {
  margin: 16px 0;
  background: var(--pink-wash);
  border: 1px solid var(--pink);
  color: var(--ink);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14.5px;
}
.live-refresh-expired a { font-weight: 600; }

/* --- footer -------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--hairline); margin-top: 64px; }
.site-footer .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
}
.site-footer a:hover { color: var(--pink); }
.site-footer .spacer { flex: 1; }

/* --- legacy classes (pre-redesign pages), tokenized ---------------------- */
/* These keep not-yet-redesigned pages presentable inside the new shell.
   Their slices will replace them with the primitives above. */
.pagination { display: flex; gap: 8px; align-items: center; margin: 16px 0; font-family: var(--mono); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 12px; border: 1px solid var(--hairline); border-radius: 8px; color: var(--muted); }
.pagination a:hover { border-color: var(--ink); color: var(--ink); }
.pagination .current { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pagination .disabled { color: var(--hairline-dark); pointer-events: none; }
.rating-positive { color: var(--up); font-weight: 600; }
.rating-negative { color: var(--down); font-weight: 600; }
.rating-neutral { color: var(--muted); }
.rating-chart-container { margin: 16px 0; }
.rating-chart { border: 1px solid var(--hairline); border-radius: 8px; display: block; }
.rating-chart .grid { stroke: var(--hairline); }
.rating-chart .line { stroke: var(--pink); }
.rating-chart .lbl { fill: var(--muted); font-family: var(--mono); font-size: 11px; }

/* Leaderboard entry page */
.entry-avatar { width: 44px; height: 44px; align-self: center; }
.owner-avatar { width: 24px; height: 24px; margin-right: 8px; }
.stat .formrow { margin-top: 8px; font-size: 15px; letter-spacing: 2px; }

/* Empty-state block with CTAs (tournaments, future empty listings) */
.empty-state { margin: 28px 0 8px; }
.empty-state .cta-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.activity-feed { max-height: 300px; overflow-y: auto; border: 1px solid var(--hairline); border-radius: 12px; padding: 12px; }
.activity-feed-item { padding: 6px 0; border-bottom: 1px solid var(--hairline); }
.activity-feed-item:last-child { border-bottom: none; }

/* --- forms (shared editorial form kit) ----------------------------------- */
/* Promoted post-redesign from the slice 5/7/8 sections so every stacked form
   (profile edit, snake create/edit, claim flow, tournament create/edit)
   shares one recipe. Inline row forms (.join-form, .seed-form, .rail-form)
   stay page-local. */
.form-stack { display: flex; flex-direction: column; gap: 20px; margin-top: 22px; max-width: 560px; }
.form-stack > .btn { align-self: flex-start; margin-top: 4px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin-bottom: 7px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline-dark);
  border-radius: 12px;
  padding: 11px 14px;
  min-height: 46px;
}
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--muted); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-wash);
}
.field input[type="url"] { font-family: var(--mono); font-size: 13.5px; }
.field input[type="number"] { font-family: var(--mono); }
.field input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 0;
  padding: 0;
  accent-color: var(--pink);
  flex-shrink: 0;
}
.field textarea { min-height: 130px; resize: vertical; line-height: 1.55; }
.field .help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.form-cta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.directory-search { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-top: 24px; max-width: 640px; }
.directory-search .field { flex: 1 1 260px; min-width: 0; }
.form-error { background: var(--pink-wash); border: 1px solid var(--pink); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-size: 14px; margin: 16px 0; }
.form-ok { background: color-mix(in srgb, var(--up) 12%, transparent); border: 1px solid var(--up); color: var(--ink); border-radius: 12px; padding: 12px 16px; font-size: 14px; margin: 16px 0; }
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 640px) {
  .form-stack > .btn { align-self: stretch; text-align: center; }
}

/* ==========================================================================
   Per-page sections. Each redesign slice owns exactly one block below and
   must not edit outside it — keeps parallel slice PRs conflict-free.
   ========================================================================== */

/* --- page: home (slice 4) ------------------------------------------------ */
/* hero (logged out) */
.home .hero {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 64px;
  align-items: center;
  padding: 28px 0 24px;
}
.home .kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--pink);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}
.home .kicker::before { content: ""; width: 28px; height: 1.5px; background: var(--pink); }
.home .hero h1 { font-size: clamp(42px, 5vw, 64px); line-height: 1.02; }
.home .hero h1 em, .home .statement h2 em { font-style: normal; color: var(--pink); }
.home .hero .lede { margin-top: 26px; font-size: 19px; color: var(--muted); max-width: 44ch; }
.home .cta-row { margin-top: 36px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.home .cta-row .btn { padding: 11px 24px; }
.home .cta-note { font-size: 13.5px; color: var(--muted); margin-top: 16px; font-family: var(--mono); }
.home .cta-note code { font: inherit; }

/* decorative board — intentionally dark-framed in both themes */
.home .board-frame { position: relative; }
.home .board {
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  grid-template-rows: repeat(11, 1fr);
  aspect-ratio: 1;
  gap: 4px;
  padding: 14px;
  background: linear-gradient(180deg, #1A141A, #171217);
  border: 1px solid #322A31;
  border-radius: 20px;
  box-shadow: 0 24px 60px -24px rgba(23, 20, 26, .5), 0 0 80px -36px rgba(232, 37, 109, .5);
}
.home .board .cell { background: #241C23; border-radius: 4px; position: relative; }
.home .board .seg { border-radius: 4px; }
.home .board .seg.head { border-radius: 7px; }
.home .board .seg.head::after {
  content: "";
  position: absolute;
  width: 18%;
  height: 18%;
  background: #161115;
  border-radius: 50%;
  top: 24%;
  right: 24%;
}
.home .board .food::after {
  content: "";
  position: absolute;
  inset: 26%;
  background: #FF5F6D;
  border-radius: 50%;
  box-shadow: 0 0 9px rgba(255, 95, 109, .55);
}
.home .board-caption {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translate(-50%, 100%);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  align-items: center;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* editorial features (logged out) */
.home .features { padding: 72px 0 16px; display: grid; grid-template-columns: repeat(3, 1fr); }
.home .feature { padding: 8px 36px 8px 0; }
.home .feature + .feature { border-left: 1px solid var(--hairline); padding-left: 36px; }
.home .feature .num { font-family: var(--mono); font-size: 12.5px; color: var(--pink); font-weight: 600; }
.home .feature h2 { font-size: 21px; letter-spacing: -.01em; margin: 14px 0 10px; }
.home .feature p { font-size: 15px; color: var(--muted); }
.home a.more { display: inline-block; margin-top: 14px; font-size: 14px; font-weight: 600; color: var(--pink); padding: 4px 0; }
.home a.more:hover { color: var(--pink-deep); }

/* closing statement (logged out) */
.home .statement { padding: 88px 0 24px; text-align: center; }
.home .statement h2 {
  font-weight: 800;
  letter-spacing: -.03em;
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.12;
  max-width: 21ch;
  margin: 0 auto;
}
.home .statement p { color: var(--muted); margin: 22px auto 0; max-width: 52ch; }
.home .statement .btn { margin-top: 34px; display: inline-block; }

/* welcome band (logged in) */
.home .welcome { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding-top: 6px; }
.welcome-avatar { width: 64px; height: 64px; border: 1px solid var(--hairline-dark); }
.home .welcome .who { min-width: 0; }
/* GitHub logins run to 39 chars; never let the welcome heading push the page wide. */
.home .welcome h1 { font-size: clamp(30px, 3.4vw, 40px); overflow-wrap: anywhere; }
.home .welcome .sub { color: var(--muted); font-size: 15.5px; margin-top: 4px; }
.home .welcome .cta-row { margin: 0 0 0 auto; }

/* snake quick-status rows (logged in) */
.home .snakes .rows { margin-top: 16px; border-top: 1px solid var(--hairline-dark); }
.home .srow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  min-height: 44px;
  border-bottom: 1px solid var(--hairline);
}
.home .srow:hover { background: var(--hover); }
.home .srow .sname { font-weight: 600; letter-spacing: -.01em; }
.home .srow:hover .sname { color: var(--pink); }
.home .srow .surl {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home .srow .badge { margin-left: auto; }
.home .srow .surl + .badge { margin-left: 0; }

/* ladder preview + recent games rail */
.home .grid { margin-top: 56px; }
.home .ladder-sub { color: var(--muted); font-size: 14.5px; margin-top: 2px; }
.home .ladder table.data { margin-top: 18px; }
.home .ladder a.more { margin-top: 18px; }

@media (max-width: 900px) {
  .home .hero { grid-template-columns: 1fr; gap: 56px; padding-top: 12px; }
  .home .features { grid-template-columns: 1fr; gap: 32px; padding: 56px 0 8px; }
  .home .feature { padding: 0; }
  .home .feature + .feature { border-left: none; border-top: 1px solid var(--hairline); padding: 32px 0 0; }
  .home .welcome .cta-row { margin-left: 0; width: 100%; }
}
@media (max-width: 640px) {
  .home .hero { gap: 44px; }
  .home .board { gap: 3px; padding: 10px; border-radius: 16px; }
  .home .statement { padding: 64px 0 16px; }
  .home .srow .badge { display: none; }
}

/* --- page: game theater (slice 3) ---------------------------------------- */

/* Theater pages resolve their theme from the theater axis (create_theater_page).
   The stage panel frames the board.battlesnake.com iframe. */
.refresh-link { color: var(--pink); }
.live-pill { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--pink); color: var(--pink-deep); display: inline-flex; gap: 7px; align-items: center; margin-left: 12px; vertical-align: 1px; }
.live-pill.quiet { border-color: var(--hairline-dark); color: var(--muted); }
.theater { display: grid; grid-template-columns: 1fr 320px; gap: 40px; margin-top: 28px; align-items: start; }
/* stage stays dark in BOTH theater themes, per the locked mockup */
.board-wrap { background: #1E181D; border: 1px solid #2A232A; border-radius: 18px; padding: 16px; box-shadow: 0 1px 2px rgba(0, 0, 0, .05), 0 24px 60px -30px rgba(0, 0, 0, .4); }
.board-wrap iframe { display: block; width: 100%; height: 100%; border: 0; border-radius: 10px; background: #171117; }
.theater-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.theater-rail-head { font-size: 18px; display: flex; align-items: baseline; gap: 10px; }
.theater-rail-head .sub-count { font-family: var(--mono); font-size: 12px; color: var(--muted); font-weight: 400; }
.snakes { margin-top: 10px; }
.scard { border: 1px solid var(--hairline); border-radius: 14px; padding: 13px 16px; margin-top: 10px; background: var(--card); }
.scard .top { display: flex; gap: 12px; align-items: center; }
.scard .name { font-weight: 600; letter-spacing: -.01em; }
.scard .owner { font-size: 12.5px; color: var(--muted); margin-top: -2px; }
.scard .place { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.scard.p1 { border-color: var(--pink); }
.scard.p1 .place { color: var(--pink-deep); font-weight: 600; }
.gmeta { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--hairline); }
.share-row { display: flex; gap: 8px; margin-top: 12px; }
.share-row input { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12.5px; color: var(--muted); background: var(--card); border: 1px solid var(--hairline-dark); border-radius: 10px; padding: 8px 12px; }
.share-row input:focus-visible { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-wash); }
.gmeta-note { color: var(--muted); font-size: 13px; margin-top: 6px; }
.rail-form.turn-json-form select { flex-basis: 100%; }
.turn-json-actions { margin-left: auto; display: flex; gap: 8px; }
/* .btn sets display, which would otherwise override [hidden] */
.turn-json-actions [hidden] { display: none; }
.turn-json-error { color: var(--down); font-size: 13px; margin-top: 10px; }

@media (max-width: 980px) {
  .theater { grid-template-columns: 1fr; }
}

/* --- page: profile + snakes (slice 5) ------------------------------------ */

/* identity header (/me) */
.profile-head { display: flex; align-items: center; gap: 22px; margin-top: 36px; }
.profile-head .avatar {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 1px solid var(--hairline-dark);
  flex-shrink: 0;
  background: var(--pill);
  box-shadow: 0 10px 26px -14px rgba(0, 0, 0, .45);
}
.profile-head .who { min-width: 0; }
.profile-head h1 { overflow-wrap: anywhere; }
.profile-head h2 { font-weight: 800; letter-spacing: -.02em; font-size: clamp(24px, 3vw, 32px); line-height: 1.15; overflow-wrap: anywhere; }
.profile-head .meta { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-top: 4px; }
.profile-head .bio { font-size: 15px; color: var(--muted); margin-top: 8px; max-width: 60ch; white-space: pre-wrap; overflow-wrap: break-word; }

.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }

/* play-account claim prompt (/me, until claimed or dismissed) */
.claim-prompt { margin-top: 28px; background: var(--pink-wash); border: 1px solid var(--pink); border-radius: 14px; padding: 18px 22px; font-size: 15px; max-width: 72ch; }
.claim-prompt-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 8px; }
.claim-prompt h2 { font-size: 20px; overflow-wrap: anywhere; }
.claim-prompt-head form { margin: 0; flex-shrink: 0; }
.claim-prompt ul { padding-left: 20px; margin: 10px 0; display: grid; gap: 6px; }
.claim-prompt a { color: var(--pink); text-decoration: underline; text-underline-offset: 2px; }
.claim-prompt .fine { color: var(--muted); font-size: 13.5px; }

/* snakes list table (/battlesnakes) */
.head-actions { margin-left: auto; padding-bottom: 6px; display: flex; gap: 10px; flex-wrap: wrap; }
.url-cell { font-family: var(--mono); font-size: 13px; color: var(--muted); max-width: 340px; }
.url-cell a { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.url-cell a:hover { color: var(--pink); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline; margin: 0; }
/* The URL rides under the name and never sets the column's width, so the
   actions stay on screen on a phone. */
.my-snakes .snake-details { flex: 1; }
.my-snakes .snake-url { display: block; width: 0; min-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.my-snakes .snake-url:hover { color: var(--pink); }

/* snake test results: each call's details sit in a full-width row beneath it */
table.data.test-results tr:hover td { background: none; }
table.data.test-results tr.call td { border-bottom: 0; padding-bottom: 4px; }
table.data.test-results tr.call-details td { padding-top: 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
table.data.test-results pre { margin-top: 8px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .profile-head { gap: 16px; }
  .profile-head .avatar { width: 60px; height: 60px; }
  .profile-actions .btn, .head-actions .btn, .claim-prompt .btn { padding: 11px 20px; }
  .claim-prompt { padding: 16px; }
  .row-actions { flex-direction: column; align-items: flex-end; gap: 6px; }
  .row-actions .btn.sm { padding: 9px 16px; }
}

/* --- page: customizations (slice 6) --------------------------------------- */

.cz-note { font-size: 16px; color: var(--muted); margin-top: 18px; }
.cz-note a { color: var(--pink); }
.cz-redeem .field input { font-size: 16px; min-height: 44px; }
.cz-redeem > .btn { min-height: 44px; }
.admin-code-form > .btn { min-height: 44px; }
.cz-group { margin-top: 48px; }
.cz-group-head { display: flex; align-items: baseline; gap: 12px; border-bottom: 1px solid var(--hairline); padding-bottom: 10px; }
.cz-group-head h2 { font-size: 22px; }
.cz-count { font-family: var(--mono); font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.cz-kind { font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 500; margin: 24px 0 12px; }
.cz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 14px; }
.cz-item { display: flex; flex-direction: column; align-items: center; min-width: 0; border: 1px solid var(--hairline); border-radius: 14px; padding: 14px 10px 12px; text-align: center; background: var(--card); transition: border-color .15s, transform .15s; }
.cz-item:hover { border-color: var(--hairline-dark); transform: translateY(-2px); }
.cz-item.locked .cz-swatch, .cz-item.locked .cz-name { opacity: .55; }
/* Snake head/tail art is dark line-work on transparent; a fixed light
   swatch keeps every asset legible in both site themes. */
.cz-swatch { width: 100%; background: #F4F1EB; border-radius: 10px; aspect-ratio: 1; display: grid; place-items: center; padding: 12px; }
.cz-swatch img { width: 100%; height: 100%; object-fit: contain; }
.cz-name { max-width: 100%; font-weight: 600; font-size: 13.5px; letter-spacing: -.01em; margin: 10px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cz-description { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 0 0 10px; overflow-wrap: anywhere; }
.cz-item .badge { margin-top: auto; }
.cz-slug { display: block; max-width: 100%; overflow-wrap: anywhere; font-size: 13px; margin-bottom: 8px; }
.cz-unlock-form { width: 100%; margin-top: 12px; }
.cz-unlock { width: 100%; min-height: 44px; }

@media (max-width: 640px) {
  .cz-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
}

/* --- page: claim/import (slice 7) ------------------------------------------ */

/* Narrow centered column for the play-account claim/recovery flow. */
.form-page { max-width: 460px; margin: 0 auto; }
.form-page .crumb { margin-bottom: 4px; }
.form-page .page-head { margin-bottom: 20px; }
.form-page h1 { font-size: clamp(28px, 3vw, 38px); }
.form-page .lede { color: var(--ink); font-size: 15.5px; margin-bottom: 16px; }
.form-page .fine { color: var(--muted); font-size: 13px; line-height: 1.6; margin-bottom: 16px; }
.form-page .fine a { color: var(--pink); }
.form-page .fine.alt { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--hairline); }

.form-page .form-stack { margin-top: 8px; }
.form-page .form-stack .fine { margin: 0; }

/* --- page: tournaments (slice 8) -------------------------------------------- */

.page-head .spacer { flex: 1; }
.head-cta { margin-bottom: 12px; }
.head-status { margin-bottom: 14px; }
.champ-chip { display: inline-block; vertical-align: -2px; margin-right: 8px; }
.badge.live { color: var(--pink-deep); background: var(--pink-wash); }

.round-pill {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--pink-deep);
  border: 1px solid var(--pink);
  background: var(--pink-wash);
  border-radius: 999px;
  padding: 5px 14px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  letter-spacing: .04em;
  margin-bottom: 12px;
  white-space: nowrap;
}
.round-pill .live-dot { width: 7px; height: 7px; flex-shrink: 0; }

.tourney-desc { margin-top: 16px; max-width: 70ch; font-size: 15.5px; }

/* bracket */
.bracket-note {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 44px;
}
.bracket-scroll { overflow-x: auto; margin-top: 10px; padding-bottom: 8px; }
.round-labels { display: grid; border-bottom: 1px solid var(--hairline); padding-bottom: 10px; }
.round-labels span {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
}
.bracket { display: grid; margin-top: 18px; }

.bracket .match {
  border: 1px solid var(--hairline-dark);
  border-radius: 12px;
  background: var(--card);
  align-self: center;
  width: 100%;
  min-width: 0;
  padding: 8px 12px;
  position: relative;
}
.bracket .match .tag {
  position: absolute;
  top: -8px;
  left: 12px;
  background: var(--paper);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 6px;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  white-space: nowrap;
}
.bracket .team { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-size: 14.5px; }
.bracket .team + .team { border-top: 1px solid var(--hairline); }
.bracket .team .chip { width: 24px; height: 16px; border-radius: 4px 9px 9px 4px; }
.bracket .team .chip::after { width: 3px; height: 3px; right: 4px; top: 4px; }
.bracket .chip.tbd { border: 1px dashed var(--hairline-dark); background: none; box-shadow: none; }
.bracket .chip.tbd::after { display: none; }
.bracket .team .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.bracket .team .score { font-family: var(--mono); font-size: 13.5px; color: var(--muted); }
.bracket .team.w .name { font-weight: 700; }
.bracket .team.w .score { color: var(--pink-deep); font-weight: 600; }
.bracket .team.l .name, .bracket .team.l .score { color: var(--muted); }
.bracket .team.tbd .name { color: var(--muted); font-style: italic; }

.bracket .conn {
  border-top: 1px solid var(--hairline-dark);
  border-right: 1px solid var(--hairline-dark);
  border-bottom: 1px solid var(--hairline-dark);
}
.bracket .conn-h { align-self: center; height: 1px; background: var(--hairline-dark); }

.bracket .match.live {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px var(--pink-wash), 0 12px 30px -18px rgba(232, 37, 109, .5);
}
.bracket .match.live .tag { color: var(--pink); font-weight: 600; }
.bracket .match.live .tag .live-dot { width: 5px; height: 5px; }
.bracket .match.live .team .score { color: var(--ink); font-weight: 600; }

.bracket .mgames {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding: 5px 2px 2px;
  border-top: 1px solid var(--hairline);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .04em;
}
.bracket .mgames a { color: var(--muted); }
.bracket .mgames a:hover { color: var(--pink); }

/* intentionally dark in both themes: a sliver of the game theater */
.theater-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  background:
    linear-gradient(rgba(244, 239, 234, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(244, 239, 234, .05) 1px, transparent 1px),
    #161115;
  background-size: 9px 9px, 9px 9px, auto;
  border-radius: 8px;
  padding: 8px 12px;
  transition: filter .15s;
}
.theater-strip:hover { filter: brightness(1.25); }
.theater-strip .play {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FF3D8A;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow: 0 0 12px -2px rgba(255, 61, 138, .8);
}
.theater-strip .play svg { width: 8px; height: 8px; display: block; margin-left: 1px; }
.theater-strip .label { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; color: #9C8F99; }
.theater-strip .go { margin-left: auto; font-family: var(--mono); font-size: 11px; color: #FF3D8A; white-space: nowrap; }

.bracket .champ {
  align-self: center;
  width: 100%;
  border: 1.5px dashed var(--hairline-dark);
  border-radius: 12px;
  padding: 18px 16px;
  text-align: center;
}
.bracket .champ.crowned { border: 1.5px solid var(--pink); background: var(--pink-wash); }
.bracket .champ .glyph { font-size: 20px; line-height: 1; }
.bracket .champ .label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .16em;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 8px;
}
.bracket .champ .who { font-family: var(--display); font-weight: 700; font-size: 15px; color: var(--muted); margin-top: 4px; }
.bracket .champ.crowned .who { color: var(--ink); font-size: 17px; }

/* registered snakes: seed move + unregister row actions */
.reg-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.seed-form { display: inline-flex; gap: 6px; align-items: center; }
.seed-form input {
  width: 64px;
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--hairline-dark);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
}

/* rail forms (owner controls, import, register) */
.owner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.owner-actions form { display: inline; }
.rail-form { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.rail-form select, .rail-form input {
  font-family: var(--body);
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--hairline-dark);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
}
.rail-form select { flex: 1; min-width: 0; }
.rail-form input[type="number"] { width: 76px; font-family: var(--mono); }
.rail-form .lbl { font-family: var(--mono); font-size: 12px; color: var(--muted); }

@media (max-width: 640px) {
  .bracket-scroll { margin-left: -20px; margin-right: -20px; padding-left: 20px; padding-right: 20px; }
  .reg-actions .btn.sm, .owner-actions .btn.sm { padding: 11px 16px; }
  .seed-form input { padding: 10px 8px; font-size: 16px; min-height: 44px; }
}

/* --- responsive ---------------------------------------------------------- */
/* Compact the logged-in nav until there is room for full spacing and names. */
@media (min-width: 1221px) and (max-width: 1700px) {
  .site-nav { gap: 10px; }
  .site-nav .links { gap: 10px; }
  .nav-user { min-width: 0; }
  .nav-user-name { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* Collapse below 1221px; page layout still switches at 980px. */
@media (max-width: 1220px) {
  .site-nav .links { display: none; }
  .mobile-menu { display: block; }
  /* Match the 44px hamburger tap target while the menu is collapsed */
  .theme-btn { width: 44px; height: 44px; }
}
@media (max-width: 980px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .site-nav .links { display: none; }
  .mobile-menu { display: block; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(odd) { border-left: none; padding-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--hairline); padding-left: 28px; }
}
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .site-nav { gap: 8px; padding: 18px 20px; } /* Bell needs room in the collapsed nav. */
  /* sign-in moves into the mobile menu sheet; avatar stays for logged-in */
  .site-nav > .btn.solid { display: none; }
  .nav-user-name {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .theme-btn { width: 44px; height: 44px; }
  .appearance { right: 16px; left: 16px; width: auto; top: 80px; }
  .page { padding: 28px 20px 96px; }
  .flash-message { width: calc(100% - 40px); }
  .modes { overflow-x: auto; scrollbar-width: none; }
  .modes::-webkit-scrollbar { display: none; }
  .mode { white-space: nowrap; }
  table.data th, table.data td { padding-left: 8px; padding-right: 8px; }
  .table-scroll th, .table-scroll td { white-space: nowrap; }
  .site-footer .inner { padding: 24px 20px; }
}
/* Narrow phones: logged-in nav is glyph + 2 theme buttons + menu + avatar.
   With the wordmark text that sums past 375px and the avatar clips. */
@media (max-width: 420px) {
  .wordmark-text { display: none; }
}

/* --- page: create game --------------------------------------------------- */

.gc.grid { margin-top: 40px; }
.gc .rail { position: sticky; top: 28px; }
.gc-section h2 { margin-bottom: 2px; }
.gc-sub { color: var(--muted); font-size: 14.5px; }

/* selectable snake rows (own snakes + search results) */
.gc-rows { margin-top: 16px; }
.gc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: 14px;
  padding: 13px 16px;
  margin-top: 10px;
  transition: border-color .15s;
}
.gc-row:hover { border-color: var(--hairline-dark); }
.gc-row.sel { border-color: var(--pink); }
.gc-row .gc-who { min-width: 0; flex: 1; }
.gc-row .gc-name { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -.01em; flex-wrap: wrap; }
.gc-row .gc-url {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gc-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.gc-actions form { display: inline; margin: 0; }
.gc-empty { margin-top: 16px; }
.gc-empty .btn { display: inline-block; margin-top: 14px; }
.gc-empty p:first-child { font-weight: 600; }

/* public snake search */
.gc-search { display: flex; gap: 8px; margin-top: 16px; max-width: 620px; flex-wrap: wrap; }
.gc-search label { flex-basis: 100%; font-weight: 600; }
.gc-search input {
  flex: 1;
  min-width: 0;
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--hairline-dark);
  border-radius: 12px;
  padding: 10px 14px;
}
.gc-search input:hover { border-color: var(--muted); }
.gc-search input:focus-visible { outline: none; border-color: var(--pink); box-shadow: 0 0 0 3px var(--pink-wash); }
.gc-results-head { margin-top: 26px; }
.gc-none { color: var(--muted); font-size: 14.5px; margin-top: 18px; }
.gc-owner, .gc-result-summary { color: var(--muted); font-size: 14px; }
.gc-owner { display: block; margin-top: 3px; }
.gc-result-summary { margin-top: 18px; }
.gc-pager { margin-top: 16px; }
.gc-configure-error {
  border: 1px solid var(--pink);
  border-radius: 10px;
  background: var(--pink-wash);
  color: var(--pink-deep);
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.gc-configure-error[hidden] { display: none; }

/* lineup rail */
.gc-slots { margin-top: 14px; }
.gc-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--hairline);
  background: var(--card);
  border-radius: 12px;
  padding: 9px 12px;
  margin-top: 8px;
  min-height: 46px;
}
.gc-slot-name { font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-slot form { display: inline; margin-left: auto; }
.gc-slot .badge { flex-shrink: 0; }
.gc-slot.empty {
  border-style: dashed;
  border-color: var(--hairline-dark);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .12em;
  justify-content: center;
}
.gc-x {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.gc-x:hover { background: var(--pink-wash); color: var(--pink-deep); }
.gc-slot.gc-unavailable {
  border-color: var(--pink);
  background: var(--pink-wash);
  color: var(--pink-deep);
  flex-wrap: wrap;
}
.gc-unavailable-copy { color: var(--pink-deep); }
.rematch-action { min-height: 44px; min-width: 110px; }

@media (max-width: 420px) {
  .gc-slot { padding: 8px; }
  .gc-slot-name { white-space: normal; overflow-wrap: anywhere; }
  .gc-slot form { flex-shrink: 0; }
}
.gc-hint { font-size: 13.5px; color: var(--muted); margin-top: 12px; }
.gc-reset { margin-top: 10px; }

/* settings + CTA */
.gc-settings { max-width: none; gap: 16px; margin-top: 16px; }
.gc-settings > .btn { align-self: stretch; text-align: center; margin-top: 8px; padding: 11px 24px; }

@media (max-width: 980px) {
  .gc.grid { grid-template-columns: 1fr; gap: 8px; }
  .gc .rail { position: static; }
}
@media (max-width: 640px) {
  .gc-row { flex-wrap: wrap; padding: 14px 16px; }
  .gc-row .gc-who { flex-basis: calc(100% - 40px); }
  .gc-actions { width: 100%; }
  .gc-actions form { flex: 1; }
  .gc-actions .btn { width: 100%; padding: 10px 14px; }
  .gc-search { max-width: none; }
  .gc-search input { flex-basis: 100%; }
  .gc-row, .gc-who, .gc-owner { min-width: 0; max-width: 100%; }
  .gc-name, .gc-owner { overflow-wrap: anywhere; }
  /* Keep mobile controls tappable and avoid iOS zooming small form text. */
  .btn, .pager a { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .field input, .field select, .field textarea, .field input[type="url"], .gc-search input { font-size: 16px; }
  .rail-form select, .rail-form input { font-size: 16px; min-height: 44px; }
  .gc-search input { min-height: 44px; }
  .gc-x { width: 44px; height: 44px; }
  .field label:has(input[type="checkbox"]) { min-height: 44px; }
}
.gc-solo-warn { color: var(--pink-deep); }

/* game view: queued-game placeholder (board viewer has no frames to show yet) */
.board-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #9C8F99;
  font-family: var(--mono);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
}

/* --- page: snake profile (/battlesnakes/{id}/profile) ---------------------- */

/* identity header */
.snake-profile .page-head { align-items: center; }
.snake-profile .snake-preview {
  width: 128px;
  height: 40px;
  object-fit: contain;
  padding: 10px 12px;
  background: var(--pill);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-sizing: content-box;
  flex-shrink: 0;
}
.snake-profile .snake-id { min-width: 0; }
.snake-profile .snake-id h1 { overflow-wrap: anywhere; }
.snake-profile .page-head .sub { padding-bottom: 0; margin-top: 2px; }
.snake-profile .owner-line { display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; }
.snake-profile .owner-line .owner-avatar { margin-right: 0; }
.snake-profile .snake-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 10px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.snake-profile .snake-meta .chip { display: inline-block; width: 22px; height: 14px; border-radius: 4px 8px 8px 4px; margin-right: 6px; vertical-align: -3px; }
.snake-profile .snake-meta .chip::after { width: 3px; height: 3px; right: 4px; top: 4px; }
.snake-profile .snake-id .snake-tags { margin-top: 10px; }
.snake-profile .snake-url { margin-top: 8px; max-width: 460px; }
.snake-profile .head-actions { padding-bottom: 0; align-self: center; }
.snake-profile .head-actions form { margin: 0; }

/* owner notice when the health sweeper paused matchmaking */
.snake-profile .snake-paused { margin-top: 24px; display: grid; gap: 8px; justify-items: start; }
.snake-profile .snake-paused .fine { color: var(--muted); font-size: 13.5px; }

/* stat band + tables */
.snake-profile .stats { margin-top: 28px; border-top: 1px solid var(--hairline); }
.snake-profile .stat-detail { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.snake-profile .stat-detail .warn { color: var(--down); }
.snake-profile table.data td .sub { display: block; color: var(--muted); font-family: var(--mono); font-size: 12px; margin-top: 2px; }

/* move latency chart */
.latency-summary { margin: 10px 0 12px; }
.latency-summary .latency-timeouts { color: var(--down); }
.latency-chart { display: block; width: 100%; height: auto; max-height: 280px; }
.latency-chart .grid { stroke: var(--hairline); stroke-width: 1; }
.latency-chart .timeout-line { stroke: var(--down); stroke-width: 1; stroke-dasharray: 4 4; }
.latency-chart .lbl { fill: var(--muted); font-family: var(--mono); font-size: 13px; }
.latency-chart .timeout-lbl { fill: var(--down); }
.latency-chart .hit { fill: transparent; }
.latency-chart a:hover .hit, .latency-chart a:focus .hit { fill: var(--hover); }
.latency-chart .plot { pointer-events: none; }
.latency-chart .p50, .latency-chart .p95 { fill: none; stroke-width: 2; stroke-linejoin: round; }
.latency-chart .p95 { stroke: var(--pink); }
.latency-chart .p50 { stroke: #3ca7a0; }
.latency-chart .pt-p95 { fill: var(--pink); }
.latency-chart .pt-p50 { fill: #3ca7a0; }
.latency-chart .timeout { fill: var(--down); }
.latency-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.latency-legend .swatch { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
.latency-legend .swatch.p95 { background: var(--pink); }
.latency-legend .swatch.p50 { background: #3ca7a0; }
.latency-legend .swatch.timeout { background: var(--down); border-radius: 50%; }

@media (max-width: 640px) {
  .snake-profile .page-head { gap: 16px; }
  .snake-profile .snake-preview { width: 96px; height: 30px; padding: 8px 10px; }
  .snake-profile .head-actions { margin-left: 0; width: 100%; }
  .snake-profile .head-actions .btn { padding: 11px 20px; }
  /* The chart scales down to fit; enlarge its labels so they stay readable at ~375px. */
  .latency-chart .lbl { font-size: 22px; }
}

/* --- page: studio ----------------------------------------------------------- */

/* Board preview (components/snake_board.rs), a port of board.battlesnake.com.
   Grid, page and food colours, the shadow, and the 16px font-size its em-based
   shadow is measured against are copied exactly from the real board. Snake
   colour: --snake on one snake's <g>, else --studio-snake from the page. */
.studio-board, .studio-board.light { font-size: 16px; background: #ffffff; }
.studio-board .grid, .studio-board.light .grid { fill: #f1f1f1; }
.studio-board.dark { background: #0f0b19; }
.studio-board.dark .grid { fill: #393939; }
.studio-board .snake > svg { fill: var(--snake, var(--studio-snake, #ff4f86)); }
.studio-board .snake > polyline { stroke: var(--snake, var(--studio-snake, #ff4f86)); }
.studio-board .snake, .studio-board .food { filter: drop-shadow(0.1em 0.1em 0.05em rgba(0,0,0,.3)); }
/* `hidden` only hides HTML elements by default; live-loop frames are SVG <g>s. */
.studio-board .studio-frame[hidden] { display: none; }

/* Page layout. Mobile first: one column (your snake, start here, preview, checks, style, save); at
   980px+ (iPad landscape) the checks sit beside the preview. Every control is at
   least 44x44 at every width, and inputs are 16px so iOS doesn't zoom. */
.studio { --studio-snake: #ff4f86; }
/* Classes below set display; `hidden` must still win. */
.studio [hidden] { display: none !important; }
.studio .page-head h1 { font-size: clamp(32px, 4vw, 48px); }
.studio-noscript { margin-top: 16px; color: var(--down); }
.studio-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; margin-top: 24px; }
.studio-panel { min-width: 0; background: var(--card); border: 1px solid var(--hairline); border-radius: 16px; padding: 18px; }
.studio-panel h2 { font-size: 20px; margin-bottom: 10px; }
.studio-muted { color: var(--muted); font-size: 14px; }
.studio .btn { min-height: 44px; min-width: 44px; }
.studio select, .studio input { font-size: 16px; }
@media (min-width: 980px) {
  .studio-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    grid-template-areas: "snake snake" "start start" "preview lints" "controls lints" "actions actions";
    align-items: start;
  }
  .studio-start { grid-area: start; }
  .studio-snake { grid-area: snake; }
  .studio-preview { grid-area: preview; }
  .studio-lints { grid-area: lints; }
  .studio-controls { grid-area: controls; }
  .studio-actions { grid-area: actions; }
}
@media (max-width: 420px) {
  .studio-panel { padding: 14px; border-radius: 14px; }
}

/* Your snake: a card per slot (head, tail), side by side from 560px, stacked on
   phones. Each card takes a dropped file; its upload button is a label the file input
   covers (a 44px+ target for touch, keyboard and VoiceOver). */
.studio-snake-lede { margin: -4px 0 12px; }
.studio-slots { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
@media (min-width: 560px) {
  .studio-slots { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.studio-slot {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; align-content: start;
  gap: 10px 12px; min-width: 0; padding: 12px;
  border: 2px dashed var(--hairline-dark); border-radius: 14px; background: var(--paper);
}
.studio-slot.dragging { border-color: var(--pink); background: var(--pink-wash); }
.studio-slot > :is(.studio-slot-upload, .studio-style, .studio-slot-actions, .studio-confirm) {
  grid-column: 1 / -1;
}
.studio-thumb { display: block; width: 64px; height: auto; border-radius: 8px; }
.studio-thumb-bg { fill: var(--card); }
.studio-thumb-body { fill: var(--studio-snake); opacity: .35; }
.studio-thumb-path { fill: var(--studio-snake); }
.studio-slot-who { min-width: 0; }
.studio-slot-title {
  font-family: var(--mono); font-size: 11.5px; font-weight: 400; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted);
}
.studio-slot-name { font-family: var(--display); font-weight: 700; font-size: 18px; overflow-wrap: anywhere; }
.studio-slot-upload { position: relative; display: flex; align-items: center; justify-content: center; text-align: center; }
.studio-slot-upload:focus-within { outline: 2px solid var(--pink); outline-offset: 2px; }
/* Over the button's 1.5px border too, so the input itself is the full 44px+. */
.studio-file {
  position: absolute; inset: -1.5px; width: calc(100% + 3px); height: calc(100% + 3px);
  margin: 0; opacity: 0; cursor: pointer;
}
.studio-style select { font-size: 16px; min-height: 46px; }
.studio-slot-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-slot-actions:not(:has(button:not([hidden]))) { display: none; }
.studio-confirm {
  display: grid; gap: 8px; padding: 10px 12px; font-size: 14.5px;
  background: var(--pink-wash); border: 1px solid var(--pink); border-radius: 12px;
}
.studio-confirm-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-slots-hint { margin-top: 8px; }
/* The bold face's spaces are narrow: "passes · Tail" ran together. */
.studio-summary { margin-top: 12px; font-weight: 600; font-size: 15px; word-spacing: .14em; }
.studio-status { margin-top: 12px; font-size: 15px; }
.studio-summary + .studio-status { margin-top: 4px; }
/* Where studio.js scrolls a result into view. */
.studio-status, .studio-preview { scroll-margin-top: 12px; }
.studio-status.error { color: var(--down); font-weight: 600; }
.studio-top-warning {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px 10px 44px;
  background: var(--pink-wash); border: 1px solid var(--pink); border-radius: 12px; font-size: 14.5px;
  position: relative;
}
/* The icon beside the first line; "Learn more" and the fix on the row below, under the text. */
.studio-top-warning > .studio-lint-icon { position: absolute; left: 12px; top: 11px; }
.studio-top-warning p { flex: 1 1 100%; min-width: 0; }

/* Segmented controls: radios cover their label, so the label is the target. */
.studio-seg { border: 0; margin-top: 14px; min-width: 0; }
.studio-seg legend, .studio-colors legend {
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin-bottom: 7px;
}
.studio-seg-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.studio-seg-opt { position: relative; display: inline-flex; }
.studio-seg-opt input, .studio-swatch input {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer;
}
.studio-seg-opt > span {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px;
  padding: 0 16px; border: 1.5px solid var(--hairline-dark); border-radius: 999px; font-weight: 600; font-size: 14.5px;
}
.studio-seg-opt input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.studio-seg-opt input:focus-visible + span { outline: 2px solid var(--pink); outline-offset: 2px; }

/* Preview: one view at a time on phones; Close-up and Live side by side from 640px. */
/* The result heading takes focus after each upload so screen readers announce the
   result, but it isn't in the tab order, so it never shows a ring. (Chrome and WebKit
   count focus moved by script after the file picker as :focus-visible.) */
.studio-preview h2[tabindex="-1"]:focus,
.studio-preview h2[tabindex="-1"]:focus-visible { outline: none; }
.studio-views { margin-top: 0; }
.studio-wide-only { display: none; }
.studio-panes { margin-top: 14px; }
.studio-pane { display: none; min-width: 0; }
.studio-panes[data-view="closeup"] > [data-pane="closeup"],
.studio-panes[data-view="live"] > [data-pane="live"],
.studio-panes[data-view="all"] > [data-pane="all"],
.studio-panes[data-view="game"] > [data-pane="game"] { display: block; }
@media (min-width: 640px) {
  .studio-view-live { display: none; }
  .studio-wide-only { display: inline; }
  .studio-panes[data-view="closeup"], .studio-panes[data-view="live"] {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start;
  }
  .studio-panes[data-view="closeup"] > [data-pane="live"],
  .studio-panes[data-view="live"] > [data-pane="closeup"] { display: block; }
  /* The two close-ups stack taller than the live board: it stays beside whichever one
     is in view. */
  .studio-panes > [data-pane="live"] { position: sticky; top: 12px; }
}
.studio-pane .studio-board, .studio-closeup { display: block; width: 100%; height: auto; border-radius: 10px; }
/* A close-up per slot: stacked (each as wide as the pane), side by side only where a
   full-width pane gives each one enough room. */
.studio-closeups { display: grid; gap: 12px; }
@media (min-width: 480px) and (max-width: 639px) {
  .studio-closeups { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.studio-closeup-fig { margin: 0; min-width: 0; }
.studio-closeup-title {
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin-bottom: 4px;
}
.studio-pane[data-pane="all"] .studio-board { max-width: 560px; }
.studio-pane-note { color: var(--muted); font-size: 13.5px; margin: 8px 0; }
.studio-play { margin-top: 10px; }
.studio-closeup { background: var(--paper); }
.studio-closeup-path { fill: var(--studio-snake); }
.studio-closeup-body { fill: var(--studio-snake); opacity: .35; }
.studio-closeup-frame { stroke: var(--muted); stroke-width: .4; stroke-dasharray: 2 2; }
.studio-gaps rect { fill: #e5383b; }
/* Game size: true CSS size, scrolling sideways rather than shrinking when narrow. */
.studio-true-size { margin: 12px 0 0; max-width: 100%; overflow-x: auto; }
.studio-true-size .studio-board { border-radius: 6px; }
.studio-true-size.phone .studio-board { width: 202px; }  /* 7 cells of ~22px */
.studio-true-size.tablet .studio-board { width: 368px; } /* 7 cells of 40px */
.studio-true-size figcaption { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Checks: warnings first, with an icon and text, not colour alone. */
.studio-lint-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
/* The icon beside the message's first line; "Learn more" and Flip/Fit on the row below,
   lined up with the message. */
.studio-lint {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; font-size: 14.5px;
  position: relative; padding-left: 32px;
}
.studio-lint > .studio-lint-icon { position: absolute; left: 0; top: 1px; }
.studio-lint-text { flex: 1 1 100%; min-width: 0; }
.studio-lint-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 22px; height: 22px;
  border-radius: 50%; font-weight: 700; font-size: 13px; background: var(--pill); color: var(--muted);
}
.studio-lint.warn .studio-lint-icon, .studio-top-warning .studio-lint-icon { background: var(--down); color: #fff; }
.studio-pass { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--up); }
.studio-pass .studio-lint-icon { background: var(--up); color: #fff; }
.studio-details { margin-top: 10px; }
.studio-details summary { display: flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 600; font-size: 14.5px; }
/* A group per slot, each with its own heading and pass state. */
.studio-checks-title { font-size: 16px; margin-bottom: 6px; }
.studio-checks:not([hidden]) ~ .studio-checks:not([hidden]) {
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hairline);
}

/* Style controls. */
.studio-colors { border: 0; min-width: 0; }
.studio-swatches { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; }
.studio-swatch {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 52px; min-height: 44px; padding: 4px; border-radius: 10px; border: 1.5px solid transparent; cursor: pointer;
}
.studio-swatch:has(input:checked), .studio-swatch-custom.active { border-color: var(--ink); }
.studio-swatch:has(input:focus-visible) { outline: 2px solid var(--pink); outline-offset: 2px; }
.studio-swatch-chip { width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(0,0,0,.15); }
/* Charcoal (#3d3d3d) all but vanishes on the dark card without a light rim. */
html[data-app-theme="dark"] .studio-swatch-chip { border-color: rgba(255,255,255,.35); }
.studio-swatch-name { font-size: 12px; color: var(--muted); }
/* Custom: a colour wheel, with the picked colour in the middle once it's in use. */
.studio-swatch-chip-custom {
  background: conic-gradient(#e5383b, #f7c948, #2bb673, #3a86ff, #8f5cf7, #ff4f86, #e5383b);
}
.studio-swatch-custom.active .studio-swatch-chip-custom {
  background: radial-gradient(circle, var(--studio-snake) 0 50%, transparent 53%),
    conic-gradient(#e5383b, #f7c948, #2bb673, #3a86ff, #8f5cf7, #ff4f86, #e5383b);
}
#studio-color-hint { margin-top: 6px; }

/* Start here: templates by app, the guide, and an example. A <details> under the cards,
   open until the first upload. */
.studio-start-summary {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; min-height: 44px;
  cursor: pointer; list-style: none;
}
.studio-start-summary::-webkit-details-marker { display: none; }
.studio-start-summary::before { content: "▸"; color: var(--muted); align-self: center; transition: transform .15s; }
.studio-start[open] > .studio-start-summary::before { transform: rotate(90deg); }
.studio-start-summary h2 { margin: 0; }
.studio-start-steps { list-style: none; counter-reset: studio-step; display: grid; gap: 16px; margin-top: 12px; }
.studio-start-steps > li { counter-increment: studio-step; position: relative; padding-left: 38px; min-width: 0; }
.studio-start-steps > li::before {
  content: counter(studio-step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
  background: var(--ink); color: var(--paper);
}
.studio-start-steps h3 { font-size: 17px; margin-bottom: 2px; }
.studio-start-steps p { margin-bottom: 8px; }
.studio-start-kind { margin-top: 10px; }
.studio-start-kind-name { display: block; font-weight: 700; margin-bottom: 4px; }
.studio-start-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.studio-start .btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; max-width: 100%; }
.studio-start-example { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--hairline); }
/* Templates across the top, then Draw and Upload side by side; three columns only once
   Draw's column fits "Read the guide" on one line. */
@media (min-width: 640px) {
  .studio-start-steps { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .studio-start-steps > li:first-child { grid-column: 1 / -1; }
}
@media (min-width: 980px) {
  .studio-start-steps { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }
  .studio-start-steps > li:first-child { grid-column: auto; }
}
/* "Learn more" beside a check: a link into the guide, as big a target as a button. Its
   text lines up with the message above it. */
.studio-learn {
  display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; padding: 0 4px; margin-left: -4px;
  color: var(--pink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* Save. */
.studio-action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.studio-privacy { margin-top: 12px; }
@media (max-width: 420px) {
  .studio-action-row .btn { flex: 1 1 100%; }
}

/* --- page: studio guide (/customizations/studio/guide) ----------------------- */
.guide { max-width: 860px; }
.guide .page-head h1 { font-size: clamp(32px, 4vw, 48px); }
.guide-lede { margin-top: 18px; font-size: 17px; max-width: 64ch; }
.guide a:not(.btn) { color: var(--pink); text-decoration: underline; text-underline-offset: 3px; }
.guide-toc { margin-top: 18px; }
.guide-toc ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 8px; }
.guide-toc a:not(.btn) {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-radius: 999px;
  background: var(--pill); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600;
}
.guide-section { margin-top: 40px; scroll-margin-top: 16px; }
.guide-section > h2 { margin-bottom: 10px; }
.guide-section p, .guide-section ul, .guide-section ol { max-width: 68ch; }
.guide-section p + p, .guide-section p + ul, .guide-section ul + p, .guide-section ol + p { margin-top: 10px; }
.guide-section ul, .guide-steps { padding-left: 1.4em; display: grid; gap: 6px; }
.guide-steps { gap: 10px; }
.guide-muted { color: var(--muted); font-size: 14.5px; }
.guide code { font-family: var(--mono); font-size: .9em; background: var(--pill); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; }
.guide .btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; text-align: center; max-width: 100%; }
.guide-downloads { display: grid; gap: 16px; margin-top: 14px; }
@media (min-width: 640px) { .guide-downloads { grid-template-columns: 1fr 1fr; } }
.guide-download { background: var(--card); border: 1px solid var(--hairline); border-radius: 16px; padding: 16px; min-width: 0; }
.guide-download h3 { font-size: 18px; margin-bottom: 10px; }
.guide-download-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.guide-rule { margin-top: 20px; scroll-margin-top: 16px; }
.guide-rule h3 { font-size: 18px; margin-bottom: 4px; }
.guide-rule:target h3 { color: var(--pink); }
.guide-figure { margin: 14px 0 0; min-width: 0; }
.guide-figure figcaption { color: var(--muted); font-size: 14px; margin-top: 6px; }
.guide-board .studio-board { display: block; width: 100%; max-width: 420px; height: auto; border-radius: 10px; }
/* The board follows the site theme (the studio has its own switch). */
html[data-app-theme="dark"] .guide-board .studio-board { background: #0f0b19; }
html[data-app-theme="dark"] .guide-board .studio-board .grid { fill: #393939; }
.guide-anatomy { display: grid; gap: 18px; margin: 6px 0 16px; }
@media (min-width: 640px) { .guide-anatomy { grid-template-columns: 1fr 1fr; } }
.guide-closeup { display: block; width: 100%; max-width: 300px; height: auto; }
.guide-closeup-bg { fill: var(--card); }
.guide-closeup-shape { fill: #ff4f86; }
.guide-closeup-body { fill: #ff4f86; opacity: .35; }
.guide-closeup-frame { stroke: var(--muted); stroke-width: .5; stroke-dasharray: 2 2; }
.guide-marker circle { fill: var(--ink); stroke: var(--card); stroke-width: 1.2; }
.guide-marker text { fill: var(--paper); font: 700 8px var(--body); text-anchor: middle; }
.guide-figure .guide-legend { color: var(--ink); font-size: 15px; padding-left: 1.4em; display: grid; gap: 4px; }

/* Notifications */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.notification-empty { padding: 12px 24px; font-size: 16px; }
.notifications-page .notification-empty { padding-left: 0; }
.notification-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--ink);
}
.notification-bell:hover, .notification-bell:focus-visible { background: var(--hairline); }
.notification-bell svg { width: 23px; height: 23px; }
.notification-badge {
  position: absolute;
  top: -2px;
  right: -5px;
  min-width: 21px;
  height: 21px;
  padding: 1px 4px;
  border-radius: 99px;
  background: var(--pink);
  color: #fff;
  font: 700 12px/19px var(--body);
  text-align: center;
}
.notification-badge[hidden] { display: none; }
#notification-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(440px, 100vw);
  max-width: none;
  max-height: none;
  height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  box-shadow: -12px 0 40px #0003;
  overflow-y: auto;
  animation: notification-slide-in .2s ease-out;
}
#notification-drawer::backdrop { background: #0008; }
@keyframes notification-slide-in { from { transform: translateX(100%); } }
.notification-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--hairline);
}
.notification-drawer-head h2 { margin: 0; font-size: 24px; }
#notification-drawer-close {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 30px;
  cursor: pointer;
}
#notification-drawer-status { padding: 0 24px; font-size: 16px; }
#notification-drawer-status:not(:empty) { padding-top: 12px; padding-bottom: 12px; }
.notification-drawer-footer { padding: 20px 24px; border-top: 1px solid var(--hairline); }
.notification-drawer-footer a { display: inline-flex; align-items: center; min-height: 44px; font-size: 16px; }
.notifications-page { max-width: 740px; margin: 0 auto; }
.notifications-page h1 { margin-bottom: 16px; }
.notification-mark-all { padding: 12px 24px; }
.notifications-page .notification-mark-all { padding-left: 0; }
.notification-mark-all button, .notification-load-more, .notification-next, #notification-drawer-status button {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid var(--hairline-dark);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: 600 16px var(--body);
  cursor: pointer;
}
.notification-items { list-style: none; margin: 0; padding: 0; }
.notification-item { border-top: 1px solid var(--hairline); }
.notification-item.unread { border-left: 4px solid var(--pink); background: var(--card); }
.notification-item form, .notification-item button { width: 100%; }
.notification-item button {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 72px;
  padding: 16px 24px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: 16px var(--body);
}
.notification-item button:hover, .notification-item button:focus-visible { background: var(--hairline); }
.notification-kind-icon { flex: 0 0 24px; text-align: center; }
.notification-item-copy { display: flex; min-width: 0; flex: 1; flex-direction: column; gap: 4px; }
.notification-item-title { font-weight: 600; overflow-wrap: anywhere; }
.notification-item.unread .notification-item-title { font-weight: 800; }
.notification-item-body { color: var(--muted); line-height: 1.4; overflow-wrap: anywhere; }
.notification-item time { color: var(--muted); font-size: 16px; }
.notification-unread-marker { font-size: 16px; font-weight: 800; color: var(--pink); text-transform: uppercase; }
.notification-load-more, .notification-next { display: block; margin: 20px 24px; }
@media (max-width: 640px) {
  #notification-drawer { width: 100vw; height: 100dvh; }
  .notification-bell { flex-basis: 44px; }
}
