/* Match screen: board, cards, dock, side panel. Owner: ui-dev. Target 1280x800, usable at 1024x768. */
.match {
  --cw: 104px;
  --ch: 78px;
  --side: 150px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
  padding: 8px 12px;
  flex: 1;
  min-height: 0;
}
@media (max-width: 1180px) {
  .match { --cw: 92px; --ch: 70px; --side: 136px; grid-template-columns: minmax(0, 1fr) 220px; padding: 6px 8px; gap: 8px; }
}
@media (max-height: 830px) {
  .match { --ch: 68px; }
  .dock-panel { max-height: 250px; }
}
@media (max-height: 790px) {
  .match { --ch: 64px; padding-top: 4px; padding-bottom: 0; }
  .match__main { gap: 4px; }
  .match__banner { min-height: 22px; }
  .table { gap: 4px; padding: 4px; grid-template-rows: var(--ch) var(--ch) 46px var(--ch) var(--ch); }
  .dock-panel { padding: 6px 10px; }
  .hand { padding-top: 4px; }
  .bd-cell { font-size: 10.5px; line-height: 1.2; }
  .bd-points-row { margin-top: 3px; }
  .score-panel__foot { margin-top: 4px; }
  .btn { min-height: 32px; }
}
.match__main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.match__side { display: flex; flex-direction: column; gap: 8px; min-height: 0; min-width: 0; }

.match__banner { display: flex; align-items: center; gap: 12px; min-height: 28px; }
.phase-banner { font-weight: 700; }
.active-turn { margin-left: auto; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; }
.active-turn:empty { display: none; }

