/* ぬりつぶし陣取り（party/paint） 独自スタイル。共通は ../common/party.css。
   テーマ色は虹系（主役はプレイヤーの8色なので、地の色は淡く抑える）。 */

:root {
  --party-accent: #2fb6c9;
  --party-accent-dark: #17828f;
  --party-accent-soft: #e0f7fa;
  --party-bg: #f3fbfd;
  --party-card: #ffffff;
  --paint-empty: #f1eef8;
}

.paint-game {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--party-bg);
  overflow: hidden;
  /* 盤をなぞってもスクロールやピンチが始まらないようにする（塗り操作の前提） */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 8px)
    calc(env(safe-area-inset-bottom) + 8px) calc(env(safe-area-inset-left) + 8px);
}

/* ---- 上部（自分の色・のこり時間・自陣のマス数） ---- */
.paint-head {
  flex: 0 0 auto;
  text-align: center;
}

.paint-mycolor {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35em;
}

.paint-chip {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border-radius: 6px;
  background: #ccc;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}

.paint-timebar {
  height: 16px;
  margin: 8px 0 4px;
  border-radius: 999px;
  background: #dfe7ea;
  overflow: hidden;
}

.paint-timebar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--party-accent);
  transition: background-color 0.2s ease;
}

.paint-timebar-fill.is-hurry {
  background: #ff5252;
}

.paint-mycount {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #557;
}

/* ---- 盤 ---- */
.paint-boardwrap {
  position: relative; /* カウントダウンをこの中だけに重ねる */
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
}

.paint-board {
  display: block;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(20, 60, 80, 0.18);
  touch-action: none;
}

/* ---- オーバーレイ ---- */
.paint-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.2rem;
  text-align: center;
  box-sizing: border-box;
}

/* 盤の中だけに重なる（.paint-boardwrap が position:relative）。
   薄く透かすのは★の位置を先に見せたいから。上のヘッダーには重ならないので
   文字が文字に透けるゴーストは起きない */
.paint-countdown {
  position: absolute;
  background: rgba(243, 251, 253, 0.82);
}

.paint-countdown-num {
  margin: 0;
  font-size: 7rem;
  font-weight: 800;
  line-height: 1;
  color: var(--party-accent-dark);
  animation: paint-pop 0.9s ease-out;
}

.paint-countdown-hint {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #557;
}

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

/* 集計中は盤を隠さない（自分の塗り具合を見ながら待てるように薄く敷く） */
.paint-waiting {
  background: rgba(243, 251, 253, 0.55);
  justify-content: flex-start;
  padding-top: 30vh;
  pointer-events: none;
}

.paint-waiting-text {
  margin: 0;
  padding: 10px 20px;
  border-radius: 999px;
  background: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--party-accent-dark);
  box-shadow: 0 4px 14px rgba(20, 60, 80, 0.2);
}

/* ---- 結果 ---- */
/* 結果画面は完全に不透明にする。半透明だと背後のプレイ画面（自分の色の見出し）が
   ゴーストのように透けるうえ、盤の色が白幕で薄まって決着が読めなくなる。
   決着した塗り地図は #result-board に描き直して見せる */
.paint-result {
  background: var(--party-bg);
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: max(env(safe-area-inset-top), 16px);
}

/* 結果画面の中の縮小盤面（最終的な陣取りの地図） */
.paint-result-board {
  display: block;
  flex: 0 0 auto;
  height: min(36vh, 300px);
  width: auto; /* 幅は下のaspect-ratioから出す（canvasの属性値ではなく） */
  aspect-ratio: 12 / 16;
  margin: 4px 0 10px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(20, 60, 80, 0.18);
}

.paint-result-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #557;
}

.paint-result-winner {
  margin: 0 0 0.4rem;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.3;
}

.paint-result-bars {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paint-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.paint-bar-rank {
  flex: 0 0 2.2em;
  text-align: right;
  color: #557;
}

.paint-bar-name {
  flex: 0 0 5.5em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.paint-bar-wrap {
  flex: 1 1 auto;
  height: 20px;
  border-radius: 999px;
  background: var(--paint-empty);
  overflow: hidden;
}

.paint-bar {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s ease-out;
}

.paint-bar-count {
  flex: 0 0 4em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.paint-bar-note {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #7d7595;
}

.paint-result-actions {
  width: 100%;
  max-width: 420px;
  margin-top: 12px;
}

.paint-result-wait {
  margin: 12px 0 0;
  font-weight: 700;
  color: #7d7595;
}

/* 横持ち・低い画面では上部の文字を小さくして盤の面積を確保する */
@media (max-height: 620px) {
  .paint-mycolor {
    font-size: 1.15rem;
  }
  .paint-countdown-num {
    font-size: 5rem;
  }
}

/* ---- チーム戦 🔴vs🔵（docs/party-team-spec.md §2.3） ----
   チーム戦OFFのときは何も出ないので、従来の画面と同じ見た目のまま。 */

.paint-team-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 2px;
  cursor: pointer;
}
.paint-team-row input {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  accent-color: var(--party-accent);
}
.paint-team-row small {
  color: var(--party-muted, #7d7595);
}
.paint-team-note {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--party-muted, #7d7595);
}
.paint-team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.paint-team-chip {
  padding: 4px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.paint-team-shuffle {
  margin-top: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 14px;
  background: var(--party-accent-soft, #ede4ff);
  color: var(--party-accent-dark, #5a2fd6);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

/* 4人未満でONのまま始めたときの1行（ヘッダーの中） */
.paint-teamnote {
  margin: 2px 0 0;
  font-size: 12px;
  text-align: center;
  color: var(--party-muted, #7d7595);
}
.paint-teamnote:empty {
  display: none;
}

/* 結果のチーム成績（個人の内訳バーの上）。
   親は align-items:center の縦フレックスなので、幅を指定しないとバーが縮む */
.paint-teamzone {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.paint-teamzone:empty {
  display: none;
}
.paint-teamrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.paint-teamrow-name {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}
.paint-teamrow-num {
  flex-shrink: 0;
  min-width: 96px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
}
.paint-teamrow-num small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--party-muted, #7d7595);
}
.paint-teamzone-label {
  margin: 10px 0 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--party-muted, #7d7595);
}
