/* Automancy Frontend Styles */

:root {
  --gold: #b8973d;
  --gold-light: #c9a84c;
  --gold-pale: rgba(184, 151, 61, 0.15);
  --gold-border: rgba(184, 151, 61, 0.3);
  --text-dark: #2a1f0e;
  --text-mid: #5a4520;
  --text-light: #8a7040;
  --serif: 'Noto Serif JP', 'Shippori Mincho', serif;
  --sans: 'M PLUS 1', sans-serif;
}

#automancy-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  background: #fff;
  color: var(--text-dark);
  font-family: var(--serif);
  line-height: 1.8;
}

.automancy-page-title {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--gold-border);
}

.automancy-page-title h1 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 3px;
  margin-bottom: 6px;
}

.automancy-page-title p {
  font-size: 13px;
  color: var(--text-light);
  letter-spacing: 2px;
  font-family: var(--sans);
}

.automancy-steps-indicator {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  margin-bottom: 2.5rem;
  position: relative;
}

.step-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  position: relative;
  cursor: default;
}

.step-item::after {
  content: '';
  position: absolute;
  top: 22px;
  left: calc(50% + 22px);
  right: calc(-50% + 22px);
  height: 1px;
  background: var(--gold-border);
}

.step-item:last-child::after { display: none; }

.step-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-light);
  position: relative;
  z-index: 1;
  transition: all 0.3s;
}

.step-item.active .step-circle {
  background: var(--text-dark);
  border-color: var(--text-dark);
  color: #e8d5a8;
}

.step-item.done .step-circle {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #fff;
}

.step-item.done .step-circle::after {
  content: '✓';
  font-size: 16px;
}

.step-item.done .step-circle span { display: none; }

.step-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-light);
  font-family: var(--sans);
  text-align: center;
  white-space: nowrap;
}

.step-item.active .step-label {
  color: var(--text-dark);
  font-weight: 500;
}

.automancy-step-content { display: none; }
.automancy-step-content.active { display: block; }

.automancy-step-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 8px;
}

.step-title-rule {
  width: 40px;
  height: 1.5px;
  background: linear-gradient(to right, transparent, var(--gold-light), transparent);
  margin: 0 auto 1.8rem;
}

.form-group {
  margin-bottom: 1.8rem;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.form-group label .required-mark {
  color: #9a4020;
  margin-left: 4px;
  font-size: 12px;
}

.form-group .hint {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  font-family: var(--sans);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.theme-btn {
  border: 1.5px solid var(--gold-border);
  background: #fff;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--text-dark);
  letter-spacing: 1px;
  transition: all 0.2s;
  border-radius: 2px;
}

.theme-btn:hover {
  border-color: var(--gold-light);
  background: var(--gold-pale);
}

.theme-btn.selected {
  border-color: var(--gold-light);
  background: var(--gold-pale);
  font-weight: 500;
  position: relative;
}

.theme-btn.selected::after {
  content: '✓';
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 10px;
  color: var(--gold-light);
}

textarea.automancy-textarea, input.automancy-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--gold-border);
  background: #fff;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--text-dark);
  line-height: 1.9;
  outline: none;
  transition: border-color 0.2s;
  border-radius: 0;
}

textarea.automancy-textarea {
  resize: vertical;
  min-height: 110px;
}

textarea.automancy-textarea:focus, input.automancy-input:focus {
  border-color: var(--gold-light);
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.emotion-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--gold-border);
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 2px;
}

.emotion-tag:hover {
  border-color: var(--gold-light);
  background: var(--gold-pale);
}

.emotion-tag input[type="checkbox"] { display: none; }

.emotion-check {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--gold-border);
  border-radius: 2px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.2s;
}

.emotion-tag input:checked ~ .emotion-check {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #fff;
}

.emotion-tag input:checked ~ .emotion-check::after { content: '✓'; }

.emotion-tag span.label-text {
  font-size: 15px;
  color: var(--text-dark);
  letter-spacing: 1px;
}

.tellers-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.teller-card {
  border: 1.5px solid var(--gold-border);
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: 2px;
  background: #fff;
}

.teller-card:hover {
  border-color: var(--gold-light);
  background: var(--gold-pale);
}

