:root {
  color-scheme: light;
  --toolbar-bg: rgba(255, 255, 255, 0.9);
  --panel-bg: rgba(255, 255, 255, 0.96);
  --accent: #34d399;
  --brand-green: #139a47;
  --brand-green-soft: #eef9f0;
  --brand-green-tint: #dff3e4;
  --danger: #f87171;
  --header-height: 58px;
  --text: #111827;
  --focus-ring: #1d4ed8;
  --focus-ring-soft: rgba(37, 99, 235, 0.45);
  --playbook-title: #1e3a5f;
  --play-canvas-aspect: 4 / 5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: #ffffff;
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#fieldCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pinch-zoom;
}

.toolbar,
.formation-strip {
  position: absolute;
  left: env(safe-area-inset-left, 8px);
  right: env(safe-area-inset-right, 8px);
  padding: 8px;
  background: var(--toolbar-bg);
  border-radius: 10px;
  backdrop-filter: blur(2px);
}


/* App header bar */
.app-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding: calc(env(safe-area-inset-top, 0px) + 7px) 12px 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border-bottom: 1px solid rgba(17, 24, 39, 0.10);
  z-index: 250;
  box-sizing: border-box;
}

.app-header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.app-header-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: block;
}

.app-header-text {
  display: flex;
  min-width: 0;
}

.app-header-name {
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 800;
  color: #111827;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-wordmark-play {
  color: #111827;
}

.brand-wordmark-drawer {
  color: var(--brand-green);
}

.app-header-menu-btn {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 8px;
  flex-shrink: 0;
}

.app-header-menu-btn:hover {
  background: rgba(17, 24, 39, 0.06);
}

.app-header-menu-btn svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #111827;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Mode toggle nav row */
.mode-nav {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  flex-shrink: 0;
  background: #ffffff;
  border: 1.5px solid rgba(17, 24, 39, 0.18);
  border-radius: 16px;
  overflow: hidden;
}

.mode-nav-btn {
  width: 46px;
  height: 36px;
  border: none;
  border-right: 1px solid rgba(17, 24, 39, 0.12);
  background: transparent;
  color: #374151;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

.mode-nav-btn:last-child {
  border-right: none;
}

.mode-nav-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.mode-nav-btn.active {
  background: var(--brand-green);
  color: #ffffff;
}

.mode-nav-btn:not(.active):hover {
  background: #f9fafb;
}

/* Draw tools toolbar — floating circle selectors at bottom of field */
.draw-toolbar {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 999px;
  padding: 8px 16px;
  backdrop-filter: blur(6px);
  z-index: 249;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
}

.tool-btn {
  width: 46px;
  height: 46px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(17, 24, 39, 0.16);
  border-radius: 50%;
  background: #ffffff;
  color: var(--brand-green);
  padding: 0;
  cursor: pointer;
}

.tool-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-btn.active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
}

.tool-btn:not(.active):hover {
  background: var(--brand-green-soft);
  border-color: var(--brand-green);
}

.tool-btn:disabled {
  color: #9ca3af;
  cursor: default;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid rgba(17, 24, 39, 0.22);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn.no-border {
  border: none;
  background: transparent;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn.active {
  background: rgba(52, 211, 153, 0.25);
  border-color: var(--accent);
}

.icon-btn:disabled {
  opacity: 0.45;
}

.icon-btn.danger {
  border-color: var(--danger);
}

.formation-strip {
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  display: flex;
  gap: 10px;
  overflow-x: auto;
  white-space: nowrap;
  padding: 12px 14px 10px;
  background: #ffffff;
  border-bottom: 1px solid rgba(17, 24, 39, 0.10);
}

.formation-btn {
  border: 1.5px solid rgba(17, 24, 39, 0.18);
  border-radius: 999px;
  background: #ffffff;
  color: var(--text);
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.formation-btn.active {
  border-color: var(--brand-green);
  background: var(--brand-green-soft);
}

.formation-item {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.formation-action-btn {
  border: none;
  background: transparent;
  color: var(--text);
  padding: 4px 5px;
  font-size: 0.75rem;
  opacity: 0.55;
  cursor: pointer;
  border-radius: 4px;
}

.formation-action-btn:hover {
  opacity: 1;
  background: rgba(17, 24, 39, 0.08);
}

.formation-action-btn.danger:hover {
  color: #ef4444;
}

.formation-empty {
  opacity: 0.7;
  font-size: 0.82rem;
}

/* Drawer overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 260;
}

.drawer-overlay[hidden] {
  display: none;
}

/* Left-side drawer */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(85vw, 420px);
  background: #ffffff;
  color: #111827;
  z-index: 261;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
}

.drawer[hidden] {
  display: none;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.10);
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
}

/* Branding */
.drawer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.drawer-brand-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: block;
}

.drawer-brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drawer-brand-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: #111827;
  line-height: 1.2;
}