/* Table grid */
.table {
  display: grid;
  grid-template-columns: var(--side) repeat(3, var(--cw)) var(--side);
  grid-template-rows: var(--ch) var(--ch) 52px var(--ch) var(--ch);
  gap: 6px;
  justify-content: center;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.slot {
  width: var(--cw);
  height: var(--ch);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: rgb(255 255 255 / 55%);
  position: relative;
}
.slot__label { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; }
.slot--legal { outline: 3px solid var(--ok); outline-offset: 1px; background: #e7f4ea; cursor: pointer; }
.slot--hover { outline-color: var(--accent); background: #dce9f6; }

.lane-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  padding: 2px 4px;
  background: #b9b8b2;
  border-radius: 6px;
  font-size: 0.8rem;
  color: #1d1d1f;
  min-width: 0;
}
.lane-bar__letter { font-weight: 800; font-size: 0.85rem; text-align: center; flex: 1; white-space: nowrap; }
.lane-bar__top { display: flex; align-items: center; justify-content: center; gap: 4px; }
.lane-bar__text { font-size: 0.68rem; text-align: center; line-height: 1.1; }
.lane-bar__pow { font-weight: 800; min-width: 20px; text-align: center; font-size: 0.95rem; }
.lane-bar--win { background: #a9d4b3; }
.lane-bar--loss { background: #e0b0b0; }

.side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pile {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  border: 1px solid #8f8d86;
  border-radius: 6px;
  background: #a7a59e;
  color: #111;
  cursor: pointer;
  padding: 2px;
  overflow: hidden;
}
.pile:hover { background: #b6b4ad; }
.pile__name { font-weight: 700; font-size: 0.8rem; }
.pile__count { font-size: 1.2rem; font-weight: 800; }
.pile__top { font-size: 0.62rem; max-width: 100%; text-align: center; line-height: 1.1; }

.staging { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px dashed var(--border); border-radius: 6px; min-height: 0; overflow: hidden; background: rgb(255 255 255 / 45%); }
.staging__label { font-size: 0.7rem; color: var(--muted); }
.staging__cards { display: flex; flex-wrap: wrap; gap: 4px; align-content: flex-start; }

/* Cards */
.card {
  --el: #8a8f98;
  position: relative;
  width: var(--cw);
  height: var(--ch);
  flex: none;
  border: 1px solid #77757c;
  border-left: 5px solid var(--el);
  border-radius: 6px;
  background: #fff;
  color: #1d1d1f;
  font-size: 11px;
  line-height: 1.15;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.card__num { position: absolute; top: 1px; left: 5px; font-size: 17px; font-weight: 800; }
.card__names {
  position: absolute;
  top: 18px; right: 3px; bottom: 15px; left: 3px;
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: 0 5px;
  text-align: center;
  font-weight: 600;
}
.card__lv { position: absolute; bottom: 1px; left: 5px; font-size: 9px; color: var(--muted); }
.card__suit { position: absolute; bottom: 1px; right: 4px; display: flex; align-items: center; gap: 3px; font-size: 10px; font-weight: 700; }
.card__chip { width: 8px; height: 8px; border-radius: 50%; background: var(--el); border: 1px solid rgb(0 0 0 / 35%); }
.card--effect {
  border: 1px dashed var(--accent);
  border-left: 5px solid var(--accent);
  background: repeating-linear-gradient(135deg, #eef3f8, #eef3f8 6px, #e3ecf5 6px, #e3ecf5 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px;
  text-align: center;
}
.card__tag { font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.card__name { font-weight: 700; font-size: 12px; }
.card__text { font-size: 10px; font-weight: 400; }
.card--back { background: repeating-linear-gradient(45deg, #2f5d8a, #2f5d8a 5px, #274d73 5px, #274d73 10px); border-color: #1b3a58; display: flex; align-items: center; justify-content: center; }
.card__back-mark { color: #cfe0f0; font-weight: 800; letter-spacing: 0.1em; font-size: 12px; }
.card--missing { display: flex; align-items: center; justify-content: center; background: #f0e0e0; }
.card--mini { width: 46px; height: 34px; border-left-width: 3px; }
.card--mini .card__back-mark { font-size: 8px; letter-spacing: 0; }
.card--mini.card--name .card__names, .card--mini .card__lv, .card--mini .card__suit, .card--mini .card__tag { display: none; }
.card--mini .card__num { font-size: 12px; }
.card--mini .card__name { font-size: 8px; }
.card--big { --cw: 128px; --ch: 96px; }
.card--big .card__num { font-size: 20px; }
.card--big .card__names { top: 24px; font-size: 12px; }

.suit-water { --el: #3b82c4; } .suit-earth { --el: #8b6b3d; } .suit-fire { --el: #d9531e; }
.suit-light { --el: #e8c547; } .suit-dark { --el: #4a3d5c; } .suit-ice { --el: #7fd0e0; }
.suit-electric { --el: #f0d000; } .suit-bug { --el: #7aa33a; } .suit-psychic { --el: #c45fa0; }
.suit-strand { --el: #8a8f98; }

/* Dock: hand and phase panels */
.dock { display: flex; flex-direction: column; gap: 6px; }
.dock-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; max-height: 300px; overflow: auto; }
.dock-panel h3 { margin: 0 0 4px; font-size: 1rem; }
.dock-panel p { margin: 4px 0; }
.hand-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }
.hand__label { font-size: 0.75rem; color: var(--muted); }
.hand { display: flex; gap: 8px; overflow-x: auto; padding: 8px 4px 6px; min-height: calc(var(--ch) + 16px); align-items: flex-end; }
.card--hand { cursor: grab; touch-action: pan-x; transition: transform 0.08s; }
.card--hand:hover { transform: translateY(-3px); }
.card--selected { outline: 3px solid var(--accent); outline-offset: 1px; transform: translateY(-8px); }
.drag-ghost { position: fixed; z-index: 200; pointer-events: none; opacity: 0.9; transform: rotate(3deg); box-shadow: 0 6px 16px rgb(0 0 0 / 35%); margin: 0; }
.hand--pick .card { cursor: pointer; }

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.action-bar__end { margin-left: auto; }

.reveal-dialog { display: flex; gap: 16px; align-items: flex-start; }
.reveal-dialog .card--big { --cw: 112px; --ch: 84px; }
.flip-dialog--waiting { text-align: center; }
.bd-tiewin { font-weight: 700; color: var(--accent, inherit); }
.wild-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0; }
.wild-row select { min-height: 32px; border-radius: 6px; border: 1px solid var(--border); padding: 2px 6px; }

/* Scoring breakdown */
.bd-lanes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bd-lane { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.bd-lane__head { display: flex; justify-content: space-between; gap: 6px; padding: 3px 8px; background: var(--surface-2); font-size: 0.8rem; }
.bd-lane__cells { display: grid; grid-template-columns: 1fr 1fr; }
.bd-cell { padding: 4px 6px; font-size: 11px; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.bd-cell--me { border-left: 1px solid var(--border); background: #f4f8fc; }
.bd-cell__who { font-weight: 700; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.bd-line--title { font-weight: 700; }
.bd-points-row { display: flex; gap: 16px; margin-top: 6px; font-size: 0.85rem; flex-wrap: wrap; }
.score-panel__foot { margin-top: 8px; }

.manual-panel { display: flex; flex-direction: column; gap: 8px; }
.manual__entries { display: flex; flex-direction: column; gap: 6px; }
.manual__row { display: flex; align-items: center; gap: 6px; }
.manual__name { min-width: 150px; font-weight: 600; }
.manual__input { width: 64px; text-align: center; }
.manual__compare summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }

/* Side panel */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.panel h3 { margin: 0 0 6px; font-size: 0.95rem; }
.scoreboard .sb-row { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 6px; border-radius: 6px; }
.sb-row--active { background: #e3ecf5; }
.sb-row__name { font-weight: 600; }
.sb-row__total { font-size: 1.5rem; }
.sb-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0 0; font-size: 0.85rem; }
.sb-meta dt { color: var(--muted); }
.sb-meta dd { margin: 0; }
.feed { display: flex; flex-direction: column; flex: 1; min-height: 140px; }
.feed__list { list-style: none; margin: 0 0 6px; padding: 0; overflow-y: auto; flex: 1; font-size: 0.8rem; max-height: 340px; }
.feed__item { overflow-wrap: anywhere; padding: 2px 0; border-bottom: 1px solid var(--surface-2); }
.feed__item time { color: var(--muted); font-size: 0.7rem; }
.feed__item--change { color: var(--warn); }
.feed__item--note { font-style: italic; }
.feed__add { display: flex; gap: 6px; }
.feed__input { flex: 1; min-width: 0; min-height: 32px; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; }

/* Tie-break panel */
.tb-flips { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.tb-flip { display: flex; align-items: center; gap: 12px; }
.tb-flip__n { min-width: 48px; font-weight: 600; }
.tb-side { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 0.75rem; }
.tb-empty { width: var(--cw); height: var(--ch); border: 1px dashed var(--border); display: grid; place-items: center; color: var(--muted); }
.tb-history { margin: 4px 0; padding-left: 18px; font-size: 0.8rem; }

/* Sandbox (T3.2) */
.sandbox-panel { display: flex; flex-direction: column; gap: 6px; border-color: var(--accent); }
.sandbox-panel .btn { padding: 4px 8px; min-height: 30px; font-size: 0.85rem; }
.sandbox-panel__exp { margin: 0; font-size: 0.8rem; word-break: break-word; }
.rescore-hint { margin: 0; font-size: 0.8rem; color: var(--danger); }
.card__menu {
  position: absolute; top: 0; right: 0; z-index: 2;
  min-width: 20px; height: 16px; padding: 0 3px; line-height: 10px;
  border: 1px solid #77757c; border-radius: 4px; background: #fff; color: #1d1d1f;
  font-size: 11px; font-weight: 700; cursor: pointer;
}
.card__menu:hover { border-color: var(--accent); }
.sbx-hover { outline: 3px solid var(--accent); outline-offset: 1px; background: #dce9f6; }
.sbx-dialog { width: min(520px, 94vw); }
.sbx-group { border: 1px solid var(--border); border-radius: 6px; margin: 8px 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 6px; }
.sbx-item-actions { margin-left: auto; display: inline-flex; gap: 4px; }
.pile-list__item { display: flex; align-items: center; gap: 6px; }
.btn--small { padding: 2px 8px; min-height: 26px; font-size: 0.8rem; }
.quick-editor { width: min(560px, 94vw); }
.quick-rules { max-height: 50vh; overflow: auto; display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.quick-rule { display: flex; align-items: center; gap: 8px; justify-content: space-between; font-size: 0.85rem; }
.quick-rule__path { font-family: ui-monospace, monospace; }
.quick-rule input, .quick-rule select { width: 120px; }
.exp-new { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.exp-new__test { display: inline-flex; gap: 4px; align-items: center; font-size: 0.85rem; }
.rules-modal__changes { margin: 4px 0; font-size: 0.85rem; }

/* V2: champion slot, stacks, counters, notices (v2.6) */
.side--staging { justify-content: center; }
.side--staging .staging { padding: 1px 3px; gap: 1px; }
.side--staging .staging__cards { flex-wrap: nowrap; gap: 3px; }
.side--staging .card--mini { width: 34px; height: 24px; }
.champ { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 0; height: 100%; }
.champ-slot {
  width: var(--cw); height: var(--ch); flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border); border-radius: 6px; background: rgb(255 255 255 / 55%); position: relative;
}
.champ-ability { flex: 1; min-height: 0; width: 100%; overflow: auto; font-size: 9.5px; line-height: 1.2; text-align: center; }
.champ-info { display: flex; flex-direction: column; gap: 1px; }
.champ-info__title { font-size: 10px; }
.champ-info__state { font-weight: 800; }
.champ-info__state--on { color: var(--ok); }
.champ-info__state--off { color: var(--muted); }
.champ-info__suits { font-size: 9px; }
.card--champion {
  border: 2px solid #b8860b; border-left: 5px solid var(--el);
  background: linear-gradient(160deg, #fff8dc, #f3e2a6);
}
.card__tag--champ { position: absolute; top: 2px; left: 0; right: 0; text-align: center; color: #7a5a00; font-size: 8px; font-weight: 800; padding-left: 10px; }
.card--champion .card__names { top: 20px; }
.card__suit-item { display: inline-flex; align-items: center; gap: 2px; }
.card--champion .card__suit { flex-direction: column; align-items: flex-end; gap: 0; font-size: 8.5px; right: 3px; line-height: 1.05; }
.card--champion .card__names { bottom: 22px; }
.card--champion .card__lv { font-size: 8.5px; }
.card--mini.card--champion .card__suit { display: none; }
.stack-badge {
  position: absolute; top: -6px; right: -6px; z-index: 3;
  min-width: 22px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: #fff; border: 1px solid #fff; font-size: 11px; font-weight: 800; cursor: pointer;
}
/* A covered-count badge overhangs the top-right corner: tag badges move left of it. */
:has(> .stack-badge) > .card .card__tags { right: 19px; }
.counter { padding: 2px 10px; border-radius: 999px; background: var(--surface-2); font-size: 0.85rem; font-weight: 600; }
.notice { border: 1px solid var(--warn); background: #fff6e0; border-radius: 6px; padding: 4px 10px; font-weight: 600; }
.notice p { margin: 2px 0; }
.bd-champ { font-size: 10px; }
.warn { color: var(--danger); font-weight: 600; }
.score-panel__head { position: sticky; top: -8px; z-index: 2; background: var(--surface); padding: 2px 0 4px; align-items: center; }
@media (max-height: 830px) {
  .dock-panel { max-height: 235px; }
}
@media (max-height: 790px) {
  .table { grid-template-rows: var(--ch) var(--ch) 40px var(--ch) var(--ch); }
  .champ-ability { font-size: 9px; }
}

/* Loot dialog and waiting banner (V3.2, ARCHITECTURE 20.5) */
.loot-dialog__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.loot-dialog__head h3 { margin: 0; }
.loot-dialog__cards { display: flex; gap: 8px; overflow-x: auto; padding: 14px 4px 8px; }
.loot-pick { position: relative; background: none; border: 2px solid transparent; border-radius: var(--radius); padding: 2px; cursor: pointer; flex: none; }
.loot-pick--on { border-color: var(--danger); background: var(--surface-2); transform: translateY(-4px); }
.loot-pick:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.loot-pick .card--hand { cursor: pointer; pointer-events: none; }
.loot-pick__new { position: absolute; top: -10px; left: 4px; z-index: 2; background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 1px 6px; border-radius: 8px; }
.loot-waiting { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; margin-bottom: 6px; font-weight: 600; text-align: center; }
