* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #ebf0f2;
  color: #2c3e50;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

header {
  background: #1e2b37;
  color: #ffffff;
  text-align: center;
  padding: 1.2rem 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 1.4rem;
  letter-spacing: 0.05em;
}

nav {
  background: #2c3e50;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 0.5rem;
  flex-wrap: wrap;
}

nav a {
  color: #ecf0f1;
  text-decoration: none;
  font-weight: bold;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: background-color 0.2s ease;
}

nav a:hover {
  background: #1abc9c;
  color: #ffffff;
}
nav a.active {
  background-color: #1a252f;
  font-weight: bold;
  border-bottom: 3px solid #3498db;
}
@media screen and (max-width: 768px) {
  nav {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
    padding: 0.5rem;
  }

  nav a {
    text-align: center;
    padding: 0.5rem;
    font-size: 0.85rem;
  }
}

.container {
  max-width: 960px;
  margin: 1.5rem auto;
  padding: 0 1rem;
}

.card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.card h2 {
  font-size: 1.3rem;
  border-bottom: 2px solid #1abc9c;
  padding-bottom: 0.5rem;
  margin-bottom: 0.8rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  background: #3498db;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: bold;
  transition: all 0.2s ease;
  user-select: none;
}

.btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-danger {
  background: #e74c3c;
}

.tab-container, .action-container {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: #7f8c8d;
  flex: 1;
  min-width: 90px;
  text-align: center;
  padding: 0.75rem 0.5rem;
  font-size: 1rem;
}

.tab-btn.active {
  background: #1abc9c;
  box-shadow: 0 2px 6px rgba(26, 188, 156, 0.4);
}

.sort-btn {
  background: #95a5a6;
  font-size: 0.85rem;
  padding: 0.5rem 0.8rem;
}

.sort-btn.active {
  background: #34495e;
  font-weight: bold;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.item-card {
  box-sizing: border-box;
  border: 2px solid #dcdde1;
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  background: #ffffff;
  user-select: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  min-height: 110px;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.item-card:hover {
  border-color: #3498db;
}

.item-card.selected {
  border-color: #1abc9c;
  background: #e8f8f5;
  box-shadow: 0 0 0 1px #1abc9c inset;
}

.item-card.selected::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 0.8rem;
  font-weight: bold;
  color: #ffffff;
  background: #1abc9c;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
}

.item-card.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: #dcdde1 !important;
  background-color: #f5f6fa !important;
}

.item-card.disabled:hover {
  border-color: #dcdde1 !important;
}

.item-card .badge-stock {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #2c3e50;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  z-index: 2;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.item-card.disabled .badge-stock {
  background: #7f8c8d;
}

.item-card .img-wrapper {
  width: 100%;
  aspect-ratio: 210 / 120;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.item-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.item-card .item-name {
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.25;
  color: #2c3e50;
  word-break: break-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  width: 100%;
}

.item-card.selected .item-name {
  color: #16a085;
}

.item-card.weapon-card.selected::after {
  display: none;
}

.count-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  width: 100%;
}

.count-btn {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 1px solid #1abc9c;
  background: #ffffff;
  color: #1abc9c;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s ease;
  user-select: none;
}

.count-btn:hover {
  background: #1abc9c;
  color: #ffffff;
}

.count-btn:active {
  transform: scale(0.95);
}

.count-num {
  font-size: 0.95rem;
  font-weight: bold;
  color: #2c3e50;
  min-width: 20px;
  text-align: center;
}

.item-card.selected .count-num {
  color: #16a085;
}

footer {
  text-align: center;
  padding: 1.5rem 1rem;
  background: #2c3e50;
  color: #bdc3c7;
  font-size: 0.8rem;
  margin-top: 2rem;
}

footer p {
  margin-bottom: 0.3rem;
}