/* Close button */
.drawer-close-btn {
  width: 40px;
  height: 40px;
  border: 1.5px solid rgba(17, 24, 39, 0.22);
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.drawer-close-btn svg {
  width: 20px;
  height: 20px;
  stroke: #111827;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}

.drawer-close-btn:hover {
  background: #f3f4f6;
}

/* Section labels */
.drawer-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #6b7280;
  padding: 16px 20px 8px;
  text-transform: uppercase;
}

/* Playbook selector row */
.drawer-playbook-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 12px;
}

.drawer-playbook-select-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1.5px solid rgba(17, 24, 39, 0.22);
  border-radius: 10px;
  padding: 0 10px;
  background: #ffffff;
  height: 44px;
  gap: 8px;
  min-width: 0;
}

.drawer-playbook-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: #111827;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-playbook-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  padding: 0;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.drawer-playbook-select:focus {
  outline: none;
}

.drawer-select-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: #6b7280;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.drawer-add-btn {
  width: 44px;
  height: 44px;
  border: 1.5px solid #1a6b3c;
  border-radius: 10px;
  background: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}

.drawer-add-btn svg {
  width: 20px;
  height: 20px;
  stroke: #1a6b3c;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
}

.drawer-add-btn:hover {
  background: #f0fdf4;
}

/* Nav items */
.drawer-nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 14px;
  padding: 14px 16px;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
  border-bottom: 1px solid rgba(17, 24, 39, 0.07);
}

.drawer-nav-item:hover {
  background: #f9fafb;
}

.drawer-nav-item.active {
  background: #f0fdf4;
}

.drawer-nav-item-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-nav-item.active .drawer-nav-item-icon {
  background: #dcfce7;
}

.drawer-nav-item-icon svg {
  width: 20px;
  height: 20px;
  stroke: #374151;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-nav-item.active .drawer-nav-item-icon svg {
  stroke: #1a6b3c;
}

.drawer-nav-item.active .drawer-nav-item-title {
  color: #1a6b3c;
}

.drawer-nav-item-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drawer-nav-item-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  line-height: 1.2;
}

.drawer-nav-item-sub {
  font-size: 0.78rem;
  color: #6b7280;
  line-height: 1.2;
}

.drawer-nav-item-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: #9ca3af;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-nav-item.active .drawer-nav-item-chevron {
  stroke: #1a6b3c;
}

/* Footer */
.drawer-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(17, 24, 39, 0.10);
}

.drawer-footer-help {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: #374151;
  cursor: pointer;
}

.drawer-footer-help svg {
  width: 20px;
  height: 20px;
  stroke: #374151;
  stroke-width: 1.8;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drawer-footer-version {
  font-size: 0.82rem;
  color: #9ca3af;
}

/* Legacy: keep .drawer-section and .drawer-title for non-menu drawers */
.drawer-title {
  font-size: 1.1rem;
  font-weight: 600;
}

.drawer-section {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
}

.panel-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.panel-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.panel-add-input {
  flex: 1;
  min-width: 0;
}

.playbook-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

.playbook-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-top: 1px solid rgba(17, 24, 39, 0.1);
  padding: 8px 0;
}

.playbook-item-meta {
  font-size: 0.75rem;
  color: #4b5563;
}

button,
select,
input {
  border: 1px solid rgba(17, 24, 39, 0.22);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
}

input[type="text"] {
  font-size: 16px;
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.save-modal {
  border: 1px solid rgba(17, 24, 39, 0.2);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  padding: 14px;
}

.save-modal::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

#savePlayForm {
  display: grid;
  gap: 8px;
  min-width: min(300px, 90vw);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(17, 24, 39, 0.1);
  font-size: 0.85rem;
  opacity: 0.85;
}

.roster-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
}

