/* Gameplay uses the available viewport, not a vertically flowing page.
   Only the battle view is fixed; collection pages and dialogs can scroll. */
body[data-view="battle"] {
  height:100dvh;
  min-height:0;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
body[data-view="battle"] .app-header {
  width:100%; flex:0 0 auto; margin:0 auto; padding:8px 30px;
  min-height:62px; gap:20px;
}
body[data-view="battle"] .brand { font-size:19px; }
body[data-view="battle"] .brand-mark { width:35px; height:40px; font-size:22px; }
body[data-view="battle"] main {
  width:100%; flex:1 1 0; min-height:0; margin:0 auto;
  display:flex; flex-direction:column;
}
#battle-view {
  flex:1 1 0; min-height:0; width:100%; padding:8px 0 4px;
  display:grid; gap:8px;
  grid-template-rows:36px minmax(0,2.6fr) minmax(38px,.9fr) minmax(0,2.4fr) minmax(0,3.2fr) 36px;
}
#battle-view > * { min-height:0; min-width:0; }
#battle-view .table-heading { margin:0; gap:12px; }
#battle-view .table-heading .text-button { min-height:36px; }
#battle-view .opponents { container-type:size; gap:14px; }
#battle-view .opponent { padding:8px 13px; display:flex; flex-direction:column; min-height:0; }
#battle-view .seat-heading { flex:0 0 auto; margin-bottom:5px; padding-bottom:5px; gap:8px; }
#battle-view .seat-heading h2 { font-size:19px; line-height:1.1; }
#battle-view .field-row { flex:1 1 0; min-height:0; align-items:center; }
#battle-view .opponent .playing-card {
  --card-width:min(calc((100cqh - 64px) * .715909),calc((33.333cqw - 110px) / 2),91px);
}
#battle-view .place-label { line-height:1.2; margin-bottom:5px; }
#battle-view .field-pair { gap:12px; }
#battle-view .table-center { margin:0; padding:0 12%; min-height:0; gap:20px; }
#battle-view .deck { width:clamp(30px,6dvh,48px); }
#battle-view .excluded { width:clamp(23px,4dvh,32px); }
#battle-view .table-flower { font-size:32px; }
#battle-view .table-caption { gap:5px; }
#battle-view .table-caption b { font-size:11px; }
#battle-view .own-mat {
  container-type:size; margin:0 auto; padding:6px 24px;
  gap:clamp(20px,5vw,70px); width:min(680px,100%);
}
#battle-view .own-mat .playing-card {
  --card-width:min(calc((100cqh - 24px) * .715909),18cqw,100px);
}
#battle-view .own-identity h2 { margin:4px 0 6px; font-size:20px; }
#battle-view .own-score b { font-size:clamp(32px,5dvh,51px); }
#battle-view .hand-area { container-type:size; margin:0; position:relative; }
#battle-view .hand-heading { height:22px; margin:0 0 7px; gap:12px; }
#battle-view .hand-heading p { font-size:11px; line-height:1.3; }
#battle-view .hand { padding-top:9px; gap:24px; }
#battle-view .hand .playing-card { --card-width:min(calc((100cqh - 58px) * .715909),120px,23cqw); }
#battle-view .card-category { padding-top:6px; line-height:1.2; }
#battle-view .hand-help { position:absolute; right:12px; bottom:12px; margin:0; min-height:44px !important; width:94px; font-size:10px; }
#battle-view .battle-footer { padding:0; gap:10px; align-items:center; }
#battle-view .quiet-button { min-height:36px; padding:0 12px; }

/* Card content follows its physical card size; no fixed-size numerals can
   force a smaller card taller or clip the character's name. */
#battle-view .playing-card { container-type:inline-size; }
#battle-view .card-number {
  width:clamp(15px,34cqw,38px); height:auto; aspect-ratio:1;
  font-size:clamp(13px,29cqw,32px); left:4cqw; top:4cqw;
}
#battle-view .card-name {
  min-height:0; font-size:clamp(5.5px,9cqw,12px);
  left:6cqw; right:6cqw; bottom:6cqw; padding:2cqw 0;
}
#battle-view .card-name.long-name { font-size:clamp(4.5px,7cqw,9px); }
#battle-view .card-decoration { width:12cqw; height:12cqw; right:7cqw; top:21cqw; transform:translateY(-50%); }

