* { box-sizing: border-box; }

/* iPhoneでダブルタップズームさせない(ピンチズームは残す)。 */
html {
  touch-action: manipulation;
}

:root {
  --bg-deep: #0a1330;
  --bg-mid: #1c3a63;
  --accent: #3aa0ff;
  --accent-soft: #7be0ff;
  --accent-bg: #eaf7ff;
  --pink: #ff5fa8;
  --text: #eef2ff;
  --text-muted: #9aa6c8;
}

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  background: var(--bg-deep);
  font-family: "M PLUS Rounded 1c", "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* --- サウンド操作 --- */
.sound-controls {
  position: fixed; top: 10px; right: 10px; z-index: 40;
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.mute-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: rgba(255,255,255,.12); color: var(--text); font-size: 16px; cursor: pointer;
}
.mute-btn.settings-btn { width: 28px; height: 28px; font-size: 13px; opacity: .85; }
.sound-panel {
  background: rgba(10,16,40,.95); border: 1px solid rgba(255,255,255,.15);
  border-radius: 10px; padding: 10px 12px; width: 190px;
}
.sound-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.sound-row:last-child { margin-bottom: 0; }
.sound-row-label { font-size: 11px; width: 44px; }
.sound-mute-btn { width: 24px; height: 24px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: var(--text); font-size: 12px; cursor: pointer; }
.sound-volume { flex: 1; }

/* --- 常時フッター --- */
.site-footer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: rgba(6,10,28,.85); backdrop-filter: blur(4px);
  padding: 6px 12px; text-align: center;
}
.footer-links, .footer-meta {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 4px;
  font-size: 10px; color: var(--text-muted); margin: 2px 0;
}
.footer-links a, .footer-meta a { color: var(--text-muted); text-decoration: none; }
.footer-links a:hover, .footer-meta a:hover { color: var(--accent-soft); }
.version-link {
  font-size: 10px; color: var(--text-muted); text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
.version-link:hover { color: var(--accent-soft); }

/* --- 画面共通 --- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 16px; padding-bottom: 96px; overflow-y: auto;
}
.panel {
  width: 100%; max-width: 420px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08); border-radius: 16px;
  padding: 24px; text-align: center;
}
.panel h1 { margin: 0 0 6px; font-size: 22px; }
.hint { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }

.link-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 16px; }
.rules-link,
.link-row .home-link,
.share-button {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 12px; border: 2px solid var(--accent-soft); border-radius: 999px;
  background: #ffffff10; color: var(--accent-soft); font-size: 12px; font-weight: 700;
  font-family: inherit; text-decoration: none; cursor: pointer;
}
.rules-link:hover, .link-row .home-link:hover, .share-button:hover {
  border-color: var(--accent); background: rgba(58,160,255,.15);
}

label { display: block; font-size: 12px; color: var(--text-muted); text-align: left; margin-bottom: 4px; }
#nickname-input {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: var(--text); font-size: 14px; margin-bottom: 14px;
}
.primary {
  width: 100%; font-size: 16px; font-weight: 800; color: #0a1330;
  background: linear-gradient(180deg,var(--accent-soft),var(--accent));
  border: none; border-radius: 999px; padding: 12px; cursor: pointer;
  box-shadow: 0 4px 0 #1c6fb0; margin-bottom: 10px;
}
.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #1c6fb0; }
.join-error { color: #ff8a8a; font-size: 12px; margin-bottom: 8px; }

.ranking-groups { margin-top: 16px; }
.ranking-group-title { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.ranking { display: flex; flex-direction: column; gap: 4px; }
.ranking-row {
  display: flex; justify-content: space-between; font-size: 13px;
  padding: 6px 10px; border-radius: 8px; background: rgba(255,255,255,.04);
}
.ranking-row .rank { color: var(--accent-soft); font-weight: 800; width: 22px; }
.ranking-empty { font-size: 12px; color: var(--text-muted); }

/* --- 法務モーダル --- */
.legal-modal { position: fixed; inset: 0; z-index: 100; }
.legal-modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.legal-modal-box {
  position: absolute; inset: 4% 6%; background: #fff; border-radius: 12px; overflow: hidden;
  display: flex; flex-direction: column;
}
.legal-modal-close {
  position: absolute; top: 8px; right: 10px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(0,0,0,.08); cursor: pointer; font-size: 14px;
}
.legal-modal-frame { flex: 1; width: 100%; border: none; }

/* --- 通信エラー(切断)バナー --- */
.disconnect-banner {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
  background: rgba(6,10,28,.9); padding: 16px;
}
.disconnect-box { text-align: center; max-width: 320px; }
.disconnect-title { font-size: 15px; font-weight: 800; margin-bottom: 4px; }

/* --- ゲーム画面 --- */
#game-screen { padding: 0; }
#game-canvas { position: absolute; inset: 0; display: block; }

#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; font-size: 13px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  background: rgba(255,255,255,.12); border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
#hud .score { font-size: 18px; }
#hud .quota-wrap { flex: 1; min-width: 140px; max-width: 240px; }
#hud .quota-bar-bg { background: rgba(255,255,255,.15); border-radius: 6px; height: 9px; overflow: hidden; }
#hud .quota-bar-fill { background: linear-gradient(90deg,var(--accent),var(--accent-soft)); height: 100%; width: 0%; transition: width .15s ease; }
#hud .quota-label { font-size: 9px; opacity: .8; margin-bottom: 2px; }
#hud .lives { font-size: 15px; letter-spacing: 2px; }
#hud .combo { font-size: 11px; opacity: .85; }

#hand-guide {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  display: flex; gap: 40px; pointer-events: none;
}
.hand-block { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hand-label { font-size: 10px; color: #cdd6f4; opacity: .8; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.hand-fingers { display: flex; gap: 5px; }
.finger-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.25);
  transition: transform .1s ease, box-shadow .1s ease;
}
.finger-dot.active { transform: scale(1.5); box-shadow: 0 0 10px 2px currentColor; }
.active-finger-name {
  position: absolute; left: 50%; bottom: 46px; transform: translateX(-50%);
  font-size: 11px; text-shadow: 0 1px 3px rgba(0,0,0,.7); min-height: 14px;
}

#stage-toast {
  position: absolute; top: 46%; left: 50%; transform: translate(-50%,-50%) scale(.8);
  font-size: 28px; font-weight: 900; text-shadow: 0 2px 8px rgba(0,0,0,.7);
  opacity: 0; pointer-events: none; transition: opacity .25s ease, transform .25s ease;
}
#stage-toast.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

/* --- リザルト画面 --- */
.stat-grid {
  display: grid; grid-template-columns: repeat(2,auto); gap: 6px 18px;
  font-size: 13px; background: rgba(255,255,255,.06); border-radius: 10px;
  padding: 14px 22px; text-align: left; margin: 0 auto 12px;
}
.stat-grid b { color: var(--accent-soft); }
.finger-report { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; }
.finger-report .fbox {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #0a1330;
}

.rotate-overlay {
  position: fixed; inset: 0; z-index: 120; background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 16px; padding: 20px;
}

/* --- 法務ページ用の装飾クラス(rules.html等から参照) --- */
.rules-hero { text-align: center; margin-bottom: 20px; }
.figure-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 16px 0; }
.status-chip-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 10px 0; }
