/* ローグハイク — 和紙と墨、朱の落款 */

:root {
  --paper: #efe9dc;
  --paper-deep: #e5ddcc;
  --sumi: #26241f;
  --usuzumi: #4a4438; /* 薄墨。以前の#6d675cはクリーム地でWCAG AA未達だった */
  --ai: #2a4a73;      /* 藍 */
  --shu: #b5382e;     /* 朱 */
  --kin: #a5813a;     /* 金茶（希少カード） */
  --line: #c9c0ad;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255,255,255,0.5), transparent 60%),
    repeating-linear-gradient(93deg, transparent 0 7px, rgba(120,105,80,0.035) 7px 8px),
    var(--paper);
  color: var(--sumi);
  font-family: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  line-height: 1.7;
}

#app { max-width: 900px; margin: 0 auto; padding: 16px; }

.screen { animation: fadein 0.4s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

button { font-family: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--ai); outline-offset: 2px; }

.btn {
  background: transparent;
  border: 1.5px solid var(--sumi);
  color: var(--sumi);
  padding: 10px 26px;
  font-size: 1rem;
  border-radius: 2px;
  letter-spacing: 0.15em;
  transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--sumi); color: var(--paper); }
.btn.primary { background: var(--sumi); color: var(--paper); }
.btn.primary:hover { background: var(--ai); border-color: var(--ai); }
.btn.ghost { border-color: var(--usuzumi); color: var(--usuzumi); }
.btn.hidden { visibility: hidden; }

/* ---------- タイトル ---------- */
.title-screen {
  min-height: 90vh;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: clamp(2.5rem, 10vh, 6rem);
  text-align: center; gap: 22px;
}
.game-title {
  writing-mode: vertical-rl;
  font-size: clamp(3.2rem, 10vw, 5.5rem);
  font-weight: 600;
  letter-spacing: 0.28em;
  margin: 0;
  padding-right: 18px;
  line-height: 1.15;
  position: relative;
}
/* 朱罫は開幕にスッと引かれる（動くものが一つあるだけで離脱が減る） */
.game-title::after {
  content: "";
  position: absolute; top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--shu);
  transform-origin: top;
  animation: ruleDraw 0.7s ease 0.25s backwards;
}
@keyframes ruleDraw { from { transform: scaleY(0); } }

/* 完成句のミニ短冊プレビュー — 「これは俳句を作るゲームだ」と3秒で伝える */
.title-preview { position: relative; margin: 4px 0 2px; }
.tp-poem {
  writing-mode: vertical-rl;
  font-size: 1.1rem; letter-spacing: 0.12em; line-height: 2;
  color: var(--sumi);
  background: linear-gradient(180deg, #fffdf6, #f6efdf);
  border: 1px solid var(--line);
  box-shadow: 2px 3px 0 rgba(60, 50, 30, 0.14);
  padding: 16px 12px;
}
.tp-poem div { white-space: nowrap; }
.tp-stamp {
  position: absolute; right: -22px; bottom: -14px;
  width: 56px; height: 56px; border-radius: 50%;
  border: 3px solid var(--shu); color: var(--shu);
  background: var(--paper);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-8deg);
  font-weight: 700; font-size: 1.05rem; line-height: 1.1;
}
.tp-stamp span { font-size: 0.58rem; letter-spacing: 0.25em; margin-left: 0.25em; }
.tagline { color: var(--usuzumi); letter-spacing: 0.2em; margin: 0; }
.title-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.title-rules { color: var(--usuzumi); font-size: 0.86rem; max-width: 34em; }
.title-rules p { margin: 4px 0; }

