/* ==========================================================================
   Yamato.com — Daifugō lessons (public/js/learn-daifugo.js)
   The lesson table borrows the game's own pieces from daifugo.css (df-seat,
   df-field, df-you, df-btn, the gold selection ring) and only sizes them for
   the lesson stage, which already carries the indigo cloth.
   ========================================================================== */

.yd-stage { align-content: center; }
.yd-stage > * { min-width: 0; }

/* Card names inside the lesson's sentences: ♥9 in red, the Joker as a chip. */
.yl-note .yd-cn, .yl-goal .yd-cn { white-space: nowrap; font-weight: 700; }
.yd-cn.is-red { color: #c0182f; }
.yd-cn.is-joker { display: inline-block; padding: 0 5px; margin: 0 1px; border-radius: 4px; background: #f1ebdc; border: 1px solid #e2d8c2; color: #7a2f26; font-size: .92em; line-height: 1.45; }
.yd-cn + .yd-cn { margin-left: 1px; }

/* ------------------------------------------------------------- the table */
.yd-table { position: relative; width: 100%; max-width: 660px; display: grid; gap: 10px; }
.yd-opps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.yd-seat { min-width: 0; padding: 8px 6px 7px; transition: box-shadow .2s, background .2s, opacity .2s; }
.yd-seat .df-seat-name { font-size: 13px; margin-bottom: 2px; }
.yd-seat .df-seat-title { margin: 0 0 4px; }
.yd-seat .df-seat-cards { min-height: 30px; }
.yd-seat .df-seat-cards .df-card { --df-w: 21px; }
.yd-seat .df-seat-cards .df-card + .df-card { margin-left: -15px; }
.yd-seat .df-seat-count { margin-top: 3px; font-size: 12px; }
.yd-seat .df-pass-tag { margin-top: 3px; }
.yd-flags:empty { display: none; }
.yd-flags { min-height: 0; }

.yd-field { min-height: 132px; padding: 12px; }
.yd-field .df-field-cards { flex-wrap: wrap; justify-content: center; }
.yd-field .df-field-cards .df-card { --df-w: 66px; }
.yd-field.is-sweep .df-field-cards { animation: yd-sweep .9s ease-in forwards; }
.yd-swept { color: #e6c479; }
/* The game's call-out (八切り, 革命 …), kept on one line in the narrower stage. */
.yd-shout { white-space: nowrap; font-size: clamp(30px, 8vw, 66px); top: 44%; }
.df-card.yd-in { animation: yd-in .3s ease-out; }
@keyframes yd-in { from { transform: translateY(-14px) scale(.96); opacity: 0; } }
@keyframes yd-sweep { 0%, 45% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateX(26px) scale(.94); } }

.yd-you { padding: 10px 12px 9px; }
.yd-you .df-you-head { margin-bottom: 2px; }
.yd-you .df-you-head .df-seat-title { margin: 0; }
.yd-you .df-actions { margin-top: 10px; }
.yd-you .df-btn { min-height: 44px; }

/* Your hand: one row, overlapped just enough to fit, the way a fan is held.
   --n (set by the script) is the number of cards; percentages are of the
   row's width, so the overlap follows the stage at every size. */
.yd-fan { --yd-w: 66px; flex-wrap: nowrap; justify-content: center; padding-top: 22px; min-height: 0; }
.yd-you .yd-fan > .df-card { --df-w: var(--yd-w); }
.yd-you .yd-fan > .df-card + .df-card { margin-left: max(calc(var(--yd-w) * -.62), min(6px, calc((100% - var(--n) * var(--yd-w)) / (var(--n) - 1)))); }
.yd-you .yd-fan > .df-card:hover { margin-right: 0; }

/* -------------------------------------------------------- quiz pieces */
.yd-quiz { width: 100%; max-width: 660px; display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 6px 0; }
.yd-zone { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 100%; }
.yd-zone-label { font-family: 'Shippori Mincho B1', serif; font-size: 13px; letter-spacing: .08em; color: #f3e6c6d9; text-align: center; }
.yd-ref .df-card { --df-w: 84px; }
.yd-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding-top: 18px; }
.yd-row .df-card { --df-w: 64px; }
.yd-bar { display: flex; justify-content: center; }
.yd-bar .df-btn { min-height: 46px; min-width: 150px; }

.df-card.yd-right::after { content: ''; position: absolute; inset: -3px; border-radius: calc(var(--df-w) * .075 + 3px); border: 2px solid #6fc08c; box-shadow: 0 0 12px #6fc08c66; pointer-events: none; }
.df-card.yd-dim { opacity: .42; }
.yd-wrong { animation: yd-shake .34s; }
@keyframes yd-shake { 25% { translate: -6px 0; } 75% { translate: 6px 0; } }

.yd-dots { display: flex; gap: 7px; }
.yd-dots span { width: 9px; height: 9px; border-radius: 50%; background: #ffffff2e; transition: background .2s; }
.yd-dots .is-now { background: #e6c479; }
.yd-dots .is-done { background: #6fc08c; }

/* The order of strength, card by card. */
.yd-order { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px 8px; width: min(100%, 560px); }
.yd-order-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.yd-order-cell .df-card { --df-w: min(100%, 70px); }
.yd-order-cell.is-mark .df-card { box-shadow: 0 0 0 2px #e6c479, 0 6px 14px #0007; }
.yd-order-cap { min-height: 16px; font-size: 11.5px; line-height: 1.3; color: #e6c479; text-align: center; white-space: nowrap; }
.yd-order-ends { width: min(100%, 560px); }
.yd-arrow { flex: 1; height: 2px; margin: 0 10px; background: linear-gradient(90deg, #f3e6c633, #e6c479); position: relative; }
.yd-arrow::after { content: ''; position: absolute; right: -2px; top: -4px; border: 5px solid transparent; border-left-color: #e6c479; border-right: 0; }

/* The ladder above the field in the revolution lessons. */
.yd-ladder { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.yd-ladder-row { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; width: min(100%, 520px); }
.yd-ladder-row span { display: grid; place-items: center; height: 24px; border-radius: 4px; background: #fffdf7; border: 1px solid #e3dccb; color: #33413f; font: 700 12px/1 Georgia, serif; }
.yd-ladder-row span:last-child { background: #233c49; border-color: #233c49; color: #f3d79c; }
.yd-ladder.is-rev .yd-ladder-row span:not(:last-child) { background: #fbeaea; border-color: #e8c2c2; color: #8c1d33; }
.yd-ladder-ends { display: flex; align-items: center; justify-content: space-between; width: min(100%, 520px); font-size: 11.5px; color: #f3e6c6b3; }

/* Slots for the "put them in order" lesson. */
.yd-slots { --yd-qw: 64px; gap: 8px; }
.yd-slot { width: var(--yd-qw); aspect-ratio: 100 / 140; border-radius: 6px; border: 1.5px dashed #f3e6c659; }
.yd-slot.is-filled { border-color: transparent; }
.yd-slot .df-card { --df-w: var(--yd-qw); }

/* Groups of cards to tap (sequences, foul finishes). */
.yd-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; }
.yd-group { cursor: pointer; justify-content: center; min-height: 92px; transition: background .15s, border-color .15s, box-shadow .15s, opacity .15s; }
.yd-group:hover { border-color: #e6c47999; }
.yd-group:focus-visible { outline: 3px solid #e6c479; outline-offset: 2px; }
.yd-group.is-picked { box-shadow: 0 0 0 1px #e6c479; }
.yd-group.is-right { border-color: #6fc08c; background: #6fc08c1f; box-shadow: 0 0 0 1px #6fc08c; }
.yd-group.is-dim { opacity: .42; }
.yd-mini { display: flex; justify-content: center; }
.yd-mini .df-card { --df-w: 42px; }
.yd-mini .df-card + .df-card { margin-left: -13px; }

/* One-answer questions. */
.yd-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; width: 100%; max-width: 620px; }
.yd-option { min-height: 46px; padding: 8px 12px; border-radius: 9px; border: 1px solid #dfd6b766; background: #ffffff12; color: #f6ecd2; font: 600 14.5px/1.4 'Shippori Mincho B1', serif; cursor: pointer; transition: background .15s, border-color .15s, opacity .15s; }
.yd-option:hover:not(:disabled) { background: #ffffff22; border-color: #e6c479; }
.yd-option:focus-visible { outline: 3px solid #e6c479; outline-offset: 2px; }
.yd-option.is-right { background: #2f6b4f; border-color: #6fc08c; color: #fff; opacity: 1; }
.yd-option.is-wrong { border-color: #e07a5f; background: #e07a5f26; }
.yd-option.is-dim { opacity: .45; }
.yd-option:disabled { cursor: default; }
.yd-ask { width: 100%; max-width: 660px; display: grid; justify-items: center; gap: 10px; margin-top: 14px; }
.yd-ask-q { font-family: 'Shippori Mincho B1', serif; font-size: 15.5px; line-height: 1.6; color: #f6ecd2; text-align: center; }

/* Finishing order and titles. */
.yd-podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; width: min(100%, 440px); }
.yd-podium-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 8px; background: #071b2a4d; border: 1px solid #dfd6b72e; color: #e8f1f5; }
.yd-podium-row.is-ask { border-color: #e6c479; box-shadow: 0 0 0 1px #e6c479; background: #ddbd7014; }
.yd-podium-place { font-size: 12.5px; color: #f3e6c6b3; }
.yd-podium-name { font-weight: 700; font-size: 14.5px; }
.yd-podium .df-seat-title { margin: 0; font-size: 12.5px; padding: 3px 11px; }

/* The card exchange. */
.yd-exchange { width: 100%; max-width: 660px; display: grid; gap: 12px; }
.yd-partner { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px 10px; }
.yd-partner .df-seat-name { margin: 0; }
.yd-partner .df-seat-title { margin: 0; }
.yd-partner-note { flex-basis: 100%; font-size: 12.5px; color: #e8f1f5b3; }
.yd-new-tag { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); z-index: 2; padding: 3px 6px; border-radius: 6px; background: #c8102e; color: #fff; font: 700 9.5px/1 'Avenir Next', 'Segoe UI', sans-serif; letter-spacing: .05em; white-space: nowrap; pointer-events: none; }
.df-card.yd-new { box-shadow: 0 0 0 2px #e07a5f, 0 4px 10px #0006; }
.df-card.yd-leave { opacity: 0; transform: translateY(-48px) scale(.9); transition: opacity .45s ease, transform .45s ease; }

/* A short desktop window (1280 × 720 and the like): tighten the table so
   the whole of it, buttons included, fits under the lesson's top bar. */
@media (min-width: 641px) and (max-height: 820px) {
  .yd-table { gap: 7px; }
  .yd-seat { padding: 5px 6px 4px; }
  .yd-seat .df-seat-name { margin: 0; }
  .yd-seat .df-seat-cards { min-height: 24px; }
  .yd-seat .df-seat-cards .df-card { --df-w: 17px; }
  .yd-seat .df-seat-cards .df-card + .df-card { margin-left: -12px; }
  .yd-seat .df-seat-count { margin-top: 1px; }
  .yd-field { min-height: 104px; padding: 8px; gap: 6px; }
  .yd-field .df-field-cards .df-card { --df-w: 58px; }
  .yd-fan { --yd-w: 60px; padding-top: 18px; }
  .yd-you { padding: 7px 12px 6px; }
  .yd-you .df-actions { margin-top: 7px; }
  .yd-you .df-btn { min-height: 42px; padding: 9px 22px; }
  .yd-you .df-hint { margin-top: 4px; }
  .yd-ladder-row span { height: 21px; }
}

/* --------------------------------------------------------------- phone */
@media (max-width: 640px) {
  .yd-table { gap: 7px; }
  .yd-opps { gap: 5px; }
  .yd-seat { padding: 5px 3px 4px; }
  .yd-seat .df-seat-name { font-size: 12px; line-height: 16px; margin: 0; }
  .yd-seat .df-seat-title { font-size: 10px; padding: 0 6px; margin: 1px 0 2px; }
  .yd-seat .df-seat-cards { min-height: 24px; }
  .yd-seat .df-seat-cards .df-card { --df-w: 16px; }
  .yd-seat .df-seat-cards .df-card + .df-card { margin-left: -11.5px; }
  .yd-seat .df-seat-count { font-size: 11px; margin-top: 1px; }
  .yd-seat .df-pass-tag { font-size: 10.5px; margin-top: 2px; }
  .yd-flags .df-flag { font-size: 11.5px; padding: 3px 9px; }
  .yd-field { min-height: 104px; padding: 8px; gap: 6px; }
  .yd-field .df-field-cards .df-card { --df-w: 54px; }
  .yd-field .df-field-meta { font-size: 11.5px; }
  .yd-you { padding: 7px 8px 6px; }
  .yd-you .df-you-head { font-size: 12.5px; }
  .yd-fan { --yd-w: 56px; padding-top: 18px; }
  .yd-you .df-actions { margin-top: 8px; gap: 8px; }
  .yd-you .df-btn { padding: 9px 14px; min-width: 104px; font-size: 14.5px; }
  .yd-you .df-hint { font-size: 11.5px; }
  /* Thirteen cards will not fan legibly on a phone; lay them out in rows,
     as the game does. */
  .yd-you .yd-fan.is-big { display: grid; grid-template-columns: repeat(auto-fill, 46px); justify-content: center; gap: 14px 5px; padding-top: 14px; }
  .yd-you .yd-fan.is-big > .df-card { --df-w: 46px; margin: 0; }

  .yd-quiz { gap: 14px; }
  .yd-ref .df-card { --df-w: 68px; }
  .yd-row { gap: 7px; padding-top: 16px; }
  .yd-row .df-card { --df-w: 52px; }
  .yd-slots { --yd-qw: 40px; gap: 5px; }
  .yd-order { gap: 8px 4px; }
  .yd-order-cap { font-size: 9.5px; white-space: normal; }
  .yd-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .yd-group { min-height: 80px; padding: 8px 4px; }
  .yd-mini .df-card { --df-w: 34px; }
  .yd-mini .df-card + .df-card { margin-left: -11px; }
  .yd-options { grid-template-columns: minmax(0, 1fr); }
  .yd-ladder-row span { height: 20px; font-size: 10px; }
  .yd-podium-row { grid-template-columns: 52px minmax(0, 1fr) auto; padding: 8px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .df-card.yd-in, .yd-field.is-sweep .df-field-cards, .yd-wrong { animation: none; }
  .df-card.yd-leave { transition: none; }
}
