/* ===== リセット & ベース ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #faf8f5;
  color: #333;
  min-height: 100vh;
}
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 64px;
}

/* ===== TOP / MV ===== */
#home-wrap {
  display: block;
}

.home-mv {
  background: linear-gradient(
    155deg,
    rgba(255, 255, 255, 0.96) 0%,
    rgba(246, 242, 236, 0.96) 58%,
    rgba(232, 238, 232, 0.92) 100%
  );
  border-bottom: 1px solid #e8e0d6;
  padding: 48px 24px 38px;
  text-align: center;
}

.mv-chars {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}
.mv-char {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(44, 38, 33, 0.14);
  margin: 0 -8px;
  transition: transform 0.2s;
}
.mv-char:hover {
  transform: translateY(-5px);
  z-index: 1;
}

.mv-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  color: #8a6f45;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.mv-title {
  font-size: 2rem;
  font-weight: 900;
  color: #2b2a28;
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: 0.04em;
}
.mv-title span {
  color: #476653;
}
.mv-desc {
  font-size: 0.82rem;
  color: #746f68;
  line-height: 1.8;
  max-width: 340px;
  margin: 0 auto;
}
.nowrap {
  white-space: nowrap;
}
.mv-divider {
  width: 40px;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    #b59a65,
    #476653,
    transparent
  );
  margin: 16px auto;
}

.home-buttons {
  padding: 28px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.btn-home-primary {
  width: 100%;
  padding: 18px;
  background: linear-gradient(135deg, #2c2a27, #476653);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.08em;
  transition: opacity 0.2s, transform 0.1s;
  box-shadow: 0 10px 24px rgba(44, 42, 39, 0.18);
}
.btn-home-primary:hover {
  opacity: 0.9;
}
.btn-home-primary:active {
  transform: scale(0.98);
}

.btn-home-secondary {
  width: 100%;
  padding: 15px;
  background: #fff;
  color: #746f68;
  border: 2px solid #e8e0d6;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: background 0.2s, border-color 0.2s;
}
.btn-home-secondary:hover {
  background: #fbfaf7;
  border-color: #cdbb9b;
}

.btn-home-register {
  width: 100%;
  padding: 15px;
  background: #f3f7f1;
  color: #476653;
  border: 2px solid #c9d6c7;
  border-radius: 14px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.04em;
  transition: background 0.2s, border-color 0.2s;
}
.btn-home-register:hover {
  background: #edf4ea;
  border-color: #78927c;
}

/* ===== 登録モーダル ===== */
#register-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
}
#register-overlay.open {
  display: flex;
}

.register-modal {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px 24px;
  width: min(90vw, 360px);
  border: 1px solid #eee7dd;
  box-shadow: 0 20px 60px rgba(44, 38, 33, 0.18);
}
.register-title {
  font-size: 1rem;
  font-weight: 800;
  color: #2b2a28;
  margin-bottom: 20px;
  letter-spacing: 0.04em;
}
.register-field {
  margin-bottom: 16px;
}
.register-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #746f68;
  margin-bottom: 6px;
  letter-spacing: 0.04em;
}
.register-input,
.register-select {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e8e0d6;
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  color: #4a4a4a;
  background: #fbfaf7;
  box-sizing: border-box;
  transition: border-color 0.2s;
  appearance: none;
}
.register-input:focus,
.register-select:focus {
  outline: none;
  border-color: #78927c;
  background: #fff;
}
.register-select {
  cursor: pointer;
}

.register-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.reg-btn-cancel {
  flex: 1;
  padding: 13px;
  background: #f3f0ea;
  color: #746f68;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.reg-btn-save {
  flex: 2;
  padding: 13px;
  background: linear-gradient(135deg, #2c2a27, #476653);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 18px rgba(44, 42, 39, 0.18);
}
.reg-btn-save:hover {
  opacity: 0.9;
}

/* ===== QUIZ AREA ===== */
#quiz-section {
  display: none;
  padding: 0 16px;
}

