/* ==========================================
   AI神社 福笑い 2026 - スタイルシート
   ========================================== */

:root {
  /* お正月カラーパレット */
  --red: #C41E3A;
  --red-dark: #8B0000;
  --gold: #D4AF37;
  --gold-light: #FFD700;
  --white: #FFFEF5;
  --black: #1A1A1A;
  --cream: #FFF8E7;
  --green: #2E8B57;
  
  /* シャドウ */
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Noto Serif JP', serif;
  background: linear-gradient(180deg, var(--cream) 0%, var(--white) 100%);
  min-height: 100vh;
  color: var(--black);
  overflow-x: hidden;
}

/* ==========================================
   共通スタイル
   ========================================== */

.screen {
  min-height: 100vh;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen.hidden {
  display: none;
}

.primary-btn {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
  color: white;
  border: none;
  padding: 16px 32px;
  font-size: 18px;
  font-family: inherit;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.primary-btn:active {
  transform: translateY(0);
}

.secondary-btn {
  background: white;
  color: var(--red);
  border: 2px solid var(--red);
  padding: 14px 28px;
  font-size: 16px;
  font-family: inherit;
  font-weight: bold;
  border-radius: 50px;
  cursor: pointer;
  transition: background 0.2s;
}

.secondary-btn:hover {
  background: var(--cream);
}

.back-btn {
  background: none;
  border: none;
  color: var(--red);
  font-size: 16px;
  font-family: inherit;
  cursor: pointer;
  padding: 8px;
}

/* ==========================================
   ローディング画面
   ========================================== */

#loading-screen {
  background: linear-gradient(135deg, var(--red) 0%, var(--red-dark) 100%);
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-content p {
  font-size: 18px;
}

/* ==========================================
   オープニング動画画面
   ========================================== */

#video-screen {
  position: relative;
  background: black;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
}

#video-screen.hidden {
  display: none !important;
}

#opening-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ==========================================
   トップ画面
   ========================================== */

#top-screen {
  position: relative;
  z-index: 10;
}

#top-screen.hidden {
  display: none !important;
}

