:root {
  font-family: Inter, Pretendard, "Noto Sans KR", Arial, sans-serif;
  color: #16383c;
  background: #dff4f2;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.85), transparent 36rem),
    #dff4f2;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

input,
textarea,
select,
.roster-inputs,
.roster-inputs label,
.slot-editor,
.slot-editor label,
.matchup-team,
.matchup-team label {
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}

input,
textarea,
select {
  -webkit-tap-highlight-color: rgba(13, 104, 112, 0.14);
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button,
.court-card,
.current-court-layout,
.overview-panel,
.drawing-layer,
.drawing-canvas,
.draggable-player,
.sideout-orb,
.rotation-step-buttons {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.app-header,
main,
footer {
  width: min(1480px, calc(100% - 32px));
  margin-inline: auto;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  margin-top: 4px;
  color: #104f54;
  font-size: clamp(28px, 5vw, 44px);
  letter-spacing: -0.06em;
}

.build-label {
  margin-top: 4px;
  color: #579093;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.creator-label {
  margin-top: 4px;
  color: #6c9ea0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

h2 {
  color: #174f54;
  font-size: 21px;
  letter-spacing: -0.04em;
}

h3 {
  color: #174f54;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.eyebrow {
  color: #25838a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.status-badge,
.summary-pill {
  border: 1px solid #a7d7d4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: #257077;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 12px;
}

main {
  display: grid;
  gap: 16px;
  padding-bottom: 32px;
}

section {
  border: 1px solid rgba(91, 164, 166, 0.3);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 35px rgba(35, 109, 113, 0.08);
  padding: 20px;
}

.section-heading,
.team-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.current-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.save-placement-button {
  margin-left: auto;
}

.help-text {
  margin-top: 8px;
  color: #54787a;
  font-size: 13px;
  line-height: 1.6;
}

.help-text.compact {
  margin: 0;
}

.overview-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.text-button {
  border: 0;
  border-radius: 999px;
  background: #e1f5f3;
  color: #1d7278;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 8px 12px;
}

.text-button.active {
  background: #0e747a;
  color: #fff;
}

.primary-button {
  border: 0;
  border-radius: 999px;
  background: #0e747a;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 11px 16px;
}

.situation-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.situation-options input {
  position: absolute;
  opacity: 0;
}

.situation-options span {
  display: block;
  border: 1px solid #b9dedd;
  border-radius: 999px;
  background: #fff;
  color: #31777b;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  padding: 9px 13px;
}

.situation-options input:checked + span {
  border-color: #0e747a;
  background: #0e747a;
  color: #fff;
}

.matchup-grid,
.roster-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.matchup-team,
.roster-team {
  border-radius: 16px;
  padding: 14px;
}

.matchup-team.home,
.roster-team.home {
  background: #edf9f8;
}

.matchup-team.away,
.roster-team.away {
  background: #fff2e8;
}

.matchup-team label,
.roster-inputs label {
  display: grid;
  gap: 6px;
  color: #457275;
  font-size: 12px;
  font-weight: 800;
}

.matchup-team label {
  margin-top: 10px;
}

.matchup-team input,
.roster-inputs input {
  width: 100%;
  border: 1px solid #c8e2e0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.9);
  color: #174f54;
  outline: none;
  padding: 9px 10px;
}

.matchup-team input:focus,
.roster-inputs input:focus {
  border-color: #0e747a;
  box-shadow: 0 0 0 3px rgba(14, 116, 122, 0.12);
}

.matchup-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  border-radius: 13px;
  background: #e7f4f4;
  color: #3b7376;
  font-size: 13px;
  padding: 12px 14px;
}

.matchup-panel {
  border: 2px solid rgba(14, 116, 122, 0.46);
  background: rgba(255, 255, 255, 0.9);
}

.matchup-result strong {
  color: #0f676d;
  text-align: right;
}

.roster-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.roster-inputs label {
  color: #0e6770;
  font-size: 14px;
  font-weight: 950;
}

.roster-inputs .libero-input {
  grid-column: span 3;
}

.slot-manager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(3, auto);
  gap: 7px;
  margin-top: 10px;
}

.slot-manager select,
.slot-button {
  border: 1px solid #b9dedd;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  color: #236c72;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
}

.slot-button {
  cursor: pointer;
}

.slot-button.active {
  border-color: #0e747a;
  background: #0e747a;
  color: #fff;
}

.slot-editor {
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 9px;
  border-top: 1px solid rgba(13, 104, 112, 0.16);
  padding-top: 9px;
}

.slot-editor.active {
  display: grid;
}

.slot-editor label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  color: #31777b;
  font-size: 11px;
  font-weight: 900;
}

.slot-editor input {
  width: 100%;
  border: 1px solid #c8e2e0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #174f54;
  padding: 7px 8px;
}

.selection-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  margin-top: 16px;
}

.team-selector {
  border-radius: 18px;
  padding: 16px;
}

.team-selector.home {
  background: #edf9f8;
}

.team-selector.away {
  background: #fff2e8;
}

.team-title strong {
  color: #0f6d73;
  font-size: 18px;
}

.versus {
  align-self: center;
  color: #72aeb1;
  font-size: 13px;
  font-weight: 900;
}

.state-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(40px, 1fr));
  gap: 7px;
  margin-top: 14px;
}