.roster-item {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
  border-top: 1px solid rgba(17, 24, 39, 0.08);
}

.drawer button,
.drawer select,
.drawer input {
  border-color: rgba(17, 24, 39, 0.22);
  background: #ffffff;
  color: #111827;
}

.drawer .icon-btn {
  background: #ffffff;
  border-color: rgba(17, 24, 39, 0.22);
}

.roster-name {
  width: 100px;
  min-width: 100px;
  flex-shrink: 0;
}

.roster-pos-dots {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.roster-pos-dot {
  min-width: 24px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  padding: 0;
  font-size: 0.68rem;
  line-height: 24px;
}

.roster-pos-dot.active {
  background: #34d399;
  border-color: #10b981;
  color: #ffffff;
}

.roster-remove {
  flex-shrink: 0;
  padding: 6px 8px;
}

.toggle-switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background-color 0.15s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: #22c55e;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Drawer nav button */
.drawer-nav-btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(17, 24, 39, 0.18);
  background: #f9fafb;
  font-size: 0.9rem;
  cursor: pointer;
}

.drawer-nav-btn:hover {
  background: #f3f4f6;
}

/* Save name row with clear button */
.save-name-row {
  position: relative;
  display: flex;
  align-items: center;
}

.save-name-row input {
  flex: 1;
  padding-right: 32px;
}

.clear-input-btn {
  position: absolute;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 0.8rem;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clear-input-btn:hover {
  color: #374151;
  background: rgba(17, 24, 39, 0.08);
}

/* Formations management list */
.formations-manage-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.formations-manage-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
}

.formations-manage-name {
  flex: 1;
  font-size: 0.9rem;
}

/* Roster position dot dimmed when another position is occupied */
.roster-pos-dot.dimmed {
  opacity: 0.3;
}

/* Concept chips – shared base style (used in filter strip and save modal) */
.concept-filter-chip,
.concept-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid rgba(17, 24, 39, 0.2);
  background: #f9fafb;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.concept-filter-chip.active,
.concept-chip.active {
  background: var(--brand-green);
  border-color: var(--brand-green);
  color: #ffffff;
}

.concept-filter-chip:hover,
.concept-chip:hover {
  border-color: var(--brand-green);
}

/* Concept filter strip – horizontal scroll bar above playbook grid */
.concept-filter-strip {
  display: flex;
  flex-direction: row;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 12px 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  flex-shrink: 0;
}

.concept-filter-strip::-webkit-scrollbar {
  display: none;
}

.gameplan-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.08);
}

.gameplan-filter-separator {
  width: 1px;
  align-self: stretch;
  background: rgba(17, 24, 39, 0.12);
  flex-shrink: 0;
}

.gameplan-filter-row .concept-filter-strip {
  flex: 1;
  min-width: 0;
  padding: 0;
  border-bottom: none;
}

.gameplan-filter-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  border: 1.5px solid rgba(17, 24, 39, 0.2);
  border-radius: 999px;
  padding: 6px 10px;
  background: #f9fafb;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  cursor: pointer;
}

.gameplan-filter-icon {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.gameplan-filter-select[aria-pressed="true"] {
  border-color: var(--brand-green);
  color: var(--brand-green);
  background: rgba(38, 145, 82, 0.1);
}

/* Concept chips row inside save modal */
.save-concepts-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}

.save-concepts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Playbook bottom bar */
.playbook-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 16px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(17, 24, 39, 0.10);
  background: #ffffff;
  flex-shrink: 0;
}

.playbook-bottom-select-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  border: 1.5px solid rgba(17, 24, 39, 0.22);
  border-radius: 10px;
  padding: 0 10px;
  background: #ffffff;
  height: 42px;
  gap: 8px;
  min-width: 0;
}

.playbook-bottom-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: #111827;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.playbook-bottom-select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 600;
  color: #111827;
  padding: 0;
  min-width: 0;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.playbook-bottom-select:focus {
  outline: none;
}

.playbook-bottom-chevron {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke: #6b7280;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.playbook-bottom-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 16px;
  border: 1.5px solid #1a6b3c;
  border-radius: 10px;
  background: #ffffff;
  color: #1a6b3c;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.playbook-bottom-new-btn svg {
  width: 18px;
  height: 18px;
  stroke: #1a6b3c;
  stroke-width: 2.5;
  fill: none;
  stroke-linecap: round;
}

