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

main {
  flex: 1;
}

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

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: 8px;
  text-align: center;
}

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

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

label[for="toggleTrueName"]:hover,
#toggleTrueName:hover {
  cursor: pointer;
}

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

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

.icon-img {
  height: 1.2em;
  vertical-align: text-bottom;
  margin-right: 0.2em;
  display: inline-block;
}

.formation-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.character-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.character-container {
  width: 110px;
  margin: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;

}

.character-slot {
  width: 110px;
  height: 110px;
  background-color: #ddd;
  border-radius: 10px;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  transition: transform 0.2s;
  margin-top: auto;
}

.character-slot:hover {
  transform: scale(1.1);
}

.character-list img {
  width: 80px;
  height: 80px;
  cursor: pointer;
  border-radius: 10px;
  transition: transform 0.2s, filter 0.2s;
  position: relative;
}

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
}

.modal-content {
  position: relative;
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  max-height: 80vh;
  width: 80%;
  overflow-y: auto;
}

.character-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.character-list img {
  width: 80px;
  height: 80px;
  cursor: pointer;
  border-radius: 10px;
  transition: transform 0.2s;
}

.character-list img:hover {
  transform: scale(1.1);
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 24px;
  font-weight: bold;
  color: #333;
  background: #f0f0f0;
  width: 32px;
  height: 32px;
  text-align: center;
  line-height: 32px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.close-btn:hover {
  background: #e0e0e0;
  color: #000;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.input-wrapper {
  position: relative;
  min-width: 150px;
  max-width: 300px;
  flex: none;
}

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

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

#personality-search {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid #bbb;
  border-radius: 4px;
}

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

.mode-section {
  margin: 10px 0;
}

.personality-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.character-hit-list {
  margin-top: 15px;
  padding: 10px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  min-height: 80px;
}

#character-hit-list .placeholder-message {
  display: block;
}

.character-card {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.character-name {
  font-weight: bold;
  margin-bottom: 4px;
}

.personalities {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.personality-tag {
  background: #e0e7ff;
  color: #1a1f36;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.85em;
}

.search-mode-tabs {
  margin-bottom: 8px;
}

.search-form {
  display: none;
}

.search-form.active {
  display: block;
}

.tab-btn {
  padding: 6px 12px;
  border: 1px solid #ccc;
  background: #f8f8f8;
  cursor: pointer;
}

.tab-btn.active {
  background: #fff;
  font-weight: bold;
}

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

.filter-row label,
.filter-row span {
  white-space: nowrap;
}

@media (max-width: 480px) {
  .grasta-check {
    flex-basis: 100%;
  }
}

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

  .character-list img {
    width: 50px;
    height: 50px;
  }
}