.table-top { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(24px, 4vw, 48px) clamp(16px, 3vw, 40px) 32px; overflow: hidden; }
.row { display: grid; grid-template-columns: repeat(6, 1fr); gap: clamp(8px, 2vw, 22px); align-items: end; perspective: 900px; }
@media (max-width: 680px) { .row { grid-template-columns: repeat(3, 1fr); row-gap: 28px; } }
.tile { appearance: none; font: inherit; color: var(--ink); position: relative; height: clamp(170px, 24vw, 230px); border: 2px solid var(--ink); border-radius: 12px; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px 6px 12px; cursor: pointer; transform-origin: 50% 100%; transition: transform .55s cubic-bezier(.55, 0, .75, .4), background .3s, box-shadow .2s; }
@media (hover: hover) {
  .tile:hover:not(:disabled) { transform: translateY(-4px); box-shadow: 0 8px 0 -2px var(--line); }
  .tile.fall:hover:not(:disabled) { transform: rotateX(44deg); box-shadow: none; }
}
.tile:active:not(:disabled) { box-shadow: 0 0 0 3px var(--line); }
.tile:disabled { cursor: default; }
.tile .nm { font-family: var(--font-head); font-weight: 700; font-size: clamp(.78rem, 1.6vw, .92rem); text-align: center; line-height: 1.4; }
.tile .nm small { display: block; font-family: var(--font-body); font-weight: 400; font-size: .75rem; color: var(--ink-3); line-height: 1.4; margin-top: 2px; }
.tile.leak .nm small { color: var(--bg); opacity: .75; }
.tile.fall .nm small, .tile.safe .nm small { color: var(--ink-2); }
.tile .key { width: 56%; max-width: 64px; transition: transform .3s; }
.tile .lbl { font-size: .75rem; color: var(--ink-3); text-align: center; line-height: 1.4; min-height: 2.8em; }
.tile .shield { position: absolute; top: 44%; right: 10%; width: 22px; opacity: 0; transform: scale(.4); transition: all .3s cubic-bezier(.3, 1.6, .5, 1); }
.tile.mfa .shield { opacity: 1; transform: none; }
.tile.bump .key { transform: rotate(-20deg) scale(1.15); }
.tile.leak { background: var(--ink); color: var(--bg); }
.tile.leak .lbl { color: var(--bg); opacity: .7; }
.tile.hit { animation: hit .35s ease; }
@keyframes hit { 30% { transform: translateX(-6px) rotate(-2deg); } 70% { transform: translateX(4px) rotate(1deg); } }
.tile.fall { transform: rotateX(52deg); background: var(--danger-soft); border-color: var(--danger); }
.tile.safe { background: var(--ok-soft); border-color: var(--ok); }
.tile.fall .lbl, .tile.safe .lbl { color: var(--ink-2); }
.tile.hint { animation: wiggle 1.4s ease .3s 2; }
.tile.fall.hint { animation-name: wiggleFall; }
@keyframes wiggleFall { 0%, 50%, 100% { transform: rotateX(52deg); } 10%, 30% { transform: rotateX(52deg) rotate(-2deg); } 20%, 40% { transform: rotateX(52deg) rotate(2deg); } }
/* 押せる札の設定欄は、切り替えられる札に見せる */
.tile .lbl { display: flex; align-items: flex-end; justify-content: center; }
.tile .chip { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 1px 4px; box-sizing: border-box; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 2px 6px; background: var(--surface); color: var(--ink-2); line-height: 1.35; transition: border-color .2s; }
.tile .chip .nx { display: inline-flex; align-items: center; gap: 1px; flex: none; }
.tile .chip .cyc { width: 10px; height: 10px; flex: none; color: var(--ink-3); }
.tile .chip .nxg { width: 12px; height: 12px; flex: none; }
@media (hover: hover) { .tile:hover:not(:disabled) .chip { border-color: var(--ink); } }
.tile:active:not(:disabled) .chip { border-color: var(--ink); }
.tile:disabled .chip .nx { visibility: hidden; }
/* 設定欄が二行になっても札からはみ出さないよう、スマートフォンでは札の高さを中身に合わせ、同じ段の札はそろえる */
@media (max-width: 680px) { .row { align-items: stretch; } }
/* 札が狭いときは、次の設定の印を設定の文字の下に回す（札からはみ出さない） */
.tile { container-type: inline-size; }
.tile .lbl { max-width: 100%; }
.outcome .delta { font-family: var(--font-head); font-weight: 700; color: var(--ok); margin-bottom: 12px; }
.outcome .goal { font-family: var(--font-head); font-weight: 700; font-size: 1.08rem; color: var(--ink); margin: 0 0 16px; }
@keyframes wiggle { 10%, 30% { transform: rotate(-2deg); } 20%, 40% { transform: rotate(2deg); } 50% { transform: none; } }
@media (prefers-reduced-motion: reduce) { .tile { transition: background .3s; } .tile.fall, .tile.fall:hover:not(:disabled) { transform: none; } .tile.hint, .tile.hit { animation: none; } }
.flykey { position: fixed; width: 34px; z-index: 30; pointer-events: none; transition: transform .45s cubic-bezier(.4, 0, .2, 1), opacity .3s; }
.ctrl { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-top: 32px; }
.ctrl .btn { white-space: nowrap; }
.legend { display: flex; gap: 20px; flex-wrap: wrap; font-size: .8rem; line-height: 1.8; color: var(--ink-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.terminal { margin-top: 28px; background: #15171a; color: #b9c2b0; font-family: var(--mono); font-size: .76rem; line-height: 1.9; border-radius: 10px; padding: 16px 20px; height: 150px; overflow: auto; }
.terminal .r { color: #f07468; } .terminal .y { color: #e3c27a; } .terminal .g { color: #7fcfa7; } .terminal .d { color: #8a9099; }
/* 「流出させる」と「倒れたドミノを立て直す」は同じ場所で入れ替える。幅が変わって横の凡例が動かないようにする */
.swap { display: grid; }
.swap > .btn { grid-area: 1 / 1; justify-self: end; }
.swap > .btn.hidden { display: inline-flex !important; visibility: hidden; }
.outcome { margin-top: 32px; max-width: var(--text); }
/* 結果は攻撃者の画面の下に出る。始めた時点で結果の高さを空けておき（.wait）、出たときに下の欄を押し下げない */
.outcome:empty:not(.wait) { margin: 0; }
.outcome .big { font-family: var(--font-head); font-weight: 700; font-size: clamp(1.6rem, 4.4vw, 2.4rem); line-height: 1.4; margin-bottom: 12px; word-break: auto-phrase; text-wrap: balance; }
.outcome.bad .big { color: var(--danger); } .outcome.good .big { color: var(--ok); }
.outcome ul { color: var(--ink-2); }
.pattern { font-family: var(--mono); line-height: 2.2; font-size: 1.05rem; }
.pattern em { font-style: normal; color: var(--accent); }
/* スマートフォンでは、札・操作・攻撃者の画面が一つの画面に収まるよう、札を低くし、余白を詰める */
@media (max-width: 680px) {
  .table-top { padding: 20px 12px 20px; }
  .row { row-gap: 16px; gap: 8px; }
  .tile { height: auto; min-height: 128px; padding: 10px 4px; letter-spacing: 0; }
  .tile .key { width: 50%; }
  .ctrl { margin-top: 20px; gap: 12px; }
  .ctrl > div:last-child { width: 100%; }
  .ctrl .btn { white-space: normal; width: 100%; padding-left: 16px; padding-right: 16px; letter-spacing: .02em; }
  .legend { gap: 6px 16px; }
  .terminal { margin-top: 16px; height: 116px; padding: 12px 14px; }
  .outcome { margin-top: 24px; }
}
/* 横向きのスマートフォンでは、札を低くし、札と操作欄が一画面に入るようにする */
@media (max-height: 500px) and (orientation: landscape) {
  .table-top { padding-top: 20px; }
  .row { align-items: stretch; }
  .tile { height: auto; min-height: 150px; }
  .ctrl { margin-top: 16px; }
}
/* 札はスクリプトで並べる。並べる前から札の段の高さを空けておき、下の操作欄が読み込み中に動かないようにする */
.row:empty { min-height: clamp(170px, 24vw, 230px); }
@media (max-width: 680px) { .row:empty { min-height: 268px; } }
@media (max-height: 500px) and (orientation: landscape) { .row:empty { min-height: 150px; } }
@media (max-height: 500px) and (orientation: landscape) and (max-width: 680px) { .row:empty { min-height: 308px; } }
/* 札の文字は、語の途中で折り返さない（折り返す位置はスクリプトで <wbr> を入れて示す） */
.tile .nm small, .tile .lbl { word-break: keep-all; overflow-wrap: anywhere; }
.tile .key { flex: none; }
/* 小さなスマートフォンでは、台を画面の端まで広げて札の幅を確保する */
@media (max-width: 480px) {
  .table-top { margin: 0 -20px; border-radius: 0; border-left: 0; border-right: 0; padding-left: 12px; padding-right: 12px; }
  .tile .nm { font-size: 12px; }
}

/* 元は style 属性だった指定（CSP の style-src に 'unsafe-inline' を付けないため、ここへ移した） */
.legend i.lg-same { background: #d4442c; }
.legend i.lg-diff { width: 20px; background: linear-gradient(90deg, #2f6fde 0 20%, #7a5bd0 20% 40%, #0e8a9a 40% 60%, #b7791f 60% 80%, #6b7a8f 80%); }
