/* ==========================================================
   百人一首 宝集め双六 - 専用スタイル
   ========================================================== */

.section.sugoroku-section {
  width: 100%;
  max-width: 1400px;
}

.sgr-h1 {
  display: flex;
  align-items: center;
  gap: .3em;
  font-family: "Kaisei HarunoUmi", serif;
  font-size: 1.8rem;
  color: #333;
  margin: .3em 0 .5em;
}
.sgr-h1-icon { font-size: 1.2em; }

.sgr-lead {
  font-size: .95rem;
  line-height: 1.9;
  margin-bottom: 1.2em;
  color: #444;
}
.sgr-lead strong { color: #B82343; }

/* ---------- ゲーム全体コンテナ ---------- */
#sgr-app {
  position: relative;
  background: linear-gradient(160deg, #fffaf0, #f3ead2);
  border: 1px solid #e4d9b8;
  border-radius: 1.2em;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .12);
  padding: 1em;
  min-height: 480px;
}

.sgr-hidden { display: none !important; }

/* ---------- スタート画面（モーダルではなく通常表示） ---------- */
.sgr-start-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5em 0;
}
.sgr-start-card {
  background: #fffdf6;
  border-radius: 1em;
  padding: 1.4em 1.3em;
  width: 100%;
  margin: 0 auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .1);
  border: 3px solid #B82343;
}

/* ---------- モーダル共通（○×クイズ・精算所） ---------- */
.sgr-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 20, 10, .55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: 1.2em;
  padding: 1em;
}
.sgr-modal {
  background: #fffdf6;
  border-radius: 1em;
  padding: 1.4em 1.3em;
  max-width: 480px;
  width: 100%;
  max-height: 90%;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
  border: 3px solid #B82343;
}
.sgr-result-modal { max-width: 900px; }
.sgr-modal-title {
  font-family: "Kaisei HarunoUmi", serif;
  font-size: 1.4rem;
  text-align: center;
  margin-bottom: .6em;
  color: #B82343;
}

.sgr-rule-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.1em;
  display: flex;
  flex-direction: column;
  gap: .5em;
}
/* サイト共通の .section ul li（桜アイコンの箇条書き）より詳細度を上げて打ち消し、
   最初の絵文字（.sgr-rule-bullet）自体をビュレットとして使う */
#sgr-app .sgr-rule-list li {
  display: flex;
  align-items: flex-start;
  gap: .5em;
  background-color: #f7f1e0;
  background-image: none;
  padding: .5em .7em;
  border-radius: .6em;
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 0;
}
.sgr-rule-bullet { flex: none; font-size: 1.1em; line-height: 1.6; }

