/* Inheritance table. Tokens come from shared/theme.css. */
:root {
  --board: #1e3a34; --board-2: #142a25;
  --parch: #f5ead2; --parch-ink: #2a2118; --parch-edge: #d9c7a0;
  --w: 82px;
  --s-L: #c2414f; --s-D: #c99a22; --s-P: #3f8a55; --s-W: #7a55a8;
}
.app { max-width: 1280px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; gap: 12px; }
.back-link { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-size: 18px; color: var(--text); }
.title { flex: 1; min-width: 0; }
.title h1 { font-size: 22px; margin: 0; }
.meta { font-size: 13px; }
.top-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .25); color: rgba(244, 239, 230, .78); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 1fr 290px; gap: 12px; align-items: start; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } }
.play { display: grid; gap: 12px; min-width: 0; }

.board {
  background: radial-gradient(ellipse at 50% 25%, var(--board) 0%, var(--board-2) 100%);
  border-radius: 20px; padding: 14px; display: grid; gap: 12px; min-width: 0; color: #f4efe6;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), inset 0 0 60px rgba(0, 0, 0, .3);
}
.zone-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: rgba(244, 239, 230, .72); margin-bottom: 4px; }

/* ---------- Family row ---------- */
.family { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; --w: 82px; }
.slot { display: grid; justify-items: center; align-content: start; min-width: 0; text-align: center; }
.slot.succ .icard { box-shadow: 0 0 0 2px var(--gold), var(--shadow); }
.slot-card { min-height: calc(var(--w) * 1.4); display: grid; place-items: center; }
.slot .note { font-size: 11.5px; color: rgba(244, 239, 230, .8); margin-top: 4px; line-height: 1.25; max-width: calc(var(--w) + 30px); }
@media (max-width: 720px) {
  .family { grid-template-columns: repeat(3, minmax(0, 1fr)); --w: 74px; row-gap: 8px; }
}