/* ---------- ラン開始予告 ---------- */
.intro-screen {
  min-height: 88vh;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: clamp(3rem, 12vh, 8rem);
  gap: 24px; text-align: center;
}
.intro-seed { color: var(--usuzumi); letter-spacing: 0.2em; margin: 0; }
.judge-card {
  display: flex; gap: 24px; align-items: stretch;
  border: 1.5px solid var(--sumi);
  background: var(--paper-deep);
  padding: 22px 28px;
  max-width: 560px;
  text-align: left;
}
.judge-name-v {
  writing-mode: vertical-rl;
  font-size: 2.6rem; font-weight: 600; letter-spacing: 0.2em;
  border-right: 2px solid var(--shu);
  padding-right: 12px;
}
.judge-info p { margin: 8px 0; font-size: 0.95rem; line-height: 1.85; }
.judge-title { letter-spacing: 0.12em; color: var(--ai); }
.judge-axis { font-size: 0.88rem; color: var(--usuzumi); }
.judge-bind strong, .judge-norma strong { color: var(--shu); }
.intro-hint { color: var(--usuzumi); font-size: 0.9rem; margin: 0; }
.run-plan { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.plan-node {
  border: 1px solid var(--line); padding: 4px 10px; font-size: 0.85rem; background: #fff8;
  display: inline-flex; flex-direction: column; line-height: 1.4;
}
.plan-node em { font-style: normal; color: var(--usuzumi); font-size: 0.75rem; }
.plan-node.boss { border-color: var(--shu); color: var(--shu); }
.plan-node.miniboss { border-color: var(--ai); color: var(--ai); }
.plan-arrow { color: var(--usuzumi); }

/* ---------- ラウンド ---------- */
.round-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap;
  border-bottom: 1.5px solid var(--sumi);
  padding-bottom: 10px; margin-bottom: 10px;
}
.round-info { display: flex; flex-direction: column; gap: 2px; }
.round-name { letter-spacing: 0.18em; font-size: 1.05rem; }
.round-name.boss { color: var(--shu); }
.round-name.miniboss { color: var(--ai); }
.round-bind { color: var(--shu); font-size: 0.88rem; }
.round-judge { color: var(--usuzumi); font-size: 0.82rem; }
.round-stats { display: flex; gap: 16px; align-items: baseline; }
.stat em { font-style: normal; font-size: 1.7rem; font-weight: 600; }
.stat span { color: var(--usuzumi); }
.stat.small { color: var(--usuzumi); font-size: 0.88rem; }

