/* つたえてドロー: テーマ上書き（クレヨンの黄土）＋ゲーム画面（docs/party-tsutaete-spec.md §4）
 *
 * 山場は公開タイムの「1枚ずつめくる」演出（300ms）。JSは1枚ぶんのDOMを差し替えるだけで、
 * 実際のめくりはCSSアニメーションが持つ（kaburi と同じ「JSは値を置くだけ」の考え方）。
 * 絵は黒1色（読み違いを絵の上手さでなく形で楽しむ）。
 */

:root {
  --party-accent: #c98a2d;
  --party-accent-dark: #9c6a17;
  --party-accent-soft: #fdf0d8;
  --party-bg: #fff9ec;
  --party-card: #ffffff;
  --ts-ink: #4a3512;
  --ts-paper: #ffffff;
  --ts-line: #e6d6b6;
}

#ts-root {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.ts-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) calc(env(safe-area-inset-right) + 14px)
    calc(env(safe-area-inset-bottom) + 18px) calc(env(safe-area-inset-left) + 14px);
  text-align: center;
}

/* 描く画面は縦に詰まりやすいので上寄せ＋すき間を小さく */
.ts-screen--draw {
  justify-content: flex-start;
  gap: 8px;
}

.ts-head {
  width: 100%;
}

.ts-title {
  font-size: 1.4rem;
  margin: 0;
  color: var(--ts-ink);
}

.ts-progress {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0;
  letter-spacing: 0.04em;
}

.ts-msg {
  font-size: 1.15rem;
  font-weight: bold;
  margin: 0;
  color: var(--ts-ink);
}

.ts-msg-sub {
  font-size: 0.95rem;
  opacity: 0.75;
  margin: 0;
}

.ts-note {
  font-size: 0.8rem;
  opacity: 0.6;
  margin: 0;
}

.ts-waiticon {
  font-size: 3.4rem;
  line-height: 1;
  animation: ts-bob 1.6s ease-in-out infinite;
}

@keyframes ts-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== 残り時間バー ===== */

.ts-timer {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.ts-timer-track {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--party-accent-soft);
  overflow: hidden;
}

.ts-timerfill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--party-accent);
  transition: width 0.2s linear;
}

.ts-timerfill.is-hurry {
  background: #e0603c;
}

.ts-timelabel {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--ts-ink);
  min-width: 3.2em;
  text-align: right;
}

/* ===== お題・答えの見出し ===== */

.ts-taskcap {
  font-size: 0.9rem;
  opacity: 0.75;
  margin: 2px 0 0;
}

.ts-taskword {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--ts-ink);
  margin: 0;
  word-break: break-all;
}

/* ===== キャンバス ===== */

.ts-canvaswrap {
  width: 100%;
  display: flex;
  justify-content: center;
}

.ts-canvas {
  width: 100%;
  max-width: min(100%, 52vh);
  aspect-ratio: 1 / 1;
  height: auto;
  background: var(--ts-paper);
  border: 3px solid var(--ts-line);
  border-radius: 16px;
  /* 描いている最中に画面がスクロールしないように（1本指で描く） */
  touch-action: none;
  cursor: crosshair;
}

.ts-canvas--view {
  cursor: default;
  touch-action: auto;
}

/* ===== インク残量 ===== */

.ts-ink {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ts-inkcap {
  font-size: 0.75rem;
  opacity: 0.6;
  min-width: 3em;
  text-align: left;
}

.ts-ink-track {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--party-accent-soft);
  overflow: hidden;
}

.ts-inkfill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--ts-ink);
  transition: width 0.2s ease;
}

.ts-inknote {
  margin: 0;
  font-size: 0.85rem;
  font-weight: bold;
  color: #b4452c;
}

/* ===== 道具 ===== */

.ts-tools {
  width: 100%;
  display: flex;
  gap: 8px;
}

