/* カスタムプロパティ（CSS変数） */
:root {
  /* カラーパレット */
  --color-main: #792389;
  --color-sub: #FDD000;
  --color-white: #FFFFFF;
  
  /* フォント */
  --font-mincho: serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
}

/* リセットCSS */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-mincho);
  font-weight: 600;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--color-sub);
  min-height: 100vh;
  box-sizing: border-box;
  letter-spacing: 0.09em;
}

img {
  width: 100%;
}

/* 画面切り替え制御 */
.screen {
  display: none;
}

.screen.active {
  display: block;
  height: calc(100% - 66px);
}

/* ラッパー（黄色い枠） */
.wrapper {
  border: 10px solid var(--color-sub);
  background-color: var(--color-main);
  /* overflow-y: scroll; */
  /* border-bottom: none; */
  min-height: 100vh;
}

/* コンテンツラッパー（最大幅設定） */
.content-wrapper {
  margin: 0 auto;
  width: 100%;
  max-width: 500px;
}

.wrapper-result .content-wrapper {
}

@media (min-width: 1024px) {
  .content-wrapper {
    /* max-width: 300px; */
  }
}

/* コンテナ */
.container {
  margin: 0 auto;
}

/* ロゴセクション */
.logo-section {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
}

.logo-image {
  max-width: 41%;
  padding: 8px 11px 3px;
  height: auto;
  display: block;
}

/* ヘッダー */
.header {
  margin-bottom: 0.4rem;
  padding: 0 1.1rem 0.7rem;
}

.title-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  text-align: center;
}

.subtitle-image {
  max-width: 40%;
  height: auto;
  display: block;
  margin: 0 0 0.8rem;
}

.completed-image {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* メインコンテンツ */
.main-content {
  border-radius: 0.5rem;
  padding: 1.1rem;
  margin-bottom: 2rem;
}

/* フォームセクション */
.form-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* margin-bottom: 1.5rem; */
  border: 3px solid #fff;
  border-radius: 12px;
  padding: 0 20px 28px;
}

.form-section._input {
  margin-bottom: 2.1rem;
  padding: 0 20px 14px;
}

.form-label-image {
  height: auto;
  display: block;
  text-align: center;
  max-width: 231px;
  width: 87%;
  margin: -14px auto 0;
  background-color: var(--color-main);
  padding: 0 13px;
}

/* 矢印画像 */
.arrow-image {
  max-width: 22px;
  width: 22px;
  height: auto;
  display: block;
  margin: 1rem auto 2rem;
  text-align: center;
}

/* アップロードタイトル */
.upload-title {
  max-width: 276px;
  width: 94%;
  height: auto;
  display: block;
  text-align: center;
  margin: -17px auto 0;
  background-color: var(--color-main);
  padding: 0 10px;
}

.upload-title img {
  width: 94%;
}

/* アップロードエリア */
.upload-area {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 0.5rem;
  padding: 1rem;
}

.retrim-link-container {
  margin-top: 12px;
}

.retrim-link {
  background: none;
  border: none;
  color: var(--color-white);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-mincho);
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 8px;
  transition: opacity 0.2s;
}

.retrim-link:hover {
  opacity: 0.8;
}

.preview-photo {
  max-width: 160px;
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0.5rem;
}