.relic-shelf { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.relic-chip {
  border: 1px solid var(--kin); color: var(--kin);
  padding: 2px 10px; font-size: 0.8rem; background: #fff6;
  cursor: help;
}

/* 短冊（縦書き・右から上五中七下五） */
.tanzaku {
  display: flex; flex-direction: row-reverse; justify-content: center;
  gap: 18px; padding: 18px 8px;
  min-height: 300px;
}
.tan-line {
  writing-mode: vertical-rl;
  display: flex; flex-direction: column; align-items: center;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fffdf6, #f6efdf);
  box-shadow: 2px 3px 0 rgba(60,50,30,0.12);
  padding: 12px 6px;
  min-width: 74px; min-height: 300px;
  cursor: pointer;
}
.tan-line.active {
  border: 2px solid var(--ai);
  background: linear-gradient(180deg, #fffef9, #f9f3e6);
  box-shadow: 4px 6px 0 rgba(42,74,115,0.28);
  transform: translateY(-4px);
}
.tan-line.locked {
  border-color: var(--line);
  background: linear-gradient(180deg, #f3ecdd, #ece2cc);
  cursor: default;
  opacity: 0.85;
}
.tan-line.locked .tan-label { color: var(--shu); font-weight: 600; }
.tan-line.pending { opacity: 0.45; cursor: default; }
.tan-line.locked .tan-word:hover, .tan-line.pending .tan-word:hover { background: none; text-decoration: none; }
.tan-word:disabled { cursor: default; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn:disabled:hover { background: transparent; color: var(--sumi); }
.btn.primary:disabled:hover { background: var(--sumi); color: var(--paper); }
.tan-label { color: var(--usuzumi); font-size: 0.78rem; letter-spacing: 0.3em; margin-bottom: 8px; }
.tan-body { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.tan-word {
  writing-mode: vertical-rl;
  background: transparent; border: none;
  font-family: inherit; font-size: 1.5rem; letter-spacing: 0.08em;
  color: var(--sumi); padding: 2px 0;
  border-radius: 2px;
}
.tan-word:hover { background: rgba(181,56,46,0.12); text-decoration: line-through; }
.tan-word.particle { color: var(--usuzumi); font-size: 1.25rem; }
.tan-word.kireji { color: var(--kin); }
.tan-count { font-size: 0.82rem; color: var(--usuzumi); margin-top: 8px; letter-spacing: 0.1em; }
.tan-count.exact { color: var(--ai); font-weight: 600; }
.tan-count.over { color: var(--shu); font-weight: 600; }

.compose-actions { display: flex; gap: 12px; justify-content: center; margin: 6px 0 16px; flex-wrap: wrap; }

/* 手札 */
.hand-label { color: var(--usuzumi); font-size: 0.82rem; letter-spacing: 0.15em; margin-bottom: 6px; }
.hand-tray { display: flex; gap: 8px; flex-wrap: wrap; }
.card {
  border: 1px solid var(--sumi); background: #fffdf6;
  padding: 8px 10px; min-width: 96px; text-align: center;
  border-radius: 2px;
  box-shadow: 1px 2px 0 rgba(60,50,30,0.15);
  transition: transform 0.1s;
  display: flex; flex-direction: column; gap: 2px; align-items: center;
}
.card:hover { transform: translateY(-3px); }
.card-word { font-size: 1.2rem; font-weight: 600; letter-spacing: 0.05em; }
.card-meta { font-size: 0.72rem; color: var(--usuzumi); display: flex; gap: 6px; }
.card-kigo { color: var(--ai); }
.card-tags { font-size: 0.68rem; color: var(--usuzumi); }
.card-warn { font-size: 0.68rem; color: var(--shu); }
.kireji-card { border-color: var(--kin); background: #fdf7e8; }
.card.unfit { opacity: 0.35; }
.card.unfit:hover { transform: none; }
.instant-card { border-style: dashed; border-color: var(--ai); color: var(--ai); background: #f2f4f8; }

.particles { margin-top: 14px; }
.particle-tray { display: flex; gap: 6px; flex-wrap: wrap; }
.p-chip {
  border: 1px dashed var(--usuzumi); background: transparent; color: var(--usuzumi);
  min-width: 44px; min-height: 44px; font-size: 1rem; border-radius: 50%;
}
.p-chip:hover { border-color: var(--sumi); color: var(--sumi); background: #fff8; }

/* ---------- 採点リビール ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(38,36,31,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 16px;
}
.score-panel {
  background: var(--paper); border: 2px solid var(--sumi);
  padding: 26px 30px;
  width: min(92vw, 640px); max-width: 92vw;
  max-height: 92dvh; overflow-y: auto;
  display: flex; gap: 26px; align-items: flex-start;
  flex-wrap: wrap;
}
.poem-vertical {
  writing-mode: vertical-rl;
  font-size: 1.6rem; letter-spacing: 0.14em; line-height: 2.1;
  min-height: 220px;
  border-right: 2px solid var(--shu);
  padding-right: 14px;
  margin: 0 auto;
}
.poem-vertical.big { font-size: 1.9rem; }
.poem-line { white-space: nowrap; }
.score-detail { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 6px; }
.score-row {
  display: flex; justify-content: space-between; font-size: 0.95rem;
  animation: rise 0.3s ease;
}
.score-row em { font-style: normal; font-weight: 600; }
.score-row.minus em, .score-row.minus span { color: var(--shu); }
.score-row.fail { color: var(--shu); font-weight: 600; }
.score-row.floor-total { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 600; }
.score-row.mult-total { font-size: 1.15rem; color: var(--ai); font-weight: 600; }
/* 役タグ：枠箱ではなく、藍の下線＋朱点の「帳簿」の意匠に寄せる */
.yaku-tag {
  display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 1px solid var(--ai); color: var(--ai);
  padding: 4px 2px 3px; font-size: 0.92rem;
  animation: risePop 0.35s ease;
}
.yaku-tag::before { content: "・"; color: var(--shu); margin-right: 0.3em; }
.yaku-tag span { flex: 1; text-align: left; }
.yaku-tag.minus { border-bottom-color: var(--shu); color: var(--shu); }
.yaku-tag em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }
@keyframes risePop {
  0% { opacity: 0; transform: translateY(8px) scale(0.97); }
  70% { transform: translateY(0) scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}
.poem-vertical.flash { animation: glow 0.55s ease; }
@keyframes glow { 50% { filter: brightness(1.4); } }

.score-stamp {
  align-self: center; margin-top: 10px;
  width: 130px; height: 130px; border-radius: 50%;
  border: 4px solid var(--shu); color: var(--shu);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-6deg);
  animation: stamp 0.35s cubic-bezier(0.2, 2.2, 0.4, 1);
  background: radial-gradient(circle, rgba(181,56,46,0.08), transparent 70%);
}
.stamp-num { font-size: 2.4rem; font-weight: 700; line-height: 1.1; }
.stamp-label { font-size: 0.9rem; letter-spacing: 0.4em; margin-left: 0.4em; }
.score-total.zero { font-size: 2rem; color: var(--shu); text-align: center; }
@keyframes stamp { from { transform: rotate(-6deg) scale(2.2); opacity: 0; } to { transform: rotate(-6deg) scale(1); opacity: 1; } }

/* ---------- 報酬 ---------- */
.reward-screen { text-align: center; padding-top: 8vh; }
.reward-title { letter-spacing: 0.25em; font-weight: 600; }
.reward-sub { color: var(--usuzumi); font-size: 0.9rem; }
.pkg-row { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 24px; }
.pkg {
  border: 1.5px solid var(--sumi); background: #fffdf6;
  padding: 18px 20px; width: 220px; text-align: left;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 2px 3px 0 rgba(60,50,30,0.15);
  transition: transform 0.12s, box-shadow 0.12s;
  font-family: inherit;
}
.pkg:hover { transform: translateY(-4px); box-shadow: 3px 6px 0 rgba(42,74,115,0.3); border-color: var(--ai); }
.pkg-item strong { font-size: 1.15rem; display: block; }
.pkg-item small { color: var(--usuzumi); font-size: 0.76rem; line-height: 1.5; display: block; }
.pkg-item.kireji strong { color: var(--kin); }
.pkg-item.instant strong { color: var(--ai); }
.relic-pkg { align-items: flex-start; }
.relic-name { color: var(--kin); font-size: 1.2rem; }

/* ---------- ラン終了 ---------- */
.end-screen {
  min-height: 88vh; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding-top: clamp(3rem, 12vh, 8rem);
  gap: 18px; text-align: center;
}
.end-title { letter-spacing: 0.2em; font-size: 1.7rem; margin: 0; }
.end-title.win { color: var(--shu); }
.end-title.lose { color: var(--usuzumi); }
.end-sub { color: var(--usuzumi); margin: 0; }
.end-best { color: var(--usuzumi); font-size: 0.9rem; }

/* ---------- LLM選者 ---------- */
.judging-panel {
  background: var(--paper); border: 2px solid var(--sumi);
  padding: 40px 60px;
}
.judging-text {
  letter-spacing: 0.3em; font-size: 1.1rem;
  animation: breathe 1.6s ease-in-out infinite;
}
@keyframes breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.senpyo {
  border-top: 1px solid var(--line); padding-top: 10px; margin-top: 6px;
  display: flex; gap: 10px; align-items: baseline;
  animation: rise 0.3s ease;
}
.senpyo-label {
  color: var(--shu); border: 1px solid var(--shu);
  padding: 1px 6px; font-size: 0.72rem; white-space: nowrap;
}
.senpyo-text { font-size: 0.92rem; }
.end-senpyo {
  border-top: none; max-width: 34em;
  flex-direction: column; align-items: center; gap: 8px;
}
.end-senpyo .senpyo-text {
  text-align: left; line-height: 2;
  font-size: 0.95rem;
}
.senpyo-wait { color: var(--usuzumi); font-size: 0.88rem; animation: breathe 1.6s ease-in-out infinite; }

/* ---------- トースト ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--sumi); color: var(--paper);
  padding: 10px 22px; border-radius: 2px; letter-spacing: 0.1em;
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s;
  z-index: 20; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 640px) {
  .tanzaku { gap: 8px; }
  .tan-line { min-width: 60px; min-height: 240px; }
  .card { min-width: 84px; }
  .overlay { padding: 8px; }
  .score-panel { flex-direction: column; flex-wrap: nowrap; align-items: center; padding: 18px 16px; gap: 14px; }
  .score-detail { width: 100%; min-width: 0; }
  .poem-vertical { min-height: 150px; padding-right: 10px; }
  /* 「次へ」は常に見える位置に留める（採点モーダルはみ出しバグの対策） */
  .score-panel > .btn {
    position: sticky; bottom: 0; align-self: stretch;
    order: 99; margin-top: 4px;
  }
  .score-stamp { margin-bottom: 14px; } /* sticky「次へ」に朱印が隠れないように */
}
