/* つみあげタワー（party/tsumi）。テーマ色は夕焼けオレンジ（仕様§5）。
 * 画面のいちばん奥に 3D の舞台（#world）を1枚敷き、その上にロビー・HUD・結果を重ねる。
 * UI は「おもちゃ」の見た目: 太めの角丸・テーマ色・押すと沈むボタン・白い太文字。 */

:root {
  --party-bg: #fff2e3;
  --party-bg2: #ffffff;
  --party-card: #ffffff;
  --party-accent: #e8843c;
  --party-accent-dark: #b3561a;
  --party-accent-soft: #ffe6cf;
  --party-text: #3a2214;
  --party-muted: #8a6a55;
  --party-line: #f3dcc6;
  --tsumi-ink: #3a2214;
  --tsumi-purple: #6b5bd6;
  --tsumi-yellow: #ffd25a;
  --band-h: 40vh;
}

body.tsumi-body {
  background: #3a2f62;
}

/* ===== 3D の舞台（全画面・いちばん奥） ===== */
.tsumi-world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* ===== ロビー: 上の帯に机の上が見え、その下にロビーのカード ===== */
.tsumi-body .party-app {
  position: relative;
  z-index: 2;
  padding-top: calc(var(--band-h) + env(safe-area-inset-top));
  pointer-events: none;
}
.tsumi-body .party-app > * {
  pointer-events: auto;
}
.tsumi-body .party-head {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: 0 4px 0 rgba(150, 70, 20, 0.28);
}
.tsumi-body .party-card {
  box-shadow: 0 5px 0 rgba(150, 70, 20, 0.22);
}
.tsumi-body .party-btn {
  border-radius: 999px;
  font-weight: 900;
}
.tsumi-body .party-btn:active {
  transform: translateY(3px);
}
.tsumi-body .tg-footer,
.tsumi-body [class*='tg-foot'] {
  position: relative;
  z-index: 2;
}
.tsumi-body.is-playing .tsumi-band,
.tsumi-body.is-opening .tsumi-band {
  display: none;
}
/* オープニングのあいだはロビー・共通ボタン・フッターを隠して、舞台だけを見せる */
.tsumi-body.is-opening .party-app,
.tsumi-body.is-opening .party-stamps-dock,
.tsumi-body.is-opening .party-playmenu,
.tsumi-body.is-opening .tsumi-game,
.tsumi-body.is-opening .tgf {
  visibility: hidden;
}

.tsumi-band {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: calc(var(--band-h) + env(safe-area-inset-top));
  z-index: 1;
  pointer-events: auto;
}
.tsumi-band__tools {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 12px);
  top: calc(env(safe-area-inset-top) + 12px);
  display: flex;
  gap: 8px;
}
.tsumi-tool {
  min-width: 48px;
  height: 48px;
  padding: 0 12px;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  color: var(--party-accent-dark);
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 4px 0 var(--party-accent-dark);
  cursor: pointer;
}
.tsumi-tool span {
  font-size: 14px;
  margin-left: 3px;
}
.tsumi-tool:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--party-accent-dark);
}
.tsumi-band__hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(60, 30, 10, 0.6);
  pointer-events: none;
}

/* ===== ゲーム画面 ===== */
.tsumi-game {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}
.tsumi-game button,
.tsumi-game .tsumi-result {
  pointer-events: auto;
}

.tsumi-hud {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 8px);
  left: calc(env(safe-area-inset-left) + 8px);
  right: calc(env(safe-area-inset-right) + 60px); /* 右上の☰（共通メニュー）とかぶらない */
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 4px 0 rgba(150, 70, 20, 0.3);
  font-weight: 900;
  color: var(--party-accent-dark);
}
.tsumi-hud__lives {
  font-size: 20px;
  letter-spacing: 1px;
  line-height: 1;
}
.tsumi-hud__lives .is-lost {
  opacity: 0.25;
  filter: grayscale(1);
}
.tsumi-hud__lives.is-hit {
  animation: tsumi-shake 0.5s;
}
.tsumi-hud__height {
  margin-left: auto;
  font-size: 15px;
}
.tsumi-hud__height b {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.tsumi-hud__best {
  font-size: 14px;
  color: var(--party-muted);
  white-space: nowrap;
}

.tsumi-turn {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 62px);
  left: 16px;
  right: 16px;
  text-align: center;
}
.tsumi-turn__name {
  display: inline-block;
  margin: 0 0 6px;
  padding: 6px 18px;
  border-radius: 999px;
  background: var(--party-accent);
  color: #fff;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 4px 0 var(--party-accent-dark);
}
.tsumi-turn__name.is-me {
  background: var(--tsumi-yellow);
  color: #4a2c00;
  box-shadow: 0 4px 0 #b07800;
  animation: tsumi-pop 0.35s cubic-bezier(0.3, 1.8, 0.6, 1);
}
.tsumi-turn__name.is-wait {
  background: rgba(255, 255, 255, 0.9);
  color: var(--party-accent-dark);
  box-shadow: 0 4px 0 rgba(150, 70, 20, 0.3);
}
.tsumi-turn__bar {
  height: 8px;
  max-width: 260px;
  margin: 0 auto;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.4);
  overflow: hidden;
}
.tsumi-turn__bar i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: #fff;
  transform-origin: left center;
}
.tsumi-turn__bar i.is-hurry {
  background: #ff7043;
}

