:root {
    --board: min(85vw, 360px);
  }
  
  body {
    margin: 0;
    padding: 20px;
    font-family: "Segoe UI", sans-serif;
    background: linear-gradient(#fafafa, #eee);
  }
  
  h1 {
    text-align: center;
    font-weight: 300;
    letter-spacing: 0.15em;
  }
  
  .wrapper {
    display: flex;
    justify-content: center;
    gap: 30px;
    flex-wrap: wrap;
  }
  
  #puzzle {
    position: relative;
    width: var(--board);
    height: var(--board);
    background: #ddd;
    border-radius: 10px;
    overflow: hidden;
    touch-action: manipulation;
  }
  
  .tile {
    position: absolute;
    background-repeat: no-repeat;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
  }
  
  .side {
    display: flex;
    flex-direction: column;
    gap: 15px;
  }
  
  /* ===== 完成演出 ===== */
  #clear-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s;
  }
  
  #clear-overlay.show {
    opacity: 1;
    pointer-events: auto; 
  }
  
  .clear-text {
    font-size: clamp(32px, 6vw, 72px);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 4px 12px rgba(0,0,0,0.6);
  
    white-space: nowrap;        /* ← 改行させない */
    text-align: center;
    max-width: 80vw;            /* ← 画面内に収める */
  }
  
  @keyframes pop {
    0% { transform: scale(0.5); }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); }
  }
  /* 完成演出ボックス */
.clear-box {
    background: white;
    padding: 30px 40px;
    border-radius: 14px;
    text-align: center;
    animation: pop 0.6s ease;
  }
  
  .clear-text {
    font-size: 2rem;
    margin-bottom: 20px;
  }
  /* 完成画像表示 */
.clear-image-wrap {
  margin-top: 24px;
  max-width: 90vw;
  max-height: 50vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

#clear-image {
  max-width: 25%;
  max-height: 25%;
  object-fit: contain;

  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);

  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* オーバーレイ表示時にフェードイン */
#clear-overlay.show #clear-image {
  opacity: 1;
  transform: scale(1);
}
  /* 完成後メッセージ */
  #after-message {
  display: none;
  margin: 60px auto 0;
  padding: 24px;
  max-width: 680px;
  text-align: center;
}

.after-text {
  font-size: clamp(16px, 4vw, 20px);
  line-height: 1.8;
  color: #333;
  background: #f7f7f7;
  border-radius: 12px;
  padding: 20px;
}
  /* もう一度ボタン */
  #retry {
    font-size: 1rem;
    margin-top: 32px;
    padding: 10px 24px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, #f5b400, #f08c00);
    color: white;
  }
  
  #retry:hover {
    opacity: 0.85;
  }

  /* フッター */
  .footer {
    margin-top: 60px;
    padding: 20px 0;
    text-align: center;
  }
  
  .top-link {
    display: inline-block;
    padding: 12px 28px;
  
    background: #222;
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    border-radius: 999px;
  
    transition: background 0.3s, transform 0.2s;
  }
  
  .top-link:hover {
    background: #444;
    transform: translateY(-2px);
  }