.state-button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: #fff;
  color: #33777b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 10px 4px;
  transition: 150ms ease;
}

.state-button:hover:not(:disabled) {
  border-color: #3c9598;
  transform: translateY(-1px);
}

.state-button.selected {
  border-color: #0e747a;
  background: #0e747a;
  color: #fff;
}

.state-button:disabled {
  cursor: not-allowed;
  opacity: 0.22;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 14px;
  background: #eff8f7;
  color: #3e6c6f;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  padding: 13px;
}

.top-options {
  border: 2px solid rgba(14, 116, 122, 0.38);
  background: rgba(255, 255, 255, 0.9);
}

.toggle-card input {
  position: absolute;
  opacity: 0;
}

.toggle-card i {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: #b8d5d4;
  transition: 150ms ease;
}

.toggle-card i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: 150ms ease;
}

.toggle-card input:checked + i {
  background: #0e747a;
}

.toggle-card input:checked + i::after {
  transform: translateX(16px);
}

.court-align-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  background: #e1f5f3;
  color: #1d7278;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  padding: 8px 10px;
}

.court-align-toggle input {
  position: absolute;
  opacity: 0;
}

.court-align-toggle i {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #b8d5d4;
}

.court-align-toggle i::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: 150ms ease;
}

.court-align-toggle input:checked + i {
  background: #0e747a;
}

.court-align-toggle input:checked + i::after {
  transform: translateX(14px);
}

.court-card {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  background: #bdd9ee;
}

.court-card.large {
  overflow: visible;
}

.court-card.empty {
  display: grid;
  min-height: 260px;
  place-items: center;
}

.empty-message {
  color: #3f708d;
  font-weight: 900;
}

.court-surface {
  display: grid;
  grid-template-rows: auto 1fr auto;
  border: 18px solid #bdd9ee;
  background: #f8c9aa;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.98);
}

.court-field {
  position: relative;
  display: grid;
  grid-template-rows: repeat(2, minmax(44px, auto)) 8px repeat(2, minmax(44px, auto));
  border: 3px solid rgba(255, 255, 255, 0.98);
  background: #f8c9aa;
}

.court-field::before,
.court-field::after {
  position: absolute;
  right: -10px;
  left: -10px;
  z-index: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.98);
  content: "";
}

.court-field::before {
  top: 33.333%;
}

.court-field::after {
  bottom: 33.333%;
}

.court-team {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: transparent;
}

.court-team.away {
  background: transparent;
}

.court-team.home {
  background: transparent;
}

.player {
  display: grid;
  min-height: 58px;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
}

.net-divider {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  border-block: 4px solid rgba(255, 255, 255, 1);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.95) 0 2px, transparent 2px 10px),
    #101010;
}

.net-divider span {
  display: none;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.24em;
}

