/* スネークバトル（party/snake） 独自スタイル。共通は ../common/party.css。
   テーマ色は緑系（docs/party-snake-spec.md §4）。
   盤はCanvas1枚なので、CSSの仕事は「盤を画面幅いっぱいの正方形にする」ことと
   その上下のわずかな情報表示だけ。 */

:root {
  --party-accent: #2fa96b;
  --party-accent-dark: #1f7d4e;
  --party-accent-soft: #ddf3e7;
  --party-bg: #eefaf3;
  --party-card: #ffffff;
  --snake-field: #f7fcf9;
  --snake-wall: #b9d5c6;
  --snake-ink: #14432c;
}

.snake-game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* 盤・情報・みんなの様子をひとかたまりにして画面の真ん中へ置く
     （盤は横幅で決まるので、縦長のスマホでは上下に余白が出る。その余白を割らない） */
  justify-content: center;
  background: var(--party-bg);
  overflow: hidden;
  /* 盤の上でスワイプするので、ブラウザのスクロール/引っぱり更新に取られないようにする */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: calc(env(safe-area-inset-top) + 6px) 8px calc(env(safe-area-inset-bottom) + 6px);
  box-sizing: border-box;
}

/* ---- 上の情報バー ---- */
.snake-hud {
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 4px 6px;
  box-sizing: border-box;
  font-size: 14px;
  font-weight: 800;
  color: var(--snake-ink);
}

.snake-hud__item {
  white-space: nowrap;
}

.snake-hud__time {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  color: var(--party-accent-dark);
}

.snake-hud__time.is-sudden {
  color: #d1442f;
  animation: snake-blink 0.8s ease-in-out infinite;
}

@keyframes snake-blink {
  50% { opacity: 0.35; }
}

/* ---- 盤（正方形。幅と高さの小さいほうに合わせる） ---- */
.snake-stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  /* スワイプは盤の全面で受ける。touch-actionは継承しないので、受け口にも書く */
  touch-action: none;
}

/* 盤ぴったりの入れ物。大きさはJSが決める（正方形）ので、演出の重ね置きが盤からはみ出さない */
.snake-board {
  position: relative;
}

#field {
  display: block;
  border-radius: 14px;
  background: var(--snake-field);
  box-shadow: 0 4px 0 rgba(20, 67, 44, 0.15);
  touch-action: none;
}

/* ---- 盤に重ねる演出（ラウンド紹介・カウントダウン・サドンデス告知） ---- */
.snake-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  background: rgba(238, 250, 243, 0.88);
  border-radius: 14px;
  pointer-events: none;
}

.snake-overlay--flash {
  background: rgba(255, 236, 230, 0.86);
}

.snake-intro-round {
  margin: 0;
  font-size: 1.1rem;
  color: var(--party-accent-dark);
  font-weight: 700;
}
.snake-intro-emoji {
  margin: 0;
  font-size: 4.5rem;
  line-height: 1;
}
.snake-intro-name {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--snake-ink);
}

.snake-count-num {
  margin: 0;
  font-size: 7rem;
  font-weight: 800;
  color: var(--party-accent);
  animation: snake-pop 0.9s ease-out;
}

@keyframes snake-pop {
  0% { transform: scale(0.4); opacity: 0; }
  55% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.snake-sudden-text {
  margin: 0;
  font-size: 2.2rem;
  font-weight: 800;
  color: #d1442f;
  animation: snake-pop 0.6s ease-out;
}
.snake-sudden-sub {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: #8c4a3a;
}

/* ---- 盤の下の一言（そうさ説明・おうえん） ---- */
.snake-hint {
  width: 100%;
  max-width: 560px;
  margin: 6px 0 0;
  min-height: 1.6em;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--party-accent-dark);
}

/* ---- 盤の下のみんなの様子（だれが何マスで、だれが星になったか） ---- */
.snake-players {
  list-style: none;
  width: 100%;
  max-width: 560px;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.snake-player {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 8px;
  border-radius: 12px;
  background: var(--party-card);
  font-size: 13px;
  font-weight: 700;
  color: var(--snake-ink);
}

.snake-player--me {
  outline: 2px solid var(--party-accent);
}

.snake-player--out {
  opacity: 0.45;
}

.snake-player__icon {
  font-size: 16px;
  line-height: 1;
}

.snake-player__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snake-player__len {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  color: #4d7a63;
}

/* ---- 結果・最終結果（全画面パネル） ---- */
.snake-panel {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 20px);
  box-sizing: border-box;
  background: var(--party-bg);
  overflow-y: auto;
}

.snake-panel-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--snake-ink);
}

.snake-rank-list,
.snake-final-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.snake-rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--party-card);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.98rem;
  font-weight: 700;
}

.snake-rank-item__rank {
  width: 2.2rem;
  flex-shrink: 0;
  color: var(--party-accent-dark);
}

.snake-rank-item__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snake-rank-item__sub {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: #6b8c7b;
}

.snake-rank-item__pt {
  flex-shrink: 0;
  width: 3.4rem;
  text-align: right;
  font-size: 0.9rem;
  color: var(--party-accent-dark);
}

/* ヘビの色をそのまま持ってくる小さな印（だれの行かひと目で分かるように） */
.snake-chip {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  flex-shrink: 0;
}

.snake-totals {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.snake-total-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.snake-total-name {
  width: 5.5rem;
  flex-shrink: 0;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.snake-total-barwrap {
  flex: 1;
  height: 12px;
  background: rgba(20, 67, 44, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.snake-total-bar {
  height: 100%;
  background: var(--party-accent);
  border-radius: 999px;
}

.snake-total-pt {
  width: 3rem;
  flex-shrink: 0;
  font-size: 0.85rem;
  text-align: right;
}

.snake-podium {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.snake-podium-item {
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--party-card);
}
.snake-podium-1 {
  background: #fff3c4;
  font-size: 1.45rem;
}
.snake-podium-2 {
  background: #eef1f0;
}
.snake-podium-3 {
  background: #ffe6cf;
}

.snake-final-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.snake-final-actions button {
  min-height: 56px;
  padding: 0 1.25rem;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
}

#btn-again {
  background: var(--party-accent);
  color: #fff;
  box-shadow: 0 4px 0 var(--party-accent-dark);
}

#btn-back-lobby {
  background: var(--party-card);
  color: var(--snake-ink);
  box-shadow: 0 4px 0 rgba(20, 67, 44, 0.15);
}

.snake-final-guestback {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-top: 4px;
  padding: 0 1.25rem;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  background: var(--party-card);
  color: var(--snake-ink);
  box-shadow: 0 4px 0 rgba(20, 67, 44, 0.15);
}