.teller-card.selected {
  border-color: var(--gold-light);
  border-width: 2px;
  background: var(--gold-pale);
}

.teller-card .selected-badge {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--gold-light);
  color: #fff;
  font-size: 10px;
  font-family: var(--sans);
  padding: 2px 6px;
  letter-spacing: 1px;
}

.teller-card.selected .selected-badge { display: block; }

.teller-photo-wrap {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  background: #f5f0e8;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  overflow: hidden;
}

.teller-photo-wrap img { width: 100%; height: 100%; object-fit: cover; }

.teller-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 2px;
  margin-bottom: 5px;
}

.teller-jutsu {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-light);
  border: 1px solid var(--gold-border);
  padding: 2px 10px;
  margin-bottom: 8px;
  font-family: var(--sans);
}

.teller-desc {
  font-size: 12px;
  color: var(--text-mid);
  line-height: 1.8;
}

.select-count-note {
  font-size: 13px;
  color: var(--text-light);
  text-align: center;
  margin-bottom: 1rem;
  font-family: var(--sans);
  padding: 10px;
  border: 1px dashed var(--gold-border);
}

.selected-count-display {
  font-size: 13px;
  text-align: center;
  margin-top: 1rem;
  color: var(--text-mid);
  font-family: var(--sans);
}

.selected-count-display span {
  font-weight: 500;
  color: var(--text-dark);
}

.summary-box {
  border: 1px solid var(--gold-border);
  margin-bottom: 1.5rem;
  background: #fff;
}

.summary-row {
  display: flex;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gold-border);
  font-size: 14px;
}

.summary-row:last-child { border-bottom: none; }

.summary-label {
  width: 120px;
  flex-shrink: 0;
  color: var(--text-light);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 1px;
}

.summary-value {
  flex: 1;
  color: var(--text-dark);
  font-size: 14px;
}

.summary-price-row {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1.5px solid var(--gold-border);
  background: var(--gold-pale);
}

.summary-price-label {
  font-size: 13px;
  color: var(--text-light);
  font-family: var(--sans);
}

.summary-price-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  font-family: var(--serif);
}

.summary-price-unit { font-size: 13px; color: var(--text-mid); }

.terms-scroll {
  height: 100px;
  overflow-y: scroll;
  border: 1px solid var(--gold-border);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-mid);
  line-height: 1.9;
  margin-bottom: 14px;
  font-family: var(--sans);
  background: #fafafa;
}

.terms-agree-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gold-border);
  cursor: pointer;
}

.terms-agree-wrap input[type="checkbox"] {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--gold-border);
  cursor: pointer;
  accent-color: var(--gold-light);
  flex-shrink: 0;
}

.terms-agree-wrap span {
  font-size: 15px;
  color: var(--text-dark);
  letter-spacing: 1px;
}

.btn-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  gap: 12px;
}

.btn-area.single { justify-content: center; }

.btn-next, .btn-prev, .btn-submit {
  font-family: var(--serif);
  font-size: 16px;
  letter-spacing: 3px;
  padding: 14px 36px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
}

.btn-next, .btn-submit {
  background: var(--text-dark);
  color: #e8d5a8;
  border: 1.5px solid var(--text-dark);
  flex: 1;
  max-width: 280px;
}

.btn-next:hover, .btn-submit:hover {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #fff;
}

.btn-prev {
  background: #fff;
  color: var(--text-light);
  border: 1.5px solid var(--gold-border);
  flex-shrink: 0;
}

.btn-prev:hover {
  border-color: var(--gold-light);
  color: var(--text-dark);
}

.payment-placeholder {
  text-align: center;
  padding: 2rem 1rem;
  border: 1px dashed var(--gold-border);
  color: var(--text-light);
  font-size: 14px;
  font-family: var(--sans);
  line-height: 2;
}

.gold-rule {
  width: 100%;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-border) 30%, var(--gold-border) 70%, transparent);
  margin: 1.5rem 0;
}

@media(max-width:600px) {
  .theme-grid { grid-template-columns: repeat(2, 1fr); }
  .tellers-grid { grid-template-columns: 1fr; }
  .emotion-grid { grid-template-columns: 1fr; }
  .btn-next, .btn-submit { max-width: 100%; }
  #automancy-container { padding: 1.5rem 1rem 3rem; }
}

