* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  /* 画面下部の広告スペース確保用の上げ底。広告サイズに合わせて調整可。 */
  --ad-bottom: 120px;
}
html, body {
  width: 100%; height: 100%;
  background: #111;
  overflow: hidden;
  font-family: "Yu Gothic", "Meiryo", sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
}
#wrap {
  position: relative;
  width: 100vw; height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-bottom: var(--ad-bottom);
}
#game {
  /* 9:16 縦長。広告分を引いた高さに収まるようスケール */
  width: min(100vw, calc((100dvh - var(--ad-bottom)) * 0.5625));
  height: min(177.78vw, calc(100dvh - var(--ad-bottom)));
  background: linear-gradient(#7ec8f0, #c8e8ff 60%, #fde9a6);
  display: block;
  cursor: crosshair;
  touch-action: none;
  /* GPUコンポジット層に分離して再描画コスト削減 */
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}
#overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  bottom: var(--ad-bottom);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.screen {
  pointer-events: auto;
  background: rgba(0,0,0,0.8);
  padding: 3vh 4vh;
  border-radius: 16px;
  text-align: center;
  border: 2px solid #ff8fa3;
  box-shadow: 0 0 40px rgba(255,143,163,0.5);
  max-width: min(80%, 50vh);   /* キャンバス(56.25vh幅)からはみ出ないように */
  max-height: 90%;
  overflow: visible;
  box-sizing: border-box;
}
.screen h1 {
  font-size: 4.5vh;
  color: #ff8fa3;
  margin-bottom: 2vh;
}
.screen p {
  font-size: 2.2vh;
  line-height: 1.6;
  margin-bottom: 2.4vh;
}
.screen .comment {
  font-size: 2.6vh;
  color: #ffe766;
  margin-bottom: 2.4vh;
  font-weight: bold;
}
#result-images {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin-bottom: 2.4vh;
  min-height: 12vh;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow: hidden;
}
#result-images img.hedoban {
  height: 12vh;
  width: auto;
  margin: 0 -3vh;   /* 重ねて詰める */
}
#result-images img.wa {
  height: 14vh;
  width: auto;
  animation: slideIn 500ms ease-out both;
}
@keyframes slideIn {
  0%   { transform: translateY(40px); opacity: 0; }
  100% { transform: translateY(0);    opacity: 1; }
}

.screen button {
  font-size: 2.6vh;
  padding: 1.4vh 4vh;
  background: #ff8fa3;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  margin: 0.5vh;
  line-height: 1.25;
}
.screen button:hover { background: #ffa5b8; }
.screen .btn-sub {
  display: block;
  font-size: 1.7vh;
  font-weight: normal;
  color: #fff5cc;
  margin-top: 0.3vh;
}
#endless-btn { background: #c97aff; }
#endless-btn:hover { background: #d99bff; }
.hidden { display: none !important; }

/* 葵ちゃんオーバーレイ（コンボ時） */
#aoi-overlay {
  position: absolute;
  left: 50%;
  top: 42%;
  width: 40vh;
  max-width: 60vw;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 0 30px rgba(255, 180, 255, 0.9));
  transition: none;
}
#aoi-overlay.show {
  animation: aoiFade 1400ms ease-out forwards;
}
@keyframes aoiFade {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  15%  { transform: translate(-50%, -50%) scale(1.25); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1.4); opacity: 0; }
}

/* スタート画面 クレジット＆リンク */
.start-credits {
  margin-top: 1.8vh;
  text-align: center;
}
.start-credits .credit-line {
  font-size: 1.6vh;
  color: #fff;
  margin-bottom: 0.6vh;
  line-height: 1.4;
}
.start-credits .credit-line a {
  color: #fff;
  text-decoration: none;
}
.start-credits .credit-line a:hover {
  color: #fff;
  text-decoration: underline;
}
.start-credits .info-link {
  display: inline-block;
  font-size: 1.8vh;
  color: #fff;
  text-decoration: none;
  padding: 0.6vh 1.5vh;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  margin-top: 0.4vh;
}
.start-credits .info-link:hover {
  background: rgba(160,212,255,0.15);
  color: #fff;
}