/* ---------- Verdict ---------- */
.verdict { background: rgba(0, 0, 0, .25); border-radius: 12px; padding: 8px 12px; font-size: 14px; line-height: 1.4; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.verdict b { color: #fff; }
.verdict .ring-line { font-weight: 700; color: var(--gold); }

/* ---------- Seats ---------- */
.seats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.seat {
  --pc: var(--p1);
  position: relative; min-width: 0; background: rgba(0, 0, 0, .22); border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; padding: 8px 10px 10px;
  display: grid; gap: 6px; justify-items: center; transition: box-shadow .2s, border-color .2s;
}
.seat.turn { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 0 22px color-mix(in srgb, var(--pc) 30%, transparent); }
.seat.holder { background: color-mix(in srgb, var(--gold) 14%, rgba(0, 0, 0, .22)); }
.seat-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; width: 100%; }
.seat-head .name { font-weight: 700; color: var(--pc); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.seat .info { font-size: 12px; color: rgba(244, 239, 230, .78); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.seat .adm { --w: 76px; min-height: calc(var(--w) * 1.4); margin-bottom: 6px; display: grid; place-items: center; position: relative; }
.seat .empty { width: var(--w); height: calc(var(--w) * 1.4); border: 2px dashed rgba(255, 255, 255, .2); border-radius: 10px; display: grid; place-items: center; font-size: 12px; color: rgba(244, 239, 230, .55); padding: 4px; text-align: center; }
.seat .status { font-size: 12px; color: rgba(244, 239, 230, .78); min-height: 16px; text-align: center; line-height: 1.3; }
.seat .status b { color: #fff; }
.ring-badge { position: absolute; top: -10px; right: -12px; font-size: 26px; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); animation: pop .5s ease-out; }
.suit-badge { position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 800; background: var(--gold); color: #2a2118; padding: 1px 6px; border-radius: 6px; white-space: nowrap; }
@keyframes pop { 0% { transform: scale(.2) rotate(-40deg); } 70% { transform: scale(1.25); } 100% { transform: scale(1); } }
.thinking { color: var(--pc); font-weight: 700; }
.thinking::after { content: ''; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- Cards ---------- */
.icard {
  --sc: var(--s-W);
  position: relative; width: var(--w); height: calc(var(--w) * 1.4); border-radius: calc(var(--w) * .1);
  background: var(--parch); color: var(--parch-ink); box-shadow: inset 0 0 0 1px var(--parch-edge), var(--shadow);
  display: grid; grid-template-rows: auto auto 1fr; overflow: hidden; user-select: none; text-align: center;
  transition: transform .15s, box-shadow .15s; font-family: Georgia, "Times New Roman", serif;
}
.icard.s-L { --sc: var(--s-L); } .icard.s-D { --sc: var(--s-D); } .icard.s-P { --sc: var(--s-P); } .icard.s-W { --sc: var(--s-W); }
.icard .band { background: var(--sc); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: calc(var(--w) * .04) calc(var(--w) * .07); }
.icard .rank { font-size: calc(var(--w) * .26); font-weight: 800; line-height: 1; }
.icard .suit { font-size: calc(var(--w) * .2); line-height: 1; }
.icard .name { font-weight: 800; font-size: calc(var(--w) * .15); padding-top: calc(var(--w) * .05); color: var(--sc); filter: brightness(.8); }
.icard .txt { font-family: var(--font); font-size: calc(var(--w) * .105); line-height: 1.2; padding: calc(var(--w) * .03) calc(var(--w) * .06) 0; align-self: start; }
.icard .kind { position: absolute; bottom: calc(var(--w) * .03); right: calc(var(--w) * .05); font-size: calc(var(--w) * .13); opacity: .8; }
.icard.small .txt { display: none; }
.icard.small .name { font-size: calc(var(--w) * .16); }
.icard.small .big-suit { display: block; }
.icard .big-suit { display: none; font-size: calc(var(--w) * .34); padding-top: calc(var(--w) * .06); }
.icard.init { --sc: #6b5a3e; }
.icard.back {
  background: radial-gradient(circle at 50% 50%, #c99a22 0 18%, transparent 19%), repeating-linear-gradient(45deg, #5a2230 0 8px, #4a1b27 8px 16px);
  box-shadow: inset 0 0 0 3px #c99a22, var(--shadow);
}
.icard.back::after { content: '💍'; position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--w) * .3); }
.icard.flash { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 4px var(--gold), 0 0 26px var(--gold); } 100% { box-shadow: inset 0 0 0 1px var(--parch-edge), var(--shadow); } }
.deck-stack { position: relative; width: var(--w); height: calc(var(--w) * 1.4); }
.deck-stack .icard { position: absolute; left: 0; top: 0; }
.deck-empty { width: var(--w); height: calc(var(--w) * 1.4); border: 2px dashed rgba(255, 255, 255, .2); border-radius: 10px; display: grid; place-items: center; font-size: 12px; color: rgba(244, 239, 230, .55); }

/* ---------- Banner ---------- */
.banner { min-height: 40px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; background: var(--surface-2); border-radius: 12px; padding: 8px 14px; font-weight: 600; }
.banner.error { background: color-mix(in srgb, var(--bad) 30%, var(--surface-2)); }
.banner.you { box-shadow: inset 3px 0 0 var(--p0); }
.banner.win { box-shadow: inset 3px 0 0 var(--good); }

/* ---------- Your hand ---------- */
.me { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px 14px; }
.me.turn { border-color: var(--p0); box-shadow: 0 0 0 1px var(--p0); }
.hand-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hand-title { flex: 1; }
.hand-note { font-size: 13px; }
.hand { display: flex; gap: 10px; margin-top: 20px; min-height: 120px; --w: 92px; align-items: flex-end; flex-wrap: wrap; }
.hand .icard { cursor: pointer; }
.hand .icard:hover { transform: translateY(-5px); }
.hand .icard.selected { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--gold), 0 8px 18px rgba(0, 0, 0, .35); }
.hand .icard.hinted { box-shadow: 0 0 0 3px var(--good), var(--shadow); }
.hand .icard.known::before { content: 'SEEN'; position: absolute; top: 2px; left: 50%; transform: translateX(-50%); font: 800 8px var(--font); background: rgba(0, 0, 0, .55); color: #fff; padding: 0 4px; border-radius: 4px; z-index: 1; display: none; }
.hand.waiting .icard { cursor: default; }
.hand.waiting .icard:hover { transform: none; }
.hand .none { color: var(--muted); font-size: 14px; padding: 20px 0; }

/* ---------- Move choices ---------- */
.choices { display: grid; gap: 8px; margin-top: 14px; }
.choices:empty { display: none; }
.choice-group { display: grid; gap: 6px; }
.choice-group h4 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 700; }
.choice-group .row { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { display: inline-flex; align-items: center; gap: 8px; text-align: left; }
.choice .out { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: rgba(0, 0, 0, .18); white-space: nowrap; }
.choice .out.good { background: color-mix(in srgb, var(--good) 30%, transparent); }
.choice .out.bad { background: color-mix(in srgb, var(--bad) 28%, transparent); }
.choice.hinted { box-shadow: 0 0 0 2px var(--good); }
.choices .why { font-size: 13px; color: var(--muted); }

/* ---------- Side ---------- */
.side { position: sticky; top: 12px; display: grid; gap: 12px; }
.cheat, .log-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.cheat summary, .log-box summary { font-weight: 700; cursor: pointer; }
.cheat ul { margin: 8px 0; padding-left: 18px; font-size: 13.5px; display: grid; gap: 4px; }
.log { list-style: none; margin: 8px 0 0; padding: 0; max-height: 440px; overflow: auto; font-size: 13.5px; display: grid; gap: 4px; }
.log li { padding: 4px 8px; border-radius: 8px; border-left: 3px solid var(--pc, var(--line)); background: var(--surface-2); }
.log li.round { background: transparent; border-left-color: transparent; color: var(--muted); font-weight: 700; text-align: center; }
.log li.ring { border-left-color: var(--gold); }
@media (max-width: 960px) { .side { position: static; } .log { max-height: 220px; } }
.btn.small { padding: 5px 10px; font-size: 13px; }

/* ---------- Dialogs ---------- */
.dlg { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--text); padding: 22px; width: min(540px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(5, 10, 20, .6); backdrop-filter: blur(2px); }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin: 12px 0; }
.field .input { width: 100%; color: var(--text); font-size: 15px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rules-opts { border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px 10px; margin: 12px 0 0; display: grid; gap: 8px; }
.rules-opts legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }
.check.off { opacity: .45; cursor: default; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.rules ol { padding-left: 20px; display: grid; gap: 6px; }
.rules ul { padding-left: 20px; display: grid; gap: 4px; }
.rules h3 { margin: 16px 0 6px; }
.role-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.role-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.role-table td:first-child { font-weight: 800; width: 28px; text-align: right; }
.role-table td:nth-child(2) { font-weight: 700; white-space: nowrap; }
.small-print { font-size: 12.5px; margin-top: 14px; }
.round-body { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; --w: 76px; margin: 8px 0; }
.round-body .score { width: 100%; text-align: center; font-size: 15px; }

@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.shake { animation: shake .35s; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .app { padding: 10px 12px 20px; gap: 10px; }
  .topbar { gap: 8px; }
  .back-link { width: 34px; height: 34px; }
  .title h1 { font-size: 18px; }
  .meta { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .top-actions { gap: 4px; flex-wrap: nowrap; }
  .top-actions .btn { padding: 6px 8px; font-size: 13px; }
  .top-actions [data-theme-toggle] { display: none; }
  .board { padding: 10px; border-radius: 16px; gap: 10px; }
  .topbar { flex-wrap: wrap; }
  .top-actions { order: 3; width: 100%; justify-content: flex-start; }
  .family { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; --w: 50px; }
  .family .zone-label { font-size: 9px; letter-spacing: 0; white-space: nowrap; }
  .slot .note { display: none; }
  .verdict { font-size: 13px; padding: 6px 10px; }
  .seats { grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 6px; }
  .seat { padding: 6px 4px; gap: 4px; }
  .seat-head .tag { display: none; }
  .seat .adm { --w: 54px; }
  .seat .info, .seat .status { font-size: 11px; }
  .ring-badge { font-size: 20px; right: -8px; }
  .me { padding: 10px 12px 12px; }
  .hand { --w: min(92px, calc((100vw - 76px) / 3.3)); gap: 8px; }
  .field-row { grid-template-columns: 1fr; }
}