/* 次の積み木とぐらぐら度（左の上） */
.tsumi-side {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 124px);
  left: calc(env(safe-area-inset-left) + 10px);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tsumi-next,
.tsumi-meter {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 3px 0 rgba(150, 70, 20, 0.25);
  font-weight: 900;
  color: var(--party-accent-dark);
}
.tsumi-next small {
  font-size: 12px;
}
.tsumi-next svg {
  display: block;
  width: 54px;
  height: 34px;
}
.tsumi-meter__face {
  font-size: 18px;
  line-height: 1;
}
.tsumi-meter__bar {
  display: block;
  width: 54px;
  height: 8px;
  border-radius: 99px;
  background: #f1e2d2;
  overflow: hidden;
}
.tsumi-meter__bar i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: #5fd38d;
  transform-origin: left center;
  transition: transform 0.3s, background 0.3s;
}
.tsumi-meter.is-danger {
  animation: tsumi-wobble 0.5s infinite;
}

.tsumi-toast {
  position: absolute;
  left: 0;
  right: 0;
  top: 36%;
  margin: 0;
  text-align: center;
  font-size: clamp(26px, 8vw, 40px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 3px var(--party-accent-dark);
  paint-order: stroke;
  text-shadow: 0 5px 0 rgba(90, 40, 10, 0.5);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.3, 1.8, 0.6, 1);
}
.tsumi-toast.is-on {
  opacity: 1;
  transform: scale(1);
}

/* 下の操作（親指の届くところ） */
.tsumi-bottom {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 150px calc(env(safe-area-inset-bottom) + 14px) 14px; /* 右下は共通のスタンプ */
  display: flex;
  justify-content: flex-start;
  gap: 8px;
}
.tsumi-hint {
  margin: 0;
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--tsumi-yellow);
  color: #4a2c00;
  font-size: 19px;
  font-weight: 900;
  box-shadow: 0 5px 0 #b07800;
  animation: tsumi-breathe 1.2s ease-in-out infinite;
}
.tsumi-hint[hidden] {
  display: none;
}
.tsumi-cheer {
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--party-accent-dark);
  font: inherit;
  font-size: 17px;
  font-weight: 900;
  box-shadow: 0 5px 0 var(--party-accent-dark);
  cursor: pointer;
}
.tsumi-cheer:active {
  transform: translateY(4px);
  box-shadow: none;
}
.tsumi-body .party-stamps-dock.is-playing {
  bottom: calc(env(safe-area-inset-bottom) + 10px);
  right: calc(env(safe-area-inset-right) + 8px);
}
.tsumi-clap {
  position: fixed;
  z-index: 4;
  margin: 0;
  font-size: 32px;
  pointer-events: none;
  animation: tsumi-float 1s ease-out forwards;
}

/* 結果 */
.tsumi-result {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 62vh;
  overflow-y: auto;
  padding: 0 12px calc(env(safe-area-inset-bottom) + 12px);
}
.tsumi-result__card {
  max-width: 420px;
  margin: 0 auto;
  padding: 14px 16px 16px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(150, 70, 20, 0.35);
  text-align: center;
  animation: tsumi-pop 0.4s cubic-bezier(0.3, 1.6, 0.6, 1);
}
.tsumi-result__title {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  color: var(--party-muted);
}
.tsumi-result__score {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: var(--party-accent-dark);
}
.tsumi-result__score b {
  font-size: 56px;
  line-height: 1;
  color: var(--party-accent);
  -webkit-text-stroke: 2px var(--party-accent-dark);
  paint-order: stroke;
}
.tsumi-result__marks,
.tsumi-result__record {
  margin: 4px 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--party-accent-dark);
}
.tsumi-result__record.is-new {
  color: #c98a00;
  animation: tsumi-pop 0.5s cubic-bezier(0.3, 1.8, 0.6, 1);
}
.tsumi-result__culprit {
  margin: 8px 0 10px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--party-accent-soft);
  color: var(--tsumi-ink);
  font-size: 17px;
  font-weight: 900;
}
.tsumi-result__culprit em {
  font-style: normal;
  color: var(--party-accent-dark);
}
.tsumi-result__cheer {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--party-muted);
}
.tsumi-result__actions {
  display: grid;
  gap: 8px;
}
.tsumi-wait {
  margin: 4px 0;
  font-weight: 800;
  color: var(--party-muted);
}

