/* ============================================================
   PLAYFUL VERSION — 遊び要素の追加スタイル
   本番(main)には含まれない実験ブランチ専用のスタイル。
   ============================================================ */

/* ---------- 1. ヒーローのドリブル演出（カーソル追従ボール） ---------- */
/* 縦スワイプは通常のスクロール、横方向の指の動きはボール追従に使う */
.hero {
  touch-action: pan-y;
}

.hero-dribble {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  display: block;
}

/* ---------- 2. PKチャレンジ（キーパーとの駆け引きミニゲーム） ---------- */
.policy-game-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 9px 18px;
  border: 1px solid rgba(247, 245, 237, 0.42);
  border-radius: 999px;
  background: transparent;
  color: var(--chalk);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 200ms ease, background-color 200ms ease;
}

.policy-game-link:hover {
  border-color: var(--yellow);
  background: rgba(189, 161, 92, 0.14);
}

.pk-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 17, 15, 0.62);
  backdrop-filter: blur(5px);
}

.pk-modal[hidden] {
  display: none;
}

.pk-widget {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(380px, 100%);
  padding: 20px 20px 22px;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  text-align: center;
}

.pk-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: rgba(14, 31, 22, 0.06);
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.pk-close:hover {
  color: var(--ink);
  background: rgba(14, 31, 22, 0.12);
}

.pk-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
  padding-right: 40px;
}

.pk-title {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--green);
  text-align: left;
}

.pk-character-select {
  display: flex;
  gap: 6px;
}

.pk-character-select button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.55;
}

.pk-character-select button.is-active {
  opacity: 1;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(0, 84, 46, 0.15);
}

/* 夜のスタジアム風ピッチ */
.pk-stage {
  position: relative;
  width: 100%;
  height: clamp(250px, 44vh, 330px);
  border: 0;
  padding: 0;
  background: linear-gradient(180deg, #0b241a 0%, #123c28 46%, #1c5537 100%);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ペナルティスポットのライン */
.pk-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 7%;
  width: 46%;
  height: 10%;
  transform: translateX(-50%);
  border: 2px solid rgba(247, 245, 237, 0.16);
  border-radius: 50%;
}

.pk-pitch {
  position: absolute;
  inset: 0;
  display: block;
}

.pk-goal {
  position: absolute;
  top: 9%;
  left: 50%;
  width: 78%;
  height: 46%;
  transform: translateX(-50%);
  border: 5px solid #f2f0e6;
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
}

.pk-net {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, rgba(242, 240, 230, 0.2) 0 1px, transparent 1px 9px),
    repeating-linear-gradient(90deg, rgba(242, 240, 230, 0.2) 0 1px, transparent 1px 9px);
  transform-origin: top center;
  will-change: transform;
}

.pk-keeper {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(34px, 9vw, 44px);
  line-height: 1;
  user-select: none;
  will-change: transform;
  animation: pk-keeper-wobble 1.6s ease-in-out infinite alternate;
}

@keyframes pk-keeper-wobble {
  from {
    margin-bottom: 0;
  }
  to {
    margin-bottom: 5px;
  }
}

.pk-keeper.is-tired {
  filter: saturate(0.75);
}

.pk-keeper.is-tired::after {
  content: "💦";
  position: absolute;
  top: -12px;
  right: -16px;
  font-size: 16px;
}

/* ねらいの的（左右に往復する） */
.pk-marker {
  position: absolute;
  top: 46%;
  left: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  border: 3px solid #ffd75e;
  box-shadow: 0 0 14px rgba(255, 215, 94, 0.85);
  transition: opacity 120ms ease;
  will-change: left, top;
}

.pk-marker::after {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: #ffd75e;
}

.pk-ball {
  position: absolute;
  bottom: 9%;
  left: 50%;
  width: 42px;
  height: 42px;
  margin-left: -21px;
  font-size: 38px;
  line-height: 1;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.45));
  user-select: none;
  will-change: transform;
}

.pk-kicker {
  position: absolute;
  bottom: 7%;
  left: calc(50% + 28px);
  font-size: 46px;
  line-height: 1;
  user-select: none;
  will-change: transform;
}

/* ゴール！などの大きな掛け声 */
.pk-callout {
  position: absolute;
  top: 66%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(26px, 7vw, 38px);
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
  pointer-events: none;
}

.pk-callout.is-golazo {
  color: #ffd75e;
}

.pk-callout.is-save {
  color: #ff9d8a;
}

/* 連続8ゴール以上のフィーバーモード：スタジアムが金色に */
.pk-stage.is-fever {
  background: linear-gradient(180deg, #2b2410 0%, #4a3d14 46%, #6b5a1c 100%);
  animation: pk-fever-pulse 700ms ease-in-out infinite alternate;
}

@keyframes pk-fever-pulse {
  from {
    box-shadow: inset 0 0 0 3px rgba(255, 200, 40, 0.5);
  }
  to {
    box-shadow: inset 0 0 26px 6px rgba(255, 200, 40, 0.55);
  }
}

.pk-level {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  font-size: 12px;
  font-weight: 800;
  color: var(--green);
  background: rgba(255, 255, 255, 0.85);
  padding: 3px 10px;
  border-radius: 999px;
}

/* スコア行は1行固定。文字量が変わってもステージの位置がぶれないようにする */
.pk-score {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
  white-space: nowrap;
}

.pk-count-wrap {
  display: flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-display);
}

.pk-count {
  font-size: 34px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
  transition: transform 120ms ease;
}

.pk-count.is-bump {
  transform: scale(1.35);
}

.pk-count-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.pk-current-rank {
  font-size: 13px;
  font-weight: 800;
  color: var(--green);
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pk-best {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pk-best b {
  color: var(--yellow);
  font-size: 15px;
}

/* ヒントは常に2行分の高さを確保し、メッセージの長短で高さが変わらないようにする */
.pk-hint {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: var(--muted);
  height: 37px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pk-hint.is-milestone {
  color: var(--green);
  font-weight: 800;
}

.pk-hint.is-miss {
  color: var(--red);
  font-weight: 800;
}

.pk-confetti {
  position: fixed;
  z-index: 81;
  border-radius: 3px;
  pointer-events: none;
  will-change: transform, opacity;
  animation: pk-confetti-burst 900ms ease-out forwards;
}

@keyframes pk-confetti-burst {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--pk-dx), var(--pk-dy)) rotate(var(--pk-rot)) scale(0.6);
    opacity: 0;
  }
}

/* スマホでは全画面でゲームを表示する */
@media (max-width: 640px) {
  .pk-modal {
    padding: 0;
  }

  .pk-widget {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    border: 0;
    justify-content: center;
    /* 万一収まらない端末でもスコアが見切れず、スクロールで届くように */
    overflow-y: auto;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  /* vhはアドレスバー分を含んでしまい下が見切れるため、
     実際に見えている高さ基準のsvhを使う（非対応端末はvhにフォールバック） */
  .pk-stage {
    flex-shrink: 0;
    height: min(46vh, 420px);
  }

  @supports (height: 1svh) {
    .pk-stage {
      height: min(50svh, 420px);
    }
  }

  .pk-score,
  .pk-hint,
  .pk-header {
    flex-shrink: 0;
  }

  .pk-close {
    top: max(14px, env(safe-area-inset-top));
    right: 16px;
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pk-confetti {
    animation: none;
    opacity: 0;
  }

  .pk-stage.is-fever,
  .pk-keeper {
    animation: none;
  }
}
