/* 全体のデザイン調整 */
body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f7fa;
  margin: 0;
  padding: 15px;
  color: #333;
  overflow-y: scroll;
}

[hidden] {
  display: none !important;
}

.site-header {
  /* ボタンなどのアクセントカラーと相性の良い鮮やかなロイヤルブルー系 */
  background: linear-gradient(135deg, #1d4ed8, #2563eb); 
  color: #ffffff;
  padding: 1px 1px;
  /* ヘッダーと下のコンテンツ（タブ）の間に余白を追加 */
  margin: -15px -15px 32px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.header-inner {
  max-width: 1200px;
  min-height: 42px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.header-title {
  cursor: pointer;
  margin: 0;
  font-size: 1.6rem;
  line-height: 1;
  font-weight: 700;
  text-align: center;
  color: #ffffff;
  letter-spacing: 0.05em;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.header-menu-wrap,
.header-menu-spacer {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
}

.header-menu-wrap {
  position: relative;
  z-index: 20;
}

.header-menu-button {
  display: flex;
  width: 42px;
  height: 42px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.header-menu-button span {
  width: 19px;
  height: 2px;
  background: #fff;
}

.header-tool-menu {
  position: absolute;
  top: 50px;
  left: 0;
  width: 210px;
  padding: 6px;
  border: 1px solid #dbe3ed;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
}

.header-tool-menu button {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: #1e293b;
  text-align: left;
  font-size: 15px;
  cursor: pointer;
}

.header-tool-menu button:hover {
  background: #eff6ff;
}

/* ホバー時の見た目（クリックできることを伝えるアニメーション） */
.header-title:hover {
  opacity: 0.85;
}

.life-tool-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  overflow-y: auto;
  overscroll-behavior-y: none;
  scrollbar-width: none;
  background: #101817;
  color: #f7f7f2;
  font-family: 'Avenir Next', 'Helvetica Neue', sans-serif;
}

html.life-tool-open,
body.life-tool-open {
  overscroll-behavior-y: none;
}

.life-tool-overlay::-webkit-scrollbar {
  display: none;
}

.life-tool-shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #242b29 0%, #5b5550 48%, #a27a70 100%);
}

.life-tool-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  width: min(100%, 980px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
}

.life-tool-header h2 {
  margin: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.life-back-button {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
}

.life-settings {
  width: min(100% - 36px, 460px);
  box-sizing: border-box;
  margin: auto;
  padding: 30px 0 52px;
}

.life-eyebrow {
  margin: 0 0 8px;
  color: #d7bbb2;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.life-settings h3 {
  margin: 0 0 30px;
  font-size: 30px;
}

.life-option-group {
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

.life-option-group legend {
  margin-bottom: 12px;
  font-size: 15px;
  font-weight: 700;
}

.life-choice-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.life-choice-row label {
  position: relative;
  cursor: pointer;
}

.life-choice-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.life-choice-row span {
  display: grid;
  min-height: 54px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(16, 24, 23, 0.22);
  font-size: 17px;
  font-weight: 700;
}

.life-choice-row input:checked + span {
  border-color: #fff;
  background: #f4f4ef;
  color: #202826;
}

.life-choice-row input:focus-visible + span {
  outline: 3px solid #49b8ec;
  outline-offset: 2px;
}

.life-start-button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  margin-top: 38px;
  padding: 16px 18px;
  border: 0;
  border-radius: 5px;
  background: #0878c9;
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.life-start-button:hover {
  background: #0569b4;
}

.life-game {
  display: flex;
  flex: 1;
  flex-direction: column;
  width: min(100%, 980px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: 12px 18px max(18px, env(safe-area-inset-bottom));
}

.life-board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

.life-game-toolbar {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 6px;
  background: rgba(24, 30, 29, 0.86);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  transform: translate(-50%, -50%);
}

.life-player-board {
  position: absolute;
  inset: 0;
}

.life-game-toolbar button {
  min-width: 90px;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: rgba(16, 24, 23, 0.25);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
}

.life-options {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #242b29 0%, #5b5550 48%, #a27a70 100%);
}

.life-options-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  width: min(100%, 600px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
}

.life-options-header h2 {
  margin: 0;
  text-align: center;
  font-size: 18px;
}

.life-options-close {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
}

.life-options-content {
  display: flex;
  width: min(100% - 36px, 460px);
  flex: 1;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 12px 0 max(24px, env(safe-area-inset-bottom));
}

.life-option-action {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(16, 24, 23, 0.24);
  color: #fff;
  text-align: left;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.life-option-action:hover,
.life-dice-roll:hover {
  background: rgba(16, 24, 23, 0.45);
}

.life-dice-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: rgba(16, 24, 23, 0.16);
}

.life-dice-options legend {
  padding: 0 6px;
  font-weight: 700;
}

.life-dice-options label {
  display: grid;
  gap: 6px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.life-dice-options select {
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  background: #f7f7f2;
  color: #202826;
  font: inherit;
}

.life-dice-roll {
  min-height: 42px;
  grid-column: 1 / -1;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 4px;
  background: rgba(16, 24, 23, 0.35);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.life-dice-result {
  display: grid;
  grid-column: 1 / -1;
  gap: 4px;
  padding: 10px;
  color: #fff;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.life-dice-total {
  font-size: 16px;
}

.life-option-return {
  margin-top: auto;
  background: #0878c9;
}

.life-confirm-dialog {
  width: min(100% - 40px, 360px);
  box-sizing: border-box;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  background: #242b29;
  color: #f7f7f2;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
}

.life-confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.life-confirm-dialog p {
  margin: 0 0 20px;
  line-height: 1.6;
}

.life-confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.life-confirm-actions button {
  min-width: 84px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.life-confirm-actions button:last-child {
  border-color: #0878c9;
  background: #0878c9;
}

.life-player-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 2px;
  overflow: hidden;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
}

.life-player-count-2 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.life-player-count-2 .life-player-1 {
  grid-row: 2;
}

.life-player-count-2 .life-player-2 {
  grid-row: 1;
  transform: rotate(180deg);
}

.life-player-count-2 .life-player-1 h3 {
  transform: translateY(24px);
}

.life-player-count-2 .life-player-2 h3 {
  transform: translateY(24px);
}

.life-player-count-3 .life-player-1 h3,
.life-player-count-4 .life-player-1 h3,
.life-player-count-4 .life-player-4 h3 {
  transform: translateY(24px);
}

.life-player-count-3 .life-player-2 h3,
.life-player-count-3 .life-player-3 h3,
.life-player-count-4 .life-player-2 h3,
.life-player-count-4 .life-player-3 h3 {
  transform: translateY(24px);
}

.life-player-count-3 .life-player-1 {
  grid-row: 2;
  grid-column: 1 / -1;
}

.life-player-count-3 .life-player-2,
.life-player-count-4 .life-player-2 {
  grid-row: 1;
  grid-column: 1;
  transform: rotate(180deg);
}

.life-player-count-3 .life-player-3,
.life-player-count-4 .life-player-3 {
  grid-row: 1;
  grid-column: 2;
  transform: rotate(180deg);
}

.life-player-count-4 .life-player-1 {
  grid-row: 2;
  grid-column: 1;
}

.life-player-count-4 .life-player-4 {
  grid-row: 2;
  grid-column: 2;
}

.life-player {
  position: relative;
  display: flex;
  min-height: 190px;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 0;
  padding: 18px 16px;
  overflow: hidden;
  background: rgba(177, 183, 139, 0.88);
  color: #fff;
}

.life-item-tools {
  position: absolute;
  z-index: 3;
  top: 42px;
  bottom: 10px;
  right: 10px;
  display: flex;
  width: 42px;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  pointer-events: none;
}

@media (min-width: 601px) {
  .life-item-tools {
    bottom: 18px;
  }
}

@media (max-width: 600px) {
  .life-item-tools {
    bottom: 14px;
  }
}

.life-item-open-button {
  align-self: flex-end;
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: 5px;
  background: rgba(20, 30, 29, 0.3);
  color: #fff;
  font-size: 23px;
  cursor: pointer;
  pointer-events: auto;
}

.life-item-display {
  display: flex;
  flex: 1;
  width: 100%;
  min-height: 0;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  align-items: stretch;
  gap: 3px;
  pointer-events: none;
}

.life-item-owned {
  display: flex;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 22px;
  flex: 0 0 auto;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(20, 30, 29, 0.34);
  color: #ffe08a;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.life-item-manager {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #242b29 0%, #5b5550 48%, #a27a70 100%);
}

.life-item-manager-header {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  width: min(100%, 600px);
  box-sizing: border-box;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px;
}

.life-item-manager-header h2 {
  margin: 0;
  text-align: center;
  font-size: 18px;
}

.life-item-manager-close {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
}

.life-item-list {
  display: grid;
  width: min(100% - 36px, 460px);
  flex: 1;
  align-content: start;
  gap: 10px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 16px 0 max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
}

.life-item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px 112px 40px;
  align-items: center;
  gap: 6px;
  min-height: 60px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  background: rgba(16, 24, 23, 0.22);
}

.life-item-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.life-item-symbol {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 5px;
  font-size: 23px;
}

.life-item-tone-light {
  color: #ffe08a;
}

.life-item-tone-fire {
  color: #ff725e;
}

.life-item-tone-water {
  color: #83d7ff;
}

.life-item-tone-wind {
  color: #b4ec8d;
}

.life-item-tone-dark {
  color: #d5adff;
}

.life-item-tone-other {
  color: #fff;
}

.life-item-name {
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.life-item-stepper {
  width: 40px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
}

.life-item-count {
  width: 100%;
  min-width: 0;
  height: 42px;
  box-sizing: border-box;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 4px;
  outline: none;
  background: rgba(16, 24, 23, 0.3);
  color: #fff;
  text-align: center;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.life-item-stepper {
  font-size: 20px;
}

.life-item-count:focus-visible {
  border-color: #49b8ec;
  outline: 2px solid #49b8ec;
  outline-offset: 2px;
}

.life-crystal-counter {
  position: absolute;
  z-index: 3;
  top: 42px;
  left: 10px;
}

.life-crystal-button {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.life-crystal-gem {
  color: rgba(255, 255, 255, 0.75);
  font-size: 46px;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.life-crystal-count {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  transform: translate(-50%, -50%);
}

.life-crystal-button.is-earned {
  filter: drop-shadow(0 0 5px rgba(255, 224, 138, 0.7));
}

.life-crystal-button.is-earned .life-crystal-gem {
  color: #ffe08a;
}

.life-tap-zone {
  position: absolute;
  z-index: 0;
  top: 0;
  bottom: 0;
  width: 50%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.life-tap-left {
  left: 0;
}

.life-tap-right {
  right: 0;
}

.life-tap-hints {
  position: absolute;
  z-index: 1;
  top: calc(50% + 64px);
  left: 50%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(calc(100% - 120px), 340px);
  transform: translateX(-50%);
}

.life-tap-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  text-align: center;
}

.life-tap-hint-left {
  grid-column: 1;
  justify-self: start;
  text-align: left;
}

.life-tap-hint-right {
  grid-column: 2;
  justify-self: end;
  text-align: right;
}

.life-delta-feedback {
  position: absolute;
  top: max(72px, calc(50% - 132px));
  z-index: 2;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.55);
  animation: life-delta-pop 160ms ease-out;
}

.life-delta-positive {
  right: 14%;
}

.life-delta-negative {
  left: 14%;
}

@keyframes life-delta-pop {
  from { opacity: 0; transform: translateY(7px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.life-player:nth-child(2) {
  background: rgba(60, 127, 156, 0.87);
}

.life-player:nth-child(3) {
  background: rgba(177, 111, 102, 0.88);
}

.life-player:nth-child(4) {
  background: rgba(103, 119, 91, 0.9);
}

.life-player h3 {
  position: relative;
  z-index: 1;
  pointer-events: none;
  margin: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  letter-spacing: 0.1em;
}

.life-total {
  position: relative;
  z-index: 1;
  display: grid;
  flex: 1;
  place-items: center;
  pointer-events: none;
  --life-total-base-size: 104px;
  max-width: 100%;
  font-size: var(--life-total-base-size);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.life-total-at-start {
  color: #7dff89;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.life-total-low {
  color: #ff5c5c;
  text-shadow: 0 2px 8px rgba(80, 0, 0, 0.65);
}

.life-controls {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(calc(100% - 88px), 340px);
  pointer-events: none;
}

.life-change-button {
  min-width: 0;
  min-height: 48px;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 4px;
  background: rgba(20, 30, 29, 0.2);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.life-change-button:active {
  background: rgba(20, 30, 29, 0.48);
}

.life-player-count-3 .life-change-button,
.life-player-count-4 .life-change-button {
  padding-right: 2px;
  padding-left: 2px;
  font-size: 11px;
}

@media (max-width: 600px) {
  .header-title {
    max-width: calc(100% - 120px);
    overflow: hidden;
    font-size: 1.05rem;
    text-overflow: ellipsis;
  }

  .life-game {
    min-height: calc(100dvh - 86px);
    padding-right: 10px;
    padding-left: 10px;
  }

  .life-player {
    padding: 14px 8px;
  }

  .life-item-row {
    grid-template-columns: minmax(0, 1fr) 36px 96px 36px;
    gap: 4px;
    padding: 6px;
  }

  .life-item-stepper {
    width: 36px;
    height: 40px;
  }

  .life-item-count {
    height: 40px;
    padding: 2px;
    font-size: 14px;
  }

  .life-total {
    --life-total-base-size: 72px;
  }

  .life-tap-hints {
    top: calc(50% + 28px);
    width: min(calc(100% - 104px), 340px);
  }

  .life-change-button {
    min-height: 48px;
    font-size: 13px;
  }
}

/* 検索エリア */
.search-container {
  display: flex;
  gap: 10px;
  max-width: 600px;
  margin: 0 auto 20px auto;
}

#search-input {
  flex: 1;
  padding: 12px 15px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 16px;
  outline: none;
  min-width: 0;
}

#search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#search-btn {
  padding: 12px 24px;
  background-color: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s;
  white-space: nowrap;
}

#search-btn:hover {
  background-color: #1d4ed8;
}

#search-btn-det {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
}

/* コントロールバー（全体の枠組み） */
.controls-container {
  display: none;
  flex-direction: column; /* 縦並びにする */
  gap: 15px;              /* 1行目と2行目の間隔 */
  max-width: 1200px;
  margin: 0 auto 20px auto;
  background: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

/* 1行目：検索結果とソートを左右に配置 */
.controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

/* 2行目：ページネーションを中央配置 */
.pagination-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center; /* ここで中央寄せ */
}

/* フッター用（既存の指定がある場合のため） */
.footer-controls-container {
  display: none; 
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  max-width: 1200px;
  margin: 20px auto 40px auto;
  background: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
}

.page-size-selector select {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  cursor: pointer;
}
.sort-selector select {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  font-size: 14px;
  cursor: pointer;
}

.pagination-container {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.page-btn {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  background-color: white;
  color: #475569;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.page-btn.active {
  background-color: #2563eb;
  color: white;
  border-color: #2563eb;
  font-weight: bold;
}

.page-btn:disabled {
  background-color: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}

.info-msg {
  text-align: center;
  color: #64748b;
  font-size: 16px;
  grid-column: 1 / -1;
  margin-top: 40px;
}

/* カードグリッド */
#card-list {
  display: grid;
  /* 4列で固定し、カードが4枚より少ない場合はその分だけ左詰めにする設定 */
  grid-template-columns: repeat(4, 1fr); 
  gap: 20px;
  max-width: 1200px; /* 全体の最大幅を制限（必要に応じて調整してください） */
  margin: 0 auto;
}

/* スマホなど画面幅が狭いときのためのレスポンシブ対応 */
@media (max-width: 900px) {
  #card-list {
    grid-template-columns: repeat(2, 1fr); /* 狭い画面では2列 */
  }
}

@media (max-width: 600px) {
  #card-list {
    grid-template-columns: 1fr; /* スマホでは1列 */
  }

  .controls-container {
    gap: 12px;
    padding: 12px;
  }

  .controls-row > div {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 10px 12px;
  }

  .page-size-selector {
    display: contents;
  }

  #search-count {
    grid-column: 1 / -1;
    margin-right: 0 !important;
    font-size: 15px;
  }

  #page-size-select-wrapper,
  #format-select-wrapper {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
  }

  #page-size-select-wrapper[style*="display: none"] + #format-select-wrapper {
    grid-column: 1 / -1;
  }

  .page-size-selector select,
  .sort-selector select {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .sort-selector {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 13px;
  }

  .pagination-container {
    gap: 6px;
  }

  .pagination-container .page-btn {
    min-width: 42px;
    padding: 8px 10px;
  }
}

/* 検索結果のカードデザイン */
.card-item {
  display: flex;
  flex-direction: column; /* 縦に並べる */
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 15px;
  height: 100%; /* グリッドの高さに追従 */
  box-sizing: border-box; /* paddingを含めたサイズ計算 */
}

/* カード名と属性を横並びにするヘッダー */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 10px;
  margin-bottom: 12px;
  min-height: 60px; /* 改行されても崩れないよう最低限の高さを確保 */
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}

.card-header small {
  font-size: 13px;
  color: #64748b;
  font-weight: normal;
}

.header-attris {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.card-body {
  flex-grow: 1; /* このエリアが伸びることでフッターを押し下げる */
  margin-bottom: 10px;
}

.card-body p {
  margin: 6px 0;
}

/* 1行目のコスト＋タイプを目立たせるスタイル */
.card-main-info {
  font-size: 14px;
  font-weight: bold;
  color: #1e293b;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 8px !important;
}

.card-footer-info {
  margin-top: auto; /* これが一番下への寄せを実現する */
  padding-top: 10px;
  border-top: 1px solid #e2e8f0; /* 線をここに含める */
}

/* タグ・バッジ装飾（詳細画面や属性用） */
.badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
  white-space: nowrap;
  margin-right: 4px; /* バッジ同士の隙間 */
  height: 22px;
  width: 25px;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

.badge-cost {
  background-color: #f1f5f9; /* 薄いグレー */
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: bold;
  display: inline-block;
  margin-right: 2px; /* バッジ同士の隙間 */
  height: 22px; 
  width: 25px;
  line-height: 18px;
  text-align: center;
  box-sizing: border-box;
}

/* 属性と共通の色分けルール */
.cost-光 { background-color: #fef08a; color: #713f12; border-color: #eab308; }
.cost-炎 { background-color: #fee2e2; color: #991b1b; border-color: #f87171; }
.cost-水 { background-color: #e0f2fe; color: #075985; border-color: #38bdf8; }
.cost-風 { background-color: #dcfce7; color: #166534; border-color: #4ade80; }
.cost-闇 { background-color: #f3e8ff; color: #6b21a8; border-color: #c084fc; }
.cost-月 { background-color: #fff7ed; color: #c2410c; border-color: #fdba74; }
.cost-時 { background-color: #eef2ff; color: #4338ca; border-color: #818cf8; }
.cost-無 { background-color: #f1f5f9; color: #475569; border-color: #cbd5e1; }

/* 数字などデフォルト */
.cost-default { background-color: #f1f5f9; color: #334155; }

.badge-type { background-color: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-race { background-color: #fff7ed; color: #9a3412; border: 1px solid #ffedd5; }

/* 属性別のカラー設定 */
.attri-光 { background-color: #fef08a; color: #713f12; border: 1px solid #eab308; }
.attri-炎 { background-color: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.attri-水 { background-color: #e0f2fe; color: #075985; border: 1px solid #38bdf8; }
.attri-風 { background-color: #dcfce7; color: #166534; border: 1px solid #4ade80; }
.attri-闇 { background-color: #f3e8ff; color: #6b21a8; border: 1px solid #c084fc; }
.attri-default { background-color: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }

.detail-btn {
  display: block;
  width: 100%;
  text-align: center;
  background-color: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 12px;
  -webkit-appearance: none;
  appearance: none;
}

.detail-btn:hover {
  background-color: #f1f5f9;
  color: #1e293b;
}

/* ポップアップ（モーダル） */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  max-width: 550px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  position: relative;
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 15px;
  background: none;
  border: none;
  font-size: 28px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  z-index: 10;
}

.modal-title {
  border-top: 2px solid #3b82f6; 
  border-bottom: 2px solid #3b82f6; 
  padding: 20px 0; 
  margin-top: 10px;
  margin-bottom: 10px;
}
/* 最初のカードの上の線は消す等の調整が必要な場合 */
.modal-title:first-child {
  border-top: none;
  margin-top: 0;
}

.modal-section {
  background-color: #f8fafc;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #f1f5f9;
}

.modal-section-title {
  font-size: 12px;
  font-weight: bold;
  color: #64748b;
  margin-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 2px;
}

/* ナビゲーションバーのスタイル */
.modal-nav-container {
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-nav-btn {
  padding: 6px 12px;
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.modal-nav-btn:hover:not(:disabled) {
  background-color: #2563eb;
  color: white;
  border-color: #2563eb;
}

.modal-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.modal-nav-counter {
  font-size: 12px;
  color: #64748b;
  font-weight: bold;
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.grid-status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
  gap: 6px;
  text-align: center;
}

.status-box {
  background: white;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.status-val {
  font-size: 16px;
  font-weight: bold;
  color: #1e293b;
}

.text-block {
  background: white;
  padding: 8px 10px;
  border-radius: 4px;
  border-left: 3px solid #cbd5e1;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.flavor-block {
  font-style: italic;
  color: #475569;
  font-size: 12px;
  line-height: 1.4;
  background: #fff;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 6px;
}

/* 禁止カードバッジ */
.ban-badge {
  display: inline-block;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: bold;
  color: white;
  border-radius: 3px;
  margin-right: 6px;
}
.ban-type-禁止 { background-color: #dc2626; }        /* 赤 */
.ban-type-サイド禁止 { background-color: #d97706; }  /* オレンジ */
.ban-type-ルーン禁止 { background-color: #2563eb; }  /* 青 */
.ban-type-コンビ禁止 { background-color: #7c3aed; }  /* 紫 */

/* タブのスタイル */
.tabs {
  display: flex;
  gap: 0; /* 隙間をなくして密着させる */
  max-width: 600px;
  margin: 0 auto 20px auto;
  border-bottom: 2px solid #e2e8f0; /* 全体に薄い下線を引く */
}

/* 各タブの共通スタイル */
.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-weight: bold;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  margin-right: 5px;
  transition: all 0.2s;
}

/* 選択中のタブのスタイル */
.tab.active {
  color: #2563eb;
  background: white;
  border-bottom: 2px solid white; /* 下線を隠すための補正 */
  margin-bottom: -2px; /* 下線と被せる */
  border-top: 3px solid #2563eb; /* 上部にアクセント */
}

.tab:hover:not(.active) {
  background: #f1f5f9;
}

/* 詳細検索フォームのデフォルト非表示 */
#detailed-search-form, #import-search-form {
  display: none;
  background: white;
  padding: 20px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  margin: 20px auto; /* 左右中央寄せ */
  max-width: 600px;  /* ここで幅を制限 */
  width: 90%;        /* スマホ対応 */
}
.form-group { margin-bottom: 10px; }
.form-group label { display: block; font-size: 13px; color: #64748b; margin-bottom: 4px; }
.form-group input, 
.form-group select {
  box-sizing: border-box;
  width: 100%;
  padding: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}

/* ATK/DEFのレイアウト調整 */
.atk-def-row {
  display: flex;
  gap: 15px;
  width: 100%;
}
.atk-def-row > .form-group {
  flex: 1;
  margin-bottom: 0;
}
/* 入力グループ（セレクト＋数値） */
.atk-def-input-group {
  display: flex;
  gap: 5px;
}
/* プルダウン */
.atk-def-input-group select {
  width: 60px;
  flex-shrink: 0;
}
/* 数値入力欄 */
.atk-def-input-group input {
    flex: 1;
    min-width: 0; /* これが効くように設定 */
}

/* ローディングオーバーレイ */
#loading-overlay {
  display: none; /* 初期は非表示 */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-weight: bold;
  color: #2563eb;
}

/* 検索対象チェックボックスエリアの調整 */
.checkbox-group {
  display: flex;
  gap: 15px;
  flex-wrap: nowrap; /* ここで折り返しを禁止 */
  align-items: center;
  margin-bottom: 15px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap; /* ラベル内のテキストも改行させない */
}

.accordion-header {
  width: 100%;
  padding: 10px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  text-align: left;
  cursor: pointer;
  font-weight: bold;
}

.checkbox-grid {
  display: block;
  max-height: 200px; /* 高さを制限 */
  overflow-y: auto;  /* 中身が多ければスクロール */
  padding: 5px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
}
.checkbox-grid label {
  display: block; /* ラベルをブロック要素にして1行占有させる */
  margin-bottom: 4px; /* 各項目間の隙間 */
  background: #f1f5f9;
  padding: 8px 10px; /* 少し縦幅を広げると押しやすい */
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  transition: all 0.2s;
}
.checkbox-grid label:has(input:checked) {
  background: #2563eb;
  color: white;
  border-color: #1d4ed8;
}

selected-tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 5px 0 10px 0;
  min-height: 20px;
}

.selected-tag {
  background: #e2e8f0;
  color: #1e293b;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border: 1px solid #cbd5e1;
}

.selected-tag:hover {
  background: #cbd5e1;
}

.remove-tag {
  margin-left: 5px;
  font-weight: bold;
}

.flat-checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}
.flat-checkbox-group label {
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  border: 1px solid #cbd5e1;
  transition: all 0.2s;
}
.flat-checkbox-group label:has(input:checked).chk-光 { background: #fde047; border-color: #ca8a04; color: #000; }
.flat-checkbox-group label:has(input:checked).chk-炎 { background: #fb7185; border-color: #e11d48; color: #fff; }
.flat-checkbox-group label:has(input:checked).chk-水 { background: #60a5fa; border-color: #2563eb; color: #fff; }
.flat-checkbox-group label:has(input:checked).chk-風 { background: #4ade80; border-color: #16a34a; color: #fff; }
.flat-checkbox-group label:has(input:checked).chk-闇 { background: #a78bfa; border-color: #7c3aed; color: #fff; }
.flat-checkbox-group label:has(input:checked).chk-無 { background: #cbd5e1; border-color: #64748b; color: #1e293b; }
.flat-checkbox-group label:has(input:checked).chk-月 { background-color: #fff7ed; color: #c2410c; border-color: #fdba74; }
.flat-checkbox-group label:has(input:checked).chk-時 { background-color: #eef2ff; color: #4338ca; border-color: #818cf8; }
.checkbox-grid input, .flat-checkbox-group input { display: none; }

/* ボタンの共通スタイル */
.search-btn, .reset-btn {
  padding: 10px;
  cursor: pointer;
  border: none;
  border-radius: 4px;
  font-weight: bold;
}

/* 検索実行ボタンのスタイル */
.search-btn {
  background-color: #3b82f6; /* 青系 */
  color: white;
}

.link-btn {
  /* ボタン特有のスタイルをリセット */
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  
  /* リンクっぽく見せるスタイル */
  color: #2563eb;          /* リンク色（青） */
  text-decoration: underline; /* 下線 */
  cursor: pointer;           /* マウスカーソルを指の形にする */
  
  /* 文字周りの調整 */
  font-family: inherit;      /* 親要素のフォントを継承 */
  font-size: inherit;        /* 親要素のフォントサイズを継承 */
  font-weight: inherit;
  display: inline;           /* ブロック要素にならないようにする */
  text-align: left;
}

/* ホバー（マウスを乗せた時）の装飾 */
.link-btn:hover {
  color: #1d4ed8;            /* 少し濃い青へ */
  text-decoration: none;     /* 下線を消すのが一般的ですが、好みで調整してください */
}

/* クリック中の挙動（オプション） */
.link-btn:active {
  color: #1e3a8a;
}

/* リセットボタンのスタイル */
.reset-btn {
  background-color: #64748b; /* グレー系 */
  color: white;
}

.reset-btn:hover {
  background-color: #475569;
}

.toggle-btn {
  background: #e2e8f0;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 12px;
}

/* キーワードのスタイル */
.keyword-tooltip {
  border-bottom: 1px dashed #333;
  cursor: pointer;
}

/* JSでbody直下に生成するツールチップ */
#keyword-tooltip-popup {
    position: fixed;
    z-index: 10000;

    box-sizing: border-box;
    width: min(250px, calc(100vw - 24px));
    max-height: min(40vh, 300px);

    padding: 8px 12px;

    background: rgba(51, 51, 51, 0.95);
    color: #fff;

    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);

    font-size: 12px;
    line-height: 1.4;
    white-space: normal;
    overflow-y: auto;

    opacity: 0;
    visibility: hidden;

    pointer-events: none;

    transition: opacity 0.15s ease;
}

/* 表示中 */
#keyword-tooltip-popup.is-visible {
    opacity: 1;
    visibility: visible;
}

/* 画面右下に固定するボタンのスタイル */
.floating-kw-btn {
  position: fixed;
  bottom: 20px;       /* 画面下部からの距離 */
  right: 20px;        /* 画面右側からの距離（左下にしたい場合は left: 20px; に変更） */
  z-index: 999;       /* 検索結果などのコンテンツより上に表示 */
  
  width: 50px;
  height: 50px;
  border-radius: 50%; /* 丸いボタンにする */
  background-color: #333333; /* ツールチップと合わせたシックな黒 */
  color: #ffffff;
  font-size: 20px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background-color 0.2s;
}

/* ホバー時の演出（PC用） */
.floating-kw-btn:hover {
  background-color: #444444;
  transform: scale(1.1); /* 少し大きくする */
}

/* タップ時の演出（スマホ用） */
.floating-kw-btn:active {
  transform: scale(0.95);
}

/* スマホでの位置微調整（ナビゲーションバーなどに被る場合の保険） */
@media screen and (max-width: 480px) {
  .floating-kw-btn {
      bottom: 25px;
      right: 20px;
      width: 46px;
      height: 46px;
      font-size: 18px;
  }
}