.top-container {
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.header-decoration {
  font-size: 32px;
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.title {
  font-size: 48px;
  color: var(--red);
  text-shadow: 2px 2px 0 var(--gold);
  margin-bottom: 5px;
}

.subtitle {
  font-size: 24px;
  color: var(--gold);
  margin-bottom: 30px;
}

.ai-character {
  background: white;
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 30px;
  border: 3px solid var(--gold);
}

.ai-face {
  font-size: 64px;
  margin-bottom: 15px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.ai-speech p {
  font-size: 16px;
  line-height: 1.8;
  margin: 5px 0;
}

.ai-speech strong {
  color: var(--red);
}

.input-section {
  margin-bottom: 24px;
}

.input-section label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  color: #666;
}

.input-section input {
  width: 100%;
  padding: 14px 20px;
  font-size: 18px;
  font-family: inherit;
  border: 2px solid #ddd;
  border-radius: 10px;
  text-align: center;
  transition: border-color 0.2s;
}

.input-section input:focus {
  outline: none;
  border-color: var(--red);
}

.button-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.privacy-notice {
  font-size: 12px;
  color: #999;
}

.credit-notice {
  font-size: 10px;
  color: #aaa;
  text-align: center;
  margin-top: 15px;
  padding-top: 10px;
  border-top: 1px solid #eee;
  font-family: monospace;
}

/* ==========================================
   カメラ画面
   ========================================== */

.camera-container {
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.camera-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 15px;
}

.camera-header p {
  font-size: 14px;
  color: #666;
}

.camera-view {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 20px;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.face-guide {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 70%;
  border: 3px dashed rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

.capture-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--red);
  border: 5px solid white;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  font-size: 32px;
  transition: transform 0.1s;
}

.capture-btn:active {
  transform: scale(0.95);
}

/* ==========================================
   処理中画面
   ========================================== */

.processing-content {
  text-align: center;
}

.ai-face.processing {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.loading-bar {
  width: 200px;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  margin-top: 20px;
  overflow: hidden;
}

.loading-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  border-radius: 4px;
  animation: progress 2s ease-in-out forwards;
}

@keyframes progress {
  0% { width: 0%; }
  50% { width: 70%; }
  100% { width: 100%; }
}

/* ==========================================
   福笑い画面
   ========================================== */

.fukuwarai-container {
  width: 100%;
  max-width: 500px;
  text-align: center;
}

.fukuwarai-area {
  position: relative;
  width: 100%;
  aspect-ratio: 3/4;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(255, 192, 203, 0.12) 0%, transparent 10%),
    radial-gradient(circle at 85% 30%, rgba(255, 192, 203, 0.12) 0%, transparent 10%),
    radial-gradient(circle at 30% 70%, rgba(255, 192, 203, 0.12) 0%, transparent 10%),
    radial-gradient(circle at 70% 80%, rgba(255, 192, 203, 0.12) 0%, transparent 10%),
    radial-gradient(circle at 50% 45%, rgba(212, 175, 55, 0.06) 0%, transparent 15%),
    linear-gradient(45deg, transparent 48%, rgba(0,0,0,0.005) 49%, rgba(0,0,0,0.005) 51%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, rgba(0,0,0,0.005) 49%, rgba(0,0,0,0.005) 51%, transparent 52%),
    linear-gradient(135deg, rgba(255, 248, 220, 0.15) 0%, rgba(255, 254, 245, 0.1) 30%, rgba(255, 248, 231, 0.15) 60%, rgba(255, 254, 245, 0.1) 100%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 8px 8px, 8px 8px, 100% 100%;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 15px;
  touch-action: none;
  box-shadow:
    0 4px 15px rgba(212, 175, 55, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(212, 175, 55, 0.3);
}

.decoration {
  position: absolute;
  font-size: 48px;
  z-index: 1;
  opacity: 0.6;
  pointer-events: none;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.1));
}

.decoration-top-left {
  top: 10px;
  left: 10px;
}

.decoration-top-right {
  top: 10px;
  right: 10px;
}

.decoration-bottom-left {
  bottom: 10px;
  left: 10px;
}

.decoration-bottom-right {
  bottom: 10px;
  right: 10px;
}

.placement-guide {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  text-align: center;
  width: 90%;
}

.placement-guide p {
  background: rgba(255, 255, 255, 0.95);
  color: var(--red);
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 2px solid var(--gold);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

#fukuwarai-canvas {
  width: 100%;
  height: 100%;
  opacity: 0.03; /* 超薄く表示 */
}

#parts-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.face-part {
  position: absolute;
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  transition: transform 0.1s;
}

.face-part:active {
  cursor: grabbing;
  transform: scale(1.1);
}

.face-part.placed {
  cursor: default;
  pointer-events: none;
}

.parts-tray {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 15px;
  background: white;
  border-radius: 15px;
  box-shadow: var(--shadow);
  margin-bottom: 15px;
  min-height: 80px;
}

.tray-part {
  padding: 10px;
  background: var(--cream);
  border: 2px solid var(--gold);
  border-radius: 10px;
  cursor: grab;
  font-size: 14px;
  font-family: inherit;
  touch-action: none;
}

.tray-part:active {
  cursor: grabbing;
}

.tray-part.used {
  opacity: 0.3;
  cursor: default;
}

.ai-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: white;
  padding: 12px 20px;
  border-radius: 50px;
  box-shadow: var(--shadow);
}

.ai-face-small {
  font-size: 28px;
}

#ai-hint-text {
  font-size: 14px;
  color: #666;
}

/* ==========================================
   結果画面
   ========================================== */

.result-container {
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.result-container h2 {
  font-size: 28px;
  color: var(--red);
  margin-bottom: 20px;
}

.face-comparison {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
}

.face-box {
  text-align: center;
}

.face-box p {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.face-box canvas {
  width: 120px;
  height: 150px;
  border-radius: 10px;
  border: 2px solid var(--gold);
  object-fit: cover;
}

.arrow {
  font-size: 24px;
  color: var(--gold);
}

.ai-reaction {
  background: white;
  border-radius: 15px;
  padding: 10px 15px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  border: 2px solid var(--gold);
}

#ai-reaction-text {
  font-size: 16px;
  line-height: 1.6;
  margin-top: 0;
}

.deviation-stats {
  background: var(--cream);
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: left;
}

.deviation-stats h3 {
  font-size: 16px;
  margin-bottom: 12px;
  text-align: center;
}

#deviation-list {
  list-style: none;
  font-size: 14px;
}