/* アップロード情報ボックス */
.upload-info-box {
  background-color: var(--color-main);
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.upload-info-text {
  color: var(--color-white);
  font-size: 0.75rem;
  line-height: 1.6;
  font-family: var(--font-mincho);
}

.upload-info-text:last-child {
  margin-bottom: 0;
}

/* アップロードボタン */
.upload-button {
  background: var(--color-sub);
  border: none;
  cursor: pointer;
  padding: 10px 25px;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  box-shadow: 2px 6px 0 #BF640F;
  border-radius: 999px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.upload-button .button-image {
  max-width: 132px;
}

.upload-button:active {
  transform: translateY(6px) scale(1);
  box-shadow: 0 0 0 #BF640F;
}

.file-input {
  position: absolute;
  top: -9999px;
  left: -9999px;
  opacity: 0;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* テキスト入力 */
.text-input {
  width: 100%;
  max-width: 178px;
  padding: 3px 9px 3px 20px;
  border: 2px solid var(--color-main);
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: serif;
  color: var(--color-main);
  transition: border-color 0.2s, box-shadow 0.2s;
  margin: 16px auto;
}

.text-input::placeholder {
  color: #E1E1E1;
}

.text-input:focus {
  outline: none;
  border-color: var(--color-sub);
  box-shadow: 0 0 0 3px rgba(253, 208, 0, 0.3);
}

.text-input-info {
  color: var(--color-white);
  font-size: 0.75rem;
  line-height: 1.6;
  font-family: var(--font-mincho);
  text-align: center;
  white-space: nowrap;
  letter-spacing: 0em;
}

@media (max-width: 350px) {
  .text-input-info {
    white-space: wrap;
  }
}

/* 送信ボタン */
.submit-button {
  width: 85%;
  margin: 0 auto;
  background: var(--color-sub);
  border: none;
  cursor: pointer;
  padding: 10px;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  box-shadow: 2px 6px 0 #BF640F;
  border-radius: 999px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.submit-button:active {
  transform: translateY(6px) scale(1);
  box-shadow: 0 0 0 #BF640F;
}

.submit-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: scale(1);
}

.button-image {
  max-width: 100%;
  height: auto;
  display: block;
}

.submit-button .button-image {
  max-width: 98px;
}

/* トリミングモーダル */
.trimming-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
}

.trimming-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.trimming-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
}

.trimming-modal-content {
  position: relative;
  background-color: var(--color-main);
  border-radius: 12px;
  padding: 24px;
  max-width: 90%;
  max-height: 90vh;
  overflow: auto;
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.trimming-modal-title {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-white);
  margin-bottom: 20px;
  text-align: center;
  font-family: var(--font-mincho);
}

/* トリミングエリア */
.trimming-area {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trimming-canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  /* widthとheightはJavaScriptで動的に設定される */
  pointer-events: none;
}

.crop-frame {
  position: absolute;
  left: 0;
  top: 0;
  /* widthとheightはJavaScriptで動的に設定される */
  aspect-ratio: 1;
  border: none;
  border-radius: 4px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  cursor: move;
  touch-action: none;
  transform: translateZ(0);
  will-change: transform;
  /* アニメーションするボーダー */
  background-image: 
    linear-gradient(90deg, rgba(0, 0, 0, 0.78) 50%, transparent 50%),
    linear-gradient(90deg, rgba(0, 0, 0, 0.78) 50%, transparent 50%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.78) 50%, transparent 50%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.78) 50%, transparent 50%);
  background-size: 10px 1px, 10px 1px, 1px 10px, 1px 10px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  animation: marching-ants 1s linear infinite;
}

@keyframes marching-ants {
  0% {
    background-position: 0 0, 0 100%, 0 0, 100% 0;
  }
  100% {
    background-position: 20px 0, -20px 100%, 0 -20px, 100% 20px;
  }
}

/* リサイズハンドル */
.resize-handle {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, .7);
  background-color: rgba(0, 0, 0, 0.2);
  cursor: nwse-resize;
  z-index: 10;
  touch-action: none;
}

.resize-handle-nw {
  top: -8px;
  left: -8px;
  cursor: nwse-resize;
}

.resize-handle-ne {
  top: -8px;
  right: -8px;
  cursor: nesw-resize;
}

.resize-handle-sw {
  bottom: -8px;
  left: -8px;
  cursor: nesw-resize;
}

.resize-handle-se {
  bottom: -8px;
  right: -8px;
  cursor: nwse-resize;
}