.position-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.drawing-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
  touch-action: pan-x pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.drawing-layer.active {
  z-index: 6;
  pointer-events: auto;
  touch-action: none;
}

.drawing-layer.active.move-mode {
  pointer-events: none;
  touch-action: pan-x pan-y pinch-zoom;
}

.drawing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.drawing-layer.active.pen-cursor {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Cpath d='M4 24 L20 8 L24 12 L8 28 Z' fill='%23101010'/%3E%3Cpath d='M18 6 L21 3 L25 7 L22 10 Z' fill='%23f4c430'/%3E%3C/svg%3E") 4 24, crosshair;
}

.drawing-layer.active.eraser-cursor {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='30' height='24' viewBox='0 0 30 24'%3E%3Cpath d='M3 15 L14 4 L27 17 L20 24 L7 24 Z' fill='%23f8b4c4' stroke='%23104f54' stroke-width='2'/%3E%3Cpath d='M14 4 L27 17 L22 22 L9 9 Z' fill='%23fffaf5' stroke='%23104f54' stroke-width='2'/%3E%3C/svg%3E") 7 18, cell;
}

.overview-panel {
  position: relative;
}

.overview-drawing-layer {
  border-radius: 22px;
}

.draggable-player {
  position: absolute;
  left: calc(var(--grid-x) * 1%);
  top: calc(var(--grid-y) * 1%);
  display: inline-flex;
  width: 72px;
  min-width: 72px;
  height: 72px;
  min-height: 72px;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(13, 104, 112, 0.72);
  border-radius: 50%;
  background: #fffaf5;
  color: #073945;
  cursor: grab;
  font-size: 32px;
  font-weight: 950;
  line-height: 1.05;
  padding: 4px;
  text-align: center;
  white-space: nowrap;
  touch-action: none;
  transform: translate(-50%, -50%);
  transition: background 120ms ease, box-shadow 120ms ease, transform 120ms ease;
  user-select: none;
  -webkit-user-select: none;
}

.draggable-player.dragging {
  z-index: 3;
  background: #fff;
  box-shadow: 0 5px 15px rgba(37, 92, 112, 0.25);
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.08);
}

.rotation-card .state-strip {
  min-height: 24px;
  font-size: 11px;
}

.state-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 38px;
  background: #bdd9ee;
  color: #244f68;
  font-size: 18px;
  font-weight: 950;
}

.ball {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(37, 92, 112, 0.18));
}

.ball::before {
  content: "\1F3D0";
}

.large {
  width: min(390px, 100%);
  margin: 0;
}

.current-court-stage {
  position: relative;
  display: flex;
  width: min(640px, 100%);
  justify-content: flex-end;
}

.current-court-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 640px) 180px;
  align-items: center;
  justify-content: center;
  gap: 118px;
  margin-top: 14px;
}

.current-drawing-layer {
  border-radius: 16px;
}