@media screen and (max-width: 768px) {
  .container {
    padding: 0 0.4rem;
    margin: 0.6rem auto;
  }
  
  .card {
    padding: 0.8rem 0.6rem;
    border-radius: 10px;
  }

  .item-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 8px;
  }

  .item-card {
    min-height: 100px;
    padding: 6px 4px;
  }

  .item-card .img-wrapper {
    width: 100%;
    aspect-ratio: 210 / 120;
    margin-bottom: 6px;
  }

  .item-card .item-name {
    font-size: 0.88rem;
    font-weight: bold;
    line-height: 1.2;
  }

  .count-control {
    gap: 0.5rem;
    margin-top: 0.5rem;
  }

  .count-btn {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    border-radius: 6px;
    position: relative;
  }

  .count-btn::before {
    content: '';
    position: absolute;
    top: -6px;
    bottom: -6px;
    left: -6px;
    right: -6px;
  }

  .count-num {
    font-size: 1rem;
    min-width: 22px;
  }
}

.empty-box {
  text-align: center;
  padding: 3rem 1rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 2px dashed #bdc3c7;
}

.full-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.full-modal-content {
  background: #ffffff;
  width: 100%;
  height: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0,0,0,0.2);
}

@media screen and (min-width: 769px) {
  .full-modal-content {
    height: 90vh;
    border-radius: 12px;
    overflow: hidden;
  }
}

.full-modal-header {
  padding: 1rem 1.2rem;
  background: #1e2b37;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.full-modal-footer {
  position: sticky;
  bottom: 0;
  background: #ecf0f1;
  border-top: 1px solid #bdc3c7;
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  z-index: 100;
}
@media screen and (min-width: 769px) {
  .full-modal-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    z-index: 10;
    bottom: -1.2rem;
  }
}

/* スマホ表示時：スクロール最下部に到達したら表示 */
@media screen and (max-width: 768px) {
  .full-modal-footer {
    position: static;
    margin-bottom: 2rem;
  }
}

.close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.full-modal-body {
  padding: 1.2rem;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.form-group {
  margin-bottom: 1.2rem;
}

.form-label {
  display: block;
  font-weight: bold;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.required {
  color: #e74c3c;
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.95rem;
  box-sizing: border-box;
}

.form-row {
  display: flex;
  gap: 0.8rem;
}

.flex-1 {
  flex: 1;
}

.radio-group {
  display: flex;
  gap: 1.2rem;
}

.radio-group label {
  cursor: pointer;
  font-size: 0.95rem;
}

.form-section {
  border-top: 1px solid #eee;
  padding-top: 1rem;
  margin-top: 1.2rem;
}

.form-section h4 {
  font-size: 1rem;
  margin-bottom: 0.8rem;
  color: #1abc9c;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slot-box {
  border: 2px dashed #bdc3c7;
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
  font-size: 0.8rem;
  color: #7f8c8d;
  cursor: pointer;
  background: #fdfdfd;
  aspect-ratio: 210 / 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.slot-box:hover {
  border-color: #1abc9c;
  color: #1abc9c;
}

.slot-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.slot-label {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 0;
  text-align: center;
}

.summon-section-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summon-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.summon-sub-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media screen and (max-width: 768px) {
  .summon-sub-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.no-autofill-password {
  -webkit-text-security: disk !important;
  text-security: disk !important;
}

.deck-card {
  padding: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.deck-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.deck-badge-target {
  font-size: 0.8rem;
  background: #3498db;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.deck-badge-private {
  font-size: 0.75rem;
  background: #e74c3c;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

.deck-badge-public {
  font-size: 0.75rem;
  background: #2ecc71;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

.deck-title {
  margin: 0.5rem 0;
  font-size: 1.1rem;
}

.deck-job {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.deck-stats {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: #555;
}

.deck-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.picker-sort-header {
  padding: 0.6rem 1.2rem;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  align-items: center;
}

.btn-x-share {
  background-color: #0f1419 !important;
  color: #ffffff !important;
  border: none !important;
  padding: 6px 10px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background-color 0.2s ease;
}

.btn-x-share:hover {
  background-color: #272c30 !important;
  color: #ffffff !important;
}

.btn-x-share .x-logo {
  font-family: sans-serif;
  font-weight: 900;
  font-size: 1.0em;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  position: sticky;
  bottom: 0;
  background-color: #f5f5f5;
  padding: 12px;
  z-index: 10;
}

@media (max-width: 768px) {
  .modal-footer {
    position: static;
    bottom: auto;
    justify-content: center;
  }
}

.status-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 5px 5px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: bold;
  color: #fff;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  line-height: 1;
}

.status-badge.owned {
  background-color: #2ecc71;
}

.status-badge.missing {
  background-color: #e74c3c;
}