:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #d7dfeb;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.layout,
.panel,
.deck-table-wrap,
.modal-panel,
.deck-select-cell,
.deck-card-skill,
.metric {
  min-width: 0;
}
.header, .layout { max-width: 1320px; margin: 0 auto; padding: 24px; }
.header { display: flex; justify-content: space-between; gap: 16px; align-items: end; }
.eyebrow, .header-note { color: var(--muted); margin: 0; }
.eyebrow { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
.header h1 { margin-bottom: 8px; }
.lead { margin-bottom: 0; color: var(--muted); }
.layout { display: grid; gap: 20px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: linear-gradient(135deg, #fff, #f8fbff);
}
.hero h2 { margin-bottom: 8px; }
.hero p { color: var(--muted); margin-bottom: 0; }
.hero-badges { display: flex; gap: 10px; flex-wrap: wrap; }
.grid-two { display: grid; grid-template-columns: 1.05fr 1fr; gap: 20px; }
.control-panel, .detail-panel { display: grid; gap: 14px; }
.control-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fbff;
}
.summary-label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.control-summary strong { font-size: 16px; }
.icon-picker-group { display: grid; gap: 12px; }
.picker-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.icon-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.icon-picker-item {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #fff;
  display: grid;
  place-items: center;
  padding: 6px;
  cursor: pointer;
  transition: 0.15s ease;
}
.icon-picker-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.icon-picker-item span {
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  color: var(--text);
}
.icon-picker-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}
.result-card, .slot-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
}
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.deck-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; font-size: 14px; }
.popup-field { display: grid; gap: 6px; }
.field-label { font-size: 14px; }
.picker-button {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fff, #eff4fb);
  border-radius: 12px;
  padding: 11px 12px;
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}
select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
}
.result-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.character-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(135deg, #f8fbff, #ffffff);
}
.character-image {
  width: 84px;
  height: 84px;
  object-fit: contain;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}
