:root {
  color-scheme: dark;
  --background: #0b1617;
  --panel: #122223;
  --raised: #192c2d;
  --line: #294040;
  --text: #f2f7f1;
  --muted: #a3b7b1;
  --accent: #c9f181;
  --ink: #17230d;
  --danger: #ffaaa1;
  font-family: Inter, system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; min-height: 100dvh; color: var(--text); background: var(--background); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:where(h1, h2, p) { margin: 0; }

.masthead { border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.masthead-inner, .site-main { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.masthead-inner { min-height: 75px; display: grid; grid-template-columns: minmax(155px, 1fr) auto minmax(155px, 1fr); align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; justify-self: start; gap: 11px; color: var(--text); font-size: 25px; font-weight: 850; letter-spacing: -.07em; text-decoration: none; line-height: 1; }
.brand-period { color: var(--accent); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); display: grid; place-items: center; color: var(--ink); }
.brand-mark i { width: 19px; height: 13px; position: relative; display: block; border: 1.7px solid currentColor; border-radius: 2px; transform: rotate(-28deg); }
.brand-mark i::after { content: ""; position: absolute; inset: 0 auto 0 50%; border-left: 1.7px solid currentColor; }
.navigation { display: flex; align-items: center; gap: 5px; }
.navigation button { border: 0; border-radius: 8px; background: transparent; color: var(--muted); padding: 9px 13px; font-size: .87rem; font-weight: 650; }
.navigation button:hover { color: var(--text); }
.navigation [aria-current="page"] { background: var(--raised); color: var(--text); }
.user-chip { justify-self: end; display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: .79rem; font-weight: 650; }
.user-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-initial { flex: 0 0 30px; height: 30px; display: grid; place-items: center; border: 1px solid #4a5a42; background: #273925; color: var(--accent); border-radius: 50%; font-weight: 750; }

.site-main { padding-block: 39px max(38px, env(safe-area-inset-bottom)); }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 27px; }
.eyebrow, .section-kicker { display: flex; align-items: center; gap: 8px; color: var(--accent); font-size: .67rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow > span { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.page-heading h1 { margin-block: 7px 4px; font-weight: 805; letter-spacing: -.055em; line-height: 1.03; font-size: clamp(2.6rem, 6vw, 4rem); }
.page-heading h1 em { font-style: normal; color: var(--accent); }
.page-description { color: var(--muted); line-height: 1.45; font-size: .94rem; }
.lineup-picker { max-width: 280px; width: 100%; display: grid; gap: 7px; font-size: .76rem; font-weight: 630; color: var(--muted); }

.rotations-panel { display: grid; grid-template-columns: 132px 1fr; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; align-items: center; gap: 10px; padding: 11px; margin-bottom: 18px; }
.rotations-panel h2 { padding-inline: 10px 0; font-size: .85rem; }
.rotation-buttons { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 7px; }
.rotation-buttons button { min-width: 0; border: 1px solid var(--line); background: var(--raised); display: flex; gap: 8px; align-items: baseline; justify-content: center; border-radius: 8px; padding: 9px 4px; white-space: nowrap; }
.rotation-buttons strong { font-size: 1rem; line-height: 1.2; }
.rotation-buttons small { font-size: .68rem; color: var(--muted); }
.rotation-buttons button:hover { border-color: #80986e; }
.rotation-buttons [aria-pressed="true"] { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.rotation-buttons [aria-pressed="true"] small { color: #3d5028; }
.tactics-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: 15px; background: var(--panel); min-width: 0; }
.court-card { overflow: hidden; }
.court-toolbar { padding: 12px 15px; min-height: 68px; display: flex; gap: 8px; justify-content: space-between; align-items: center; }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border-radius: 9px; background: #0b1819; border: 1px solid var(--line); }
.segmented button { min-width: 83px; background: transparent; border: 0; border-radius: 6px; color: var(--muted); padding: 7px 13px; font-weight: 680; font-size: .82rem; }
.segmented button[aria-pressed="true"] { background: #2a4033; color: var(--accent); }
.traces-button { padding: 8px 10px; border: 1px solid var(--line); background: transparent; border-radius: 8px; color: var(--muted); font-size: .76rem; font-weight: 650; }
.traces-button[aria-pressed="true"] { background: #20372d; border-color: #385747; color: #dbefcf; }
.trace-icon { color: var(--accent); font-size: .98rem; margin-right: 2px; line-height: .7; }

.court-stage {
  --net: 24.6575%;
  --home: 68.4932%;
  position: relative;
  display: grid;
  justify-items: center;
  overflow: hidden;
  isolation: isolate;
  padding-block: 7px 11px;
  background: radial-gradient(ellipse at 50% 43%, #2b5361 0%, #1c3942 54%, #142c35 100%);
  border-block: 1px solid #45606a;
}
.court-stage::before { content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none; opacity: .32; background-image: linear-gradient(#87afbc31 1px, transparent 1px), linear-gradient(90deg, #87afbc31 1px, transparent 1px); background-size: 28px 28px; background-position: center top; }
.court-diagram { position: relative; width: min(100% - 66px, 290px); aspect-ratio: 100 / 146; }
.opponent-court, .home-court { position: absolute; inset-inline: 0; }
.opponent-court { top: -7px; height: calc(var(--net) + 7px); background: linear-gradient(180deg, #79584bd4, #a76d54); border-inline: 2px solid #ebc4a576; }
.home-court { top: var(--net); height: var(--home); border: 2px solid #ffe1bb; border-top: 0; background-color: #a96749; background-image: linear-gradient(180deg, #673a34a0 0%, #7a422c44 33.333%, #f6b98223 33.333%, #43271b24 100%), repeating-linear-gradient(90deg, #fed0ad12 0 1px, transparent 1px 22px); }
.attack-line { position: absolute; top: 33.3333%; inset-inline: 0; border-top: 1px dashed #ffe1bbe0; }
.net { height: 6px; position: absolute; z-index: 1; inset-inline: -12px; top: var(--net); transform: translateY(-50%); border-top: 2px solid #fff5d9; border-bottom: 1px solid #4b2d30; background: repeating-linear-gradient(90deg, #523d36 0 1px, #fff2d0b0 1px 5px); box-shadow: 0 3px 5px #0a0c0b40; }
.net::before, .net::after { content: ""; width: 4px; height: 13px; background: #fff2d5; border-radius: 2px; position: absolute; top: 50%; transform: translateY(-50%); }
.net::before { left: 0; }
.net::after { right: 0; }
.court-zones { position: absolute; inset-inline: 0; display: grid; grid-template-columns: repeat(3, 1fr); color: #ffdfbd85; font-size: clamp(1.4rem, 5vw, 2.1rem); font-weight: 750; text-align: center; line-height: 1; pointer-events: none; }
.court-zones-front { top: 11%; }
.court-zones-back { top: 61%; }
.court-side-caption, .net-caption { color: #c2d9dcad; position: absolute; font-size: .55rem; font-weight: 750; letter-spacing: .16em; }
.opponent-caption, .home-caption { left: max(12px, calc(50% - 146px - 41px)); writing-mode: vertical-rl; transform: rotate(180deg); }
.opponent-caption { top: 5%; }
.home-caption { top: 64%; }
.net-caption { inset-inline-end: max(7px, calc(50% - 146px - 54px)); top: calc(var(--net) + 3px); transform: translateY(-50%); }
#traces, #court-players { position: absolute; z-index: 2; width: 100%; height: 100%; inset: 0; overflow: visible; pointer-events: none; }
#court-players { z-index: 3; }
.player { display: flex; flex-direction: column; align-items: center; background: transparent; padding: 0; border: 0; color: var(--text); position: absolute; width: 35px; height: 35px; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: auto; }
.player-token { flex: 0 0 35px; width: 35px; height: 35px; display: grid; place-items: center; color: #121e20; background: var(--role); border: 2px solid #faffefc4; border-radius: 50%; font-size: .76rem; font-weight: 850; box-shadow: 0 2px 7px #22191b88; }
.player-name { position: absolute; top: calc(100% + 2px); max-width: 76px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .61rem; font-weight: 700; letter-spacing: .01em; padding: 1px 4px; border-radius: 4px; background: #182927f0; }
.player[aria-pressed="true"] .player-token { outline: 2px solid #fff; outline-offset: 2px; }
.player.is-me::after { content: "Я"; position: absolute; top: -5px; right: -6px; background: #172624; padding: 2px 3px; color: white; border: 1px solid white; border-radius: 5px; font-size: .6rem; font-weight: 800; }
.player.is-me { z-index: 1; }
.ball { z-index: 4; pointer-events: none; position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 1px solid #6c451c; background: conic-gradient(#ffe5a1, #fff7dd, #eaaa55, #fff5cd, #ffe5a1); box-shadow: 0 1px 5px #281a11a0; transform: translate(-50%, -50%); }

.playback { padding: 12px 15px; }
.transport { display: grid; grid-template-columns: auto 39px minmax(30px, 1fr) 39px; align-items: center; gap: 9px; }
.play-button { background: var(--accent); color: var(--ink); border: 0; border-radius: 8px; min-height: 38px; min-width: 91px; padding-inline: 10px; font-weight: 800; font-size: .8rem; display: flex; gap: 7px; align-items: center; justify-content: center; }
.play-symbol { width: 12px; height: 12px; background: currentColor; clip-path: polygon(15% 3%, 96% 50%, 15% 97%); }
.play-button.is-playing .play-symbol { clip-path: polygon(10% 0%, 38% 0%, 38% 100%, 10% 100%, 10% 0%, 62% 0%, 90% 0%, 90% 100%, 62% 100%, 62% 0%); }
.icon-button, .speed-button { border: 1px solid var(--line); background: var(--raised); border-radius: 8px; min-height: 38px; font-weight: 750; }
.icon-button { font-size: 1.3rem; line-height: 1; }
.speed-button { font-size: .76rem; padding: 0; }
.seek-wrap { display: grid; padding-inline: 2px; }
#seek { display: block; width: 100%; margin: 0; accent-color: var(--accent); cursor: ew-resize; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.tactics-sidebar { display: grid; gap: 14px; }
.phase-card, .roles-card { padding: 18px; }
.phase-card h2, .roles-card h2, .edit-card h2 { font-size: 1.15rem; letter-spacing: -.025em; line-height: 1.25; }
.phase-card h2 { font-size: 1.35rem; margin-block: 7px 5px; }
.phase-card p, #player-detail { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.phases { list-style: none; margin: 13px 0 0; padding: 0; display: grid; gap: 4px; }
.phases button { width: 100%; text-align: left; padding: 8px; display: grid; grid-template-columns: 25px 1fr; align-items: start; gap: 8px; border: 1px solid transparent; background: transparent; border-radius: 8px; }
.phases button:hover { background: var(--raised); }
.phases button[aria-current="step"] { background: #20372b; border-color: #385641; }
.phase-number { border: 1px solid #51665c; color: #c4d7cb; border-radius: 50%; width: 23px; height: 23px; display: grid; place-items: center; margin-top: 1px; font-size: .65rem; font-weight: 750; }
[aria-current="step"] .phase-number { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.phase-text { display: grid; gap: 2px; }
.phase-text strong { font-size: .8rem; font-weight: 710; }
.phase-text small { line-height: 1.38; font-size: .72rem; color: var(--muted); }
.roles-card h2 { margin-bottom: 10px; }
#player-detail { margin-bottom: 7px; }
.role-legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
.role-legend button { background: none; border: 1px solid transparent; border-radius: 7px; padding: 4px; display: flex; align-items: center; gap: 6px; text-align: left; min-width: 0; }
.role-legend button:hover, .role-legend button[aria-pressed="true"] { background: var(--raised); border-color: var(--line); }
.role-legend button.is-benched { opacity: .66; }
.role-mini { display: grid; flex: 0 0 25px; height: 25px; border-radius: 50%; background: var(--role); color: #142020; place-items: center; font-size: .61rem; font-weight: 820; }
.role-caption { font-size: .71rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.role-caption strong, .role-caption small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-caption strong { white-space: normal; }
.role-caption small { color: var(--muted); margin-top: 2px; }

[data-family="setter"] { --role: #e1f593; }
[data-family="outside"] { --role: #8cd8df; }
[data-family="opposite"] { --role: #efacc8; }
[data-family="middle"] { --role: #f8c382; }
[data-family="libero"] { --role: #c8b7ff; }

.primary-button, .secondary-button { border: 1px solid transparent; padding: 10px 14px; min-height: 40px; border-radius: 8px; font-weight: 750; font-size: .83rem; }
.primary-button { background: var(--accent); color: var(--ink); }
.secondary-button { border-color: var(--line); background: var(--raised); }
.secondary-button.danger { color: var(--danger); }
.lineup-list { display: grid; gap: 10px; }
.lineup-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; }
.lineup-item h2 { font-size: 1rem; overflow-wrap: anywhere; }
.lineup-item p { font-size: .79rem; color: var(--muted); margin-top: 5px; }
.lineup-item .form-actions { flex-shrink: 0; }
.empty, .notice { padding: 16px; color: var(--muted); }
.notice, .form-error { color: var(--danger); }
.edit-card { margin-top: 14px; padding: 20px; }
.edit-card h2 { margin-bottom: 15px; }
.edit-card form, .assignment-fields { display: grid; gap: 12px; }
.assignment-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.edit-card label { display: grid; gap: 5px; color: var(--muted); font-size: .79rem; font-weight: 640; }
select, input:not([type="range"]) { min-width: 0; width: 100%; padding: 9px 10px; border-radius: 7px; background: #0d1b1c; border: 1px solid #395052; color: var(--text); min-height: 42px; font-size: .91rem; }
.form-note, .form-error { font-size: .79rem; line-height: 1.45; }
.form-note { color: var(--muted); }
.form-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.member-list { list-style: none; padding: 0; margin: 0; display: grid; }
.member-list li { padding-block: 9px; display: flex; gap: 10px; align-items: baseline; border-top: 1px solid var(--line); overflow-wrap: anywhere; font-size: .86rem; }
.member-list small, #member-count { color: var(--muted); font-size: .75rem; }
.access-panel { max-width: 430px; margin: 8vh auto; padding: 31px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); display: grid; gap: 12px; }
.access-panel h1 { font-size: 2.75rem; letter-spacing: -.07em; }
.access-panel p { color: var(--muted); line-height: 1.5; }
.toast { position: fixed; z-index: 10; inset: auto 14px max(16px, env(safe-area-inset-bottom)); width: fit-content; max-width: calc(100% - 28px); margin-inline: auto; padding: 10px 14px; color: var(--text); background: var(--raised); border: 1px solid #5c7766; border-radius: 9px; }

@media (max-width: 850px) {
  .masthead-inner, .site-main { width: calc(100% - 36px); }
  .rotation-buttons button { gap: 4px; }
  .rotations-panel { grid-template-columns: 112px 1fr; }
  .tactics-grid { grid-template-columns: minmax(0, 1.3fr) minmax(265px, 1fr); }
  .net-caption { display: none; }
}

@media (max-width: 660px) {
  .masthead-inner, .site-main { width: calc(100% - 24px); }
  .masthead-inner { min-height: 57px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 9px; padding-block: 9px; }
  .brand { font-size: 22px; gap: 7px; }
  .brand-mark { width: 29px; height: 29px; }
  .navigation { order: 3; flex-basis: 100%; justify-content: space-between; }
  .navigation button { flex: 1; padding: 8px 5px; }
  .user-chip { max-width: 53%; }
  .site-main { padding-top: 19px; }
  .page-heading { align-items: start; flex-wrap: wrap; margin-bottom: 15px; gap: 9px; }
  .page-heading h1 { font-size: 2.65rem; }
  .page-description { font-size: .83rem; }
  .lineup-picker { max-width: none; }
  .lineup-picker select { min-height: 36px; }
  .rotations-panel { display: block; padding: 8px; margin-bottom: 12px; }
  .rotations-panel h2 { padding: 0; margin-bottom: 7px; }
  .rotation-buttons { gap: 4px; }
  .rotation-buttons button { display: grid; gap: 0; justify-items: center; padding: 5px 2px; }
  .rotation-buttons small { font-size: .59rem; }
  .tactics-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .court-toolbar { min-height: 54px; padding: 7px 8px; }
  .segmented button { min-width: 64px; padding-inline: 8px; }
  .traces-button { padding-inline: 7px; }
  .court-diagram { width: min(100% - 59px, 235px); }
  .opponent-caption, .home-caption { left: max(5px, calc(50% - 118px - 24px)); }
  .player, .player-token { width: 29px; height: 29px; }
  .player-token { flex-basis: 29px; font-size: .69rem; }
  .playback { padding: 8px; }
  .phase-card, .roles-card, .edit-card { padding: 13px; }
  .tactics-sidebar { gap: 12px; }
  .role-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lineup-item { align-items: start; flex-direction: column; gap: 10px; }
}

@media (max-width: 350px) {
  .assignment-fields { grid-template-columns: minmax(0, 1fr); }
}

.confirmation { width: min(420px, calc(100% - 32px)); padding: 18px; color: var(--text); }
.confirmation::backdrop { background: #050b0de0; }
.confirmation h2 { font-size: 1.13rem; }
.confirmation p { margin-block: 8px 16px; color: var(--muted); overflow-wrap: anywhere; }