/* MyPage / Result Styles */
.result-page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
  background: #fff;
  color: #333;
}

.result-header {
  text-align: center;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 20px;
  margin-bottom: 30px;
}

.result-header h1 {
  font-size: 28px;
  letter-spacing: 4px;
  color: #000;
}

.coordinator-section {
  background: #fdfaf1;
  padding: 25px;
  border-left: 6px solid var(--gold);
  margin-bottom: 40px;
}

.teller-section {
  margin-bottom: 50px;
  border-bottom: 1px solid #eee;
  padding-bottom: 30px;
}

.teller-info {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.teller-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  overflow: hidden;
}

.teller-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Payment Elements Styles */
.payment-container {
  padding: 1.5rem 0;
}

.payment-info-box {
  background: var(--gold-pale);
  padding: 1.5rem;
  border: 1.5px solid var(--gold-border);
  margin-bottom: 2rem;
  text-align: center;
}

.payment-msg {
  font-size: 15px;
  color: var(--text-dark);
  margin-bottom: 1rem;
  font-family: var(--sans);
}

.payment-amount-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
}

.payment-amount-display .label {
  font-size: 14px;
  color: var(--text-mid);
}

.payment-amount-display .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-dark);
  font-family: var(--serif);
}

.payment-amount-display .unit {
  font-size: 14px;
  color: var(--text-mid);
}

#payment-form {
  max-width: 500px;
  margin: 0 auto;
}

#card-element {
  padding: 18px 16px;
  border: 1.5px solid var(--gold-border);
  background: #fff;
  margin-bottom: 1rem;
  transition: all 0.3s;
}

#card-element:focus {
  border-color: var(--gold-light);
}

#card-errors {
  color: #d63638;
  font-size: 13px;
  margin-bottom: 1.5rem;
  font-family: var(--sans);
  text-align: center;
  min-height: 1.5rem;
}

.payment-waiting-msg {
  text-align: center;
  margin-bottom: 1.5rem;
}

.payment-waiting-msg p {
  font-size: 14px;
  color: var(--gold-light);
  font-weight: 500;
  margin-top: 10px;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.spinner-small {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(184, 151, 61, 0.2);
  border-top-color: var(--gold-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Success Animation */
.payment-success-animation {
  text-align: center;
  padding: 3rem 0;
  animation: fadeIn 0.5s ease-out;
}

.checkmark-circle {
  width: 80px;
  height: 80px;
  position: relative;
  display: inline-block;
  vertical-align: top;
  margin-bottom: 20px;
}

.checkmark-circle .background {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--gold-pale);
  position: absolute;
}

.checkmark-circle .checkmark {
  border-radius: 5px;
}

.checkmark-circle .checkmark.draw:after {
  animation-duration: 800ms;
  animation-timing-function: ease;
  animation-name: checkmark;
  transform: scaleX(-1) rotate(135deg);
}

.checkmark-circle .checkmark:after {
  opacity: 1;
  height: 40px;
  width: 20px;
  transform-origin: left top;
  border-right: 3px solid var(--gold-light);
  border-top: 3px solid var(--gold-light);
  content: "";
  left: 18px;
  top: 42px;
  position: absolute;
}

@keyframes checkmark {
  0% { height: 0; width: 0; opacity: 1; }
  20% { height: 0; width: 20px; opacity: 1; }
  40% { height: 40px; width: 20px; opacity: 1; }
  100% { height: 40px; width: 20px; opacity: 1; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Ritual Page Styles (Redesign) ===== */
#ritual-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  font-family: var(--serif);
}

.ritual-header {
  text-align: center;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--gold-border);
  margin-bottom: 2rem;
}

.ritual-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 3px;
  margin-bottom: 6px;
}

.ritual-header p {
  font-size: 13px;
  color: var(--text-light);
  font-family: var(--sans);
  letter-spacing: 1px;
}

/* 進捗インジケーター */
.progress-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 2rem;
}

.progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  flex: 1;
  position: relative;
}

.progress-step::after {
  content: '';
  position: absolute;
  top: 16px;
  left: calc(50% + 16px);
  right: calc(-50% + 16px);
  height: 1px;
  background: var(--gold-border);
}

.progress-step:last-child::after { display: none; }