@media(max-width:720px) {
  body[data-view="battle"] .app-header { padding:6px 14px; gap:5px; min-height:0; }
  body[data-view="battle"] .brand { font-size:17px; }
  body[data-view="battle"] .brand-mark { width:30px; height:34px; font-size:20px; }
  body[data-view="battle"] .tabs { padding:2px; }
  body[data-view="battle"] .tab { min-height:35px !important; }
  body[data-view="battle"] main { padding:0 12px max(4px,env(safe-area-inset-bottom)); }
  #battle-view {
    gap:6px; padding:4px 0 0;
    grid-template-rows:36px minmax(0,3.8fr) 43px minmax(0,1.75fr) minmax(0,2.8fr) 36px;
  }
  #battle-view .table-heading { gap:8px; }
  #battle-view .round-label { padding:5px 8px; }
  #battle-view .turn-badge { padding:7px 10px; font-size:10px; }
  #battle-view .opponents { display:grid; grid-template-rows:repeat(3,minmax(0,1fr)); grid-template-columns:1fr; gap:6px; }
  #battle-view .opponent { container-type:size; padding:3px 10px; display:grid; grid-template-columns:75px minmax(0,1fr); gap:8px; }
  #battle-view .seat-heading { margin:0; padding:0; gap:2px 5px; border:0; }
  #battle-view .seat-heading h2 { font-size:17px; }
  #battle-view .hand-count { margin:1px 0 0; padding:2px 5px; }
  #battle-view .field-row { gap:7px; }
  #battle-view .field-pair { gap:10px; }
  #battle-view .place-label { font-size:8px; margin-bottom:3px; }
  #battle-view .opponent .playing-card { --card-width:min(calc((100cqh - 15px) * .715909),47px); }
  #battle-view .score { min-width:38px; }
  #battle-view .score b { font-size:30px; }
  #battle-view .table-center { padding:0; justify-content:center; }
  #battle-view .deck-area { gap:17px; }
  #battle-view .deck { width:28px; }
  #battle-view .excluded { width:22px; }
  #battle-view .excluded-wrap small { margin-top:2px; font-size:6px; }
  #battle-view .deck-count { bottom:2px; font-size:5px; padding:1px 2px; }
  #battle-view .deck-count b { font-size:8px; }
  #battle-view .deck .back-emblem { font-size:11px; }
  #battle-view .table-flower { display:none; }
  #battle-view .own-mat { padding:5px 11px; justify-content:space-between; gap:10px; }
  #battle-view .own-mat .playing-card { --card-width:min(calc((100cqh - 17px) * .715909),58px); }
  #battle-view .own-mat .field-pair { gap:17px; }
  #battle-view .own-identity h2 { font-size:16px; margin:4px 0; }
  #battle-view .own-identity .eyebrow { font-size:6px; }
  #battle-view .own-score b { font-size:34px; }
  #battle-view .hand-heading { gap:8px; height:18px; margin:0 0 5px; }
  #battle-view .hand-heading p { font-size:9px; }
  #battle-view .hand-heading .eyebrow { padding-right:8px; }
  #battle-view .hand { gap:25px; padding-top:9px; }
  #battle-view .hand .playing-card { --card-width:min(calc((100cqh - 48px) * .715909),94px,24cqw); }
  #battle-view .hand-help { right:0; bottom:16px; width:54px; padding:2px; font-size:8px; line-height:1.6; }
  #battle-view .quiet-button { font-size:9px; padding:0 10px; }
  #battle-view .preview-note { font-size:6px; }
}

/* Short portrait screens use the same three seats in a compact strip,
   leaving room for the player's two full cards and all controls. */
