* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

.hidden {
  display: none;
}

main {
  flex: 1;
}

body {
  font-family: "Roboto", "Helvetica Neue", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  margin: 0;
  padding: 0;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  height: 100%;
}

.page-title {
  font-size: 1.5em;
  font-weight: 600;
  color: #1a1f36;
  margin: 0 0 16px 8px;
  letter-spacing: 0.5px;
  font-family: "Yu Mincho", "游明朝", "Hiragino Mincho ProN", "ヒラギノ明朝 ProN W3", "ＭＳ Ｐ明朝", serif;
  padding-bottom: 6px;
}

.visually-hidden {
  position: absolute;
  left: -9999px;
}

.content {
  padding: 20px;
  margin: 0;
}

#loadingOverlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #ccc;
  border-top-color: #4a90e2;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

#buffTableContainer table {
  margin-bottom: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.table-scroll {
  width: 100%;
  margin-bottom: 16px;
}

.table-scroll::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.table-scroll::-webkit-scrollbar-track {
  background: #f0f0f0;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 6px;
}

.table-scroll::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.table-title {
  font-size: 16px;
  font-weight: bold;
  margin: 12px 0 4px;
}

th,
td {
  padding: 8px;
  text-align: center;
}

table,
th,
td {
  border: 2px solid #bbb;
}

th {
  background-color: #f2f4f7;
  font-weight: bold;
  border-bottom: 2px solid #bbb;
}

th.effect-col,
td.effect-col {
  width: 220px;
}

th:not(.effect-col),
td:not(.effect-col) {
  width: calc((100% - 300px) / 6);
}

td {
  word-break: break-word;
}

.cell-line {
  width: 100%;
}

.effect-col {
  text-align: left;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  font-family: "Roboto", "Helvetica Neue", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  margin: 4px 0;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: #0078d7;
  box-shadow: 0 0 4px rgba(0, 120, 215, 0.3);
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 18px;
  color: #aaa;
  display: none;
}

.clear-btn:hover {
  color: #333;
}

#partySelector {
  margin-top: 8px;
}

.party-slot {
  max-width: 300px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-wrapper {
  position: relative;
  flex: 1;
}

.input-wrapper input {
  width: 100%;
  padding-right: 28px;
}

.suggestion-box {
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background-color: white;
  border: 1px solid #ccc;
  border-top: none;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  border-radius: 0 0 6px 6px;
  display: none;
}

.suggestion-box div {
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.suggestion-box div:hover {
  background-color: #f5f5f5;
}

.suggestion-box .selected {
  background-color: #e6f0ff;
}

.suggestion-box::-webkit-scrollbar {
  width: 6px;
}

.suggestion-box::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.suggestion-box::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 4px;
}

.suggestion-box::-webkit-scrollbar-thumb:hover {
  background: #999;
}

label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
}

label>input[type="checkbox"],
label>input[type="radio"] {
  margin-right: 0.4em;
}

input[type="radio"],
input[type="checkbox"],
label:has(input[type="radio"]),
label:has(input[type="checkbox"]),
select {
  cursor: pointer;
}

.icon-img {
  height: 16px;
  vertical-align: text-bottom;
  margin-right: 0.1em;
  display: inline-block;
}

[class^="filter-title"] {
  flex: 0 0 7em;
  padding: 0.25em 0.6em;
  margin-right: 0.5em;
  border-radius: 6px;
  font-weight: bold;
  width: 7em;
  font-family: "Segoe UI", "Hiragino Sans", sans-serif;
}

button {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid #232b50;
  border-radius: 6px;
  background: #fff;
  color: #232b50;
  font-family: "Roboto", "Helvetica Neue", "Helvetica Neue", Arial, sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

button:hover {
  background: #e8ebf5;
  border-color: #2a3570;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#skillModalTitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #ddd;
  font-size: 14px;
}

.skill-modal-character {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

#skillModalList {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 4px;
}

#skillModalList label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}

#skillModalList label:hover {
  background: #f2f4f7;
}

