/* A match occupies one viewport; detail and log dialogs own their overflow. */
body[data-view="match"]:has(.arena) { --match-bottom: 0px; padding: 0; height: 100dvh; overflow: hidden; }
body[data-view="match"]:has(.arena) .app-header { height: 52px; min-height: 52px; }
body[data-view="match"]:has(.arena) footer { display: none; }
body[data-view="match"]:has(.arena) main { height: calc(100dvh - 52px - var(--match-bottom)); min-height: 0; padding: 8px 16px; display: grid; grid-template-rows: 34px minmax(130px, .9fr) minmax(160px, 1fr); gap: 8px; }
.match-top { margin: 0; min-height: 0; }
.match-top h1 { font-size: 20px; }
.match-top .eyebrow { margin: 0 0 2px; font-size: 8px; }
.match-tools button { min-height: 32px; height: 32px; width: 34px; }
.arena { display: grid; grid-template-rows: 14px 78px minmax(0, 1fr); gap: 6px; padding: 10px 14px; min-height: 0; }
.arena-topline { margin: 0; font-size: 8px; padding-bottom:0; }
.scoreboard { margin: 0 auto; width: 100%; grid-template-columns: 1fr 60px 1fr; gap: 12px; }
.score .hp { font-size: 30px; line-height: 1; margin:4px 0 6px; }
.score .player-label { font-size: 8px; }
.score .player-label .icon { width: 12px; height: 12px; }
.score > small { font-size: 8px; margin-top:4px; }
.hp-line { margin: 5px 0; }
.clock { min-height: 0; }
.chronos-mini { width: 48px; height: 48px; display: block; margin: auto; }
.clock > span { font-size: 7px; }
.board, .player, .field-cards { min-height: 0; }
.board { gap: 18px; width:100%; height:100%; max-width:none; margin:0; }
.player { display: grid; grid-template-rows: minmax(0, 1fr) 24px 14px; }
.field-cards { height: 100%; }
.battle-slot { min-height: 0; padding: 16px 4px 3px; overflow: hidden; }
.battle-slot button { height: 100%; width: auto; aspect-ratio: 5 / 7; }
.battle-slot { background:#ffffff05; border-radius:6px; }
.battle-slot img { height: 100%; width: 100%; object-fit: contain; }
.slot-label { font-size: 7px; top: 4px; left: 5px; }
.slot-placeholder .icon { width: 18px; height: 18px; }
.field-bottom { margin: 0; gap: 5px; flex-wrap: nowrap; }
.field-bottom > button, .field-bottom > span { min-height: 24px; padding: 2px 0; font-size: 7px; }
.set-status { padding: 1px 0 0; font-size: 7px; }
.turn-controls { margin: 0; min-height: 0; }
.turn-controls > .hand-panel { height: 100%; min-height: 0; margin: 0; padding: 9px 12px; display: grid; grid-template-rows: 30px minmax(0, 1fr) 44px; gap: 7px; position: relative; }
.hand-panel > h2 { display: none; }
.hand-panel .hand-top { grid-row: 1; }
.hand-panel .hand-help { position: absolute; right: 14px; top: 37px; z-index: 5; }
.hand-help > summary { padding: 3px; font-size: 9px; }
.hand-help[open] { background: var(--paper); padding: 10px; max-width: 280px; border: 1px solid var(--line); box-shadow: 0 4px 14px #291a3920; }
.hand-help[open] p { margin: 8px 0; }
.hand { grid-row: 2; display: grid; grid-template-columns: repeat(var(--hand-columns, 5), minmax(0, 1fr)); grid-template-rows: repeat(var(--hand-rows, 1), minmax(0, 1fr)); gap: 9px; margin: 0; padding: 0; overflow: visible; }
.hand .card { width: auto; min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) 28px; gap: 5px; position: relative; }
.hand-art { border: 0; padding: 0; min-height: 0; width: 100%; background: transparent; }
.hand-art img { height: 100%; width: 100%; object-fit: contain; object-position:bottom; display: block; border-radius: 4px; }
.hand .hand-select { position: static; border: 1px solid #c5b4d0; min-height: 28px; padding: 3px; width: 100%; border-radius: 5px; background: #f9f5fc; }
.hand .chosen .hand-select { background: var(--purple); color: white; }
.hand .selection-order { position: static; background: transparent; color: inherit; display: inline-flex; width: auto; height: 18px; font: 12px ui-monospace,monospace; }
.hand .selection-order .icon { width: 16px; height: 16px; }
.hand-detail, .hand-card-stats { display: none; }
.hand-panel .hand-action, .choice-panel .hand-action { position: static; grid-row: 3; margin: 0; border: 0; border-top: 1px solid #cdbfd6; padding: 5px 0 0; box-shadow: none; background: transparent; min-height: 0; }
.hand-action .primary { min-height: 36px; padding: 7px 12px; }
.hand-action > span { font-size: 18px; }
.turn-controls > .panel, .turn-controls > .cover { min-height: 0; max-height: 100%; padding: 14px; }
.turn-controls > .cover { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.turn-controls .cover-symbol { margin: 0; }
.turn-controls .cover h2 { font-size: 20px; margin: 0; }
.turn-controls .cover p { margin: 0; font-size: 11px; }
.turn-controls .effect { font-size: 11px; padding: 8px; margin: 5px 0; }
.turn-controls h2 { font-size: 17px; margin: 0 0 8px; }
.turn-controls .actions { gap: 7px; }
.turn-controls .actions button { min-height: 36px; padding: 7px 10px; font-size: 11px; line-height: 1.5; }
.attack-versus { padding: 0; }
.attack-versus strong { font-size: 30px; }
.choice-panel { display: flex; flex-direction: column; height: 100%; gap: 6px; }
.choice-panel > .eyebrow { margin: 0; }
.choice-grid { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; flex: 1; min-height: 0; gap: 5px; padding: 0; overflow: hidden; }
.choice-card { flex: 1 1 45px; max-width: 100px; width: auto; min-height: 0; display: flex; flex-direction: column; }
.choice-card img { object-fit: contain; min-height: 0; flex: 1; }
.choice-card > span { display: none; }
.choice-art { flex: 1; min-height: 0; padding: 0; border: 0; display: flex; background: transparent; }
.choice-art img { width: 100%; height: 100%; }
.choice-select { min-height: 28px; margin-top: 4px; padding: 3px 7px; font-size: 10px; }
.choice-select[aria-pressed="true"] { background: var(--purple); color: white; }
.choice-panel .hand-action { flex: 0 0 44px; }
.card-preview { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: #100b16; color: white; overflow: hidden; }
.card-preview #detail-body, .card-preview .detail-layout { height: 100%; width: 100%; }
.card-preview .detail-layout { display: block; padding: max(48px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) calc(60px + var(--safe-bottom)) max(10px, env(safe-area-inset-left, 0px)); }
.card-preview .detail-layout > img { height: 100%; width: 100%; max-width: none; object-fit: contain; margin: 0; border-radius: 0; }
.close { display:grid; place-items:center; line-height:1; }
.close > .icon { display:block; width:20px; height:20px; }
.card-preview .close { position: absolute; z-index: 4; top: max(12px, env(safe-area-inset-top, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); width: 44px; height: 44px; min-height: 44px; padding: 0; background: #ffffff16; color: white; border: 1px solid #ffffff30; border-radius: 50%; }
.card-data { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 20px var(--safe-bottom); background: #21182ff5; }
.card-data > summary { display: flex; justify-content: space-between; padding: 14px 0; font-size: 12px; }
.card-data[open] { top: max(64px, env(safe-area-inset-top, 0px)); overflow-y: auto; }
.card-data > p { font-size: 13px; line-height: 1.9; }
.card-data .muted, .card-data small { color: #cabcd3; }
.card-data a { color: #e5dbee; }
@media(max-width:600px) {
  body[data-view="match"]:has(.arena) { --match-bottom: var(--mobile-nav-height); }
  body[data-view="match"]:has(.arena) main { padding: 5px 10px; gap: 6px; grid-template-rows: 32px minmax(125px, 1.05fr) minmax(145px, .95fr); }
  .arena { padding: 8px; grid-template-rows: 12px 78px minmax(0, 1fr); gap: 4px; }
  .board { gap: 12px; }
  .field-cards { gap: 5px; }
  .perspective-tabs button { min-height: 28px; font-size: 9px; padding: 3px 7px; }
  .turn-controls > .hand-panel { padding: 8px; grid-template-rows: 28px minmax(0, 1fr) 44px; gap: 6px; }
  .hand { gap: 6px; }
  .hand-action .primary { font-size: 10px; max-width: none; }
  .turn-controls > .cover { padding: 10px; }
  .turn-controls .cover .primary { min-width: 0; }
}
@media(min-width:901px) and (min-height:621px) {
  body[data-view="match"]:has(.arena) main { max-width:none; grid-template-columns:minmax(0,1.2fr) minmax(0,1fr); grid-template-rows:36px minmax(0,1fr); gap:12px; padding:10px 22px 18px; }
  .match-top { grid-column:1/-1; }
  .arena,.turn-controls { grid-row:2; }
  .arena { grid-template-rows:18px 94px minmax(0,1fr); padding:16px; gap:14px; }
  .score .hp { font-size:40px; }
  .score > small,.score .player-label { font-size:10px; }
  .scoreboard { grid-template-columns:1fr 80px 1fr; gap:18px; }
  .chronos-mini { width:65px;height:65px; }
  .board { gap:18px; }
  .battle-slot { padding:26px 8px 10px; }
  .slot-label { font-size:9px;top:8px;left:8px; }
  .player { grid-template-rows:minmax(0,1fr) 36px 22px; }
  .field-bottom > button,.field-bottom > span { font-size:10px;min-height:32px; }
  .set-status { font-size:9px;padding-top:5px; }
  .hand { grid-template-columns:repeat(var(--desktop-hand-columns,3),minmax(0,1fr));grid-template-rows:repeat(var(--desktop-hand-rows,2),minmax(0,1fr));gap:12px; }
  .turn-controls > .hand-panel { grid-template-rows:38px minmax(0,1fr) 52px; padding:14px;gap:12px; }
  .hand-panel .hand-help { top:18px; }
  .hand-panel:has(.perspective-tabs) .hand-help { top:48px; }
}
@media(max-height:620px) and (min-width:650px) {
  body[data-view="match"]:has(.arena) main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: 32px minmax(0, 1fr); }
  .match-top { grid-column: 1 / -1; }
  .arena, .turn-controls { grid-row: 2; }
}