.playbook-bottom-new-btn:hover {
  background: #f0fdf4;
}

.playbook-bottom-secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid rgba(17, 24, 39, 0.18);
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
}

.playbook-bottom-secondary-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.playbook-bottom-secondary-btn[aria-pressed="true"] {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}

.playbook-bottom-secondary-btn:hover {
  background: #f9fafb;
}

.playbook-bottom-secondary-btn[aria-pressed="true"]:hover {
  background: #1f2937;
}

@media (max-width: 680px) {
  .toolbar,
  .formation-strip {
    border-radius: 0;
    left: 0;
    right: 0;
  }
}

/* View mode toggle in drawer */
.view-mode-toggle {
  display: flex;
  gap: 4px;
}

.view-mode-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(17, 24, 39, 0.22);
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
}

.view-mode-btn.active {
  background: rgba(52, 211, 153, 0.25);
  border-color: var(--accent);
  font-weight: 600;
}

/* Playbook grid view */
.playbook-view {
  position: fixed;
  top: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.playbook-view[hidden] {
  display: none;
}

.playbook-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.print-page {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 680px) {
  .playbook-grid {
    padding: 16px;
    gap: 14px;
  }

  .print-page {
    gap: 14px;
  }
}

.play-card {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.12s ease;
  width: 100%;
  padding: 0;
  text-align: left;
  appearance: none;
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.06);
  height: clamp(236px, 36vw, 316px);
}

.play-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px 8px;
  min-height: 58px;
}

