/* =============================================
   AIじゃんけん勝ち抜きバトル — ai-janken.css
   レイアウト：カメラ全面、キャラ中央上部フロート
   ============================================= */

.aij-root, .aij-root * { box-sizing: border-box; margin: 0; padding: 0; }

.aij-root {
  --main:         #1e3a5f;
  --main-light:   #2d5a8f;
  --accent:       #d4af37;
  --accent-light: #f4cf5f;
  --base:         #ffffff;
  --border:       rgba(255,255,255,0.3);
  --text-dark:    #1e3a5f;
  --shadow:       0 4px 16px rgba(0,0,0,0.25);
  --shadow-lg:    0 8px 30px rgba(0,0,0,0.35);

  font-family: 'M PLUS Rounded 1c', 'BIZ UDGothic', sans-serif;
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0d1b2e;
  color: #fff;
  position: relative;
}

/* ===== ヘッダー ===== */
#jk-header {
  background: var(--main);
  border-bottom: 3px solid var(--accent);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  height: 48px;
  z-index: 10;
}
#jk-header h1 {
  font-size: clamp(12px,1.8vw,17px); font-weight: 700; color: #fff;
  border: none !important; padding: 0 !important; margin: 0 !important;
}
.jk-stats { display: flex; gap: 18px; }
.jk-stat  { text-align: center; }
.jk-stat-label { font-size: 9px; opacity: 0.55; letter-spacing: 0.04em; }
.jk-stat-value { font-size: 17px; font-weight: 700; color: var(--accent); line-height: 1.1; }
.jk-total { font-size: 9px; opacity: 0.45; }

/* ===== ステージバー ===== */
#jk-progress-bar {
  background: rgba(10,20,40,0.75);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  padding: 4px 14px;
  display: flex;
  gap: 3px;
  align-items: center;
  flex-shrink: 0;
  overflow-x: auto;
  height: 36px;
  z-index: 10;
}
.jk-stage-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.3);
  flex-shrink: 0; overflow: hidden;
  background: rgba(255,255,255,0.06);
  transition: all 0.3s;
  position: relative;
}
.jk-stage-dot img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: none; }
.jk-stage-dot.unlocked img { display: block; }
.jk-stage-dot.current { border-color: var(--accent); box-shadow: 0 0 10px var(--accent); transform: scale(1.25); }
.jk-stage-dot.defeated img { display: block; filter: grayscale(1) brightness(0.35); }
.jk-stage-dot.defeated { border-color: rgba(255,255,255,0.08); }
.jk-stage-arrow { color: rgba(255,255,255,0.2); font-size: 9px; flex-shrink: 0; }

/* ===== アリーナ（背景画像が見える） ===== */
#jk-arena {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.75) 0%, rgba(240,242,245,0.82) 100%),
    url('https://ict-primaryschool-juniorhighschool.com/wp-content/uploads/2026/05/ChatGPT-Image-2026%E5%B9%B45%E6%9C%8823%E6%97%A5-16_50_50.jpg')
    center center / cover no-repeat;
}

/* カメラ映像：中央に小さく */
#jk-video {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scaleX(-1);
  width: min(80%, 700px);
  height: auto;
  aspect-ratio: 4/3;
  border-radius: 20px;
  border: 3px solid var(--accent);
  box-shadow: 0 8px 32px rgba(30,58,95,0.25);
  display: block;
  z-index: 1;
  object-fit: cover;
}
#jk-canvas {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scaleX(-1);
  width: min(80%, 700px);
  aspect-ratio: 4/3;
  border-radius: 20px;
  pointer-events: none;
  z-index: 2;
}

/* ===== キャラクター：カメラ上端・中央揃え（位置はJSで設定） ===== */
#jk-chara-float {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}
#jk-chara-info {
  text-align: center;
  background: rgba(10,20,40,0.7);
  padding: 3px 14px;
  border-radius: 20px;
  border: 1px solid rgba(212,175,55,0.5);
  backdrop-filter: blur(4px);
}
#jk-chara-round { font-size: 10px; opacity: 0.65; }
#jk-chara-name  { font-size: clamp(13px,2vw,18px); font-weight: 900; color: var(--accent); }

/* キャラ＋手：横並び・下揃え・左揃え（組として中央揃えしない） */
#jk-chara-body {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 10px;
}

#jk-chara-img {
  height: clamp(130px, 30vh, 280px);
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 6px 24px rgba(0,0,0,0.55));
  display: block;
}
#jk-chara-img.aij-shake  { animation: aijShake  0.45s ease; }
#jk-chara-img.aij-bounce { animation: aijBounce 0.45s ease; }
@keyframes aijShake {
  0%,100%{ transform: translateX(0); }
  20%{ transform: translateX(-12px); } 40%{ transform: translateX(12px); }
  60%{ transform: translateX(-8px); }  80%{ transform: translateX(8px); }
}
@keyframes aijBounce {
  0%,100%{ transform: translateY(0); }
  40%{ transform: translateY(-20px); } 70%{ transform: translateY(-10px); }
}

/* キャラの手（キャラの右隣） */
#jk-chara-hand-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  padding-bottom: 4px;
}
#jk-chara-hand-wrap.show { opacity: 1; }
#jk-chara-hand-emoji {
  width: clamp(65px,10vw,110px);
  height: clamp(65px,10vw,110px);
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.6));
  display: block;
}
#jk-chara-hand-label {
  background: rgba(10,20,40,0.85);
  color: #fff;
  font-size: clamp(11px,1.6vw,16px);
  font-weight: 900;
  padding: 3px 12px;
  border-radius: 14px;
  border: 2px solid var(--accent);
  white-space: nowrap;
}