/* ===== オープニング ===== */
.tsumi-opening {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}
.tsumi-opening__logo {
  position: absolute;
  inset: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(30px, 9vw, 54px);
  font-weight: 900;
  color: #fff;
  background: radial-gradient(circle, rgba(232, 132, 60, 0.88), rgba(58, 47, 98, 0.96));
  animation: tsumi-pop 0.45s cubic-bezier(0.3, 1.8, 0.6, 1);
}
.tsumi-opening__title {
  position: absolute;
  left: 0;
  right: 0;
  top: 22%;
  margin: 0;
  text-align: center;
  font-size: clamp(44px, 13vw, 84px);
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 4px var(--party-accent);
  paint-order: stroke;
  text-shadow: 0 8px 0 var(--party-accent-dark);
  animation: tsumi-pop 0.5s cubic-bezier(0.3, 1.8, 0.6, 1);
}
.tsumi-opening__cap {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  margin: 0;
  text-align: center;
  font-size: 21px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5), 0 0 12px rgba(0, 0, 0, 0.5);
}
.tsumi-opening__skip {
  position: absolute;
  right: calc(env(safe-area-inset-right) + 14px);
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--party-accent-dark);
  font: inherit;
  font-weight: 900;
  box-shadow: 0 4px 0 var(--party-accent-dark);
  pointer-events: auto;
  cursor: pointer;
}

/* ===== トロフィー ===== */
.tsumi-modal {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(40, 24, 60, 0.55);
}
.tsumi-modal[hidden] {
  display: none;
}
.tsumi-modal__card {
  width: min(100%, 440px);
  max-height: 86vh;
  overflow-y: auto;
  padding: 16px;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 6px 0 rgba(150, 70, 20, 0.4);
}
.tsumi-modal__title {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 900;
  color: var(--party-accent-dark);
  text-align: center;
}
.tsumi-modal__note {
  margin: 10px 0;
  font-size: 12px;
  color: var(--party-muted);
  text-align: center;
}
.tsumi-trophies {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.tsumi-trophies li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 16px;
  background: #f7f1ea;
  color: #a8968a;
}
.tsumi-trophies li.is-got {
  background: #fff3c4;
  color: var(--party-text);
}
.tsumi-trophies__emoji {
  font-size: 26px;
}
.tsumi-trophies b {
  display: block;
  font-size: 15px;
}
.tsumi-trophies small {
  font-size: 12px;
  font-weight: 700;
}

.tsumi-toasts {
  position: fixed;
  left: 0;
  right: 0;
  top: calc(env(safe-area-inset-top) + 64px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}
.tsumi-toastp {
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  color: var(--party-accent-dark);
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 4px 0 var(--party-accent-dark);
  animation: tsumi-pop 0.3s ease-out;
}

@keyframes tsumi-pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes tsumi-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}
@keyframes tsumi-wobble {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-4deg);
  }
  75% {
    transform: rotate(4deg);
  }
}
@keyframes tsumi-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}
@keyframes tsumi-float {
  from {
    transform: translateY(0) scale(0.8);
    opacity: 1;
  }
  to {
    transform: translateY(-80px) scale(1.2);
    opacity: 0;
  }
}

@media (min-width: 900px) {
  :root {
    --band-h: 46vh;
  }
  .tsumi-side {
    top: calc(env(safe-area-inset-top) + 130px);
    left: 24px;
  }
  .tsumi-hud {
    max-width: 520px;
    left: 50%;
    transform: translateX(-50%);
    right: auto;
    width: calc(100% - 140px);
  }
}

/* ===== ページの続き（common の mountBelow。2026-10-04） =====
   最初の画面の下端に「つまみ」（--party-peek）が重なるので、下の操作（ヒント・応援・スタンプ）と
   結果をそのぶん上げる。続きの上に透けないよう、通知は続き（z-index:60）より下へ */
.tsumi-bottom,
.tsumi-result {
  bottom: var(--party-peek, 0px);
}
.tsumi-body .party-stamps-dock.is-playing {
  bottom: calc(env(safe-area-inset-bottom) + 10px + var(--party-peek, 0px));
}
.tsumi-toasts {
  z-index: 59;
}