#deviation-list li {
  padding: 8px 0;
  border-bottom: 1px dashed #ddd;
}

#deviation-list li:last-child {
  border-bottom: none;
}

/* ==========================================
   プロンプト画面
   ========================================== */

/* 占い結果コンテナ */
.fortune-container {
  max-width: 600px;
  width: 100%;
  text-align: center;
}

.fortune-header {
  margin-bottom: 30px;
}

.fortune-header p {
  font-size: 14px;
  color: #666;
}

#prompt-name {
  font-size: 20px;
  color: var(--red);
}

/* 占い結果エリア */
.fortune-result {
  background: white;
  border: 3px solid var(--gold);
  border-radius: 20px;
  padding: 25px;
  margin-bottom: 30px;
  text-align: left;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fortune-result h3 {
  text-align: center;
  color: var(--red);
  font-size: 18px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 10px;
}

.fortune-text {
  font-size: 15px;
  line-height: 1.9;
  color: #333;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* 数秘術詳細エリア */
.numerology-details {
  display: none !important; /* 完全に非表示 */
}

.numerology-details h3 {
  text-align: center;
  color: var(--red);
  font-size: 18px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 10px;
}

.numerology-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.numerology-item {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.numerology-item.full-width {
  grid-column: 1 / -1;
}

.numerology-item .label {
  font-size: 12px;
  color: #999;
  font-weight: 500;
}

.numerology-item .value {
  font-size: 15px;
  color: #333;
  font-weight: bold;
}

/* 旧プロンプト用CSS（互換性のため残す） */
.prompt-container {
  max-width: 500px;
  width: 100%;
  text-align: center;
}

.prompt-header {
  margin-bottom: 20px;
}

.prompt-header p {
  font-size: 14px;
  color: #666;
}

.prompt-content {
  margin-bottom: 20px;
}

.prompt-meta {
  margin: -6px 0 16px 0;
  text-align: left;
}

.prompt-warning {
  background: #fff3f3;
  border: 1px solid #f5b5b5;
  color: #b00020;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
  margin: 0 0 8px 0;
}

.prompt-debug {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: #444;
  margin: 0;
  opacity: 0.9;
}

#prompt-text {
  width: 100%;
  height: 50vh;
  min-height: 400px;
  max-height: 600px;
  padding: 16px;
  font-size: 13px;
  font-family: 'Courier New', monospace;
  line-height: 1.6;
  border: 2px solid var(--gold);
  border-radius: 15px;
  background: white;
  resize: vertical;
  overflow-y: auto;
}

/* 占い結果アクション */
.fortune-actions {
  margin-bottom: 30px;
  text-align: center;
}

.prompt-actions {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.copy-feedback {
  margin-top: 10px;
  color: var(--green);
  font-weight: bold;
}

.copy-feedback.hidden {
  display: none;
}

.usage-guide {
  background: var(--cream);
  padding: 20px;
  border-radius: 15px;
  margin-bottom: 20px;
  text-align: center;
}

.usage-guide .ai-face-small {
  font-size: 32px;
  margin-bottom: 10px;
}

.usage-guide p {
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

.usage-guide .guide-main {
  font-size: 16px;
  font-weight: bold;
  color: var(--red);
  margin-bottom: 5px;
}

.usage-guide .guide-sub {
  font-size: 14px;
  color: #333;
  margin-bottom: 15px;
}

.ai-logos {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.ai-logos span {
  padding: 8px 16px;
  background: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: bold;
  color: #333;
}

/* ==========================================
   画像拡大モーダル
   ========================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.modal-content {
  position: relative;
  z-index: 10001;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-close {
  position: absolute;
  top: -50px;
  right: 0;
  background: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.modal-close:hover {
  transform: scale(1.1);
}

#modal-canvas {
  max-width: 100%;
  max-height: 95vh;
  border: 3px solid white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.face-box canvas {
  cursor: pointer;
  transition: transform 0.2s;
}

.face-box canvas:hover {
  transform: scale(1.05);
}

.tap-hint {
  font-size: 16px;
  color: var(--gold);
  margin-top: 5px;
  font-weight: bold;
  opacity: 0.8;
  animation: pulse-hint 2s ease-in-out infinite;
}

@keyframes pulse-hint {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ==========================================
   レスポンシブ
   ========================================== */

/* 小画面（400px以下） */
@media (max-width: 400px) {
  .title {
    font-size: 36px;
  }

  .subtitle {
    font-size: 20px;
  }

  .ai-face {
    font-size: 48px;
  }

  .primary-btn {
    padding: 14px 24px;
    font-size: 16px;
  }

  #prompt-text {
    height: 60vh;
    min-height: 300px;
    max-height: none;
    font-size: 12px;
  }

  /* 占い結果モバイル対応 */
  .fortune-result {
    padding: 20px 15px;
  }

  .fortune-text {
    font-size: 14px;
    line-height: 1.8;
  }

  .numerology-grid {
    grid-template-columns: 1fr;
  }

  .numerology-item .value {
    font-size: 14px;
  }
}

/* タブレット縦向き（768px以上） */
@media (min-width: 768px) {
  .screen {
    padding: 40px;
  }

  .top-container {
    max-width: 550px;
  }

  .title {
    font-size: 56px;
  }

  .subtitle {
    font-size: 28px;
  }

  .ai-face {
    font-size: 80px;
  }

  .ai-speech p {
    font-size: 18px;
  }

  .input-section input {
    font-size: 20px;
    padding: 16px 24px;
  }

  .primary-btn {
    padding: 18px 40px;
    font-size: 20px;
  }

  .secondary-btn {
    padding: 16px 36px;
    font-size: 18px;
  }

  .camera-container,
  .fukuwarai-container {
    max-width: 600px;
  }

  .result-container {
    max-width: 650px;
  }

  .face-box canvas {
    width: 160px;
    height: 200px;
  }

  .face-comparison {
    gap: 25px;
  }

  .arrow {
    font-size: 32px;
  }

  .fortune-container {
    max-width: 700px;
  }

  .fortune-result {
    padding: 30px;
  }

  .fortune-text {
    font-size: 16px;
    line-height: 2;
  }

  .deviation-stats {
    padding: 25px;
  }

  #deviation-list {
    font-size: 15px;
  }

  .parts-tray {
    padding: 20px;
    gap: 15px;
  }

  .tray-part {
    padding: 14px 16px;
    font-size: 16px;
  }

  .ai-hint {
    padding: 16px 28px;
  }

  .ai-face-small {
    font-size: 36px;
  }

  #ai-hint-text {
    font-size: 16px;
  }

  .decoration {
    font-size: 64px;
  }
}

/* タブレット横向き/デスクトップ（1024px以上） */
@media (min-width: 1024px) {
  .screen {
    padding: 60px;
  }

  .top-container {
    max-width: 650px;
  }

  .title {
    font-size: 64px;
  }

  .subtitle {
    font-size: 32px;
    margin-bottom: 40px;
  }

  .ai-character {
    padding: 32px;
    margin-bottom: 40px;
  }

  .ai-face {
    font-size: 96px;
  }

  .ai-speech p {
    font-size: 20px;
    line-height: 2;
  }

  .button-section {
    flex-direction: row;
    justify-content: center;
    gap: 20px;
  }

  .camera-container,
  .fukuwarai-container {
    max-width: 700px;
  }

  .result-container {
    max-width: 750px;
  }

  .face-box canvas {
    width: 200px;
    height: 250px;
  }

  .face-comparison {
    gap: 40px;
  }

  .fortune-container {
    max-width: 800px;
  }

  .fortune-result {
    padding: 40px;
  }

  .fortune-result h3 {
    font-size: 22px;
  }

  .fortune-text {
    font-size: 17px;
  }

  .modal-close {
    width: 50px;
    height: 50px;
    font-size: 28px;
    top: -60px;
  }
}