.sgr-choice-label { font-weight: 700; margin-bottom: .4em; font-size: .9rem; }
.sgr-count-choices { display: flex; gap: .5em; margin-bottom: 1.2em; }
.sgr-count-btn {
  flex: 1;
  border: 2px solid #d8cba0;
  background: #fff;
  border-radius: .8em;
  padding: .6em .3em;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  font-size: .9rem;
  transition: .15s;
  font-family: inherit;
}
.sgr-count-btn:hover { border-color: #B82343; }
.sgr-count-btn.is-selected {
  border-color: #B82343;
  background: #fdeef1;
  box-shadow: 0 0 0 2px rgba(184, 35, 67, .25) inset;
}

/* ---------- スタートするコマの選択 ---------- */
.sgr-range-choices { display: flex; align-items: flex-end; gap: .6em; margin-bottom: .4em; }
.sgr-range-field {
  display: flex;
  flex-direction: column;
  gap: .3em;
  font-size: .8rem;
  font-weight: 700;
  color: #555;
}
.sgr-range-input {
  border: 2px solid #d8cba0;
  border-radius: .8em;
  padding: .5em .6em;
  font-size: .95rem;
  font-family: inherit;
  width: 6em;
  box-sizing: border-box;
}
.sgr-range-input:focus { border-color: #B82343; outline: none; }
.sgr-range-unit { font-weight: 400; color: #888; margin-left: .3em; }
.sgr-range-hint { font-size: .72rem; color: #888; margin-bottom: 1.2em; }

/* ---------- キャラクター（絵文字）選択 ---------- */
.sgr-player-setup { display: flex; flex-direction: column; gap: .6em; margin-bottom: 1.2em; }
.sgr-setup-row {
  border: 2px solid #d8cba0;
  border-radius: .8em;
  padding: .5em .6em;
  background: #fff;
}
.sgr-setup-row-head {
  display: flex;
  align-items: center;
  gap: .5em;
  margin-bottom: .4em;
  font-size: .82rem;
  font-weight: 700;
}
.sgr-setup-row-avatar { font-size: 1.4rem; line-height: 1; }
.sgr-avatar-choices { display: flex; flex-wrap: wrap; gap: .35em; }
.sgr-avatar-btn {
  width: 2.1em;
  height: 2.1em;
  border-radius: .6em;
  border: 2px solid #e0d6b8;
  background: #fdfaf0;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: .12s;
  font-family: inherit;
  padding: 0;
}
.sgr-avatar-btn:hover { border-color: #B82343; }
.sgr-avatar-btn.is-selected {
  border-color: #B82343;
  background: #fdeef1;
  box-shadow: 0 0 0 2px rgba(184, 35, 67, .25) inset;
}
.sgr-avatar-btn:disabled { opacity: .3; cursor: not-allowed; }

.sgr-best-display {
  text-align: center;
  font-size: .82rem;
  color: #a5790a;
  font-weight: 700;
  background: #fff7e6;
  border: 1px solid #e6c977;
  border-radius: .6em;
  padding: .5em .6em;
  margin-bottom: 1em;
}

.sgr-primary-btn {
  display: block;
  width: 100%;
  padding: .75em 1em;
  background: #B82343;
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 2em;
  cursor: pointer;
  font-size: 1rem;
  letter-spacing: .05em;
  box-shadow: 0 3px 0 #8a1a30;
  transition: .12s;
  font-family: inherit;
}
.sgr-primary-btn:hover { background: #c9385a; }
.sgr-primary-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #8a1a30; }
.sgr-primary-btn:disabled { background: #ccc; box-shadow: 0 3px 0 #999; cursor: not-allowed; }

/* ---------- 歌人の歌モーダル（コマをクリックすると表示） ---------- */
.sgr-poem-card { text-align: left; }
.sgr-poem-source { font-size: .8rem; color: #a5790a; font-weight: 700; margin-bottom: .4em; }
.sgr-poem-text {
  font-family: "Kaisei HarunoUmi", serif;
  font-size: 1.05rem;
  line-height: 1.7;
  color: #333;
  margin-bottom: .5em;
}
.sgr-poem-text ruby { ruby-align: center; }
.sgr-poem-text rt { font-size: .6em; color: #888; }
.sgr-poem-translation-label { font-size: .78rem; color: #a5790a; font-weight: 700; margin-bottom: 0; }
.sgr-poem-translation { font-size: .85rem; color: #666; line-height: 1.7; margin-bottom: 1em; }

/* ---------- 手番インジケーター（サイコロを振るボタンの下） ---------- */
.sgr-turn-indicator {
  display: inline-block;
  font-weight: 700;
  background: #fff;
  border: 2px solid #7EA549;
  border-radius: 1.5em;
  padding: .35em 1em;
  margin: .6em 0 0;
  font-size: .85rem;
  cursor: pointer;
  transition: background-color .15s;
}
.sgr-turn-indicator:hover { background-color: #f4faee; }
.sgr-turn-indicator.is-disabled { cursor: not-allowed; opacity: .7; }

/* ---------- レイアウト ---------- */
.sgr-layout { position: relative; display: flex; gap: 1em; align-items: flex-start; }
.sgr-board-panel { position: relative; flex: 1 1 60%; min-width: 0; }
.sgr-side-panel { flex: 0 0 300px; display: flex; flex-direction: column; gap: .8em; }
/* PCでは手番中プレイヤーのコマの高さに合わせて上下にスライドする（JS側でtranslateYを設定） */
@media (min-width: 901px) {
  .sgr-side-panel { transition: transform .25s ease; }
}

@media (max-width: 900px) {
  .sgr-layout { flex-direction: column; }
  .sgr-side-panel { flex: 1 1 auto; width: 100%; }
  .sgr-board-panel { width: 100%; }
}

/* ---------- 盤面（うねうねした100マスの道） ---------- */
.sgr-board-scroll {
  max-height: min(72vh, 640px);
  overflow-y: auto;
  overflow-x: hidden;
  border-radius: 1em;
  -webkit-overflow-scrolling: touch;
}
/* PCでは内側スクロールをやめ、盤面全体をそのまま表示する（必要ならページ全体がスクロールする） */
@media (min-width: 901px) {
  .sgr-board-scroll {
    max-height: none;
    overflow-y: visible;
  }
}
.sgr-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--sgr-cols, 10), var(--sgr-cell, 64px));
  grid-auto-rows: var(--sgr-cell, 64px);
  gap: 20px;
  justify-content: center;
  padding: 1.2em;
  background: #e8f0d8;
  border-radius: 1em;
  border: 2px dashed #b7cf97;
}

.sgr-board-path {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 0;
}

.sgr-square {
  position: relative;
  z-index: 1;
  width: var(--sgr-cell, 64px);
  height: var(--sgr-cell, 64px);
  background: #fff;
  border: 2px solid #cfc39a;
  border-radius: .6em;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: 0 2px 3px rgba(0, 0, 0, .12);
  transition: box-shadow .2s;
}
.sgr-sq-num {
  font-size: calc(var(--sgr-cell, 64px) * .28);
  font-weight: 700;
  color: #777;
  line-height: 1;
}
.sgr-sq-num-milestone {
  font-size: calc(var(--sgr-cell, 64px) * .38);
  color: #B82343;
}
.sgr-sq-name {
  font-size: calc(var(--sgr-cell, 64px) * .155);
  color: #888;
  line-height: 1.1;
  white-space: nowrap;
}
.sgr-sq-tokens {
  position: absolute;
  bottom: 2px;
  display: flex;
  gap: 2px;
  width: calc(var(--sgr-cell, 64px) * .92);
  flex-wrap: wrap-reverse;
  justify-content: center;
}

.sgr-sq-start { background: #eaf6ff; border-color: #7ac6e0; }
.sgr-sq-goal { background: linear-gradient(160deg, #ffe9c2, #ffd08a); border-color: #e0a63e; }
.sgr-sq-treasure { background: #fff6da; border-color: #e6c34c; }

.sgr-sq-current-human { box-shadow: 0 0 0 3px #2f7bd6; }
.sgr-sq-out-of-range { opacity: .35; filter: grayscale(.6); }

/* 一人プレイのとき、クイズに正解済みのマスに付く目印 */
.sgr-sq-done-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: calc(var(--sgr-cell, 64px) * .16);
  line-height: 1;
  color: #fff;
  background: #7EA549;
  border-radius: .3em;
  padding: .12em .3em;
  font-weight: 700;
  z-index: 2;
}

.sgr-token {
  display: flex;
  align-items: center;
  justify-content: center;
  width: calc(var(--sgr-cell, 64px) * .42);
  height: calc(var(--sgr-cell, 64px) * .42);
  font-size: calc(var(--sgr-cell, 64px) * .28);
  line-height: 1;
  background: #fff;
  border-radius: 50%;
  border: 2px solid var(--sgr-player-color, #2f7bd6);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
  flex: none;
}
.sgr-token-hop { animation: sgrHop .25s ease; }
@keyframes sgrHop {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-10px) scale(1.15); }
  100% { transform: translateY(0) scale(1); }
}

/* ---------- プレイヤーカード ---------- */
.sgr-players-panel { display: flex; flex-direction: column; gap: .6em; }
.sgr-player-card { background: #fff; border: 2px solid #e4d9b8; border-radius: .9em; padding: .6em .7em; }
.sgr-player-card.is-current-turn { border-color: #7EA549; box-shadow: 0 0 0 2px rgba(126, 165, 73, .3); }
.sgr-player-card.is-finished { opacity: .55; }
.sgr-player-head { display: flex; align-items: center; gap: .4em; margin-bottom: .4em; font-size: .85rem; }
.sgr-player-avatar {
  font-size: 1.1rem;
  width: 1.9em;
  height: 1.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--sgr-player-color, #2f7bd6);
  background: #fff;
  flex: none;
}
.sgr-player-name { font-weight: 700; flex: 1; }
.sgr-player-pos { font-size: .78rem; color: #555; white-space: nowrap; }
.sgr-player-pos b { color: #7EA549; font-size: .9rem; }
.sgr-player-score { font-size: .8rem; color: #555; white-space: nowrap; }
.sgr-player-score b { color: #B82343; font-size: .95rem; }

/* 宝は最大100個まで増えうるので、空きスロットは作らず手に入れた分だけ並べる */
.sgr-treasure-slots { display: flex; flex-wrap: wrap; gap: 3px; min-height: 1.7em; align-items: center; }
.sgr-slots-empty { font-size: .72rem; color: #999; }
.sgr-slot {
  width: 1.7em;
  height: 1.7em;
  flex: none;
  border-radius: .4em;
  background: #f2f2ea;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  border: 1px solid #ddd;
}
.sgr-slot.is-filled { background: #fff6da; border-color: #e6c34c; animation: sgrPop .3s ease; cursor: pointer; }
@keyframes sgrPop {
  0% { transform: scale(.4); opacity: 0; }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- サイコロ ---------- */
.sgr-dice-area { background: #fff; border: 2px solid #e4d9b8; border-radius: .9em; padding: .8em .7em 1em; text-align: center; }
.sgr-dice-scene {
  perspective: 400px;
  display: flex;
  justify-content: center;
  margin-bottom: .6em;
  cursor: pointer;
  padding: .3em;
  border-radius: .8em;
  transition: background-color .15s;
}
.sgr-dice-scene:hover { background-color: #fbf4dc; }
.sgr-dice-scene.is-disabled { cursor: not-allowed; opacity: .5; pointer-events: none; }
.sgr-dice {
  width: 52px;
  height: 52px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
  transition: transform .8s cubic-bezier(.34, 1.56, .64, 1);
}
.sgr-face {
  position: absolute;
  width: 52px;
  height: 52px;
  background: #fffdf6;
  border: 2px solid #333;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 6px;
  box-sizing: border-box;
}
.sgr-face-1 { transform: translateZ(26px); }
.sgr-face-6 { transform: rotateY(180deg) translateZ(26px); }
.sgr-face-2 { transform: rotateY(90deg) translateZ(26px); }
.sgr-face-5 { transform: rotateY(-90deg) translateZ(26px); }
.sgr-face-3 { transform: rotateX(90deg) translateZ(26px); }
.sgr-face-4 { transform: rotateX(-90deg) translateZ(26px); }
.sgr-pip { width: 9px; height: 9px; border-radius: 50%; background: #B82343; align-self: center; justify-self: center; }
.p-tl { grid-column: 1; grid-row: 1; }
.p-tr { grid-column: 3; grid-row: 1; }
.p-ml { grid-column: 1; grid-row: 2; }
.p-c { grid-column: 2; grid-row: 2; }
.p-mr { grid-column: 3; grid-row: 2; }
.p-bl { grid-column: 1; grid-row: 3; }
.p-br { grid-column: 3; grid-row: 3; }


.sgr-dir-choices { display: flex; gap: .5em; margin-top: .6em; }
.sgr-dir-btn {
  flex: 1;
  padding: .65em .4em;
  border-radius: 1.6em;
  border: none;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  color: #fff;
  transition: .12s;
  font-family: inherit;
}
.sgr-dir-back { background: #7c9fe0; box-shadow: 0 3px 0 #5578bd; }
.sgr-dir-back:hover { background: #6f92d6; }
.sgr-dir-back:active { transform: translateY(2px); box-shadow: 0 1px 0 #5578bd; }
.sgr-dir-forward { background: #7EA549; box-shadow: 0 3px 0 #5c7d32; }
.sgr-dir-forward:hover { background: #74983f; }
.sgr-dir-forward:active { transform: translateY(2px); box-shadow: 0 1px 0 #5c7d32; }
.sgr-dir-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

/* ---------- トースト ---------- */
.sgr-toast {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -140%);
  background: #333;
  color: #fff;
  padding: .6em 1.1em;
  border-radius: 2em;
  display: flex;
  align-items: center;
  gap: .4em;
  font-size: .85rem;
  z-index: 80;
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
  white-space: nowrap;
  max-width: 90%;
  text-overflow: ellipsis;
  overflow: hidden;
}
.sgr-toast.is-show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- ○×クイズ（モーダルではなく sgr-dice-area の下に通常表示） ---------- */
.sgr-quiz-panel {
  background: #fff;
  border: 2px solid #B82343;
  border-radius: .9em;
  padding: .8em .7em;
}
.sgr-quiz-timer-wrap { height: 6px; background: #eee; border-radius: 3px; overflow: hidden; margin-bottom: .7em; }
.sgr-quiz-timer-bar { height: 100%; background: linear-gradient(90deg, #7EA549, #e6c34c, #B82343); width: 100%; transition: width .1s linear; }
.sgr-quiz-source { font-size: .72rem; color: #888; margin-bottom: .3em; }
.sgr-quiz-question { font-size: .95rem; line-height: 1.6; margin-bottom: .8em; font-weight: 700; }
.sgr-quiz-choices { display: flex; gap: .5em; margin-bottom: .6em; }
.sgr-quiz-btn {
  flex: 1;
  padding: .7em .4em;
  border-radius: .8em;
  border: 2px solid #ccc;
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: .12s;
  font-family: inherit;
}
.sgr-quiz-true { color: #2f7bd6; }
.sgr-quiz-false { color: #d64f2f; }
.sgr-quiz-btn:hover { border-color: currentColor; background: #f7f7f7; }
.sgr-quiz-btn:disabled { opacity: .5; cursor: not-allowed; }
.sgr-quiz-result-text { font-weight: 700; margin-bottom: .4em; }
.sgr-quiz-explain {
  font-size: .8rem;
  color: #555;
  line-height: 1.6;
  margin-bottom: .8em;
  background: #f7f1e0;
  padding: .6em .7em;
  border-radius: .6em;
}

/* ---------- 精算所（結果） ---------- */
.sgr-result-banner { text-align: center; font-weight: 700; font-size: 1.15rem; margin-bottom: 1em; color: #B82343; }
.sgr-result-cols { display: flex; gap: .8em; margin-bottom: 1em; overflow-x: auto; padding-bottom: .2em; }
.sgr-result-col { flex: 1 0 150px; min-width: 150px; background: #f7f1e0; border-radius: .8em; padding: .7em .6em; font-size: .78rem; }
.sgr-result-col h3 { font-size: .9rem; margin-bottom: .5em; text-align: center; display: flex; align-items: center; justify-content: center; gap: .3em; }
.sgr-result-rank { font-size: .72rem; font-weight: 700; color: #a5790a; }
.sgr-result-col table { width: 100%; border-collapse: collapse; }
.sgr-result-col td { padding: .2em 0; }
.sgr-result-col td:last-child { text-align: right; font-weight: 700; }
.sgr-result-col tr.sgr-result-subhead td {
  font-weight: 700;
  font-size: .75rem;
  color: #a5790a;
  padding-top: .7em;
  border-top: 1px dashed #d8cba0;
}
.sgr-result-col tr.sgr-result-total td { border-top: 2px solid #B82343; padding-top: .4em; font-weight: 900; color: #B82343; }
.sgr-result-col.is-winner { box-shadow: 0 0 0 3px #e6c34c inset; }
.sgr-result-best {
  text-align: center;
  font-size: .85rem;
  color: #555;
  background: #f7f1e0;
  border-radius: .6em;
  padding: .6em .7em;
  margin-bottom: 1em;
  line-height: 1.7;
}

@media (max-width: 600px) {
  .sgr-result-cols { flex-direction: column; }
}

/* ---------- 説明コンテンツ ---------- */
.sgr-info { margin-top: 2em; font-size: .85rem; line-height: 1.8; }
.sgr-info-h2 {
  font-family: "Kaisei HarunoUmi", serif;
  font-size: 1.2rem;
  border-left: 5px solid #B82343;
  padding-left: .5em;
  margin: 1.4em 0 .6em;
}
.sgr-treasure-table-wrap { overflow-x: auto; }
.sgr-treasure-table { width: 100%; border-collapse: collapse; font-size: .8rem; background: #fff; }
.sgr-treasure-table th, .sgr-treasure-table td { border: 1px solid #ddd; padding: .5em .6em; text-align: left; white-space: nowrap; }
.sgr-treasure-table th { background: #f7f1e0; }
.sgr-cat-label { color: #a5790a; font-weight: 700; }
.sgr-howto-list { padding-left: 1.4em; display: flex; flex-direction: column; gap: .9em; }
.sgr-howto-list li { list-style: decimal; padding-left: .3em; }
.sgr-howto-list li p { margin: 0 0 .3em; }
.sgr-howto-list li p:last-child { margin-bottom: 0; }
.sgr-howto-title { font-weight: 700; font-size: 1rem; color: #B82343; margin-bottom: .3em; }
.sgr-howto-note {
  font-size: .85rem;
  color: #555;
  background: #f7f1e0;
  border-radius: .6em;
  padding: .6em .9em;
  margin-top: 1em;
}