.modal-content {
  min-height: 50vh;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  margin: 10vh auto;
  padding: 12px;
  background: #fff;
  min-width: 320px;
  max-width: 90%;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.skill-list label {
  display: block;
  margin: 4px 0;
  cursor: pointer;
}

.modal-actions {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.cell-tag {
  display: inline-block;
  padding: 2px 6px;
  margin-right: 4px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.target-tag {
  background-color: #dceeff;
  color: #004080;
}

.source-tag {
  background-color: #e3f8e3;
  color: #1b6626;
}

.cell-line {
  display: grid;
  grid-template-columns: 50% 50%;
  column-gap: 4px;
  align-items: start;
  margin-bottom: 2px;
}

.cell-target,
.cell-source {
  justify-self: start;
  min-width: 0;
  text-align: left;
}

.cell-source {
  min-width: 0;
}

.cell-line[data-skill] {
  position: relative;
  cursor: help;
}

.cell-line[data-skill]::after {
  content: attr(data-skill);
  position: absolute;
  bottom: 100%;
  left: 0;
  transform: translateY(-4px);
  background: #333;
  color: #fff;
  padding: 4px 8px;
  font-size: 12px;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 1000;
}

.cell-line[data-skill]:hover::after {
  opacity: 1;
}

.help-icon {
  display: none;
  margin-left: 4px;
  font-size: 11px;
  color: #666;
  border: 1px solid #aaa;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  cursor: help;
}

.help-tooltip {
  transform: translateY(-120%);
  white-space: pre-line;
  position: absolute;
  max-width: 300px;
  padding: 6px 8px;
  background: #333;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  border-radius: 4px;
  display: none;
  z-index: 1000;
}

.toggle-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  opacity: 0;
  cursor: pointer;
}

.toggle-label {
  width: 44px;
  height: 22px;
  background: #ccc;
  position: relative;
  display: inline-block;
  border-radius: 22px;
  transition: 0.4s;
  box-sizing: border-box;
}

.toggle-label:after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 100%;
  left: 0;
  top: 0;
  z-index: 2;
  background: #fff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  transition: 0.4s;
}

.toggle-input:checked+.toggle-label {
  background-color: #4BD865;
}

.toggle-input:checked+.toggle-label:after {
  left: 22px;
}

.toggle-button {
  position: relative;
  width: 44px;
  height: 22px;
  margin: 0;
}

body.show-help .help-icon {
  display: inline-flex;
}

.toggle-wrapper {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.toggle-text {
  font-size: 12px;
  color: #333;
  user-select: none;
}

@media (max-width: 1500px) {
  .table-title {
    font-size: 14px;
  }

  table {
    font-size: 10px;
  }

  .icon-img {
    height: 14px;
  }

  .cell-tag {
    font-size: 10px;
  }

  th.effect-col,
  td.effect-col {
    width: 190px;
  }
}

@media (max-width: 1300px) {
  table {
    border-left: none;
  }

  .table-scroll {
    overflow-x: auto;
  }

  .table-scroll table {
    min-width: 900px;
  }

  th:not(.effect-col),
  td:not(.effect-col) {
    width: 180px;
  }

  th.effect-col,
  td.effect-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background-color: #fff;
    border-left: none;
    border-right: none;
    box-shadow:
      inset 2px 0 0 #bbb,
      inset -2px 0 0 #bbb;
  }

  th.effect-col+th,
  td.effect-col+td {
    border-left: none;
  }


  th.effect-col {
    z-index: 3;
    background-color: #f2f4f7;
  }
}

@media (max-width: 600px) {
  .content {
    padding: 12px;
  }
}

@media (max-width: 460px) {
  .page-title {
    text-align: center;
  }

  .suggestion-box {
    width: 100%;
  }
}

@media (max-width: 420px) {
  table {
    font-size: 9px;
  }

  .icon-img {
    height: 12px;
  }

  th,
  td {
    padding: 6px;
    text-align: center;
  }

  .cell-tag {
    font-size: 9px;
  }

  th.effect-col,
  td.effect-col {
    width: 170px;
  }

  .help-icon {
    font-size: 9px;
    width: 12px;
    height: 12px;
  }
}