:root {
  --bg: #f6f4ef;
  --paper: #fffdf8;
  --ink: #202124;
  --muted: #85827d;
  --line: #ded9ce;
  --blue: #2368a2;
  --red: #b2453e;
  --shadow: 0 10px 26px rgba(42, 37, 30, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
#app {
  max-width: 920px;
  min-height: 100svh;
  margin: 0 auto;
  padding-bottom: 82px;
}
body:not(.logged-in) #app {
  display: grid;
  max-width: 100%;
  place-items: center;
  padding: 18px;
  background: url("./assets/homepage-background.png") center / cover no-repeat;
}
.login-card {
  display: grid;
  width: min(100%, 380px);
  gap: 18px;
}
.login-card h2 {
  color: #0b3d6b;
  text-align: center;
  font-size: 28px;
}
.login-card p {
  margin: 0;
  color: rgba(35, 104, 162, 0.72);
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}
.login-card label {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 54px;
  padding: 0 18px;
  background: rgba(255,255,255,.56);
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 999px;
}
.login-card input {
  min-height: 48px;
  color: #123e68;
  font-weight: 850;
  background: transparent;
  border: 0;
  outline: 0;
}
.login-card button,
.pill-button,
.icon-button,
.segmented button,
.admin-row button,
[data-import-seed],
[data-export-club],
.admin-game-card button,
.admin-player-card button,
.admin-player-add button,
.draft-card button {
  min-height: 38px;
  padding: 0 16px;
  color: var(--ink);
  font-weight: 850;
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.login-card button {
  min-height: 54px;
  color: #fff;
  background: #2f6fdd;
  border-color: #2f6fdd;
}
.login-card .text-button {
  min-height: 34px;
  color: rgba(35, 104, 162, 0.82);
  font-size: 10px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}
.login-card .setup-message {
  padding: 10px 12px;
  color: #0b3d6b;
  line-height: 1.55;
  text-align: center;
  background: rgba(255,255,255,.52);
  border: 1px solid rgba(255,255,255,.74);
  border-radius: 14px;
}
.login-card .setup-message span {
  display: block;
}
.login-card .setup-message strong {
  font-weight: 950;
}
.error { color: var(--red) !important; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top)) 18px 12px;
  background: rgba(246,244,239,.92);
  border-bottom: 1px solid rgba(222,217,206,.72);
  backdrop-filter: blur(14px);
}
h1 { margin: 0; font-size: 25px; }
h2 { margin: 0 2px 10px; font-size: 20px; }
h3 { margin: 0; }
main { padding: 14px; }
.topbar-actions { display: flex; gap: 8px; }
.stack { display: grid; gap: 18px; }
.card {
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.segmented {
  display: flex;
  gap: 8px;
  margin: 0 0 10px;
  overflow-x: auto;
}
.segmented button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
.note {
  margin: -2px 2px 10px;
  color: rgba(106,105,101,.62);
  font-size: 10px;
  font-weight: 750;
}
.table-wrap {
  overflow-x: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}
th {
  color: var(--muted);
  font-size: 12px;
}
.extreme {
  color: var(--red);
  font-weight: 950;
}
.rank-board {
  display: grid;
  gap: 8px;
  padding: 10px;
}
.rank-row {
  display: grid;
  grid-template-columns: 44px 34px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  gap: 10px;
  padding: 8px 10px;
  background: linear-gradient(90deg, rgba(255,253,248,.98), rgba(255,253,248,.72));
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rank-badge {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 950;
  border-radius: 8px;
  background: rgba(32,33,36,.06);
}
.rank-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(35,104,162,.08);
}
.rank-row strong {
  overflow: hidden;
  font-size: 15px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rank-row em {
  min-width: 72px;
  color: var(--blue);
  font-style: normal;
  font-size: 16px;
  font-weight: 950;
  text-align: right;
}
.rank-top {
  border-color: transparent;
}
.rank-1 {
  background: linear-gradient(90deg, rgba(244,188,59,.34), rgba(255,253,248,.86));
}
.rank-2 {
  background: linear-gradient(90deg, rgba(184,194,205,.34), rgba(255,253,248,.86));
}
.rank-3 {
  background: linear-gradient(90deg, rgba(196,126,61,.30), rgba(255,253,248,.86));
}
.rank-1 .rank-badge {
  color: #7a5200;
  background: linear-gradient(135deg, #ffe7a3, #d89a19);
}
.rank-2 .rank-badge {
  color: #4f5962;
  background: linear-gradient(135deg, #f2f5f7, #aeb8c2);
}
.rank-3 .rank-badge {
  color: #6d3f15;
  background: linear-gradient(135deg, #f4c497, #b56b2e);
}
.rank-muted {
  opacity: .62;
}
.rank-muted em {
  color: var(--muted);
}
.game-list { display: grid; gap: 12px; margin-top: 12px; }
.game-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.game-head em {
  margin-left: auto;
  padding: 7px 14px;
  font-style: normal;
  font-weight: 850;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.game-head em + em { margin-left: 0; }
.blue { color: var(--blue); }
.red { color: var(--red); }
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.kpis div {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.kpis span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}
.kpis strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}
.kpis .blue-kpi span,
.kpis .blue-kpi strong {
  color: var(--blue);
}
.kpis .red-kpi span,
.kpis .red-kpi strong {
  color: var(--red);
}
.player-grid,
.admin-player-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.avatar-rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.avatar-link {
  display: grid;
  gap: 6px;
  justify-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 900;
}
.avatar-link span {
  display: grid;
  width: 62px;
  height: 62px;
  place-items: center;
  font-size: 30px;
  background: rgba(255,253,248,.82);
  border: 1px solid var(--line);
  border-radius: 50%;
  box-shadow: var(--shadow);
}
.player-list {
  display: grid;
  gap: 12px;
}
.player-card {
  display: grid;
  gap: 6px;
}
.player-card > span { font-size: 32px; }
.full-player-card {
  text-align: left;
}
.player-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.player-name-block {
  display: flex;
  align-items: center;
  gap: 10px;
}
.player-name-block span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: rgba(255,253,248,.82);
  border: 1px solid var(--line);
  border-radius: 50%;
}
.expand-player {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,253,248,.76);
  font-weight: 950;
}
.player-kpis {
  grid-template-columns: repeat(3, 1fr);
}
.player-extra {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.player-extra span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.player-extra p {
  margin: 4px 0 0;
  line-height: 1.7;
}
.player-extra button {
  padding: 4px 8px;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-weight: 850;
}
.match-setup {
  display: grid;
  gap: 12px;
  padding: 10px 0 16px;
}
.setup-row,
.direction-selects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.direction-selects {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.venue-field,
.direction-selects label {
  display: grid;
  gap: 6px;
}
.venue-field span,
.direction-selects span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.venue-field input,
.direction-selects select {
  min-height: 42px;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
  text-align-last: center;
  background: rgba(255,253,248,.78);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.setup-field-error {
  color: var(--red) !important;
  font-size: 10px !important;
}
.table-stage {
  display: grid;
  grid-template-columns: minmax(74px, 110px) minmax(220px, 320px) minmax(74px, 110px);
  grid-template-rows: 42px auto 42px;
  grid-template-areas:
    ". top ."
    "left table right"
    ". bottom .";
  gap: 8px;
  align-items: center;
  justify-content: center;
  place-items: center;
  min-height: 0;
  padding: 2px 0 4px;
}
.game-table {
  grid-area: table;
  width: min(46vw, 310px);
  aspect-ratio: 1;
  background: url("./assets/guandan-table.png") center / contain no-repeat;
  filter: drop-shadow(0 18px 24px rgba(35, 104, 162, .16));
}
.seat {
  display: grid;
  min-width: 104px;
  min-height: 36px;
  place-items: center;
  padding: 0 16px;
  color: #fff;
  border-radius: 999px;
  font-weight: 950;
  box-shadow: var(--shadow);
}
.seat-blue { background: var(--blue); }
.seat-red { background: var(--red); }
.seat-top { grid-area: top; }
.seat-bottom { grid-area: bottom; }
.seat-left {
  grid-area: left;
  transform: rotate(-90deg);
}
.seat-right {
  grid-area: right;
  transform: rotate(90deg);
}
.start-row {
  display: flex;
  justify-content: center;
  margin-top: -4px;
}
.start-button {
  min-width: 170px;
  min-height: 48px;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue);
  border-radius: 999px;
  font-weight: 950;
  box-shadow: var(--shadow);
}
.start-button.is-disabled {
  color: var(--muted);
  background: rgba(255,253,248,.76);
  border-color: var(--line);
  cursor: not-allowed;
}
.setup-message {
  margin: -4px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 850;
}
.rules-block {
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.section-head p,
.rule-note-block p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.score-table {
  margin: 10px 0;
}
.rule-note-block {
  display: grid;
  gap: 4px;
}
.inline-rule-link {
  margin: 0 4px;
  padding: 0;
  color: var(--blue);
  background: transparent;
  border: 0;
  font-weight: 950;
}
.collapsible-card summary,
.rule-section summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
}
.collapsible-card summary::-webkit-details-marker,
.rule-section summary::-webkit-details-marker {
  display: none;
}
.hands-visual {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.hand-visual-row {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1fr) 210px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  background: rgba(35, 104, 162, .08);
  border: 1px solid rgba(35, 104, 162, .14);
  border-radius: 8px;
}
.hand-visual-row strong {
  font-size: 14px;
}
.hand-visual-row strong span,
.hand-visual-row em {
  display: block;
  color: #aba8a8;
  font-size: 12px;
  font-style: normal;
  font-weight: 850;
}
.hand-visual-row p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  font-weight: 850;
}
.card-sample,
.card-group,
.sample-line {
  display: flex;
  align-items: center;
}
.card-sample {
  gap: 8px;
  flex-wrap: wrap;
}
.card-group {
  gap: 0;
}
.stacked-sample {
  display: grid;
  gap: 4px;
}
.playing-card {
  display: grid;
  width: 34px;
  height: 46px;
  margin-left: -3px;
  padding: 4px;
  color: #1d2a35;
  background: linear-gradient(180deg, #fff, #f3f7fb);
  border: 1px solid #cfd7df;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(31, 44, 56, .12);
}
.playing-card:first-child {
  margin-left: 0;
}
.playing-card b {
  font-size: 12px;
  line-height: 1;
}
.playing-card i {
  align-self: end;
  justify-self: end;
  font-style: normal;
  line-height: 1;
}
.red-suit {
  color: var(--red);
}
.joker-card::before {
  content: "J";
  align-self: center;
  justify-self: center;
  font-size: 21px;
  font-weight: 950;
}
.red-joker {
  color: #d23c34;
}
.black-joker {
  color: #1d2a35;
}
.rules-toc {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}
.rules-toc button {
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 850;
}
.rule-section {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.rule-section-body {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.6;
}
.rule-section-body p {
  margin: 0;
}
.numbered-rule {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
}
.rule-number {
  color: var(--blue);
  font-weight: 950;
  text-align: right;
}
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.admin-list {
  display: grid;
  gap: 8px;
}
.admin-maintenance-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.admin-maintenance-actions button {
  width: 100%;
}
.admin-row {
  display: grid;
  grid-template-columns: 1fr 1fr 110px auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.admin-row input,
.admin-row select,
.admin-player-card input,
.admin-player-add input,
.draft-card input,
.draft-card select,
.draft-card textarea {
  min-height: 40px;
  padding: 0 12px;
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.draft-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.draft-card label {
  display: grid;
  gap: 6px;
}
.draft-card label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.draft-card textarea {
  min-height: 96px;
  padding: 12px;
  border-radius: 8px;
  resize: vertical;
}
.draft-notes,
.draft-card .subtle,
.draft-card button {
  grid-column: 1 / -1;
}
.subtle {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.admin-player-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(255,253,248,.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 850;
}
.admin-player-card[draggable="true"] {
  cursor: grab;
}
.admin-player-card[draggable="true"]:active {
  cursor: grabbing;
}
.admin-player-card.is-dragging {
  opacity: .48;
}
.admin-player-card.is-drag-over {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.admin-player-card > span,
.admin-player-card input {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 999px;
}
.admin-player-card > span {
  background: rgba(255,253,248,.72);
  border: 1px solid var(--line);
}
.drag-handle {
  margin-right: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
}
.admin-player-card > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.admin-player-card.editing {
  grid-template-rows: auto auto auto;
}
.admin-player-add {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.admin-game-list,
.admin-version-list,
.admin-log-list {
  display: grid;
  gap: 10px;
}
.admin-game-card,
.admin-version-card,
.admin-log-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: rgba(255,253,248,.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.admin-game-main {
  display: grid;
  grid-template-columns: 110px 58px minmax(0, 1fr) 90px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  font-weight: 850;
}
.admin-game-main span,
.admin-game-main strong {
  min-width: 0;
}
.admin-game-actions {
  display: grid;
  grid-auto-flow: column;
  gap: 8px;
}
.admin-version-card > div:first-child,
.admin-log-row {
  min-width: 0;
}
.admin-version-card strong,
.admin-log-row span,
.admin-log-row strong,
.admin-log-row em,
.admin-log-row p {
  display: block;
  margin: 0;
}
.admin-version-card span,
.admin-log-row span,
.admin-log-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  font-style: normal;
  font-weight: 750;
}
.admin-log-row {
  grid-template-columns: 132px 130px 110px minmax(0, 1fr);
}
.admin-log-row p {
  color: var(--ink);
}
.danger-button {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}
.emoji-picker {
  grid-column: 2 / 3;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.emoji-picker button {
  width: 34px;
  height: 34px;
  padding: 0;
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: none;
}
.match-battle-shell {
  position: relative;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
}
.summary-drawer {
  position: sticky;
  top: 82px;
  align-self: start;
  min-height: 220px;
}
.summary-tab {
  width: 44px;
  min-height: 56px;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: 18px;
  font-size: 22px;
  font-weight: 950;
  box-shadow: var(--shadow);
}
.summary-panel {
  display: none;
  width: 300px;
  margin-top: 10px;
  padding: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.summary-open {
  grid-template-columns: 320px 1fr;
}
.summary-open .summary-panel {
  display: grid;
  gap: 8px;
}
.drawer-head h2 {
  margin-bottom: 4px;
}
.summary-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.summary-kpis {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.summary-kpis div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.summary-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.summary-kpis strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 33, 36, .28);
}
.battle-review-card {
  display: grid;
  width: min(92vw, 720px);
  max-height: min(84svh, 760px);
  gap: 12px;
  overflow: auto;
}
.battle-review-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.battle-review-head h2 {
  margin-bottom: 4px;
}
.battle-review-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.review-kpis {
  grid-template-columns: repeat(4, 1fr);
}
.review-kpis .blue-kpi strong {
  color: var(--blue);
}
.review-kpis .red-kpi strong {
  color: var(--red);
}
.battle-review-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.battle-review-actions button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,253,248,.76);
  font-weight: 900;
}
.battle-review-actions button:last-child {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
.round-stack {
  min-width: 0;
}
.round-block {
  display: grid;
  gap: 12px;
}
.round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.first-turn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 850;
}
.first-turn .label {
  color: var(--muted);
  font-size: 12px;
}
.return-setup-button,
.battle-actions button {
  min-height: 38px;
  padding: 0 14px;
  background: rgba(255,253,248,.76);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 850;
}
.deal-editor-list {
  display: grid;
  gap: 10px;
}
.deal-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: rgba(255,253,248,.7);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.deal-editor.draft {
  border-style: dashed;
}
.deal-line-info {
  display: grid;
  grid-template-columns: 54px 120px minmax(92px, 1fr) minmax(100px, 1.2fr) 86px;
  gap: 6px;
  align-items: center;
}
.deal-no {
  color: var(--muted);
  font-weight: 950;
}
.deal-level-pair {
  display: flex;
  gap: 10px;
  grid-column: 2;
  font-weight: 950;
}
.deal-result {
  grid-column: 5;
  justify-self: end;
  font-weight: 850;
  text-align: right;
}
.deal-meta {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  font-weight: 750;
}
.deal-meta.first-to-deal {
  grid-column: 3;
}
.deal-meta.tribute-value {
  grid-column: 4;
}
.deal-meta em {
  color: var(--muted);
  font-style: normal;
  font-weight: 750;
}
.tribute-value {
  justify-content: flex-start;
}
.red-result {
  color: var(--red);
}
.muted-result {
  color: var(--muted);
}
.deal-inputs {
  display: grid;
  grid-template-columns: 62px 1fr;
  gap: 10px;
  align-items: end;
}
.rebellion-input {
  display: grid;
  grid-template-rows: 22px 40px;
  gap: 6px;
  justify-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.rebellion-input span {
  align-self: center;
  text-align: center;
}
.rebellion-input input {
  width: 40px;
  height: 40px;
  margin: 0;
  appearance: none;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.rebellion-input input:checked {
  background: var(--blue);
  border-color: var(--blue);
}
.rebellion-input input:checked::after {
  content: "✓";
  color: #fff;
  font-size: 20px;
  font-weight: 950;
  line-height: 1;
}
.rebellion-input.is-hidden {
  visibility: hidden;
}
.place-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.place-select {
  display: grid;
  gap: 6px;
}
.place-select span {
  justify-self: center;
  min-width: 84px;
  padding: 6px 12px;
  color: #fff;
  text-align: center;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 950;
}
.place-select.team-blue span { background: var(--blue); }
.place-select.team-red span { background: var(--red); }
.place-select select {
  min-height: 42px;
  padding: 0 12px;
  text-align: center;
  text-align-last: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 850;
}
.battle-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.next-round-button:disabled {
  color: rgba(29,47,66,.32);
  cursor: not-allowed;
}
.end-battle-button {
  color: #fff;
  background: var(--blue) !important;
  border-color: var(--blue) !important;
}
.round-footer {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1eee6;
}
.round-footer.ended {
  background: #eef6ef;
  border-color: rgba(47, 123, 87, 0.32);
}
.round-result-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.round-result-head h3 {
  text-align: center;
  font-size: 24px;
}
.round-meta {
  display: grid;
  grid-template-columns: repeat(2, auto);
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
}
.round-meta strong {
  grid-row: span 2;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  white-space: nowrap;
}
.round-result-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}
.result-pill {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 18px;
  font-weight: 900;
  white-space: nowrap;
}
.result-pill.score {
  font-size: 18px;
}
.compact-table {
  margin-top: 8px;
}
.empty-state p {
  color: var(--muted);
  line-height: 1.5;
}
.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: 920px;
  margin: 0 auto;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,253,248,.88);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.tabbar button {
  min-height: 46px;
  color: var(--muted);
  font-weight: 850;
  background: transparent;
  border: 0;
  border-radius: 999px;
}
.tabbar button.active {
  color: var(--blue);
  background: rgba(35,104,162,.12);
}
@media (max-width: 720px) {
  #app { max-width: 720px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .player-grid, .admin-player-grid, .avatar-rail { grid-template-columns: repeat(2, 1fr); }
  .admin-row { grid-template-columns: 1fr; }
  .draft-card,
  .admin-player-add { grid-template-columns: 1fr; }
  .emoji-picker { grid-column: 1 / -1; }
  .match-battle-shell,
  .summary-open {
    grid-template-columns: 1fr;
  }
  .summary-drawer {
    position: static;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 0;
  }
  .summary-tab {
    width: auto;
    min-height: 38px;
    padding: 0 16px;
    font-size: 16px;
  }
  .summary-panel {
    width: 100%;
    margin: 0;
  }
  .battle-actions {
    grid-template-columns: 1fr;
  }
  .review-kpis,
  .battle-review-actions {
    grid-template-columns: 1fr;
  }
  .admin-game-card,
  .admin-game-main,
  .admin-game-actions,
  .admin-version-card,
  .admin-log-row {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
  }
  .round-head {
    flex-wrap: wrap;
  }
  .first-turn {
    justify-content: center;
  }
  .direction-selects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-stage {
    grid-template-columns: 64px minmax(190px, 1fr) 64px;
    grid-template-rows: 38px auto 38px;
    gap: 6px;
  }
  .game-table { width: min(54vw, 290px); }
  .seat {
    min-width: 88px;
    min-height: 34px;
    padding: 0 12px;
  }
  .hand-visual-row { grid-template-columns: 1fr; }
  .rules-toc { grid-template-columns: repeat(2, 1fr); }
  .player-extra { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .deal-line-info,
  .deal-inputs,
  .place-grid {
    grid-template-columns: 1fr;
  }
  .deal-result {
    justify-self: start;
  }
}
