/* Illustrated player playmats, laid out toward the people at the table. */
.table-grid { gap: 15px; }
.pcard { --realm-x: 0%; --realm-y: 0%; border: 1px solid color-mix(in srgb, var(--seat) 80%, #efe2b2); border-radius: 20px; background: #101411; box-shadow: 0 6px 22px #0006, inset 0 0 0 2px #0005; }
.pcard[data-realm="1"] { --realm-x: 33.333333%; }
.pcard[data-realm="2"] { --realm-x: 66.666667%; }
.pcard[data-realm="3"] { --realm-x: 100%; }
.pcard[data-realm="4"] { --realm-y: 100%; }
.pcard[data-realm="5"] { --realm-x: 33.333333%; --realm-y: 100%; }
.pcard[data-realm="6"] { --realm-x: 66.666667%; --realm-y: 100%; }
.pcard[data-realm="7"] { --realm-x: 100%; --realm-y: 100%; }
.pcard::before { display: none; }
.pcard::after { z-index: 5; inset: 5px; border-radius: 15px; background: none; border: 1px solid color-mix(in srgb, var(--seat) 42%, transparent); box-shadow: inset 0 0 30px #0004; pointer-events: none; }
.pcard > .pcard-in { isolation: isolate; overflow: hidden; container-name: seat; }
.pcard-in::before { content: ''; position: absolute; inset: 0; z-index: 0; background-image: var(--art, url('../images/realms-atlas.jpg')); background-size: 400% 200%; background-position: var(--realm-x) var(--realm-y); opacity: .92; pointer-events: none; }
.pcard.has-art .pcard-in::before { background-size: cover; background-position: center 32%; }
.pcard-in::after { content: ''; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, #030908b8 0%, #03090830 27%, #0309081f 56%, #030908b3 100%); pointer-events: none; }
.pcard-in > :not(.pcard-admin):not(.pcard-damage):not(.stat-row) { position: relative; z-index: 2; }
.pcard .pcard-head { flex: none; min-height: 44px; padding: 0 12px; background: #06120fed; border-bottom: 1px solid #f6e8bf50; }
.pcard .pname { flex: 1; min-width: 0; min-height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; box-shadow: none; color: #fff9e8; font-size: clamp(22px, 5cqw, 32px); line-height: 1.1; font-weight: 750; text-align: left; text-shadow: none; }
.pcard .pcard-admin, .pcard .pcard-damage { position: absolute; z-index: 6; top: auto; bottom: 0; height: 44px; min-height: 44px; border: 2px solid #f5e9c2; border-radius: 8px; box-shadow: 0 2px 8px #0009; line-height: 1; }
.pcard .pcard-admin { right: 4px; width: 44px; min-width: 44px; padding: 0; font-size: 22px; color: #fff9e8; background: #294437; }
.pcard .pcard-damage { left: 4px; width: 88px; min-width: 88px; padding: 0 5px; font-size: 16px; font-weight: 750; color: #291d07; background: #f5cb75; }
.pcard .pcard-damage:hover { background: #ffe4ac; }
.pcard .pcard-admin:hover { background: #3c604d; }
.pcard .pcard-life { isolation: isolate; flex: 1 1 auto; container: life / size; padding: 0 12px; gap: 8px; min-height: 44px; }
.pcard .life-num { --control-size: clamp(44px, 24cqh, 68px); --life-diameter: clamp(44px, min(92cqh, calc(100cqw - 2 * var(--control-size) - 16px)), 238px); position: relative; display: grid; place-items: center; flex: none; width: var(--life-diameter); height: var(--life-diameter); padding: 0 0 3px; min-width: 44px; border: 1px solid #fff1c777; border-radius: 50%; background: radial-gradient(circle, #080d0adb 20%, #080d0ab8 58%, #080d0a55); font-family: Georgia, 'Times New Roman', serif; font-weight: 700; font-size: clamp(34px, calc(var(--life-diameter) * .72), 170px); letter-spacing: -.05em; line-height: 1; color: #fff9e8; text-shadow: 0 2px 14px #000; box-shadow: 0 0 0 5px #090c0866, 0 0 0 6px color-mix(in srgb, var(--seat) 60%, #edd398), 0 9px 30px #0008; }
.pcard .life-num::after { content: ''; position: absolute; inset: -11px; border: 1px solid #f7e6b633; border-radius: 50%; pointer-events: none; }
.pcard .life-btn { flex: none; width: clamp(44px, 24cqh, 68px); height: clamp(44px, 24cqh, 68px); min-width: 44px; min-height: 44px; border: 2px solid #fff9e8; background: #fff0c9; color: #19251b; font-size: 34px; font-weight: 500; box-shadow: 0 3px 12px #0009; }
.pcard .life-btn.plus { background: #f4cb7d; }
.pcard .life-btn:hover { background: #fff9e8; }
.pcard .life-btn:active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--seat) 75%, transparent); }
.pcard .life-help, .pcard .pcard-turn { display: none; }
.pcard .stat-row { position: absolute; z-index: 6; bottom: 0; left: 100px; right: 54px; height: 44px; display: flex; align-items: center; flex-wrap: nowrap; min-height: 0; gap: 6px; padding: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.pcard .stat-row::-webkit-scrollbar { display: none; }
.pcard .stat-row:empty { display: none; }
.pcard .stat { flex: none; min-height: 36px; font-size: 14px; padding: 5px 9px; color: #fff5db; background: #070e0bd4; border-color: #ffffff30; backdrop-filter: blur(7px); }
.pcard .turn-tot { color: #e7e5d4; text-shadow: 0 1px 4px #000; }
.pcard button.pcard-cmdr { display: none; }
.pcard button.pcard-cmdr:has(.cmdr-names.empty) { display: none; }
.pcard .cmdr-names.empty { color: #f3e4c7; }
.pcard.is-turn { border-color: #f9d487; box-shadow: 0 0 0 2px #f9d487, 0 0 32px #edba4e38; animation: none; }
.pcard.is-turn::after { border-color: #f8d98b77; box-shadow: inset 0 0 45px #e5b64726; }
.pcard .turn-flag, .pcard .turn-now { color: #ffe5a2; }
.pcard.is-low:not(.is-turn) { border-color: #ff9a86; }
.pcard.is-dead .pcard-in::before { filter: grayscale(1); }
.pcard.is-dead { filter: none; }
.pcard.is-dead .life-num { color: #ffc1b4; }
.pcard .badge.defeated { color: #ffc1b4; border: 1px solid #ffc1b480; background: #361a18; pointer-events: none; }
body.art-full .pcard.has-art .pcard-in::before { opacity: 1; }
body.art-full .pcard.has-art::after { box-shadow: none; }

/* Make the local seating controls useful from any edge. */
.table-tools { gap: 6px; }
.table-tools #table-layout { color: var(--gold); border-color: #dfc79044; }
.table-network { display: block; border: 0; background: none; padding: 0; margin-top: 5px; color: var(--accent); font-size: 10px; text-align: left; cursor: pointer; }
.table-network::before { content: '●'; margin-right: 6px; font-size: 8px; }
.table-network.is-reconnecting { color: #ffd284; }
.invite-network-note { font-size: 12px; line-height: 1.6; color: var(--muted); }
.invite-seats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; text-align: left; margin: 13px 0; }
.invite-seat { display: flex; align-items: center; gap: 7px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; }
.invite-seat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-seat small { font-size: 9px; color: var(--muted); margin-left: auto; }
.invite-seat-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invite-seat-state { margin-left: auto; font-size: 9px; color: var(--muted); white-space: nowrap; }
.invite-seat::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--seat); }
.invite-seat.is-taken { background: #b3e5bf0b; border-color: #b3e5bf33; }
.invite-seat.is-taken small { color: var(--accent); }
.invite-seat.is-taken .invite-seat-state { color: var(--accent); }
.layout-opt { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 4px 14px; padding: 14px; }
.layout-opt .layout-preview { grid-column: 1; grid-row: 1 / span 2; position: relative; display: block; width: 82px; height: 64px; border-radius: 8px; border: 1px solid var(--line); background: #0b1510; }
.layout-opt .lo-label, .layout-opt .lo-desc { display: block; grid-column: 2; }
.layout-opt .lo-desc { margin-top: 5px; }
.layout-opt .lo-copy { min-width: 0; grid-column: 2; }
.layout-preview span { position: absolute; display: grid; place-items: center; width: 32px; height: 22px; background: #3a6345; color: #dbedcf; border: 1px solid #b3e5bf77; font-size: 10px; border-radius: 4px; }
.layout-preview span:nth-child(1) { left: 5px; top: 6px; }
.layout-preview span:nth-child(2) { right: 5px; top: 6px; }
.layout-preview span:nth-child(3) { left: 5px; bottom: 6px; }
.layout-preview span:nth-child(4) { right: 5px; bottom: 6px; }
.layout-preview[data-layout="sides"] span:nth-child(-n+2) { transform: rotate(180deg); }
.layout-preview[data-layout="around"] span { width: 27px; height: 17px; }
.layout-preview[data-layout="around"] span:nth-child(1) { top: auto; bottom: 4px; left: 27px; }
.layout-preview[data-layout="around"] span:nth-child(2) { left: 0; top: 23px; transform: rotate(90deg); }
.layout-preview[data-layout="around"] span:nth-child(3) { bottom: auto; top: 4px; left: 27px; transform: rotate(180deg); }
.layout-preview[data-layout="around"] span:nth-child(4) { right: 0; top: 23px; bottom: auto; transform: rotate(270deg); }
.preview-seat { background-image: linear-gradient(#04100944,#04100988), url('../images/realms-atlas.jpg') !important; background-size: 100% 100%,400% 200% !important; }
.preview-seat.mint { background-position: center,66.6667% 0% !important; transform: rotate(180deg); }
.preview-seat.blue { background-position: center,33.3333% 0% !important; transform: rotate(180deg); }
.preview-seat.coral { background-position: center,0% 0% !important; }
.preview-seat.gold { background-position: center,100% 0% !important; }
.preview-seat > div, .preview-seat footer { color: #fff2d8; }
.preview-seat section b { text-shadow: 0 2px 10px #000; }
.preview-seat section i { background: #08100bc9; }

@media (max-width: 1020px) {
  .table-tools { grid-template-columns: repeat(5,1fr); }
}
@media (max-width: 680px) {
  .table-grid { gap: 10px; }
  .pcard { border-radius: 14px; }
  .pcard::after { inset: 4px; border-radius: 10px; }
  .pcard .pcard-life { padding: 0 10px; }
  .table-tools .icon-btn { padding: 0 4px; font-size: 13px; }
  .invite-seats { grid-template-columns: 1fr; max-height: 220px; overflow-y: auto; }
  .invite-qr { width: 160px; height: 160px; margin: 12px auto; }
  .invite-code { font-size: 32px; margin: 8px 0; }
  .invite-modal .muted { margin: 9px 0; }
}
/* Narrow seats reserve one footer for Damage and More. The name keeps a full
   row, and active counters remain in the space between the two actions. */
@container seat (max-width: 279px) {
  .pcard .pcard-life { margin-bottom: 44px; padding: 0 8px; gap: 6px; }
  .pcard .life-num::after { inset: -5px; }
  .pcard .stat { padding: 5px; }
}
@container seat (max-height: 245px) {
  .pcard .life-num::after { inset: -5px; }
}
@container seat (min-height: 220px) and (min-width: 240px) {
  .pcard .pname { font-size: clamp(28px, 5cqw, 32px); }
}
/* A tablet's tall narrow seats fit all four actions on one footer. This leaves
   the center free for a life total that can be read across the table. */
@container seat (min-height: 245px) and (min-width: 240px) and (max-width: 340px) {
  .pcard .pcard-life { display: grid; place-items: center; margin-bottom: 44px; padding: 0 12px; }
  .pcard .life-num { --life-diameter: clamp(44px, min(92cqh, calc(100cqw - 12px)), 238px); }
  .pcard .life-btn { position: absolute; bottom: -44px; width: 44px; height: 44px; }
  .pcard .life-btn.minus { left: 4px; }
  .pcard .life-btn.plus { right: 4px; }
  .pcard .pcard-damage { left: 56px; }
  .pcard .pcard-admin { right: 56px; }
  .pcard .stat-row { top: 0; bottom: auto; left: auto; right: 8px; max-width: 110px; }
  .pcard:has(.stat-row:not(:empty)) .pcard-head { padding-right: 128px; }
}
/* On short landscape seats, actions share the header so life keeps its height. */
@container seat (max-height: 150px) and (min-width: 200px) {
  .pcard .pcard-head { padding: 0 134px 0 8px; }
  .pcard .pname { font-size: 20px; }
  .pcard .pcard-admin { top: 0; bottom: auto; right: 4px; }
  .pcard .pcard-damage { top: 0; bottom: auto; left: auto; right: 50px; width: 80px; min-width: 80px; font-size: 15px; }
  .pcard .pcard-life { margin-bottom: 0; padding: 0 10px; }
  .pcard .stat-row:not(:empty) { position: relative; inset: auto; height: 36px; padding: 0 10px; }
}
@media (max-height: 460px) and (orientation: landscape) {
  @container seat (max-height: 180px) and (min-width: 240px) {
    .pcard .pcard-head { padding: 0 134px 0 8px; }
    .pcard .pname { font-size: 22px; }
    .pcard .pcard-admin { top: 0; bottom: auto; right: 4px; }
    .pcard .pcard-damage { top: 0; bottom: auto; left: auto; right: 50px; width: 80px; min-width: 80px; font-size: 15px; }
    .pcard .pcard-life { margin-bottom: 0; padding: 0 10px; }
    .pcard .stat-row:not(:empty) { position: relative; inset: auto; height: 36px; padding: 0 10px; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .pcard, .pcard-in { transition: none !important; }
}