/* トリミングボタングループ */
.trimming-button-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.trimming-button {
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  font-family: var(--font-mincho);
  min-width: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.trimming-button:active {
  transform: translateY(6px) scale(1);
  box-shadow: 0 0 0 #BF640F;
}

.trimming-button-secondary {
  background-color: #E5E7EB;
  color: #374151;
  box-shadow: 2px 6px 0 #BF640F;
}

.trimming-button-secondary:hover {
  background-color: #D1D5DB;
}

.trimming-button-primary {
  background: var(--color-sub);
  color: var(--color-main);
  box-shadow: 2px 6px 0 #BF640F;
}

.trimming-button-primary:hover {
  background: var(--color-sub);
}

.trimming-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.trimming-button:disabled:active {
  transform: none;
  box-shadow: 2px 6px 0 #BF640F;
}

.placeholder-text {
  color: #6b7280;
  font-size: 1rem;
}

/* ボタングループ */
.button-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.button {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.button-primary {
  background: transparent;
  border: none;
  padding: 0;
}

.button-primary:hover {
  transform: scale(1.05);
}

.button-secondary {
  background-color: #e5e7eb;
  color: #374151;
}

.button-secondary:hover {
  background-color: #d1d5db;
}

/* ローディング画面 */
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 2rem 1rem;
}

.loading-shurikens {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.loading-shuriken {
  width: 55px;
  height: auto;
  display: block;
  animation: spin 3s linear infinite;
}

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

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

.loading-text {
  font-size: 1.25rem;
  color: var(--color-white);
  font-family: var(--font-mincho);
  text-align: center;
  animation: fadeInUp 0.8s ease-out;
}

/* ローディング画面表示時にロゴを非表示 */
body.loading-active .logo-section {
  visibility: hidden;
}

/* 完了画面 */
#result-screen .container {
  margin-top: 30px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* メインコンテンツ（紫背景） */
.result-main-content {
  background-color: var(--color-main);
  border: 3px solid #fff;
  border-radius: 12px;
  padding: 0 20px 20px;
  margin: 0 1.1rem 1.7rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.result-title {
  max-width: 200px;
  width: 62.5%;
  height: auto;
  display: block;
  text-align: center;
  margin: -26px auto 1.5rem;
  background-color: var(--color-main);
  padding: 0 10px;
}

.result-title-image {
  margin: 0 auto;
  width: 73%;
  height: auto;
  display: block;
}

.result-area {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  background-color: var(--color-main);
  max-width: 261px;
}

.result-image {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 0.5rem;
}

.result-save-instruction {
  color: var(--color-white);
  font-size: 0.875rem;
  text-align: center;
  font-family: var(--font-mincho);
  margin: 0;
}

/* 下部セクション（黄色背景） */
.result-bottom-section {
  background-color: var(--color-sub);
  padding: 32px 10px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 101%;
  margin-left: -1px;
}

@media (min-width: 500px) {
  .result-bottom-section {
    max-width: 464px;
    margin: 0 auto;
  }
}

.printer-section {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.printer-icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
  width: 100%;
}

.printer-text {
  color: var(--color-main);
  font-size: 0.875rem;
  line-height: 1.6;
  font-family: var(--font-mincho);
  margin: 0;
  flex: 1;
  font-weight: 600;
}

.print-button-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.print-button {
  background: var(--color-main);
  border: none;
  cursor: pointer;
  padding: 10px 25px;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  box-shadow: 0px 6px 0 #370440;
  border-radius: 999px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  min-width: 200px;
}

.print-button-image {
  max-width: 77px;
  height: auto;
  display: block;
}

.print-button:active {
  transform: translateY(6px) scale(1);
  box-shadow: 0 0 0 #370440;
}

/* もう一度やるボタン */
.result-button-container {
  display: flex;
  justify-content: center;
  flex: 1;
  align-items: center;
  padding: 1.7rem;
}

.result-retry-button {
  width: 100%;
  max-width: 340px;
  background: var(--color-main);
  border: none;
  cursor: pointer;
  padding: 10px;
  transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
  display: flex;
  justify-content: center;
  align-items: center;
}

.result-retry-button:active {
  transform: translateY(6px) scale(1);
  box-shadow: 0 0 0 #BF640F;
}

.result-retry-button .button-image {
  max-width: 136px;
  width: 100%;
  height: auto;
  display: block;
}

.retry-btn-icon {
  width: 22px;
  height: 22px;
  display: block;
  margin-top: 4px;
  margin-right: 10px;
  transition: transform 0.2s ease-out;
}

.result-retry-button:active .retry-btn-icon {
  transform: translateX(-5px);
}

