.footer {
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5em;
  text-align: center;
  padding: 16px 0 8px 0;
  margin-top: 1em;
  font-size: 0.97em;
  color: #888;
  background: none;
  z-index: 1001;
  position: relative;
  flex-wrap: wrap;
}
.footer-policy {
  color: #888;
  font-size: 0.8em;
  text-decoration: underline;
}
.footer-policy:hover {
  color: #ff7f7f;
}
.footer-copyright {
  margin: 0.3em 0;
  font-size: 0.96em;
  color: #aaa;
}

.footer-tkgames-link {
  color: #888;
  text-decoration: underline;
  transition: color 0.2s;
}
.footer-tkgames-link:hover {
  color: #ff7f7f;
}

@media (max-width: 600px) {
  .footer {
    flex-direction: column;
    gap: 0.2em;
  }
}

.footer-links {
  display: flex;
  gap: 1em;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.footer-copyright {
  width: 100%;
  text-align: center;
  margin-top: 6px;
}

.footer-copyright {
  flex-basis: 100%;
  order: 2;
}
canvas {
  display: block;
  width: 100%;
  max-width: 100vw;
  height: auto;
  margin: 0 auto;
}
@media (max-width: 600px) {
  .param-toggle {
    padding-top: 3px !important;
    padding-bottom: 3px !important;
    font-size: 0.98em !important;
    min-height: 3em !important;
    line-height: 1.1 !important;
  }
}
@media (min-width: 601px) {
  .btn,
  .param-toggle,
  label.btn,
  #terms-btn {
    max-width: 340px;
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 1.08em;
  }
  .param-controls-wrapper {
    margin-bottom: 12px;
  }
}
@media (min-width: 601px) {
  .btn,
  .param-toggle,
  label.btn,
  #terms-btn {
    max-width: 340px;
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.param-controls-wrapper {
  width: 100%;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.param-toggle {
  font-weight: bold;
  font-size: 1.08em;
  padding: 8px 0;
  cursor: pointer;
  outline: none;
  width: 100%;
  max-width: 340px;
  margin-bottom: 0;
  transition: background 0.2s;
}
.param-toggle.open {
  background: #ffe6e6;
}
.param-toggle {
  position: relative;
  padding-right: 1.4em;
}
.param-toggle::after {
  content: "▾";
  position: absolute;
  right: 0.5em;
  top: 50%;
  transform: translateY(-50%) rotate(0deg);
  transform-origin: center;
  font-size: 2em;
  color: #fff;
  transition: transform 0.18s ease, color 0.12s ease;
  line-height: 1;
}
.param-toggle:hover::after {
  color: rgba(255,255,255,0.95);
}
.param-toggle.open::after {
  transform: translateY(-50%) rotate(180deg) scale(1.02);
  color:#ff9fcf;
}
.param-controls {
  width: 100%;
  max-width: 340px;
  margin-left: auto;
  margin-right: auto;
  background: #fff8f8;
  border-radius: 12px;
  box-shadow: 0 2px 12px #0001;
  padding: 0 18px 0 18px;
  box-sizing: border-box;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: max-height 0.4s cubic-bezier(.4,0,.2,1), opacity 0.3s, padding 0.3s;
}
.param-controls.open {
  padding: 16px 18px 10px 18px;
  opacity: 1;
  pointer-events: auto;
}
@media (max-width: 600px) {
  .param-controls, .param-toggle {
    max-width: 98vw;
  }
}
@media (min-width: 601px) {
  .param-controls {
    margin-left: auto;
    margin-right: auto;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  background: rgba(0,0,0,0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  overflow: hidden;
}
.modal-content {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 32px #0003;
  padding: 28px 20px 20px 20px;
  width: min(90vw, 350px);
  text-align: left;
  font-size: 1.08em;
  animation: modalIn 0.18s cubic-bezier(.4,1.6,.6,1) 1;
  max-height: calc(100vh - 40px);
  overflow: auto;
  margin: 0 auto;
  box-sizing: border-box;
}
.modal-content h2 {
  margin-top: 0;
  font-size: 1.3em;
  color: #ff7f7f;
  text-align: center;
}
.modal-content ul {
  padding-left: 1.2em;
  margin-bottom: 18px;
}
.modal-content li {
  margin-bottom: 0.7em;
  line-height: 1.6;
}
.modal-content .btn {
  width: 100%;
  margin-top: 8px;
}
@keyframes modalIn {
  from { transform: translateY(40px) scale(0.97); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
#ui .slider-group .label-spacer {
  display: block;
  height: 10px;
}
#ui .slider-group {
  margin: 18px 0 10px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fff8;
  border-radius: 14px;
  padding: 16px 28px;
  font-size: 1rem;
  gap: 8px;
  box-shadow: 0 2px 12px #0001;
  max-width: 320px;
  min-width: 180px;
  width: fit-content;
}
#ui .slider-group label {
  display: block;
  margin-bottom: 0;
}
#ui .slider-group label > br {
  display: block;
  margin-bottom: 6px;
  content: "";
}
#ui .slider-group input[type="range"] {
  width: 200px;
  vertical-align: middle;
  margin-top: 0;
}
#ui .slider-group span {
  display: inline-block;
  min-width: 24px;
  text-align: right;
  margin-left: 2px;
  color: #ff7f7f;
  font-weight: bold;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #f8f6f0;
}
body {
  min-height: 100vh;
  font-family: 'Kosugi Maru', 'Rounded Mplus 1c', 'Noto Sans JP', 'Arial Rounded MT Bold', 'Arial', sans-serif;
  text-align: center;
}