.drawing-mode-panel {
  position: sticky;
  right: 14px;
  bottom: 14px;
  z-index: 9;
  display: none;
  grid-template-columns: repeat(3, auto);
  gap: 7px;
  justify-self: end;
  align-self: end;
  margin-top: -62px;
  padding: 8px;
  border: 1px solid rgba(13, 104, 112, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 26px rgba(37, 92, 112, 0.16);
}

.current-court-layout.drawing-active .drawing-mode-panel,
.current-court-layout:has(.drawing-layer.active) .drawing-mode-panel {
  display: grid;
}

.drawing-mode-panel button {
  border: 1px solid #a7d7d4;
  border-radius: 999px;
  background: #eef9f8;
  color: #174f54;
  cursor: pointer;
  font-size: 13px;
  font-weight: 950;
  padding: 9px 12px;
}

.drawing-mode-panel button.active {
  border-color: #0e747a;
  background: #0e747a;
  color: #fff;
}

.court-side-tools {
  position: relative;
  z-index: 7;
  display: grid;
  justify-items: center;
  gap: 16px;
}

.drawing-toolbar {
  display: grid;
  width: 260px;
  gap: 8px;
  justify-items: center;
  border: 1px solid #a7d7d4;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  padding: 10px;
  box-shadow: 0 10px 24px rgba(37, 92, 112, 0.1);
}

.text-note-toolbar {
  display: grid;
  width: 260px;
  grid-template-columns: repeat(4, auto);
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid #a7d7d4;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.76);
  padding: 10px;
  box-shadow: 0 10px 24px rgba(37, 92, 112, 0.1);
}

.drawing-toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.toolbar-divider {
  width: calc(100% - 22px);
  height: 1px;
  background: rgba(13, 104, 112, 0.22);
}

.draw-tool {
  display: inline-grid;
  min-width: 48px;
  height: 42px;
  place-items: center;
  border: 2px solid rgba(13, 104, 112, 0.26);
  border-radius: 999px;
  background: #eef9f8;
  color: #174f54;
  cursor: pointer;
  font-size: 15px;
  font-weight: 950;
}

.draw-tool.red {
  color: #be123c;
}

.draw-tool.blue {
  color: #1d4ed8;
}

.draw-tool.active {
  border-color: rgba(13, 104, 112, 0.82);
  background: #0f858b;
  color: #fff;
}

.draw-tool:disabled {
  cursor: default;
  opacity: 0.38;
}

.clear-tool {
  min-width: 62px;
  font-size: 12px;
}

.text-note-tool {
  min-width: 58px;
  font-size: 12px;
  line-height: 1.05;
}

.text-size-tool {
  min-width: 46px;
}

.color-dot {
  display: block;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(13, 104, 112, 0.18);
}

.color-dot.black {
  background: #101010;
}

.color-dot.red {
  background: #e11d48;
}

.color-dot.blue {
  background: #2563eb;
}

.width-label {
  color: #2d6870;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.width-line {
  display: block;
  width: 26px;
  border-radius: 999px;
  background: #101010;
  box-shadow: 0 0 0 2px rgba(13, 104, 112, 0.16);
}

.width-line.thin {
  height: 3px;
}

.width-line.thick {
  height: 7px;
}

.eraser-icon {
  position: relative;
  display: block;
  width: 25px;
  height: 17px;
  transform: rotate(-28deg);
}

.eraser-icon::before,
.eraser-icon::after {
  position: absolute;
  inset-block: 0;
  content: "";
}

.eraser-icon::before {
  left: 0;
  width: 15px;
  border: 2px solid rgba(13, 104, 112, 0.72);
  border-right-width: 1px;
  border-radius: 5px 2px 2px 5px;
  background: #f8b4c4;
}

.eraser-icon::after {
  right: 0;
  width: 11px;
  border: 2px solid rgba(13, 104, 112, 0.72);
  border-left-width: 1px;
  border-radius: 2px 5px 5px 2px;
  background: #fffaf5;
}

.sideout-orb {
  display: grid;
  width: 180px;
  height: 180px;
  place-items: center;
  border: 6px solid rgba(13, 104, 112, 0.78);
  border-radius: 50%;
  background: linear-gradient(145deg, #0e747a, #11959b);
  box-shadow: 0 16px 35px rgba(14, 116, 122, 0.22);
  color: #fff;
  cursor: pointer;
  font-size: 28px;
  font-weight: 950;
  line-height: 1.08;
  text-align: center;
}

.sideout-orb:active {
  transform: scale(0.97);
}

.rotation-step-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.rotation-step-buttons button {
  border: 1px solid #a7d7d4;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #0f676d;
  cursor: pointer;
  font-size: 13px;
  font-weight: 950;
  padding: 9px 13px;
}

.large .court-surface {
  border-width: 17px;
}

.large .court-field {
  aspect-ratio: 1 / 2;
  grid-template-rows: repeat(2, 1fr) 12px repeat(2, 1fr);
  border-width: 4px;
}

.large .court-field::before,
.large .court-field::after {
  right: -12px;
  left: -12px;
  height: 4px;
}

.large .net-divider {
  border-block-width: 4px;
}

.large .player {
  min-height: 0;
  font-size: 15px;
}

.large .state-strip {
  min-height: 48px;
  font-size: 31px;
}

.large .ball {
  width: 26px;
  height: 26px;
}

.large .draggable-player {
  width: 72px;
  min-width: 72px;
  height: 72px;
  min-height: 72px;
  font-size: 21px;
  padding: 4px;
}

.court-service-ball {
  position: absolute;
  z-index: 4;
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  font-size: 38px;
  line-height: 1;
  filter: drop-shadow(0 5px 10px rgba(37, 92, 112, 0.16));
}

.court-service-ball::before {
  content: "\1F3D0";
}

.court-service-ball.away {
  top: -58px;
  left: 12%;
  transform: translateX(-50%);
}

.court-service-ball.home {
  right: 12%;
  bottom: -58px;
  transform: translateX(50%);
}

.rotation-overview {
  display: grid;
  grid-template-columns: repeat(6, minmax(148px, 1fr));
  column-gap: 8px;
  row-gap: 16px;
  margin-top: 16px;
  min-width: 936px;
}

.overview-panel {
  overflow-x: auto;
}

.rotation-card {
  position: relative;
  overflow: visible;
}

.rotation-card.current-overview {
  outline: 5px solid #e11d48;
  outline-offset: 3px;
  box-shadow: 0 0 0 7px rgba(225, 29, 72, 0.13);
}

.current-overview-badge {
  position: absolute;
  top: -14px;
  right: -6px;
  z-index: 12;
  display: inline-grid;
  min-width: 42px;
  min-height: 25px;
  place-items: center;
  border: 2px solid #fffaf5;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 13px;
  font-weight: 950;
  box-shadow: 0 5px 12px rgba(108, 27, 54, 0.24);
}

.court-card.rotation-card,
.rotation-card .court-surface,
.rotation-card .court-field {
  overflow: visible;
}

.rotation-card:not(:nth-child(4n))::after {
  display: none;
}

.rotation-index {
  position: absolute;
  top: 8px;
  left: 9px;
  z-index: 1;
  color: rgba(17, 79, 84, 0.6);
  font-size: 11px;
  font-weight: 900;
}

.rotation-card .player {
  position: relative;
  z-index: 3;
  min-height: 0;
  overflow: visible;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rotation-card .player span {
  position: relative;
  z-index: 4;
  display: inline-grid;
  width: 48px;
  min-width: 48px;
  height: 48px;
  min-height: 48px;
  place-items: center;
  border: 2px solid rgba(13, 104, 112, 0.72);
  border-radius: 50%;
  background: #fffaf5;
  box-shadow: 0 0 0 2px rgba(255, 250, 245, 0.95);
  font-size: 15px;
  font-weight: 950;
  line-height: 1;
  padding: 2px;
}

.matchup-line-layer {
  position: absolute;
  inset: 0;
  z-index: 6;
  overflow: visible;
  pointer-events: none;
}

.matchup-line-layer.editing {
  pointer-events: auto;
  touch-action: none;
}

.matchup-line-layer line {
  stroke: rgba(13, 104, 112, 0.82);
  stroke-width: 1.9;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.matchup-line-handle {
  cursor: grab;
  fill: #0d6870;
  stroke: #fffaf5;
  stroke-width: 1.6;
  pointer-events: auto;
  touch-action: none;
  vector-effect: non-scaling-stroke;
}

.matchup-line-handle:active {
  cursor: grabbing;
}

.text-note-layer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: clamp(-420px, -24vw, -180px);
  z-index: 8;
  pointer-events: none;
}

.text-note-layer.editing {
  pointer-events: auto;
}

.text-note {
  position: absolute;
  left: calc(var(--note-x) * 1%);
  top: calc(var(--note-y) * 1%);
  width: calc(var(--note-w) * 1%);
  height: calc(var(--note-h) * 1%);
  min-width: 84px;
  min-height: 42px;
  border: 2px solid rgba(13, 104, 112, 0.56);
  border-radius: 12px;
  background: rgba(255, 250, 245, 0.92);
  box-shadow: 0 8px 18px rgba(28, 82, 91, 0.12);
  pointer-events: none;
}

.text-note textarea {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: #073945;
  font: inherit;
  font-size: calc(var(--note-size) * 1px);
  font-weight: 900;
  line-height: 1.2;
  padding: 8px 10px;
  text-align: center;
  align-content: center;
  touch-action: auto;
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
  -webkit-tap-highlight-color: rgba(13, 104, 112, 0.14);
}

.text-note:not(.editing) textarea {
  pointer-events: none;
}

.text-note.editing {
  cursor: move;
  border-color: rgba(13, 104, 112, 0.92);
  pointer-events: auto;
}

.text-note-resize {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 18px;
  height: 18px;
  border: 2px solid #fffaf5;
  border-radius: 50%;
  background: #0d6870;
  cursor: nwse-resize;
  touch-action: none;
}

.text-note-delete {
  position: absolute;
  top: -11px;
  right: -11px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid #fffaf5;
  border-radius: 50%;
  background: #e11d48;
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 950;
  line-height: 1;
  touch-action: manipulation;
}

.text-note-move {
  position: absolute;
  top: -11px;
  left: -11px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 2px solid #fffaf5;
  border-radius: 50%;
  background: #0d6870;
  color: #fff;
  cursor: move;
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  touch-action: none;
}

.rotation-card .court-service-ball {
  width: 26px;
  height: 26px;
  font-size: 23px;
}

.rotation-card .court-service-ball.away {
  top: -29px;
  left: 12%;
  transform: translateX(-50%);
}

.rotation-card .court-service-ball.home {
  right: 12%;
  bottom: -29px;
  transform: translateX(50%);
}

.rotation-card .state-strip {
  min-height: 24px;
  font-size: 15px;
}

.rotation-card .court-surface {
  border-width: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.98);
}

.rotation-card .court-field {
  aspect-ratio: 1 / 1.18;
  grid-template-rows: repeat(2, 1fr) 4px repeat(2, 1fr);
}

.rotation-card .court-team {
  border-top-width: 0;
}

.rotation-card .player {
  border-right-width: 0;
}

.rotation-card .net-divider {
  border-block: 2px solid #101010;
  background: #101010;
}

.rotation-card .court-field {
  border-width: 2px;
}

.rotation-card .court-field::before,
.rotation-card .court-field::after {
  right: -5px;
  left: -5px;
  height: 2px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 24px;
  color: #5e8486;
  font-size: 12px;
}

@media (max-width: 960px) {
  .rotation-overview {
    grid-template-columns: repeat(6, minmax(112px, 1fr));
  }

  .rotation-card:not(:nth-child(4n))::after {
    display: none;
  }

  .current-court-layout {
    grid-template-columns: minmax(0, 500px);
    gap: 16px;
  }

  .sideout-orb {
    width: 180px;
    height: 180px;
    justify-self: center;
    font-size: 28px;
  }

  .drawing-toolbar,
  .text-note-toolbar {
    width: min(260px, 100%);
  }
}

@media (max-width: 680px) {
  .app-header,
  main,
  footer {
    width: min(100% - 18px, 560px);
  }

  .app-header {
    padding-top: 18px;
  }

  section {
    border-radius: 16px;
    padding: 14px;
  }

  .selection-grid {
    grid-template-columns: 1fr;
  }

  .versus {
    display: none;
  }

  .option-grid,
  .matchup-grid,
  .roster-grid {
    grid-template-columns: 1fr;
  }

  .rotation-overview {
    grid-template-columns: repeat(6, minmax(112px, 1fr));
  }

  .roster-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-buttons {
    gap: 6px;
  }

  .state-button {
    padding: 9px 2px;
  }

  footer {
    display: grid;
  }

  .rotation-card .player {
    min-height: 0;
    font-size: 10px;
  }

  .sideout-orb {
    width: 150px;
    height: 150px;
    font-size: 23px;
  }

  .drawing-toolbar,
  .text-note-toolbar {
    width: min(240px, 100%);
  }

  .draw-tool {
    min-width: 42px;
    height: 38px;
    font-size: 14px;
  }
}
