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

/* 基本スタイル */
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: #111827;
  color: #ffffff;
  line-height: 1.6;
}

/* レイアウト */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.min-h-screen {
  min-height: 100vh;
}

/* グリッド */
.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 768px) {
  .md\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* フレックスボックス */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

/* スペーシング */
.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.p-8 {
  padding: 2rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 0.75rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.mb-8 {
  margin-bottom: 2rem;
}

.mt-6 {
  margin-top: 1.5rem;
}

/* テキスト */
.text-center {
  text-align: center;
}

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.text-4xl {
  font-size: 2.25rem;
}

.text-6xl {
  font-size: 3.75rem;
}

.font-bold {
  font-weight: 700;
}

.font-medium {
  font-weight: 500;
}

/* カラー */
.bg-gray-700 {
  background-color: #374151;
}

.bg-gray-800 {
  background-color: #1f2937;
}

.bg-gray-900 {
  background-color: #111827;
}

.text-gray-300 {
  color: #d1d5db;
}

.text-gray-400 {
  color: #9ca3af;
}

.text-gray-500 {
  color: #6b7280;
}

.text-white {
  color: #ffffff;
}

.text-purple-400 {
  color: #a78bfa;
}

.text-blue-400 {
  color: #60a5fa;
}

.text-pink-400 {
  color: #f472b6;
}

.text-yellow-400 {
  color: #fbbf24;
}

.text-green-400 {
  color: #34d399;
}

/* ボーダー */
.border {
  border-width: 1px;
}

.border-2 {
  border-width: 2px;
}

.border-gray-600 {
  border-color: #4b5563;
}

.border-gray-700 {
  border-color: #374151;
}

.border-dashed {
  border-style: dashed;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-xl {
  border-radius: 0.75rem;
}

.rounded-2xl {
  border-radius: 1rem;
}

.rounded-full {
  border-radius: 9999px;
}

/* シャドウ */
.shadow-lg {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.shadow-md {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* トランジション */
.transition-all {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 300ms;
}

.transition-transform {
  transition-property: transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 300ms;
}

/* ホバー効果 */
.hover\:scale-105:hover {
  transform: scale(1.05);
}

.hover\:opacity-90:hover {
  opacity: 0.9;
}

.hover\:bg-gray-600:hover {
  background-color: #4b5563;
}

.hover\:bg-gray-700:hover {
  background-color: #374151;
}

.hover\:border-purple-500:hover {
  border-color: #a855f7;
}

/* カーソル */
.cursor-pointer {
  cursor: pointer;
}

.cursor-not-allowed {
  cursor: not-allowed;
}

/* フォーム要素 */
input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.5);
}

/* カスタムスタイル */
.card {
  background-color: #1f2937;
  border-radius: 1rem;
  padding: 1.5rem;
  border: 1px solid #374151;
  transition: all 0.3s;
  overflow: visible;
  position: relative;
}

.card:hover {
  transform: scale(1.05);
  border-color: #a855f7;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background: linear-gradient(to right, #a855f7, #ec4899);
  color: white;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  background-color: #374151;
  color: #d1d5db;
}

.btn-secondary:hover {
  background-color: #4b5563;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: #374151;
  color: white;
  border: 1px solid #4b5563;
  border-radius: 0.5rem;
  transition: all 0.3s;
}

.form-input:focus {
  border-color: #a855f7;
}

/* プログレスバー */
.progress-bar {
  height: 2rem;
  background-color: #374151;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  max-width: 100%;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  transition: width 1s ease-out;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.75rem;
}

/* グラデーション */
.gradient-purple {
  background: linear-gradient(to right, #a78bfa, #f472b6);
}

.gradient-blue {
  background: linear-gradient(to right, #60a5fa, #06b6d4);
}

.gradient-pink {
  background: linear-gradient(to right, #f472b6, #fb7185);
}

.gradient-green {
  background: linear-gradient(to right, #34d399, #10b981);
}

.gradient-orange {
  background: linear-gradient(to right, #fb923c, #ef4444);
}

.gradient-text {
  background: linear-gradient(to right, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* モーダル */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
  overflow-y: auto;
}

.modal-content {
  background-color: #1f2937;
  border-radius: 1rem;
  padding: 1.5rem;
  max-width: 42rem;
  width: 100%;
  margin: 2rem auto;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* アイコングリッド */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.25rem;
}

.icon-cell {
  aspect-ratio: 1;
  border-radius: 0.125rem;
  transition: all 0.3s;
}

/* チケットバナー */
.ticket-banner {
  background: linear-gradient(to right, #059669, #10b981);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

/* メッセージリスト */
.message-list {
  max-height: 24rem;
  overflow-y: auto;
}

.message-item {
  background-color: #374151;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

/* アニメーション */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* スクロールバー */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #1f2937;
}

::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* レスポンシブ - スマホ最適化 */
@media (max-width: 768px) {
  /* コンテナをほぼ全幅に */
  .container {
    max-width: 100%;
    padding: 0 0.5rem;
  }
  
  /* フォントサイズ縮小と行間調整 */
  body {
    font-size: 14px;
    line-height: 1.6;
  }
  
  /* タッチターゲットの最小サイズ確保 */
  a, button, input, select, textarea {
    min-height: 44px;
  }
  
  .text-6xl {
    font-size: 1.75rem;
  }
  
  .text-4xl {
    font-size: 1.5rem;
  }
  
  .text-3xl {
    font-size: 1.25rem;
  }
  
  .text-2xl {
    font-size: 1.125rem;
  }
  
  .text-xl {
    font-size: 1rem;
  }
  
  .text-sm {
    font-size: 0.8rem;
  }
  
  /* カード幅を最大化・パディング削減 */
  .card {
    margin: 0 0 0.75rem 0;
    padding: 0.5rem;
    border-radius: 0.5rem;
  }
  
  /* ボタンサイズ調整 */
  .btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    min-height: 44px;
  }
  
  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    min-height: 36px;
  }
  
  /* フォーム要素の最適化 */
  .form-input {
    font-size: 16px;
    padding: 0.75rem;
    min-height: 44px;
  }
  
  /* モーダル */
  .modal-content {
    margin: 0.25rem;
    padding: 0.75rem;
    max-height: 95vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  #challengeDetail .container {
    padding: 0;
  }
  
  /* メッセージリスト */
  .message-list {
    max-height: none;
    overflow-y: visible;
  }
  
  .message-item {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  /* グリッドレイアウト最適化 */
  .grid {
    gap: 0.5rem;
  }
  
  /* プログレスバー幅調整 */
  .progress-bar {
    height: 1.75rem;
  }
  
  /* アイコングリッド調整 */
  .icon-grid {
    grid-template-columns: repeat(8, 1fr);
    gap: 0.25rem;
  }
  
  /* 友人入力エリア */
  .friend-input-group {
    padding: 0.25rem;
  }
  
  /* 黄色背景（URL）部分を最小化 */
  .bg-yellow-100 {
    padding: 0.25rem;
    font-size: 0.7rem;
  }
  
  /* 例文カードの調整 */
  .message-card {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
  }
  
  .message-card p {
    font-size: 0.8rem;
    line-height: 1.4;
  }
  
  /* パディング調整 */
  .p-8 {
    padding: 0.75rem;
  }
  
  .p-6 {
    padding: 0.5rem;
  }
  
  .p-4 {
    padding: 0.375rem;
  }
  
  .py-2 {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }
  
  .py-3 {
    padding-top: 0.375rem;
    padding-bottom: 0.375rem;
  }
  
  /* マージン調整 */
  .mb-8 {
    margin-bottom: 1rem;
  }
  
  .mb-6 {
    margin-bottom: 0.75rem;
  }
  
  .mb-4 {
    margin-bottom: 0.5rem;
  }
  
  .mb-3 {
    margin-bottom: 0.375rem;
  }
  
  .mb-2 {
    margin-bottom: 0.25rem;
  }
}

/* さらに小さい画面用（400px以下） */
@media (max-width: 400px) {
  .container {
    padding: 0 0.375rem;
  }
  
  .text-6xl {
    font-size: 1.5rem;
  }
  
  .text-4xl {
    font-size: 1.25rem;
  }
  
  .text-3xl {
    font-size: 1.125rem;
  }
  
  .card {
    padding: 0.375rem;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* パディング調整 */
  .p-8 {
    padding: 0.5rem;
  }
  
  .p-6 {
    padding: 0.375rem;
  }
  
  .p-4 {
    padding: 0.25rem;
  }
  
  /* 例文カードさらに縮小 */
  .message-card {
    padding: 0.375rem;
  }
  
  .message-card p {
    font-size: 0.75rem;
  }
}

/* ローディング */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #a855f7;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* エラーメッセージ */
.error-message {
  background-color: #991b1b;
  color: #fef2f2;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

/* 成功メッセージ */
.success-message {
  background-color: #166534;
  color: #f0fdf4;
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
}

/* ========== 友人入力フォームのスタイル ========== */
.friends-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.friends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.friends-title {
    font-size: 1rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
}

.add-friend-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    font-size: 0.875rem;
}

.add-friend-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

#friends-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.friend-input-group {
    animation: slideIn 0.3s ease-out;
}

.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.friend-name-input,
.friend-twitter-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.friend-name-input {
    flex: 1;
    min-width: 120px;
}

.friend-twitter-input {
    flex: 1;
    min-width: 150px;
}

.friend-name-input::placeholder,
.friend-twitter-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.remove-friend-btn {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    width: 36px;
    height: 36px;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.remove-friend-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.1);
}

/* ========== 友人リスト表示のスタイル ========== */
.friends-list {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.friends-label {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.5rem;
}

.friends-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.friend-chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 2rem;
    padding: 0.25rem 0.75rem 0.25rem 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.friend-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #374151;
    transition: opacity 0.3s ease;
}

.friend-name {
    color: rgba(255, 255, 255, 0.9);
}

.friend-twitter {
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.friend-twitter:hover {
    text-decoration: underline;
}

/* ========== アニメーション ========== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== レスポンシブ対応 ========== */
@media (max-width: 640px) {
    .input-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .friend-name-input,
    .friend-twitter-input {
        width: 100%;
    }
    
    .remove-friend-btn {
        align-self: flex-end;
        margin-top: -2.5rem;
        margin-right: 0.5rem;
    }
    
    .friends-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .add-friend-btn {
        width: 100%;
        justify-content: center;
    }
}

/* 既存のmessage-cardスタイルに追加する調整 */
.message-card {
    position: relative;
    overflow: visible;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.message-card p {
    margin: 0;
    color: rgba(255, 255, 255, 0.8);
}

/* サポーターアイコンのスタイル */
.supporter-avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background-color: #374151;
    transition: opacity 0.3s ease;
}

.supporter-avatar[loading="lazy"] {
    opacity: 0.8;
}

.supporter-avatar:not([loading]) {
    opacity: 1;
}

.supporter-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    min-height: 40px;
}

.supporter-info {
    flex: 1;
}

.supporter-info strong {
    display: block;
    margin-bottom: 0.25rem;
}

.twitter-link {
    color: #60a5fa;
    text-decoration: none;
    font-size: 0.875rem;
}

.twitter-link:hover {
    text-decoration: underline;
}

/* 既存のmessage-itemスタイルに追加 */
.message-item .supporter-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

/* シェアモーダルのスタイル */
.share-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
  cursor: pointer;
}

.share-modal-content {
  background-color: #1f2937;
  border-radius: 1rem;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  cursor: default;
}

.share-modal-content .form-input {
  background-color: #374151;
  color: #d1d5db;
}

.share-modal-content .space-y-2 > * + * {
  margin-top: 0.5rem;
}

.share-modal-content .text-center {
  text-align: center;
}

.share-modal-content .w-full {
  width: 100%;
}

/* ボタンのスモールサイズ */
.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

/* ========== 見切れ問題の修正（2025/01/11追加） ========== */

#editModal .modal-content {
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#challengeDetail {
  overflow-x: hidden;
  position: relative;
}

@media (max-width: 480px) {
  .icon-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* ========== Twitterアイコンのちらつき対策 ========== */

.supporter-avatar {
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background-color: #374151;
  transition: opacity 0.3s ease;
}

.supporter-avatar[loading="lazy"] {
  opacity: 0.8;
}

.supporter-avatar:not([loading]) {
  opacity: 1;
}

.supporter-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  min-height: 40px;
}

.friend-avatar {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #374151;
  transition: opacity 0.3s ease;
}