.mochi-title {
  font-family: 'Kosugi Maru', 'Arial Rounded MT Bold', 'Arial', sans-serif;
  font-size: 2.8rem;
  letter-spacing: 0.1em;
  text-align: center;
  margin: 1em 0 0.5em 0;
  color: #ff7f7f;
  text-shadow: 0 2px 8px #fff6, 0 1px 0 #fff;
  font-weight: normal;
}

.subtitle {
  font-size: 1.05rem;
  color: #ff7f7f;
  text-align: center;
  margin-top: 6px;
  margin-bottom: 1em;
  font-weight: 600;
}

#ui {
  text-align: center;
  margin-bottom: 32px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#ff9fcf;
  color:#fff;
  padding:10px 18px;
  min-height:3em;
  border-radius:999px;
  cursor:pointer;
  font-weight:bold;
  outline: none;
  border: none;
  box-sizing: border-box;
}
.btn input{display:none}

#canvas {
  display: block;
  margin: 24px auto 32px auto;
  max-width: 100vw;
  height: auto;
  z-index: 0;
  touch-action: none;
}
@media (max-width: 600px) {
        #ui, #ui * {
          box-sizing: border-box;
          max-width: 100%;
        }
        body {
          overflow-x: hidden;
        }
      #ui .slider-group input[type="range"]:focus {
        outline: none;
        box-shadow: none;
      }
    #ui .slider-group {
      margin: 8px 0 4px 0;
    }
    #ui p {
      margin: 10px 0 6px 0;
      font-size: 1em;
    }
  html, body {
    font-size: 18px;
    padding: 0;
    margin: 0;
    background: #f8f6f0;
  }
  body {
    padding: 4vw 2vw 6vw 2vw;
    box-sizing: border-box;
  }
  .mochi-title {
    font-size: 2.2rem;
    margin: 1em 0 0.5em 0;
  }
  #ui {
    width: 100%;
    max-width: 100vw;
    border-radius: 18px;
    background: #fff9;
    box-shadow: 0 2px 16px #0002;
    padding: 4vw 2vw 3vw 2vw;
    margin-bottom: 24px;
  }
  #ui .slider-group {
    padding: 16px 3vw;
    max-width: 100vw;
    min-width: 0;
    width: 100vw;
    font-size: 1.15rem;
    border-radius: 0;
    background: none;
    box-shadow: none;
  }
  #ui .slider-group label {
    font-size: 1.1em;
  }
  #ui .slider-group input[type="range"] {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
    height: 38px;
    margin: 0;
    touch-action: pan-x;
  }
  #ui .slider-group span {
    min-width: 24px;
    font-size: 1.2em;
    margin-right: 0.5em;
  }
  #canvas {
    width: 100vw;
    max-width: 100vw;
    margin: 0 0 1em 0;
    border-radius: 16px;
    /* allow transparent areas in the image to show through */
    background: transparent;
    box-shadow: 0 2px 8px #0001;
    box-sizing: border-box;
    position: relative;
    left: 50%;
    transform: translateX(-50%);
  }

  /* Fix footer vw overflow when body has horizontal padding on mobile */
  #footer {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    left: 0 !important;
    transform: none !important;
    padding-left: 2vw !important;
    padding-right: 2vw !important;
  }
  .btn {
    font-size: 1.2em;
    padding: 18px 0;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    border-radius: 999px;
    margin-bottom: 10px;
  }
}

/* --- サイド広告（PC向け） ---
   サイズは既存ページに合わせる：幅300px / max-height:800px
   表示は大画面のみ（例：幅1000px以上）で、レイアウトを崩さないよう固定表示にする
*/
.game-ad-side {
  display: none;
}
@media (min-width: 1100px) {
  .game-ad-side {
    display: block;
    width: 300px;
    max-height: 800px;
    /* ページ内の右上に配置（スクロール追従しない） */
    position: absolute;
    top: 20px;
    right: 20px;
    box-sizing: border-box;
    background: #f8f6f0;
    border-radius: 12px;
    overflow: auto;
    padding: 10px;
    font-size: 0.95rem;
    color: #333;
    z-index: 1000;
  }
}

/* デスクトップで広告分の領域を確保し、キャンバスが広告と重ならないようにする */
@media (min-width: 1000px) {
  #canvas {
    max-width: calc(100vw - 340px); /* 300px広告 + 20px gap each side */
    box-sizing: border-box;
  }
}

/* ドラッグ中にカーソル位置へ表示する手の画像 */
#drag-hand {
  position: fixed;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: none;
  z-index: 3000;
  user-select: none;
}

@media (max-width: 600px) {
  #drag-hand { width: 44px; height: 44px; }
}

/* PCでドラッグ中にマウスカーソルを非表示にする */
body.hide-cursor, body.hide-cursor * {
  cursor: none !important;
}

/* トグルはモバイルでは非表示（PCのみ表示） */
@media (max-width: 700px) {
  #show-hand-toggle-wrapper { display: none !important; }
}

/* 画像位置調整パッド */
.position-pad {
  width: 140px;
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(180deg,#fff 0%,#fff6 100%);
  box-shadow: 0 2px 8px #0001;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.position-pad:after{
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 100%; height: 1px; background: #ffd6e6; transform: translateX(-50%);
  z-index: 0;
}
.position-pad:before{
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 100%; background: #ffd6e6; transform: translateY(-50%);
  z-index: 0;
}
.position-pad .pad-knob{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ff7f7f;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  position: absolute;
  transform: translate(-50%, -50%);
  touch-action: none;
  z-index: 1;
}
@media (max-width: 600px) {
  .position-pad { width: 120px; height: 120px; }
  .position-pad .pad-knob { width: 16px; height: 16px; }
}