dialog:has(#athlete-form) {
  --studio-ink: #19322f;
  --studio-muted: #54655d;
  --studio-line: #cad2c5;
  --studio-paper: #f6f5ed;
  --studio-accent: #205f50;
  width: min(952px, calc(100vw - 32px));
  max-width: none;
  max-height: min(760px, calc(100dvh - 24px));
  padding: 0;
  overflow: hidden;
  color: var(--studio-ink);
  background: var(--studio-paper);
  border: 1px solid #5d7068;
  border-radius: 12px;
  color-scheme: light;
}
dialog[open]:has(#athlete-form) { display: flex; flex-direction: column; }
dialog:has(#athlete-form) .sheet-head {
  flex: none;
  padding: 12px 24px;
  color: #f5f6eb;
  background: #183632;
}
dialog:has(#athlete-form) .sheet-head h2 {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: clamp(22px, 3vw, 30px);
  font-weight: 600;
  line-height: 1.2;
}
dialog:has(#athlete-form) .sheet-head h2::before {
  content: "";
  width: 18px;
  height: 20px;
  background: var(--sea);
  clip-path: polygon(23% 0,100% 0,95% 24%,18% 24%,15% 40%,92% 40%,86% 64%,9% 64%,6% 80%,83% 80%,78% 100%,0 100%);
}
dialog:has(#athlete-form) #close {
  width: 40px; min-height: 40px;
  border: 0; border-radius: 50%;
  background: #2c4943;
  font-size: 24px; font-weight: 400;
}
dialog:has(#athlete-form) #sheet { display: flex; min-height: 0; }
#athlete-form {
  display: grid;
  grid-template-columns: minmax(0, .78fr) minmax(0, 1.22fr);
  gap: 28px;
  width: 100%;
  min-height: 0;
  padding: 24px;
}
.athlete-preview {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-height: 0; min-width: 0;
  overflow: hidden;
  background: #1a3734;
  color: #fff9ea;
  border-radius: 8px;
}
.roster-stage {
  position: relative;
  overflow: hidden;
  background: #d6bf96;
}
.roster-stage::before {
  content: "";
  position: absolute; inset: 0 0 26%;
  background: url("art/harbor-clerestory.webp") 39% center / cover;
  filter: saturate(.65);
  opacity: .9;
}
.roster-uniform { position: absolute; inset: 0; }
.roster-stage[data-view=closeup]::before { bottom: 0; }
.roster-stage[data-view=closeup] .roster-uniform::before { display: none; }
.roster-uniform::before {
  content: ""; position: absolute; left: 50%; bottom: 7%;
  width: min(30%, 112px); height: 3%; border-radius: 50%;
  background: #776c5955; transform: translateX(-50%);
}
.roster-uniform canvas { position: relative; width: 100%; height: 100%; }
.roster-caption {
  position: relative;
  min-width: 0;
  padding: 18px 20px 12px;
  border-top: 4px solid var(--sea);
}
.roster-byline {
  display: flex; gap: 12px; justify-content: space-between; align-items: baseline;
  color: #c1d9c9; font-size: 14px; font-weight: 500;
}
#roster-club, #roster-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#roster-number { white-space: nowrap; font-variant-numeric: tabular-nums; }
#roster-name { margin-top: 4px; font-size: clamp(26px, 4vw, 38px); font-weight: 600; line-height: 1.08; }
.roster-views {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 4px; margin: 0 16px 16px; padding: 4px;
  background: #102724; border-radius: 8px;
}
.roster-views button {
  min-width: 0; min-height: 40px; padding: 0 4px; border: 0;
  background: transparent; color: #d9e4db; font-size: 14px; font-weight: 500;
}
.roster-views button:hover { background: #294741; }
.roster-views button[aria-pressed=true] { background: #d9e9db; color: #16382f; }
.athlete-editor-panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.athlete-fields {
  display: grid; gap: 16px;
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  padding: 4px; margin: -4px;
  scrollbar-color: #a5b5a7 transparent; scrollbar-width: thin;
}
#athlete-form fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
#athlete-form label, #athlete-form legend {
  display: flex; justify-content: space-between; align-items: baseline;
  width: 100%; padding: 0; margin: 0 0 6px;
  font-size: 14px; font-weight: 600; line-height: 1.3;
}
#athlete-form legend span, #width-value { color: var(--studio-muted); font-size: 13px; font-weight: 400; }
#width-value { font-variant-numeric: tabular-nums; }
#profile-name {
  height: 44px; padding: 0 12px; border: 1px solid #9faea0; border-radius: 6px;
  background: #fffef8; color: var(--studio-ink); font-size: 16px;
}
.cut-grid { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); gap: 6px; }
#hair-options { grid-template-columns: repeat(6,minmax(0,1fr)); }
#hair-options button { height: 52px; aspect-ratio: auto; }
#athlete-form .color-fields > label:has(select) { display: block; }
#athlete-form select {
  display: block; width: 100%; min-height: 36px; margin-top: 4px; padding: 4px 9px;
  color: var(--studio-ink); background: #fffdf5; border: 1px solid var(--studio-line);
  border-radius: 5px; font: inherit;
}
.player-options { display: flex; gap: 8px; }
.player-options button { flex: 1; min-height: 44px; background: #fffef8; color: var(--studio-ink); border: 1px solid #9faea0; border-radius: 6px; }
.player-options button[aria-pressed=true] { background: #cadfcb; border-color: var(--studio-accent); box-shadow: inset 0 0 0 1px var(--studio-accent); }
.cut-grid button {
  position: relative; min-width: 0; min-height: 0; aspect-ratio: 1; padding: 2px;
  overflow: hidden; background: #e1e5da; border: 1px solid #c6cfc1; border-radius: 6px;
}
.cut-grid button:hover, .tone-grid button:hover { border-color: var(--studio-accent); }
.cut-grid canvas { width: 100%; height: 100%; object-fit: contain; touch-action: manipulation; }
.cut-grid button[aria-pressed=true] {
  background: #cadfcb; border-color: var(--studio-accent); box-shadow: inset 0 0 0 2px var(--studio-accent);
}
.cut-grid button[aria-pressed=true]::after {
  content: ""; position: absolute; right: 0; bottom: 0; width: 14px; height: 14px;
  background: var(--studio-accent); clip-path: polygon(100% 0,100% 100%,0 100%);
}
.tone-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.tone-grid button {
  display: grid; place-items: center;
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
}
.tone-grid button[data-tone=natural] {
  width: auto; padding: 0 12px; margin-right: 4px;
  color: var(--studio-ink); font-size: 13px; border-radius: 6px; border-color: var(--studio-line);
}
.tone-grid button:not([data-tone=natural])::before {
  content: ""; width: 28px; height: 28px; background: var(--tone); border-radius: 50%; border: 1px solid #172c281a;
}
.tone-grid button[aria-pressed=true] { box-shadow: inset 0 0 0 2px var(--studio-accent); }
.tone-grid button[data-tone=natural][aria-pressed=true] { color: var(--studio-accent); background: #deeadb; }
.color-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
#athlete-form .color-control {
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  height: 42px; margin: 0; padding: 0 8px;
  background: #fffef8; border: 1px solid var(--studio-line); border-radius: 6px;
}
#athlete-form input[type=color] {
  appearance: none; width: 40px; height: 40px; padding: 5px 2px;
  border: 0; background: transparent; cursor: pointer;
}
#athlete-form input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
#athlete-form input[type=color]::-webkit-color-swatch { border: 1px solid #172c2838; border-radius: 4px; }
#athlete-form input[type=color]::-moz-color-swatch { border: 1px solid #172c2838; border-radius: 4px; }
#natural-hair {
  min-height: 38px; padding: 0 4px; border: 0; background: transparent;
  color: var(--studio-accent); font-size: 13px; font-weight: 500; text-decoration: underline;
}
#natural-hair:disabled { color: var(--studio-muted); opacity: 1; text-decoration: none; }
#tape-value { font: 13px/1 ui-monospace, Consolas, monospace; color: var(--studio-muted); }
#athlete-form label.color-control { cursor: pointer; }
#athlete-form input[type=range] {
  display: block; width: 100%; height: 24px; padding: 0; margin: 0;
  background: transparent; border: 0; accent-color: var(--studio-accent); cursor: pointer;
}
.athlete-actions {
  display: flex; flex: none; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--studio-line);
}
.athlete-actions button { min-height: 44px; padding: 0 20px; font-weight: 600; font-size: 15px; }
#cancel-athlete { background: transparent; color: var(--studio-muted); border: 1px solid transparent; }
#cancel-athlete:hover { background: #e6eade; }
.athlete-actions .primary { background: var(--studio-accent); color: #fffef6; border-color: var(--studio-accent); }
.athlete-actions .primary:hover { background: #194a3e; }
#sheet #profile-message { flex: 1; margin: 0; font-size: 13px; color: #903c2e; }
#profile-message:empty { display: none; }
#athlete-form :focus-visible { outline: 3px solid #a45c0b; outline-offset: 1px; }

@media (max-width: 760px) and (orientation: landscape) {
  #athlete-form { grid-template-columns: minmax(0,.65fr) minmax(0,1.35fr); gap: 16px; }
}
@media (max-height: 560px) and (orientation: landscape) {
  dialog:has(#athlete-form) { width: calc(100vw - 16px); max-width: 952px; max-height: calc(100dvh - 8px); }
  dialog:has(#athlete-form) .sheet-head { padding: 4px 16px; }
  #athlete-form { gap: 16px; padding: 12px 16px; }
  .roster-caption { padding: 8px 12px; }
  #roster-name { font-size: 24px; }
  .roster-views { margin: 0 8px 8px; }
  .roster-views button { min-height: 36px; }
  .athlete-actions { margin-top: 8px; padding-top: 8px; }
}
@media (max-width: 650px) and (orientation: portrait) {
  dialog:has(#athlete-form) { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  dialog:has(#athlete-form) .sheet-head { padding: 8px 16px; }
  #athlete-form { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr); gap: 16px; padding: 12px; }
  .athlete-preview {
    grid-template: 1fr auto / minmax(0, .86fr) minmax(0, 1.14fr);
    height: clamp(124px,19dvh,176px);
  }
  .roster-stage { grid-row: 1 / 3; }
  .roster-caption { align-self: center; border: 0; padding: 8px 12px; }
  .roster-byline { font-size: 12px; gap: 4px; }
  #roster-name { font-size: 26px; }
  .roster-views { margin: 0 8px 8px; gap: 0; padding: 2px; }
  .roster-views button { min-height: 36px; font-size: 12px; }
  .cut-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 6px; }
  .cut-grid button { aspect-ratio: auto; height: 48px; }
  .athlete-actions { margin-top: 8px; padding-top: 8px; }
}
@media (min-width: 440px) and (max-width: 650px) and (orientation: portrait) {
  .cut-grid { grid-template-columns: repeat(8,minmax(0,1fr)); }
}
@media (max-width: 360px) {
  .tone-grid { gap: 0; }
  .tone-grid button { width: 36px; }
  .roster-views { margin-inline: 4px; }
  .color-fields { gap: 8px; }
}

#custom-head{width:100%;height:100%}#custom-head[hidden]{display:none}
.team-score{display:grid;justify-items:center;min-width:32px}
.team-score span{max-width:96px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-radius:3px;padding:1px 4px;background:#173439;color:#fff8e9;font-size:11px;font-weight:700}
.team-score b{text-shadow:0 1px 2px #173439;-webkit-text-stroke:1px #173439}
dialog:has(#kit-form){width:min(520px,94vw);max-height:94dvh;overflow:auto}
#kit-form{display:grid;grid-template-columns:minmax(96px,.85fr) minmax(0,1.15fr);gap:16px;margin-top:16px}
.kit-preview{background:#365458;border-radius:6px;overflow:hidden;align-self:start}
.lobby-teams section{min-width:0}
.lobby-teams h3{overflow-wrap:anywhere;margin-bottom:4px}
.lobby-kit{display:flex;align-items:center;gap:6px;margin-bottom:10px;font-size:13px}
.lobby-kit::before{content:"";width:24px;height:12px;flex:none;border:1px solid var(--border);border-radius:2px;background:linear-gradient(110deg,var(--primary) 60%,var(--accent) 60%)}
.lobby-teams .edit-team{margin-bottom:12px;padding:4px 8px}
.kit-preview canvas{display:block;width:100%;height:auto;aspect-ratio:4/5}
#kit-form label{font-size:14px;margin:0 0 4px}
.kit-fields select,.kit-fields input{width:100%;min-height:40px;margin:0 0 12px}
.kit-fields select{font:inherit;color:var(--paper);border:1px solid var(--border);border-radius:4px;padding:4px 8px;background:#0c2428}
.kit-fields select:focus-visible{outline:3px solid var(--gold);outline-offset:2px}
.kit-colours{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.kit-colours input{display:block;margin:4px 0 8px;padding:2px;cursor:pointer}
#kit-message:empty{display:none}
@media(max-width:440px){dialog:has(#kit-form){padding:12px}#kit-form{gap:10px;grid-template-columns:minmax(80px,.65fr) minmax(0,1.35fr)}}
@media(orientation:landscape) and (max-height:520px){
  dialog:has(#kit-form){padding:12px 16px}
  #kit-form{margin-top:8px;grid-template-columns:minmax(100px,.7fr) minmax(0,1.3fr)}
  .kit-fields{display:grid;grid-template-columns:1fr 1fr;column-gap:8px;align-content:start}
  .kit-fields label[for=kit-side],#kit-side{grid-column:1}
  .kit-fields label[for=kit-style],#kit-style{grid-column:2}
  .kit-fields label[for=kit-side],.kit-fields label[for=kit-style]{grid-row:1}
  #kit-side,#kit-style{grid-row:2}
  #kit-form[data-team] .kit-fields label[for=kit-name]{grid-row:1;grid-column:1}
  #kit-form[data-team] #kit-name{grid-row:2;grid-column:1}
  .kit-fields label[for=kit-name],#kit-name,.kit-colours,#kit-message{grid-column:1/-1}
  .kit-fields select,.kit-fields input{margin-bottom:6px}
}