.progress-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-family: var(--sans);
  color: var(--text-light);
  position: relative;
  z-index: 1;
  transition: all 0.3s;
}

.progress-step.active .progress-dot {
  background: var(--text-dark);
  border-color: var(--text-dark);
  color: #e8d5a8;
}

.progress-step.done .progress-dot {
  background: var(--gold-light);
  border-color: var(--gold-light);
  color: #fff;
}

.progress-step.done .progress-dot::after {
  content: '✓';
  font-size: 13px;
}

.progress-step.done .progress-dot span { display: none; }

.progress-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-light);
  font-family: var(--sans);
  text-align: center;
  white-space: nowrap;
}

.progress-step.active .progress-label {
  color: var(--text-dark);
  font-weight: 500;
}

/* 占い師ブロック */
.ritual-block {
  display: none;
  animation: fadeUp 0.4s ease;
}

.ritual-block.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.teller-header-rit {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 0 16px;
  border-bottom: 1px solid var(--gold-border);
  margin-bottom: 20px;
}

.teller-avatar-rit {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  background: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
}

.teller-avatar-rit img { width: 100%; height: 100%; object-fit: cover; }

.teller-eyebrow-rit {
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--text-light);
  font-family: var(--sans);
  margin-bottom: 3px;
}

.teller-name-large {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: 2px;
}

.teller-jutsu-badge {
  display: inline-block;
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-light);
  border: 1px solid var(--gold-border);
  padding: 2px 10px;
  margin-top: 5px;
  font-family: var(--sans);
}

.teller-message-rit {
  font-size: 14px;
  line-height: 2.2;
  color: var(--text-mid);
  border-left: 2px solid var(--gold-light);
  padding: 10px 14px;
  margin-bottom: 20px;
}

/* 入力エリア */
.input-area-rit {
  border: 1px solid var(--gold-border);
  margin-bottom: 20px;
  overflow: hidden;
}

.input-area-label-rit {
  background: var(--gold-pale);
  border-bottom: 1px solid var(--gold-border);
  padding: 8px 16px;
  font-size: 9px;
  letter-spacing: 4px;
  color: var(--text-light);
  font-family: var(--sans);
  display: flex;
  align-items: center;gap: 6px;
}

.input-area-label-rit::before { content: '◈'; color: var(--gold-light); }
.input-area-body-rit { padding: 18px 16px; }

/* カード選択UI */
.card-deck {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.card-item {
  width: 64px;
  height: 96px;
  border: 1.5px solid var(--gold-border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  font-size: 11px;
  color: var(--text-light);
  letter-spacing: 1px;
  font-family: var(--sans);
}

.card-item::before {
  content: '？';
  font-size: 24px;
  color: var(--gold-border);
  font-family: var(--serif);
}

.card-item:hover {
  border-color: var(--gold-light);
  background: var(--gold-pale);
}

.card-item.selected {
  border-color: var(--gold-light);
  border-width: 2px;
  background: var(--gold-pale);
}

.card-item.selected::before {
  content: '✦';
  color: var(--gold-light);
  font-size: 20px;
}

/* ローディング画面 */
.loading-screen {
  display: none;
  text-align: center;
  padding: 3rem 1rem;
  animation: fadeUp 0.5s ease;
}

.loading-screen.active { display: block; }

.loading-tellers {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.loading-teller-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.loading-avatar-rit {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-border);
  background: #f5f0e8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  position: relative;
  overflow: hidden;
}

.loading-avatar-rit img { width: 100%; height: 100%; object-fit: cover; }

.loading-avatar-rit.spinning::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--gold-light);
  animation: spin-rit 1.4s linear infinite;
}

.loading-avatar-rit.done::after {
  content: '✓';
  position: absolute;
  inset: 0;
  background: rgba(201,168,76,0.12);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--gold-light);
}

@keyframes spin-rit {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-bar-wrap {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 1.5rem;
  height: 2px;
  background: rgba(184, 151, 61, 0.15);
  position: relative;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  background: var(--gold-light);
  width: 0%;
  transition: width 0.5s ease;
}

/* 完了画面 */
.complete-screen {
  display: none;
  text-align: center;
  padding: 2rem 1rem;
  animation: fadeUp 0.5s ease;
}

.complete-screen.active { display: block; }