/* ===== 余白エリアのPCの手（カメラ左右） ===== */
.jk-side-hand {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s;
}
.jk-side-hand.hidden { display: none !important; }

#jk-side-hand-left  { left: 16px; }
#jk-side-hand-right { right: 16px; }

.jk-side-hand img {
  width: clamp(80px, 12vw, 160px);
  height: clamp(80px, 12vw, 160px);
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
}
.jk-side-hand-label {
  background: rgba(10,20,40,0.8);
  color: #fff;
  font-size: clamp(12px,2vw,18px);
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 16px;
  border: 2px solid var(--accent);
  white-space: nowrap;
  backdrop-filter: blur(4px);
}

/* ===== じゃんけんコール（上部に表示） ===== */
#jk-call-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(32px,6vw,64px);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 0 30px rgba(212,175,55,0.9), 0 3px 8px rgba(0,0,0,0.9);
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s;
  white-space: nowrap;
  background: rgba(10,20,40,0.55);
  padding: 6px 24px;
  border-radius: 30px;
  backdrop-filter: blur(4px);
}
#jk-call-overlay.show { opacity: 1; }

/* ===== 勝敗バナー ===== */
#jk-result-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.85);
  transition: opacity 0.15s, transform 0.15s;
}
#jk-result-banner.show { opacity: 1; transform: scale(1); }
#jk-result-banner-text {
  font-size: clamp(44px,9vw,90px);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 4px 24px rgba(0,0,0,0.8);
}
#jk-result-banner-sub {
  font-size: clamp(14px,2.5vw,22px);
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  background: rgba(0,0,0,0.5);
  padding: 4px 16px;
  border-radius: 12px;
}
.b-win  { color: #6ef08a; }
.b-lose { color: #ff7070; }
.b-draw { color: #ffd166; }
.b-foul { color: #ff7070; }

/* ===== 手判定ラベル（カメラ左上フロート） ===== */
#jk-my-hand-label {
  position: absolute;
  top: 14px;
  left: calc(50% - min(80%, 700px) / 2 + 10px);
  font-size: clamp(13px,2vw,18px);
  font-weight: 900;
  padding: 5px 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.88);
  color: var(--main);
  border: 2px solid rgba(255,255,255,0.5);
  z-index: 20;
  white-space: nowrap;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow);
}
#jk-my-hand-label.detected {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(212,175,55,0.5);
}

/* ===== ボタン（最下部フロート） ===== */
#jk-bottom-bar {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 12px;
  z-index: 20;
  flex-wrap: nowrap;
}
.jk-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 30px;
  font-size: 15px; font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
}
.jk-btn:active   { transform: scale(0.95); }
.jk-btn:disabled { opacity: 0.35 !important; cursor: not-allowed; }
.jk-btn-gold {
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  color: var(--main);
  font-size: 17px; padding: 12px 32px;
  box-shadow: 0 4px 14px rgba(212,175,55,0.45);
}
.jk-btn-gold:hover:not(:disabled) { box-shadow: 0 6px 20px rgba(212,175,55,0.6); transform: translateY(-2px); }
.jk-btn-ghost {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 2px solid rgba(255,255,255,0.4);
  backdrop-filter: blur(4px);
}
.jk-btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.25); }

/* ===== ゲームオーバー ===== */
#jk-gameover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5,12,25,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 55;
  text-align: center;
  padding: 30px;
  backdrop-filter: blur(6px);
}
#jk-gameover-overlay.hidden { display: none !important; }
#jk-gameover-overlay h2  { font-size: 28px; font-weight: 900; color: #ff7070; border: none !important; padding: 0 !important; margin: 0 !important; }
#jk-gameover-streak      { font-size: 48px; font-weight: 900; color: var(--accent); }
#jk-gameover-msg         { font-size: 14px; opacity: 0.7; }
#jk-gameover-chara       { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid rgba(255,100,100,0.5); display: none; box-shadow: var(--shadow); }

/* ===== クリア ===== */
#jk-clear-overlay {
  position: absolute;
  inset: 0;
  background: rgba(5,12,25,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 55;
  text-align: center;
  padding: 30px;
  backdrop-filter: blur(6px);
  animation: aijClearIn 0.5s ease;
}
@keyframes aijClearIn { from { opacity:0; transform:scale(0.9); } to { opacity:1; transform:scale(1); } }
#jk-clear-overlay.hidden { display: none !important; }
#jk-clear-overlay h2 { font-size: 36px; font-weight: 900; color: var(--accent); border: none !important; padding: 0 !important; margin: 0 !important; }
#jk-clear-count      { font-size: 52px; font-weight: 900; color: var(--accent-light); }
.jk-clear-stars      { font-size: 48px; letter-spacing: 8px; color: var(--accent); }
.jk-clear-sub        { font-size: 14px; opacity: 0.7; }

/* ===== ローディング ===== */
#jk-loading {
  position: absolute;
  inset: 0;
  background: rgba(5,12,25,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 70;
  font-size: 14px;
  backdrop-filter: blur(4px);
}
#jk-loading.hidden { display: none !important; }
.jk-spinner {
  width: 44px; height: 44px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: aijSpin 0.8s linear infinite;
}
@keyframes aijSpin { to { transform: rotate(360deg); } }

/* ===== スマホ ===== */
@media (max-width: 600px) {
  #jk-chara-img { height: clamp(100px,22vh,180px); }
  #jk-my-hand-label { font-size: 15px; bottom: 56px; }
}