.character-name { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.deck-character-head span { color: var(--muted); font-size: 13px; }
.character-icons { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.character-icons img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 2px;
}
.deck-character-icons { display: flex; gap: 6px; flex-wrap: wrap; }
.deck-character-icons img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 2px;
}
.metric {
  padding: 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid #dbeafe;
}
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 18px; margin-top: 4px; }
.condition-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 16px;
}
.condition-display.is-empty {
  color: var(--muted);
}
.condition-display img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 1px;
}
.condition-display strong {
  display: inline;
  font-size: 16px;
  margin-top: 0;
}
.section-title { margin: 18px 0 10px; font-size: 16px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { background: #e0ecff; color: #1d4ed8; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.skill-item {
  position: relative;
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 136px;
  padding: 7px 11px;
  font-family: var(--font-m-plus-1-code), sans-serif;
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
  text-align: left;
  background: linear-gradient(#fffef6, #fff0b8);
  border: 1px solid #806300;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(128, 99, 0, 0.18);
  color: #1d2d63;
  white-space: normal;
  overflow: hidden;
}
.deck-character-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.skill-item + .skill-item { margin-top: 10px; }
.slot-card { display: grid; gap: 10px; }
.slot-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.slot-head select { max-width: 100%; }
.deck-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(160px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.slot-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.slot-meta select {
  width: 100%;
}
.slot-card { display: none; }
.deck-meta-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.deck-scroll-hint {
  display: none;
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.deck-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.deck-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 920px;
}
.deck-table th, .deck-table td {
  border-right: 1px solid #e5eaf2;
  border-bottom: 1px solid #e5eaf2;
  padding: 12px;
  text-align: center;
  vertical-align: middle;
}
.deck-table thead th { background: #fafcff; }
.deck-row-label {
  text-align: left !important;
  font-weight: 700;
  background: #f8fafc;
  width: 180px;
  line-height: 1.45;
}
.deck-label-head {
  width: 180px;
  background: #f8fafc;
}
.deck-col {
  width: 122px;
  min-width: 122px;
}
.deck-col.is-active-col { background: #f8fbff; }
.deck-select-cell {
  width: 100%;
  min-height: 250px;
  border: 0;
  background: transparent;
  padding: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 8px;
}
.deck-select-cell.is-empty {
  color: var(--muted);
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.06), transparent 58%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.deck-select-cell.is-selected { align-content: start; }
.deck-select-cell:hover { background: rgba(37, 99, 235, 0.04); }
.deck-card-empty {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 100%;
  color: var(--muted);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.deck-card-empty-short {
  display: none;
}
.deck-select-cell.is-empty .deck-card-empty::before {
  content: "+";
  display: block;
  font-size: 42px;
  line-height: 1;
  margin-bottom: 8px;
  color: var(--accent);
  opacity: 0.75;
}
.deck-card-image {
  width: 92px;
  height: 92px;
  object-fit: contain;
  margin: 0 auto 8px;
  display: block;
}
.deck-card-name { font-weight: 800; margin-bottom: 6px; }
.deck-card-tag,
.character-option-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fde2f0;
  color: #be185d;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
}
.deck-card-skill {
  position: relative;
  width: 100%;
  min-width: 136px;
  padding: 7px 11px;
  font-family: var(--font-m-plus-1-code), sans-serif;
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.9);
  text-align: left;
  background: linear-gradient(#fffef6, #fff0b8);
  border: 1px solid #806300;
  border-radius: 6px;
  box-shadow: 0 1px 0 rgba(128, 99, 0, 0.18);
  color: #1d2d63;
  margin-bottom: 8px;
  overflow: hidden;
}
.skill-item[data-pattern="1"],
.deck-card-skill[data-pattern="1"] {
  background: linear-gradient(90deg, #ff7a7a, #ffb86b, #fff36b, #7dff9a, #6bdcff, #8e7bff);
  border-color: #365BCD;
  box-shadow: 0 1px 0 rgba(54, 91, 205, 0.18);
}
.skill-item[data-pattern="2"],
.deck-card-skill[data-pattern="2"] {
  background: linear-gradient(#fff6bd, #ffe28a);
  border-color: #806300;
  border-radius: 4px;
}
.skill-item[data-pattern="2"]::before,
.deck-card-skill[data-pattern="2"]::before {
  content: "";
  position: absolute;
  display: block;
  top: 1px;
  left: 1px;
  width: calc(100% - 2px);
  height: calc(100% - 2px);
  border: 1px solid #806300;
  border-radius: 4px;
  pointer-events: none;
}
.skill-item[data-pattern="3"],
.deck-card-skill[data-pattern="3"] {
  background: linear-gradient(#fffe72 6%, #ffcb4f 14%, #fff97a 50%, #ffac32 50%, #fdff83 94%);
  border-color: #806300;
  box-shadow: 0 1px 0 rgba(128, 99, 0, 0.18);
}
.deck-card-skill-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
}
.deck-card-skill-meta,
.deck-card-skill-exp,
.deck-card-skill-empty {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(29, 45, 99, 0.9);
  line-height: 1.4;
}
.deck-card-icons { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.deck-card-icons img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 2px;
}
.deck-card-selectors {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.deck-card-selectors label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.deck-card-selectors select {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  min-width: 64px;
}
.deck-card-sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.deck-empty { color: var(--muted); background: #fcfdff; }
.reset-button {
  width: 100%;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff, #eef2f7);
  border-radius: 14px;
  padding: 14px 12px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}
.deck-table tbody tr:hover td { background: #fafcff; }
.deck-table tbody tr:hover th { background: #f8fafc; }
.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 50;
}
.modal.is-open { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-panel {
  position: relative;
  margin: 4vh auto;
  width: min(760px, calc(100vw - 16px));
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  padding: 12px;
}
.deck-table-wrap {
  -webkit-overflow-scrolling: touch;
}
.deck-row-label,
.deck-label-head {
  position: sticky;
  left: 0;
  z-index: 2;
}
.deck-label-head {
  z-index: 3;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 20px;
  cursor: pointer;
}
.modal-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.modal-specialty-section {
  display: grid;
  gap: 6px;
}
.modal-specialty-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  padding: 2px 2px;
}
.modal-specialty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
}
.modal-empty {
  padding: 14px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: #fafcff;
}
.character-option {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}
.character-option img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.character-option.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12); }
.character-option-body strong { display: block; margin-bottom: 3px; font-size: 13px; }
.character-option-icons { display: flex; gap: 6px; flex-wrap: wrap; }
.character-option-icons img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 1px;
}
@media (max-width: 900px) {
  .header, .grid-two, .form-grid, .deck-grid, .control-summary { grid-template-columns: 1fr; display: grid; }
  .hero { flex-direction: column; align-items: flex-start; }
  .header { align-items: start; }
  .modal-panel { margin: 12px auto; }
}
@media (max-width: 768px) {
  .header,
  .layout {
    padding: 16px;
  }
  .header {
    gap: 12px;
  }
  .header-note {
    font-size: 12px;
  }
  .header h1 {
    font-size: 28px;
    line-height: 1.15;
  }
  .lead,
  .hero p {
    font-size: 14px;
    line-height: 1.6;
  }
  .panel {
    padding: 16px;
    border-radius: 16px;
  }
  .hero {
    gap: 14px;
  }
  .hero h2 {
    font-size: 22px;
    line-height: 1.25;
  }
  .hero-badges {
    gap: 8px;
  }
  .icon-picker {
    gap: 8px;
  }
  .icon-picker-item {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    padding: 5px;
  }
  .deck-meta-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .deck-scroll-hint {
    display: block;
  }
  .metric {
    padding: 10px;
  }
  .metric strong {
    font-size: 16px;
  }
  .condition-display {
    font-size: 14px;
  }
  .condition-display strong {
    font-size: 14px;
  }
  .deck-table {
    min-width: 760px;
  }
  .deck-table-wrap {
    position: relative;
    padding-bottom: 2px;
    box-shadow: inset -24px 0 18px -20px rgba(37, 99, 235, 0.18);
  }
  .deck-row-label,
  .deck-label-head {
    width: 104px;
    min-width: 104px;
    font-size: 12px;
  }
  .deck-table th,
  .deck-table td {
    padding: 7px 5px;
  }
  .deck-col {
    width: 80px;
    min-width: 80px;
  }
  .deck-select-cell {
    min-height: 168px;
    padding: 6px 4px;
  }
  .reset-button {
    padding: 8px 6px;
    font-size: 15px;
    border-radius: 10px;
  }
  .deck-card-image {
    width: 62px;
    height: 62px;
  }
  .deck-card-name {
    font-size: 11px;
    line-height: 1.2;
  }
  .deck-card-empty {
    font-size: 14px;
  }
  .deck-card-skill {
    min-width: 0;
    padding: 5px 6px;
  }
  .deck-card-skill-name {
    font-size: 10px;
  }
  .deck-card-skill-meta,
  .deck-card-skill-exp,
  .deck-card-skill-empty {
    font-size: 11px;
  }
  .deck-card-selectors select {
    min-width: 44px;
    padding: 2px 4px;
    font-size: 10px;
  }
  .modal-panel {
    width: min(720px, calc(100vw - 12px));
    max-height: 90vh;
    padding: 10px;
  }
  .modal-specialty-grid,
  .modal-list {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .header,
  .layout {
    padding: 12px;
  }
  .header h1 {
    font-size: 24px;
  }
  .hero h2 {
    font-size: 20px;
  }
  .panel {
    padding: 14px;
  }
  .picker-label {
    margin-bottom: 6px;
  }
  .icon-picker-item {
    width: 44px;
    height: 44px;
  }
  .deck-meta-row {
    grid-template-columns: 1fr;
  }
  .deck-table {
    min-width: 680px;
  }
  .deck-scroll-hint {
    font-size: 11px;
    margin-bottom: 10px;
  }
  .deck-row-label,
  .deck-label-head {
    width: 88px;
    min-width: 88px;
    font-size: 10px;
  }
  .deck-col {
    width: 66px;
    min-width: 66px;
  }
  .deck-select-cell {
    min-height: 150px;
    gap: 4px;
    padding: 5px 3px;
  }
  .reset-button {
    font-size: 13px;
    line-height: 1.25;
    padding: 7px 4px;
  }
  .deck-card-image {
    width: 46px;
    height: 46px;
  }
  .deck-card-icons img {
    width: 14px;
    height: 14px;
  }
  .deck-card-name {
    font-size: 10px;
    line-height: 1.2;
  }
  .deck-card-tag,
  .character-option-tag {
    font-size: 10px;
    padding: 1px 5px;
  }
  .deck-card-skill {
    padding: 4px 5px;
    border-radius: 5px;
  }
  .deck-card-skill-name {
    font-size: 9px;
  }
  .deck-card-selectors label {
    font-size: 9px;
  }
  .deck-card-empty-full {
    display: none;
  }
  .deck-card-empty-short {
    display: inline;
  }
  .modal-header h2 {
    font-size: 18px;
    line-height: 1.25;
  }
  .character-option {
    grid-template-columns: 40px 1fr;
    padding: 7px;
  }
  .character-option img {
    width: 40px;
    height: 40px;
  }
}