@media(max-width:720px) and (max-height:700px) {
  #battle-view { grid-template-rows:36px minmax(0,2.1fr) 40px minmax(0,1.9fr) minmax(0,2.8fr) 36px; gap:5px; }
  #battle-view .opponents { grid-template-columns:repeat(3,minmax(0,1fr)); grid-template-rows:minmax(0,1fr); gap:6px; }
  #battle-view .opponent { padding:5px; display:flex; }
  #battle-view .seat-heading { display:flex; flex-wrap:nowrap; align-items:center; gap:3px; }
  #battle-view .seat-heading h2 { width:auto; flex:1; font-size:13px; }
  #battle-view .seat-heading .win-dots { width:auto; }
  #battle-view .seat-heading .win-dots i { display:none; }
  #battle-view .seat-heading .hand-count { display:none; }
  #battle-view .field-row { position:relative; padding-bottom:15px; justify-content:center; }
  #battle-view .field-pair { gap:5px; }
  #battle-view .opponent .playing-card { --card-width:min(calc((100cqh - 42px) * .715909),calc((100cqw - 5px) / 2),44px); }
  #battle-view .opponent .score { position:absolute; bottom:0; left:0; right:0; display:flex; justify-content:center; align-items:baseline; gap:4px; }
  #battle-view .opponent .score b { font-size:16px; }
  #battle-view .opponent .score small { font-size:6px; }
}

/* Landscape phones / very short desktop windows: opponents on the left,
   own field and hand on the right, instead of shrinking a tall page. */
@media(min-width:721px) and (max-height:500px) {
  body[data-view="battle"] .app-header { padding:3px 18px; min-height:48px; }
  body[data-view="battle"] .brand { font-size:15px; }
  body[data-view="battle"] .brand-mark { width:27px; height:31px; font-size:18px; }
  body[data-view="battle"] .brand small { display:none; }
  body[data-view="battle"] .tabs { padding:1px; }
  body[data-view="battle"] .tab { padding:0 10px; min-height:36px; font-size:10px; }
  body[data-view="battle"] main { padding:0 16px; }
  #battle-view { grid-template-columns:1fr 1fr; grid-template-rows:32px minmax(0,1fr) minmax(0,1.4fr) 32px; gap:6px 14px; padding-top:4px; }
  #battle-view .table-heading { grid-column:1; grid-row:1; gap:8px; }
  #battle-view .table-heading .text-button { min-height:32px; font-size:8px; }
  #battle-view .round-label { font-size:7px; padding:5px; }
  #battle-view .turn-badge { font-size:9px; padding:6px 8px; }
  #battle-view .opponents { grid-column:1; grid-row:2/4; display:grid; grid-template-columns:1fr; grid-template-rows:repeat(3,minmax(0,1fr)); gap:5px; }
  #battle-view .opponent { container-type:size; display:grid; grid-template-columns:70px minmax(0,1fr); gap:8px; padding:3px 9px; border-radius:10px; }
  #battle-view .seat-heading { display:flex; flex-wrap:wrap; border:0; margin:0; padding:0; gap:1px; }
  #battle-view .seat-heading h2 { font-size:14px; width:100%; }
  #battle-view .hand-count { padding:1px 3px; font-size:7px; margin:0; }
  #battle-view .opponent .playing-card { --card-width:min(calc((100cqh - 13px) * .715909),43px); }
  #battle-view .place-label { font-size:7px; margin-bottom:2px; }
  #battle-view .score b { font-size:28px; }
  #battle-view .table-center { grid-column:2; grid-row:1; padding:0; justify-content:flex-end; }
  #battle-view .table-caption,#battle-view .table-flower,#battle-view .excluded-wrap,#battle-view .deck .back-emblem { display:none; }
  #battle-view .deck { width:auto; aspect-ratio:auto; box-shadow:none; border:0; background:none; }
  #battle-view .deck-count { position:static; font-size:9px; padding:4px 8px; }
  #battle-view .deck-count b { font-size:12px; }
  #battle-view .own-mat { grid-column:2; grid-row:2; width:100%; gap:12px; padding:4px 14px; }
  #battle-view .own-mat .playing-card { --card-width:min(calc((100cqh - 13px) * .715909),62px); }
  #battle-view .own-identity .eyebrow { display:none; }
  #battle-view .own-identity h2 { font-size:15px; }
  #battle-view .own-score b { font-size:30px; }
  #battle-view .hand-area { grid-column:2; grid-row:3; }
  #battle-view .hand-heading { height:15px; margin-bottom:0; }
  #battle-view .hand-heading p { font-size:9px; }
  #battle-view .hand-heading .eyebrow { display:none; }
  #battle-view .hand .playing-card { --card-width:min(calc((100cqh - 38px) * .715909),72px); }
  #battle-view .hand { padding-top:8px; }
  #battle-view .card-category { font-size:7px; padding-top:4px; }
  #battle-view .hand-help { width:56px; font-size:7px; right:0; bottom:5px; }
  #battle-view .battle-footer { grid-column:1/3; grid-row:4; }
  #battle-view .battle-footer .quiet-button { min-height:32px; font-size:9px; }
}