.quiz-header {
  background: #fff;
  border-bottom: 1px solid #e8e0d6;
  margin: 0 -16px 18px;
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.btn-to-home {
  background: #f3f0ea;
  border: none;
  border-radius: 99px;
  padding: 6px 14px;
  font-size: 0.78rem;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn-to-home:hover {
  background: #e8e0d6;
}
.quiz-header-title {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
  color: #4a4a4a;
  margin-top: 18px;
}

/* 名前入力 */
.name-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 20px;
  border: 1px solid #eee7dd;
  box-shadow: 0 10px 24px rgba(44, 38, 33, 0.06);
}
.name-card label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #555;
  display: block;
  margin-bottom: 10px;
}
.name-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e8e0d6;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border 0.2s;
}
.name-input:focus {
  border-color: #78927c;
}

/* プログレス */
.progress-wrap {
  margin-bottom: 24px;
}
.progress-label {
  font-size: 0.78rem;
  color: #746f68;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}
.progress-bar {
  height: 6px;
  background: #e8e0d6;
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2c2a27, #476653);
  border-radius: 99px;
  transition: width 0.4s ease;
}

/* 軸バッジ */
.axis-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 99px;
  margin-bottom: 12px;
}
.axis-EI {
  background: #eef2ec;
  color: #476653;
}
.axis-SN {
  background: #f3f0ea;
  color: #8a6f45;
}
.axis-TF {
  background: #edf4ea;
  color: #476653;
}
.axis-JP {
  background: #f5eee3;
  color: #7f633d;
}

/* 質問カード */
.question-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  margin-bottom: 16px;
  border: 1px solid #eee7dd;
  box-shadow: 0 10px 24px rgba(44, 38, 33, 0.06);
}
.question-num {
  font-size: 0.72rem;
  color: #bbb;
  margin-bottom: 8px;
}
.question-text {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.65;
  margin-bottom: 18px;
  color: #333;
}
.name-highlight {
  color: #8a6f45;
}

.scale-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scale-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid #e8e0d6;
  cursor: pointer;
  transition: all 0.2s;
  background: #faf8f5;
}
.scale-option:hover {
  border-color: #78927c;
  background: #f7faf5;
}
.scale-option.selected {
  border-color: #476653;
  background: #edf4ea;
}
.scale-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ccc;
  flex-shrink: 0;
  transition: all 0.2s;
}
.scale-option.selected .scale-dot {
  border-color: #476653;
  background: #476653;
}
.scale-label {
  font-size: 0.88rem;
  line-height: 1.4;
  color: #555;
}
.scale-option.selected .scale-label {
  color: #333;
  font-weight: 600;
}

