.modal-mask {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: rgba(5, 9, 18, 0.78);
  backdrop-filter: blur(10px);
  z-index: 10040;
}

.modal-mask.open { display: flex; }

.modal {
  width: min(880px, calc(100vw - 14px));
  max-height: calc(100vh - 14px);
  overflow: auto;
  border-radius: 16px;
  background: rgba(10, 14, 24, 0.96);
  border: 1px solid rgba(126, 224, 255, 0.18);
  padding: 10px;
  display: grid;
  gap: 10px;
}

.auth-modal { width: min(480px, calc(100vw - 24px)); }

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.calculator-modal .modal-head { justify-content: flex-end; }

.picker-window {
  position: relative;
  width: min(1420px, calc(100vw - 14px));
  max-height: calc(100vh - 14px);
  padding: 8px;
  overflow: hidden;
}
.skill-picker-window { overflow: auto; }

.main-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  font-size: 16px;
  line-height: 1;
}

.modal-control-panel { position: relative; z-index: 30; overflow: visible; padding: 10px; }
.modal-control-row { display: flex; align-items: flex-end; gap: 8px; }
.modal-picker-filter-field, .modal-summary-field { flex: 0 0 142px; }
.modal-summary-field { flex-basis: 220px; }
.modal-summary-chip { min-height: 32px; padding: 0 9px; border: 1px solid rgba(126, 224, 255, 0.2); background: rgba(126, 224, 255, 0.08); color: #dffbff; font-size: 11px; }
.picker-panel-close { top: 10px; right: 10px; z-index: 60; }

.picker-workspace { position: relative; z-index: 1; margin-bottom: 0; height: calc(100vh - 130px); min-height: 0; }
.skill-picker-single { grid-template-columns: minmax(0, 1fr); }
.skill-picker-list-shell { padding-right: 0; }

.dropdown { position: relative; }
.dropdown-toggle { width: 100%; height: 32px; padding: 0 9px; border-radius: 9px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(9, 14, 28, 0.9); color: var(--text); display: flex; align-items: center; justify-content: space-between; gap: 6px; cursor: pointer; font-size: 11px; }
.dropdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-caret { color: var(--muted); transition: transform 160ms ease; }
.dropdown.open .dropdown-caret { transform: rotate(180deg); }
.dropdown-menu { position: absolute; top: calc(100% + 4px); left: 0; display: none; min-width: 228px; padding: 6px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(10, 14, 24, 0.98); box-shadow: var(--shadow); z-index: 100; }
.dropdown.open .dropdown-menu { display: block; }
.picker-filter-menu { min-width: 420px; }
.picker-simple-menu { max-height: 320px; overflow: auto; }
.dropdown-cascader { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; align-items: start; }
.dropdown-cascader-pane { display: grid; gap: 6px; min-width: 0; align-content: start; }
.dropdown-cascader-title, .dropdown-option-area-arrow { font-size: 10px; line-height: 1; }
.dropdown-cascader-title { padding: 4px 2px 2px; color: var(--muted); font-weight: 700; }
.dropdown-option.area-option { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dropdown-option-area-arrow { color: #b9d5ff; flex: none; }
.dropdown-option { width: 100%; text-align: left; border: 1px solid transparent; background: rgba(255,255,255,0.04); color: #f8fbff; border-radius: 12px; padding: 8px 10px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.dropdown-option:hover { background: rgba(126, 224, 255, 0.12); border-color: rgba(126, 224, 255, 0.18); }
.dropdown-option.active { background: rgba(126, 224, 255, 0.16); border-color: rgba(126, 224, 255, 0.28); color: #e7fbff; }
.weakness-dropdown .dropdown-menu { left: auto; right: 0; width: 228px; }
.weakness-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.weakness-option { display: flex; align-items: center; gap: 4px; min-height: 26px; padding: 4px 5px; border-radius: 7px; color: #dce9ff; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); cursor: pointer; user-select: none; font-size: 11px; font-weight: 700; }
.weakness-option:hover, .weakness-option:has(input:checked) { border-color: rgba(126, 224, 255, 0.36); background: rgba(126, 224, 255, 0.12); color: #ecfdff; }
.weakness-option input { width: 11px; height: 11px; accent-color: #7ee0ff; }

.list-shell, .picker-detail-panel { min-width: 0; min-height: 0; overflow-y: auto; }

.list-shell { padding-right: 2px; }
.picker-detail-panel { background: transparent; box-shadow: none; }

.picker-grid, .skill-list { display: grid; gap: 6px; }

.picker-grid {
  grid-template-columns: repeat(auto-fill, minmax(var(--card-width), 1fr));
  grid-auto-rows: 62px;
  align-items: stretch;
}
.skill-list { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.detail-accordion {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
}

.detail-accordion summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  color: #eef6ff;
  font-size: 11px;
  font-weight: 700;
}

.detail-accordion summary::-webkit-details-marker {
  display: none;
}

.detail-accordion summary::after {
  content: '▸';
  color: var(--muted);
  transition: transform 160ms ease;
}

.detail-accordion[open] summary::after {
  transform: rotate(90deg);
}

.detail-accordion .picker-stat-grid {
  padding: 0 8px 8px;
}

.picker-card {
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  height: 62px;
  min-height: 62px;
  padding: 6px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.picker-clear-card {
  align-items: center;
  justify-items: center;
  text-align: center;
}

.picker-clear-card .picker-card-body,
.picker-clear-card .picker-card-title,
.picker-clear-card .picker-card-name {
  justify-content: center;
  justify-items: center;
  text-align: center;
}

.picker-card:hover,
.picker-card.active,
.skill-item:hover,
.skill-item.active {
  transform: translateY(-2px);
  border-color: rgba(126, 224, 255, 0.28);
  background: rgba(18, 26, 46, 0.9);
}

.picker-portrait { width: 40px; height: 40px; border-radius: 7px; }

.picker-card-body,
.picker-card-body-simple {
  display: grid;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}

.picker-card-body-simple { grid-column: 1 / -1; }

.picker-card-sub,
.detail-copy,
.skill-desc,
.skill-cost,
.picker-stat-label,
.muted-chip {
  color: var(--muted);
}

.picker-card-name,
.detail-heading { font-size: 12px; }
.picker-card-name {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.picker-confirm {
  width: fit-content;
  min-width: 0;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(126, 224, 255, 0.14);
  border-color: rgba(126, 224, 255, 0.28);
  color: #e7fbff;
  font-weight: 700;
  font-size: 9px;
  line-height: 1.2;
}

.picker-card .picker-confirm {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.skill-item .picker-confirm {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.picker-stat-grid,
.field-grid.modal-form-grid {
  display: grid;
  gap: 6px;
}

.picker-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.picker-stat-label { font-size: 8px; line-height: 1; font-weight: 700; }
.picker-stat-value { color: #f3f7ff; font-size: 11px; line-height: 1.15; font-weight: 800; }

.skill-item {
  position: relative;
  border-radius: 10px;
  padding: 6px 6px 5px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.skill-picker-item {
  display: grid;
  align-content: start;
  gap: 5px;
  padding-right: 46px;
  background: rgba(8, 12, 22, 0.34);
}

.skill-picker-item .skill-desc {
  margin-top: 0;
  max-height: 68px;
  overflow-y: auto;
}

.skill-top { justify-content: space-between; }
.skill-name { font-size: 11px; font-weight: 700; line-height: 1.25; }
.skill-cost { font-size: 10px; white-space: nowrap; color: #ffd799; }
.skill-desc { margin-top: 4px; max-height: 96px; overflow-y: auto; font-size: 11px; line-height: 1.4; white-space: pre-wrap; }
.effect-tag { display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 999px; background: rgba(126, 224, 255, 0.12); border: 1px solid rgba(126, 224, 255, 0.18); color: #dffbff; font-size: 9px; line-height: 1; white-space: nowrap; }

.empty-state {
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
}

@media (max-width: 1080px) {
  .app-shell {
    width: min(100vw - 10px, 100%);
    padding: 28px 5px 14px;
  }

  .turn-table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .plan-bar,
  .plan-section-grid-plan,
  .plan-section-grid-boss,
  .workspace-shell,
  .picker-workspace {
    grid-template-columns: 1fr;
  }

  .picker-stat-grid,
  .skill-list {
    grid-template-columns: 1fr;
  }

  .section-head,
  .modal-control-row,
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .turn-cell { min-width: 124px; }

  .picker-window { padding: 6px; }

  .page-auth-actions {
    right: 5px;
  }

  .picker-workspace {
    height: auto;
  }
}