.play-card:hover,
.play-card:focus-visible {
  box-shadow: 0 0 0 3px var(--focus-ring-soft);
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.play-card-thumb-wrap {
  width: 100%;
  position: relative;
  background: #f3f4f6;
  overflow: hidden;
  border-top: 1px solid #e5e7eb;
  border-radius: 0 0 8px 8px;
  flex: 1;
}

.play-card-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

@media (max-width: 679px) {
  .playbook-grid {
    gap: 12px;
    padding: 12px;
  }

  .play-card {
    height: 236px;
  }

  .play-card-label {
    font-size: 0.95rem;
  }
}

.play-card-label {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.35;
  font-weight: 600;
  color: var(--playbook-title);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
  min-width: 0;
}

.play-card-order-btn {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.play-card-order-btn:hover:not(:disabled) {
  background: #f3f4f6;
  color: #6b7280;
}

.play-card-order-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.play-card-order-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.play-card-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 7px 10px 9px;
  border-top: 1px solid #e5e7eb;
}

.undo-toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 500;
  background: rgba(17, 24, 39, 0.96);
  color: #ffffff;
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.undo-toast[hidden] {
  display: none;
}

.play-card-gameplan-btn {
  min-height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  border: 1px solid var(--brand-green);
  background: transparent;
  color: var(--brand-green);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.play-card-gameplan-btn.active {
  background: var(--brand-green);
  color: #ffffff;
}

.play-card-gameplan-btn:hover {
  background: rgba(38, 145, 82, 0.08);
}

.play-card-gameplan-btn.active:hover {
  background: #227e48;
}

.undo-toast button {
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  background: transparent;
  color: #ffffff;
  font-weight: 600;
  padding: 4px 10px;
}

.undo-toast button:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.playbook-empty {
  text-align: center;
  color: #6b7280;
  font-size: 0.9rem;
  padding: 32px 16px;
}

.play-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  border: 2px dashed rgba(17, 24, 39, 0.25);
  background: #f9fafb;
  cursor: pointer;
  border-radius: 10px;
  aspect-ratio: var(--play-canvas-aspect, 9 / 16);
  font-size: 0.82rem;
  color: #6b7280;
  width: 100%;
}

.play-card-add svg {
  width: 28px;
  height: 28px;
  stroke: #9ca3af;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Full-screen play detail - transparent overlay, header only */
.play-detail-view {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 300;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.play-detail-view[hidden] {
  display: none;
}

.play-detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(17, 24, 39, 0.12);
  flex-shrink: 0;
  background: var(--toolbar-bg);
  backdrop-filter: blur(2px);
  pointer-events: all;
}

.play-detail-title {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.play-detail-icon-btn {
  flex-shrink: 0;
}

.play-detail-assign-panel {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  max-width: 420px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(17, 24, 39, 0.18);
  padding: 14px;
  pointer-events: all;
}

.play-detail-assign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.play-detail-assign-title {
  font-size: 1rem;
  font-weight: 700;
}

.play-detail-assign-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(50vh, 320px);
  overflow-y: auto;
}

.play-detail-assign-item {
  width: 100%;
  border: 1px solid rgba(17, 24, 39, 0.12);
  border-radius: 12px;
  background: #ffffff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.play-detail-assign-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: #4b5563;
  font-size: 0.85rem;
}

.play-detail-assign-position {
  border-radius: 999px;
  background: var(--brand-green-soft);
  color: var(--brand-green);
  padding: 2px 8px;
  font-weight: 600;
}

.play-detail-assign-empty {
  margin: 0;
  color: #4b5563;
}

.play-detail-backdrop {
  flex: 1;
  pointer-events: none;
}

.app.playbook-mode .formation-strip {
  display: none;
}

.app.playbook-mode .draw-toolbar {
  display: none;
}

.app.play-detail-active .toolbar,
.app.play-detail-active .formation-strip,
.app.play-detail-active .app-header,
.app.play-detail-active .mode-nav,
.app.play-detail-active .draw-toolbar {
  display: none;
}

/* In normal view, each print-page stays as a two-column grid chunk */
.print-page {
  width: 100%;
}

.app.pdf-export-mode .playbook-grid {
  padding: 0;
}

.app.pdf-export-mode .print-page {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.14in;
  width: min(7.3in, 100%);
  margin: 0 auto 0.16in;
}

.app.pdf-export-mode .play-card {
  min-height: 0;
  height: auto;
}

.app.pdf-export-mode .play-card-header {
  justify-content: flex-start;
  min-height: 0;
  padding: 0.12in 0.14in 0.1in;
}

.app.pdf-export-mode .play-card-label {
  font-size: 10.5pt;
}

.app.pdf-export-mode .play-card-thumb-wrap {
  aspect-ratio: var(--play-canvas-aspect, 4 / 5);
  flex: none;
}

.app.pdf-export-mode .play-card-gameplan-btn,
.app.pdf-export-mode .play-card-actions {
  display: none !important;
}

@media print {
  @page {
    size: letter portrait;
    margin: 0.25in;
  }

  html,
  body {
    height: auto;
    overflow: visible;
    background: #ffffff;
  }

  .app {
    position: static;
    inset: auto;
    overflow: visible;
  }

  .toolbar,
  .formation-strip,
  .drawer-overlay,
  .drawer,
  .play-detail-view,
  .app-header,
  .mode-nav,
  .draw-toolbar,
  .playbook-bottom-bar,
  .gameplan-filter-row,
  .concept-filter-strip,
  #fieldCanvas {
    display: none !important;
  }

  .playbook-view {
    position: static;
    inset: auto;
    display: block !important;
    width: 100%;
    overflow: visible;
    background: #ffffff;
  }

  .playbook-grid {
    display: block;
    width: 100%;
    overflow: visible;
    padding: 0;
  }

  /* Allow each rendered play group to use the full printable page width */
  .print-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.16in;
    width: min(7.3in, 100%);
    margin: 0 auto 0.16in;
    break-after: page;
    page-break-after: always;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Prevent the last page from adding an extra blank page */
  .print-page.print-page--last {
    break-after: avoid;
    page-break-after: avoid;
  }

  .play-card {
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 0;
    height: auto;
    align-self: start;
  }

  .play-card-thumb-wrap {
    aspect-ratio: var(--play-canvas-aspect, 4 / 5);
    flex: none;
  }

  .play-card-label {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    display: block;
    -webkit-line-clamp: unset;
  }

  .app.pdf-export-mode .print-page {
    gap: 0.14in;
  }

  .app.pdf-export-mode .play-card {
    min-height: 0;
    cursor: default;
    box-shadow: none;
  }

  .app.pdf-export-mode .play-card-header {
    justify-content: flex-start;
    min-height: 0;
    padding: 0.12in 0.14in 0.1in;
  }

  .app.pdf-export-mode .play-card-label {
    font-size: 10.5pt;
  }

  .app.pdf-export-mode .play-card-gameplan-btn,
  .app.pdf-export-mode .play-card-actions {
    display: none !important;
  }

}