/* Counts sit alongside the deck rather than over its printed ornament. */
#battle-view .table-center { container-type:size; }
#battle-view .draw-pile { display:flex; align-items:center; gap:10px; }
#battle-view .deck-area { align-items:flex-start; }
#battle-view .draw-pile .deck,#battle-view .excluded { width:min(calc((100cqh - 10px) * .715909),48px); }
#battle-view .excluded-wrap small { margin-top:2px; font-size:7px; line-height:1; }
#battle-view .deck-count {
  position:static; display:inline-flex; align-items:center; justify-content:center;
  gap:4px; padding:6px 8px; border:1px solid #abc4b3; border-radius:7px;
  font-size:10px; line-height:1; background:var(--cream); white-space:nowrap;
}
#battle-view .deck-count b { font:700 16px/1 system-ui,sans-serif; font-variant-numeric:lining-nums tabular-nums; }
#battle-view .score { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; }
#battle-view .score small { line-height:1; }
#battle-view .score b { line-height:1; font-variant-numeric:lining-nums tabular-nums; }
#battle-view .card-number { height:clamp(15px,34cqw,38px); }
@media(max-width:720px) {
  #battle-view .draw-pile { gap:8px; }
  #battle-view .deck-count { font-size:8px; padding:5px 6px; }
  #battle-view .deck-count b { font-size:13px; }
  #battle-view .win-token { width:8px; height:8px; }
}
@media(max-width:720px) and (max-height:700px) {
  #battle-view .seat-heading .win-token { display:none; }
  #battle-view .opponent .score { flex-direction:row; gap:4px; }
}
@media(min-width:721px) and (max-height:500px) {
  #battle-view .draw-pile .deck { display:none; }
}
/* Keep the shared piles centered independently of the status text. */
#battle-view .table-center { position:relative; justify-content:center; padding:0; }
#battle-view .deck-area { flex:none; }
#battle-view .round-tokens { position:absolute; right:0; max-width:calc(50% - 120px); text-align:right; }
#battle-view.is-targeting[data-target-type="pass"] .deck-area { visibility:hidden; }
#battle-view.is-targeting[data-target-type="pass"] .round-tokens { right:auto; left:50%; transform:translateX(-50%); max-width:100%; text-align:center; }
@media(max-width:720px) {
  #battle-view .round-tokens { max-width:calc(50% - 100px); }
}
@media(min-width:721px) and (max-height:500px) {
  #battle-view .table-center { grid-column:1 / -1; grid-row:4; }
  #battle-view .draw-pile .deck,#battle-view .excluded-wrap { display:block; }
  #battle-view .draw-pile .deck { aspect-ratio:63/88; border:2px solid var(--cream); background-image:var(--card-back); background-size:100% 100%; }
  #battle-view .deck-area { gap:18px; }
  #battle-view .battle-footer { pointer-events:none; justify-content:flex-end; }
  body[data-view="battle"] #battle-view .battle-footer #result-button { pointer-events:auto; margin:0 0 0 auto; }
}