/* ナビ */
.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  gap: 12px;
}
.btn {
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-prev {
  background: #f3f0ea;
  color: #746f68;
}
.btn-prev:hover {
  background: #e8e0d6;
}
.btn-next {
  background: linear-gradient(135deg, #2c2a27, #476653);
  color: #fff;
  flex: 1;
}
.btn-next:hover {
  opacity: 0.92;
}
.btn-next:disabled {
  background: #ddd;
  cursor: not-allowed;
}

/* ===== 結果 ===== */
#result-wrap {
  display: none;
  padding: 24px 16px 0;
}

.result-img-wrap {
  border-radius: 20px 20px 0 0;
  overflow: hidden;
  position: relative;
}
.result-main-img {
  width: 100%;
  display: block;
}
.res-person-badge {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  color: #fff;
  text-align: center;
  padding: 28px 16px 10px;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
}

/* グループカラー */
.group-analyst {
  background: linear-gradient(135deg, #3d2a6b, #7b5ea7);
}
.group-diplomat {
  background: linear-gradient(135deg, #1a5c40, #4a9a72);
}
.group-sentinel {
  background: linear-gradient(135deg, #1a3f6b, #3a7abf);
}
.group-explorer {
  background: linear-gradient(135deg, #6b4510, #b08a3a);
}

.result-body {
  background: #fff;
  border-radius: 0 0 20px 20px;
  padding: 24px 22px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.09);
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
}

.axes-result {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.axis-item {
  background: #f5f2ec;
  border-radius: 10px;
  padding: 10px 12px;
}
.axis-item .axis-label {
  font-size: 0.7rem;
  color: #999;
  margin-bottom: 3px;
}
.axis-item .axis-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #555;
}

.personality-section {
  background: linear-gradient(135deg, #fdf4ff 0%, #f0f8ff 100%);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 14px;
}
.personality-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #a855f7;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}
.personality-text {
  font-size: 0.85rem;
  line-height: 1.75;
  color: #444;
}

.hint-section {
  border-top: 1px solid #f0ece6;
  padding-top: 16px;
  position: relative;
  min-height: 90px;
}
.hint-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #a855f7;
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}
.hint-text {
  font-size: 0.85rem;
  line-height: 1.7;
  color: #666;
  padding-right: 90px;
}

.res-char-deco {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: 110px;
  height: 110px;
  object-fit: cover;
  object-position: center bottom;
  mix-blend-mode: multiply;
  pointer-events: none;
  opacity: 0.88;
}

/* 保存プロンプト */
.save-prompt {
  background: #fff;
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
  margin-bottom: 12px;
  text-align: center;
}
.save-prompt p {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 16px;
  font-weight: 600;
}
.save-buttons {
  display: flex;
  gap: 10px;
}
.btn-save-yes {
  flex: 1;
  background: #b08a5a;
  color: #fff;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-save-yes:hover {
  background: #8f6d3f;
}
.btn-save-no {
  flex: 1;
  background: #f0ece6;
  color: #888;
  padding: 12px;
  border-radius: 10px;
  border: none;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}
.btn-save-no:hover {
  background: #e5e0d8;
}

.btn-retry {
  width: 100%;
  margin-top: 4px;
  background: #f0ece6;
  color: #888;
  font-weight: 700;
  padding: 13px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.btn-retry:hover {
  background: #e5e0d8;
}

/* ===== 保存一覧 ===== */
#saved-wrap {
  display: none;
  padding: 0 16px;
}
.saved-header {
  background: #fff;
  border-bottom: 1px solid #f0ece6;
  margin: 0 -16px 18px;
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.saved-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #4a4a4a;
  margin-top: 18px;
}
.btn-back {
  background: #f0ece6;
  border: none;
  border-radius: 99px;
  padding: 7px 16px;
  font-size: 0.82rem;
  color: #888;
  cursor: pointer;
  font-family: inherit;
}
.btn-back:hover {
  background: #e5e0d8;
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.saved-item {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px 14px 26px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}
.saved-item::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 10px;
  background: #e5e0d8;
}
.saved-item:hover {
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.12);
}
.saved-item-analyst::before {
  background: linear-gradient(180deg, #3d2a6b, #7b5ea7);
}
.saved-item-diplomat::before {
  background: linear-gradient(180deg, #1a5c40, #4a9a72);
}
.saved-item-sentinel::before {
  background: linear-gradient(180deg, #1a3f6b, #3a7abf);
}
.saved-item-explorer::before {
  background: linear-gradient(180deg, #6b4510, #b08a3a);
}

.saved-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.saved-icon img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.saved-info {
  flex: 1;
  min-width: 0;
}
.saved-main-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: baseline;
  gap: 10px;
}
.saved-name {
  min-width: 0;
  font-size: 1rem;
  color: #4a4a4a;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-type {
  font-size: 1rem;
  font-weight: 700;
  color: #4a4a4a;
  min-width: 0;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-typename {
  font-size: 0.78rem;
  color: #888;
}
.saved-date {
  font-size: 0.7rem;
  color: #bbb;
  min-width: 0;
  text-align: right;
  white-space: nowrap;
}
.btn-delete {
  background: none;
  border: none;
  color: #ddd;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.btn-delete:hover {
  color: #e88;
}
.saved-arrow {
  color: #aaa;
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  margin-left: auto;
}
.saved-empty {
  text-align: center;
  color: #bbb;
  font-size: 0.88rem;
  padding: 40px 0;
}

/* ===== 詳細ビュー ===== */
#detail-wrap {
  display: none;
  padding: 0 0 24px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  background: #fff;
  border-bottom: 1px solid #f0ece6;
  position: sticky;
  top: 0;
  z-index: 10;
}
.detail-back-btn {
  background: none;
  border: none;
  color: #a855f7;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  padding: 4px 0;
}
.detail-header-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #4a4a4a;
}
.detail-delete-btn {
  background: none;
  border: none;
  color: #ddd;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
}
.detail-delete-btn:hover {
  color: #e88;
}

.det-profile {
  display: block;
  padding: 24px 16px 22px;
  background: linear-gradient(135deg, #fdf4ff 0%, #f0f8ff 100%);
}
.det-avatar {
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  border: 3px solid #fff;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
  background: #fff;
  margin-bottom: 18px;
}
.det-avatar img {
  width: 100%;
  height: auto;
  display: block;
}
.det-profile-info {
  padding: 0 2px;
}
.det-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #333;
  margin-bottom: 2px;
}
.det-typecode {
  font-size: 1rem;
  font-weight: 700;
  color: #a855f7;
  margin-bottom: 6px;
}
.det-typecode span {
  font-size: 0.8rem;
  color: #888;
  font-weight: 500;
  margin-left: 4px;
}
.det-group-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  color: #fff;
  letter-spacing: 0.04em;
}

.det-section {
  margin: 0 16px 12px;
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.det-section:first-of-type {
  margin-top: 16px;
}
.det-section-auto {
  background: #fafafa;
}

.det-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.det-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #888;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}
.det-section-header .det-section-title {
  margin-bottom: 0;
}

.det-edit-btn {
  background: none;
  border: none;
  color: #a855f7;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.det-auto-text {
  font-size: 0.85rem;
  line-height: 1.75;
  color: #555;
}

.det-hint-box {
  margin: 0 16px 12px;
  background: linear-gradient(135deg, #fdf4ff, #f0f8ff);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.08);
}

.det-relation-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.rel-tag {
  padding: 6px 14px;
  border-radius: 99px;
  border: 2px solid #eee;
  background: #fafafa;
  font-size: 0.82rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.rel-tag.active {
  background: #a855f7;
  border-color: #a855f7;
  color: #fff;
}

.det-memo-view {
  font-size: 0.85rem;
  line-height: 1.8;
  color: #444;
  min-height: 24px;
  white-space: pre-wrap;
  word-break: break-word;
}
.det-memo-view:empty::before {
  content: "（未記入）";
  color: #ccc;
}

.det-memo-edit {
  display: none;
  width: 100%;
  box-sizing: border-box;
  border: 2px solid #d8b4fe;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.8;
  color: #444;
  resize: none;
  background: #fdf4ff;
}
.det-memo-edit:focus {
  outline: none;
}

/* ===== レスポンシブ ===== */
@media (max-width: 400px) {
  .axes-result {
    grid-template-columns: 1fr;
  }
  .type-code {
    font-size: 2.2rem;
  }
  .type-character {
    font-size: 4rem;
  }
  .mv-title {
    font-size: 1.7rem;
  }
  .mv-icon {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
  }
}

/* モバイル：詳細画面を全画面オーバーレイ */
@media (max-width: 600px) {
  #detail-wrap {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #f7f5f2;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 40px;
    /* safe area対応（iPhoneのノッチ・ホームバー） */
    padding-top: env(safe-area-inset-top);
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
  }
  .detail-header {
    position: sticky;
    top: 0;
    z-index: 110;
  }
}
