:root {
  color-scheme: dark;
  --inset-bottom: env(safe-area-inset-bottom, 0px);
}
header { padding-top: calc(25px + env(safe-area-inset-top, 0px)); }
main { padding-inline: max(16px, env(safe-area-inset-left, 0px)); }
.app-bar .logout { margin-inline-start: auto; padding: 5px 12px; }
.formation { max-width: 690px; margin-inline: auto; }
.pitch { margin-top: 0; padding: 12px 9px; }
.line { margin: 12px 0; }
.slot { display: grid; place-content: center; justify-items: center; gap: 4px; line-height: 1.35; }
.slot.filled { background: #101920; }
.slot:disabled { opacity: 1; }
.slot b { overflow-wrap: anywhere; }
.portrait {
  position: relative; display: inline-grid; place-items: center; overflow: hidden;
  width: 50px; height: 50px; flex: 0 0 50px; border-radius: 50%;
  background: #2b303c; border: 1px solid #bba26675; color: #f2cd77; font-weight: bold;
}
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 29%; }
.slot .captain-mark { color: #f2cd77; }
.pick-person { display: flex; align-items: center; gap: 10px; line-height: 1.5; }
.staff h2 { margin-block: 0; }
.staff p { margin-top: 4px; }
.staff-grid, .squad-controls { display: grid; gap: 12px; grid-template-columns: repeat(2,minmax(0,1fr)); }
.staff-grid label, .squad-controls label { margin: 0; }
.staff-grid select, .squad-controls select, .squad-controls input { display: block; width: 100%; margin-top: 4px; }
.squad-controls button, .squad-controls p { grid-column: 1 / -1; margin: 0; }
#player-picker {
  color: inherit; border: 1px solid #504431; border-radius: 22px; background: #181c25;
  width: min(94vw,540px); padding: 16px; max-height: min(88dvh, 690px); overflow: auto;
}
#player-picker::backdrop { background: #05070bd1; }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-top h2 { font-size: 18px; margin: 0; }
.picker-filters { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; margin-block: 12px; }
#player-picker .list { max-height: min(52dvh, 420px); }
@media (max-width: 700px) {
  header { padding: calc(13px + env(safe-area-inset-top, 0px)) 16px 12px; }
  header h1 { font-size: 22px; }
  header p { display: none; }
  main { padding-top: 8px; padding-bottom: calc(85px + var(--inset-bottom)); }
  .app-nav {
    position: fixed; z-index: 8; inset: auto 0 0;
    padding: 7px max(8px,env(safe-area-inset-right, 0px)) calc(7px + var(--inset-bottom));
    margin: 0; background: #10141cf5; border-top: 1px solid #3d3831; display: flex;
    flex-wrap: nowrap; gap: 4px;
  }
  .app-nav button { flex: 1; min-width: 0; min-height: 46px; padding: 4px; font-size: clamp(10px,3vw,13px); line-height: 1.3; }
  .app-bar { gap: 8px; margin-bottom: 8px; }
  .app-bar label { width: 100%; margin: 2px 0; display: flex; align-items: center; gap: 8px; }
  .app-bar select { flex: 1; min-width: 0; }
  .notice { font-size: 13px; }
  .slot { min-height: 76px; padding: 5px 3px; }
  .line { margin-block: 8px; }
  .pitch { padding-block: 9px; }
  .pitch::before { inset: 7px; }
  .slot .portrait { width: 42px; height: 42px; }
  #player-picker {
    margin: auto auto 0; width: 100%; max-width: none; border-radius: 22px 22px 0 0;
    padding-bottom: calc(14px + var(--inset-bottom));
  }
  input, select { font-size: 16px; }
  .staff-grid select { font-size: 16px; }
  #msg { top: max(8px,env(safe-area-inset-top,0px)); }
}
@media (max-width: 360px) {
  .staff-grid { grid-template-columns: 1fr; }
}