.ts-tool {
  flex: 1;
  min-height: 48px;
  padding: 6px 4px;
  border: 3px solid var(--ts-line);
  border-radius: 14px;
  background: #fff;
  color: var(--ts-ink);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
}

.ts-tool.is-on {
  border-color: var(--party-accent);
  background: var(--party-accent-soft);
}

/* ===== ボタン・入力 ===== */

.ts-btn {
  width: 100%;
  min-height: 56px;
  padding: 12px 18px;
  border: none;
  border-radius: 16px;
  background: var(--party-accent-soft);
  color: var(--party-accent-dark);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
}

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

.ts-btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--party-accent-dark);
}

.ts-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ts-input {
  width: 100%;
  min-height: 60px;
  padding: 10px 16px;
  border: 3px solid var(--ts-line);
  border-radius: 16px;
  background: #fff;
  color: var(--ts-ink);
  font-family: inherit;
  font-size: 1.4rem;
  text-align: center;
}

.ts-input:focus {
  outline: none;
  border-color: var(--party-accent);
}

/* ===== 公開タイム ===== */

/* パンくず・めくった1枚・「次へ」をひとかたまりで画面の真ん中に置く
 * （1枚に目が行くように。上下に散らすと視線が迷う） */
.ts-screen--reveal {
  justify-content: center;
  gap: 12px;
}

.ts-crumbs {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.95rem;
}

.ts-crumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid var(--ts-line);
  opacity: 0.4;
}

.ts-crumb.is-done {
  opacity: 1;
}

.ts-crumb.is-now {
  border-color: var(--party-accent);
  background: var(--party-accent-soft);
  transform: scale(1.12);
}

.ts-crumb-arrow {
  opacity: 0.4;
  font-size: 0.8rem;
}

/* めくり演出（1枚300ms。仕様§4）。公開タイムは1枚を画面いっぱいに見せる */
.ts-flipcard {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--party-card);
  border-radius: 20px;
  padding: 16px 14px;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.08);
  animation-name: ts-flip;
  animation-duration: 300ms;
  animation-timing-function: ease-out;
  transform-origin: center;
}

@keyframes ts-flip {
  from {
    transform: perspective(700px) rotateY(-88deg);
    opacity: 0.2;
  }
  to {
    transform: perspective(700px) rotateY(0deg);
    opacity: 1;
  }
}

/* めくった1枚の絵は、描いていたときより大きく見せる */
.ts-flipcard .ts-canvas {
  max-width: min(100%, 58vh);
}

.ts-reveal-cap {
  font-size: 0.85rem;
  opacity: 0.7;
  margin: 0 0 4px;
}

.ts-reveal-word {
  /* 公開タイムの1枚は画面いっぱいに（仕様§4）。字数が多くてもはみ出さない可変サイズ */
  font-size: clamp(2rem, 11vw, 3.2rem);
  line-height: 1.3;
  font-weight: 800;
  color: var(--ts-ink);
  margin: 0;
  word-break: break-all;
}

.ts-reveal-by {
  font-size: 0.9rem;
  opacity: 0.7;
  margin: 8px 0 0;
}

.ts-reveal-blank,
.ts-reveal-lost {
  font-size: 1.05rem;
  font-weight: bold;
  color: #9a8464;
  margin: 8px 0 0;
}

.ts-reveal-verdict {
  font-size: 1rem;
  font-weight: bold;
  color: var(--ts-ink);
  margin: 0;
}

.ts-reveal-verdict.is-match {
  font-size: 1.15rem;
  color: #2e7d32;
  animation: ts-pop 0.4s ease-out;
}

@keyframes ts-pop {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 画面が低い端末では絵を小さめにして、ボタンが隠れないようにする */
@media (max-height: 700px) {
  .ts-canvas {
    max-width: min(100%, 44vh);
  }
  .ts-taskword {
    font-size: 1.5rem;
  }
}

/* ---- 結果画面の共通部品（common/result.js の showFinal）に幅を与える ---- */
.ts-screen .party-final {
  width: 100%;
  max-width: 430px;
}
