/* =====================================================================
   style.css — 花札 こいこい ツール固有のスタイル。
   共通スタイルは /_shared/shirugear.css に任せる。
   札そのものの色はライト/ダークで変えない（札らしく見せるため）。
   ===================================================================== */

/* 共通CSSより確実に隠す */
#act[hidden],
#put-btn[hidden],
#modal[hidden],
#pending-note[hidden],
.hk-oya[hidden],
.hk-koi[hidden],
.hk-flash[hidden] {
  display: none;
}

.hk-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: var(--sg-space-1, 4px);
}
.hk-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}
.hk-more > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--sg-primary, #3b5bdb);
}
.hk-pending {
  color: var(--sg-warm, #b54708);
}

/* ---------- 色（場の敷物） ---------- */
.hk-game {
  --hk-felt: #e4efe3;
  --hk-felt-line: #b9d3b8;
  --hk-glow: #f0a500;
  --hk-sel: #3b5bdb;
  --hk-hot: #2f9e44;
  --hk-chip: #fff3e2;
  --hk-chip-fg: #8a4b00;
  padding: 14px 12px;
}
html.sg-dark .hk-game {
  --hk-felt: #1d3226;
  --hk-felt-line: #2f4d3b;
  --hk-glow: #ffc24d;
  --hk-sel: #8aa8ff;
  --hk-hot: #51cf66;
  --hk-chip: #3a2c14;
  --hk-chip-fg: #ffd08a;
}
@media (prefers-color-scheme: dark) {
  html:not(.sg-dark):not(.sg-light) .hk-game {
    --hk-felt: #1d3226;
    --hk-felt-line: #2f4d3b;
    --hk-glow: #ffc24d;
    --hk-sel: #8aa8ff;
    --hk-hot: #51cf66;
    --hk-chip: #3a2c14;
    --hk-chip-fg: #ffd08a;
  }
}

.hk-info {
  margin: -2px 0 8px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--sg-muted, #5a6573);
}
.hk-info:empty {
  display: none;
}
.hk-top {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* ---------- 札 ---------- */
.hk-card {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  line-height: 0;
  border-radius: 6px;
  min-width: 0;
  color: inherit;
  font: inherit;
}
.hk-card svg {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.hk-card svg text {
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
}
button.hk-card {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button.hk-card:disabled {
  cursor: default;
}
button.hk-card:focus-visible {
  outline: 3px solid var(--hk-sel);
  outline-offset: 2px;
}

/* 手札 */
.hk-hand {
  padding-bottom: 6px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  max-width: 560px;
  margin: 8px auto 0;
  padding-top: 8px;
}
/* 場に同じ月がある手札: 下に印（光の札の金の枠と見分けるため、枠ではなく棒で示す） */
.hk-hand .hk-card {
  position: relative;
}
.hk-hand .hk-card.can-take::after {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -7px;
  height: 4px;
  border-radius: 2px;
  background: var(--hk-glow);
}
.hk-hand .hk-card.is-selected {
  transform: translateY(-8px);
}
.hk-hand .hk-card.is-selected svg {
  box-shadow: 0 0 0 3px var(--hk-sel), 0 4px 10px rgba(0, 0, 0, 0.3);
}
.hk-hand .hk-card:disabled svg {
  filter: saturate(0.85);
}

/* 場 */
.hk-field-wrap {
  position: relative;
  margin: 10px 0 6px;
  padding: 8px;
  border-radius: 12px;
  background: var(--hk-felt);
  border: 1px solid var(--hk-felt-line);
}
.hk-field {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  max-width: 560px;
  margin: 0 auto;
  min-height: 60px;
}
.hk-field .hk-card.is-match svg {
  box-shadow: 0 0 0 3px var(--hk-glow), 0 0 12px 2px var(--hk-glow);
  animation: hk-pulse 1.1s ease-in-out infinite;
}
.hk-card.is-hot svg {
  box-shadow: 0 0 0 2px var(--hk-hot), 0 1px 2px rgba(0, 0, 0, 0.25);
}
@keyframes hk-pulse {
  50% {
    box-shadow: 0 0 0 3px var(--hk-glow), 0 0 4px 0 var(--hk-glow);
  }
}
.hk-deck {
  position: relative;
}
.hk-deck .hk-card {
  opacity: 0.95;
}
.hk-deck__count {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  min-width: 1.8em;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #5c1013;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}
.hk-card--drawn svg {
  box-shadow: 0 0 0 3px var(--hk-glow), 0 3px 8px rgba(0, 0, 0, 0.3);
}
.hk-card--drawn.is-flip {
  animation: hk-flip 0.36s ease-out;
}
@keyframes hk-flip {
  from {
    transform: perspective(300px) rotateY(90deg) translateX(-30%);
    opacity: 0.4;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

/* こいこい！の一言 */
.hk-flash {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 6px 18px;
  border-radius: 999px;
  background: #d23a2f;
  color: #fff;
  font-weight: 800;
  font-size: 1.2rem;
  pointer-events: none;
  white-space: nowrap;
}
.hk-flash.is-on {
  animation: hk-pop 1.2s ease-out forwards;
}
@keyframes hk-pop {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---------- 双方の欄 ---------- */
.hk-side__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.hk-who {
  font-weight: 700;
}
.hk-oya,
.hk-koi {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: 1px;
}
.hk-oya {
  background: var(--sg-primary-soft, #eaeefc);
  color: var(--sg-primary, #3b5bdb);
}
.hk-koi {
  background: #d23a2f;
  color: #fff;
}
.hk-hand-count {
  color: var(--sg-muted, #5a6573);
  font-size: 0.85rem;
}
.hk-cpu-hand {
  display: flex;
  gap: 2px;
  margin: 4px 0 6px;
}
.hk-cpu-hand .hk-card {
  width: 18px;
}

/* 取り札（種類ごと） */
.hk-caps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 10px;
  margin-top: 4px;
}
@media (min-width: 560px) {
  .hk-caps {
    grid-template-columns: 0.8fr 1fr 1fr 1.5fr;
  }
}
.hk-group {
  min-width: 0;
}
.hk-group__label {
  display: block;
  font-size: 0.75rem;
  color: var(--sg-muted, #5a6573);
  line-height: 1.5;
}
/* 枚数が増えると自動で重なる（各札は縮み、最後の1枚だけは全部見せる） */
.hk-pile {
  display: flex;
  min-height: 36px;
  padding-right: 2px;
}
.hk-pile .hk-card {
  flex: 0 1 24px;
  width: 24px;
  min-width: 3px;
  overflow: visible;
}
.hk-pile .hk-card svg {
  width: 24px;
  max-width: none;
}
.hk-pile .hk-card:last-child {
  flex-shrink: 0;
}
@media (min-width: 560px) {
  .hk-pile .hk-card {
    flex-basis: 30px;
    width: 30px;
  }
  .hk-pile .hk-card svg {
    width: 30px;
  }
  .hk-pile {
    min-height: 45px;
  }
}
.hk-yaku {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--sg-fg, #1a2230);
}

/* ステータス・操作 */
.hk-status {
  min-height: 2.9em;
  margin: 6px 0;
  text-align: center;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
}
.hk-status.is-ok { color: var(--sg-success, #067647); }
.hk-status.is-warn { color: var(--sg-warm, #b54708); }
.hk-actions {
  margin-top: 16px;
}
.hk-act,
.hk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.hk-act .sg-btn,
.hk-actions .sg-btn {
  padding: 6px 14px;
  font-size: 0.92rem;
}
.hk-record {
  text-align: center;
  font-size: 0.9rem;
  color: var(--sg-muted, #5a6573);
}

/* ---------- ダイアログ ---------- */
.hk-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 14, 20, 0.55);
}
.hk-modal__box {
  width: 100%;
  max-width: 380px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--sg-surface, #fff);
  color: var(--sg-fg, #1a2230);
  border: 1px solid var(--sg-border, #dde2ec);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 18px 18px 16px;
}
.hk-modal__title {
  margin: 0 0 8px;
  font-size: 1.1rem;
}
.hk-modal__body p {
  margin: 6px 0;
  line-height: 1.6;
  font-size: 0.93rem;
}
.hk-ylist {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}
.hk-ylist li {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--hk-chip, #fff3e2);
  color: var(--hk-chip-fg, #8a4b00);
  font-weight: 600;
}
.hk-ylist li + li {
  margin-top: 4px;
}
.hk-modal {
  --hk-chip: #fff3e2;
  --hk-chip-fg: #8a4b00;
}
html.sg-dark .hk-modal {
  --hk-chip: #3a2c14;
  --hk-chip-fg: #ffd08a;
}
@media (prefers-color-scheme: dark) {
  html:not(.sg-dark):not(.sg-light) .hk-modal {
    --hk-chip: #3a2c14;
    --hk-chip-fg: #ffd08a;
  }
}
.hk-note {
  color: var(--sg-muted, #5a6573);
  font-size: 0.85rem !important;
}
.hk-modal__btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* ---------- 解説の役の表 ---------- */
.hk-table-wrap {
  overflow-x: auto;
  margin: 0.8em 0;
}
.hk-yaku-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.5;
}
.hk-yaku-table caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: 4px;
}
.hk-yaku-table th,
.hk-yaku-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--sg-border, #e3e3e3);
  text-align: left;
  vertical-align: top;
}
.hk-yaku-table th[scope="row"] {
  white-space: nowrap;
  font-weight: 600;
}
.hk-yaku-table td:last-child {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.hk-yaku-table thead th {
  color: var(--sg-muted, #777);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  .hk-field .hk-card.is-match svg,
  .hk-card--drawn.is-flip,
  .hk-flash.is-on {
    animation: none;
  }
}
