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

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

main {
  flex: 1;
}

body {
  font-family: 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;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.table-wrapper {
  overflow-x: auto;
  width: 100%;
  box-sizing: border-box;
}

th,
td {
  padding: calc(8px * var(--scale, 1));
  text-align: center;
}

table,
th,
td {
  border: calc(1.5px * var(--scale, 1)) solid #bbb;
}

th {
  background-color: #f2f4f7;
  font-weight: bold;
  border-bottom: calc(2px * var(--scale, 1)) solid #bbb;
}

#characterTable {
  font-size: calc(14px * var(--scale, 1));
}

.table-wrapper.scroll-mode th,
.table-wrapper.scroll-mode td {
  white-space: nowrap;
}

.table-wrapper.wrap-mode th,
.table-wrapper.wrap-mode td {
  white-space: normal;
  word-break: break-word;
}

#characterTable td.skill-description {
  text-align: left;
}

.thin-line {
  border: none;
  border-top: 1px solid #ddd;
  margin: 6px 0;
}

#characterTable .desc-separator {
  border: none;
  border-top: calc(1px * var(--scale, 1)) solid #ccc;
  margin: calc(8px * var(--scale, 1)) 0;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px;
  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);
}

.filter-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-container {
  display: block;
  position: relative;
  max-width: 320px;
}

.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;
}

.filter-container label {
  font-size: 16px;
  color: #333;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
}

.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;
}

select {
  background-color: #fff;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg fill='gray' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
}

select::-ms-expand {
  display: none;
}

.filter-buttons {
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: flex-end;
  margin: 10px 0;
}

.filter-buttons button {
  padding: 6px 12px;
  border: 1px solid #ccc;
  background-color: #f9f9f9;
  cursor: pointer;
}

.filter-buttons button:hover {
  background-color: #eee;
}

fieldset {
  border: 1px solid #ccc;
  padding: 10px 15px;
  margin-bottom: 15px;
  border-radius: 6px;
}

fieldset label {
  display: inline-flex;
  align-items: center;
  margin-right: 10px;
  cursor: pointer;
}

fieldset.closed {
  padding: 0;
  margin-bottom: 5px;
  border-width: 0;
  max-height: 1.5em;
}

fieldset label,
fieldset p {
  transition: opacity 0.3s ease;
}

fieldset.closed label,
fieldset.closed p {
  opacity: 0;
  pointer-events: none;
}

legend {
  padding: 0 8px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

fieldset legend::after {
  content: '▼';
  float: right;
  line-height: 1;
  font-size: 0.8em;
  transition: transform 0.3s ease;
  transform: rotate(0deg);
}

fieldset.closed legend::after {
  transform: rotate(90deg);
}

fieldset input[type="checkbox"] {
  margin-right: 4px;
}

.calc-fieldset label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 16px;
}

.calc-fieldset input[type="number"] {
  width: 100px;
  padding: 6px 10px;
  font-size: 14px;
}

.shortcut-container {
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shortcut-container button {
  flex: 0 0 auto;
  min-width: 48px;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f8f8f8;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.shortcut-container button:hover {
  background: #eaeaea;
  border-color: #999;
}

.shortcut-container button:active {
  background: #dcdcdc;
}

.icon-img {
  height: calc(18px * var(--scale, 1));
  vertical-align: text-bottom;
  margin-right: 0.1em;
  display: inline-block;
}

.chara-icon {
  width: calc(26px * var(--scale, 1));
  height: calc(26px * var(--scale, 1));
  vertical-align: middle;
  margin-right: calc(4px * var(--scale, 1));
}

.weapon-icon,
.armor-icon {
  width: calc(30px * var(--scale, 1));
  height: calc(30px * var(--scale, 1));
  vertical-align: middle;
}

.effect-label {
  color: #3399ff;
  border: 1px solid #3399ff;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

.effect-add-label {
  color: #66cc99;
  border: 1px solid #66cc99;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 0.9em;
}

.effect-initiative {
  background-color: #ffe0e0;
  color: #990000;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.effect-delayed {
  background-color: #e6f0ff;
  color: #0070f3;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.sa-ability {
  background-color: #e6f0ff;
  color: #0070f3;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
}

.tab-container {
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-buttons {
  display: flex;
  border-bottom: 1px solid #ccc;
  background: #f7f7f7;
}

.tab-buttons button {
  flex: 1;
  padding: 8px 12px;
  background: #f7f7f7;
  border: none;
  border-right: 1px solid #ccc;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.tab-buttons button:last-child {
  border-right: none;
}

.tab-buttons button:hover {
  background: #e9e9e9;
}

.tab-buttons button.active {
  background: #fff;
  color: #007bff;
  border-bottom: 2px solid #007bff;
  font-weight: 600;
}

.skillFilterSet {
  display: none;
  background: #fff;
}

.skillFilterSet.active {
  display: block;
}

fieldset.no-border {
  border: none;
  margin-bottom: 0;
}

[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;
}

p.filter-title1 {
  background-color: #fff8cc;
  color: #997a00;
}

p.filter-title2 {
  background-color: #e3f8e3;
  color: #1b6626;
}

p.filter-title3 {
  background-color: #ffe0e0;
  color: #990000;
}

p.filter-title4 {
  background-color: #dceeff;
  color: #004080;
}

p.filter-title5 {
  background-color: #f3e0ff;
  color: #5e2a99;
}

p.filter-title6 {
  background-color: #ffedd5;
  color: #b45309;
}

p.filter-title7 {
  background-color: #ffe6f2;
  color: #993366;
}

p.filter-title8 {
  background-color: #f2f2f2;
  color: #333333;
}

p.filter-title9 {
  background-color: #e0f7ff;
  color: #005c73;
}

.filter-fieldset {
  border: 1px solid #ccc;
  padding: 0.8em 1em;
  border-radius: 6px;
}

.filter-row {
  display: flex;
  align-items: center;
  margin: 0.3em 0;
}

.filter-row label {
  margin-right: 0.8em;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 0.8em;
}

.filter-settings {
  display: flex;
  align-items: center;
  gap: 1.5em;
  flex-wrap: wrap;
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.6em 1em;
  margin-bottom: 0.8em;
  font-size: 0.9em;
}

.filter-settings label {
  margin-right: 0.25em;
}

.filter-settings input[type="number"] {
  width: 60px;
  margin-right: 0.4em;
}

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

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

fieldset.search-range>div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em 0.6em;
  margin-top: 0.3em;
}

fieldset.search-range label {
  white-space: nowrap;
}

.tab-warning {
  color: red;
  margin-left: 0.5em;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

.tab-warning.show {
  opacity: 1;
}

@media (max-width: 520px) {
  .filter-container {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-bottom: 4px;
  }

  .filter-container input[type="number"],
  .filter-container label {
    width: 100%;
  }

}

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

  .filter-buttons {
    position: static;
    flex-direction: row;
    gap: 10px;
    margin: 10px 0;
    justify-content: flex-end;
  }

  .search-container {
    width: 100%;
  }

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