/* Desktop battlefield: the board, hand and command area share one viewport.
   Cards retain their full rules in the inspector/dialog; motion uses DOM bounds. */
.battle-lane{min-width:0}
@media (min-width:900px) and (min-height:560px){
  body.match-playing{height:100dvh;overflow:hidden}
  .match-playing header{height:50px;padding:0 20px;gap:16px;box-shadow:none}
  .match-playing .brand{font-size:.875rem;gap:10px}
  .match-playing .brandmark{font-size:1.6rem;padding:1px 6px}
  .match-playing .brand small{display:none}
  .match-playing .nav{padding:10px 14px;font-size:.875rem}
  .match-playing .edition{font-size:.75rem}
  .match-playing #app{height:calc(100dvh - 50px)}
  .match-playing .workspace,.match-playing .workspace.inspector-open{position:relative;display:block;height:100%;min-height:0}
  .match-playing .table{
    --hand-height:clamp(150px,23dvh,218px);
    height:100%;min-height:0;padding:6px 20px 0;position:relative;isolation:isolate;
    display:grid;grid-template-columns:minmax(0,1fr);
    grid-template-rows:34px 64px minmax(0,1fr) 18px minmax(0,1fr) 60px var(--hand-height);
    gap:3px;background-size:cover;background-position:center;
  }
  .match-playing .match-top{grid-row:1;margin:0;padding:0 8px;background:transparent;border:0;border-radius:0;align-items:center;z-index:21}
  .match-playing .match-top .eyebrow{display:none}
  .match-playing .match-top h2{font-size:1.25rem;text-shadow:0 1px 2px white}
  .match-playing .match-top .small{padding:6px 10px;font-size:.8125rem;background:#f7fafcf0}
  .match-playing .player-end{position:relative;max-width:none;width:100%;margin:0;display:flex;align-items:center;justify-content:center;min-height:0}
  .match-playing .opponent-end{grid-row:2}
  .match-playing .your-end{grid-row:6}
  .match-playing .player-bar{width:clamp(410px,45vw,600px);height:58px;padding:4px 12px;border-radius:30px;gap:12px;flex-shrink:0;background:#f7fafcee}
  .match-playing .player-bar .avatar{width:48px;height:48px}
  .match-playing .player-info strong{font-size:.8125rem}
  .match-playing .player-info small{font-size:.75rem}
  .match-playing .hp{font-size:2rem;line-height:1;min-width:56px}
  .match-playing .hp small{font-size:.625rem;margin-top:3px}
  .match-playing .card-piles{padding:0 5px 0 10px;gap:9px}
  .match-playing .pile{width:42px;min-height:44px;height:44px;padding:2px;border-radius:4px;gap:0}
  .match-playing .pile b{font-size:1rem;line-height:1.1}
  .match-playing .pile span{font-size:.75rem}
  .match-playing .resources{position:absolute;left:0;top:50%;transform:translateY(-50%);width:calc((100% - clamp(410px,45vw,600px))/2 - 14px);min-height:0;max-height:54px;margin:0;padding:5px 8px;gap:4px;background:#f4f8fbe8;border:1px solid #b8cbd5;border-radius:7px;overflow:auto;align-content:center;font-size:.75rem}
  .match-playing .resources>span:first-child{flex-basis:100%;white-space:nowrap}
  .match-playing .resources>span:last-child:not(.resource):not(:first-child){display:none}
  .match-playing .resource{width:16px;height:20px;font-size:.75rem;flex-shrink:0}
  .match-playing .battle-lane{min-height:0;display:grid;grid-template-rows:16px minmax(0,1fr);gap:0}
  .match-playing .opponent-lane{grid-row:3}
  .match-playing .your-lane{grid-row:5}
  .match-playing .battle-lane>.zone-head{margin:0 8px;align-items:center;font-size:.75rem;line-height:16px;opacity:.85}
  .match-playing .board-row{min-height:0;height:100%;padding:7px 12px 9px;gap:14px;align-items:center;justify-content:safe center;overflow:auto;scrollbar-width:thin}
  .match-playing .empty-zone{min-height:0;height:100%;max-height:120px;max-width:900px;font-size:.8125rem;background:#f7fafc10;border-color:#a7bdc585}
  .match-playing .board-row .card{width:clamp(110px,10.5vw,154px);flex-basis:clamp(110px,10.5vw,154px);height:100%;max-height:172px;min-height:0;padding:4px;display:grid;grid-template-rows:28px minmax(20px,1fr) 22px;gap:0;position:relative}
  .match-playing .board-row .card-top{min-height:0;padding:1px 2px}
  .match-playing .board-row .card-title{font-size:.9375rem;line-height:1;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
  .match-playing .board-row .cost{width:20px;height:20px;min-width:20px;font-size:.75rem}
  .match-playing .board-row .art{height:100%;min-height:0;width:100%;background-position:center 35%}
  .match-playing .board-row .card-type,.match-playing .board-row .card-text{display:none}
  .match-playing .board-row .card-bottom{padding:1px 3px;align-self:end;grid-row:3}
  .match-playing .board-row .card-bottom>span:first-child{display:none}
  .match-playing .board-row .stats{margin-left:auto;font-size:.875rem;line-height:1.1}
  .match-playing .board-row .card-status{position:absolute;left:6px;right:39px;bottom:6px;line-height:1;font-size:.75rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .match-playing .combat-divider{grid-row:4;margin:0;gap:14px;align-self:center;font-size:.75rem;line-height:18px}
  .match-playing .hand-dock{grid-row:7;position:relative;max-width:none;width:100%;height:100%;min-height:0;margin:0;padding:0 300px 0 10px;border-radius:12px 12px 0 0;background:linear-gradient(#edf3f74d,#edf3f7db 28%);display:grid;grid-template-rows:24px minmax(0,1fr)}
  .match-playing .hand-dock>.zone-head{margin:0;padding:0 6px;font-size:.75rem}
  .match-playing .hand-dock .text-button{padding:2px 8px;font-size:.8125rem}
  .match-playing .hand{height:100%;min-height:0;padding:15px 15px 5px;margin:0;align-items:stretch;justify-content:safe center;overflow:auto;scrollbar-width:thin}
  .match-playing .hand .card{width:clamp(108px,9.5vw,145px);flex-basis:clamp(108px,9.5vw,145px);height:100%;max-height:192px;min-height:0;padding:4px;display:grid;grid-template-rows:32px minmax(25px,1fr) 22px;transform-origin:center bottom}
  .match-playing .hand .card+.card{margin-left:-22px}
  .match-playing .hand .card-top{min-height:0;padding:1px 2px}
  .match-playing .hand .card-title{font-size:1rem;line-height:1.05}
  .match-playing .hand .art{height:100%;min-height:0}
  .match-playing .hand .card-type,.match-playing .hand .card-text{display:none}
  .match-playing .hand .card-bottom{padding:1px 2px;font-size:.75rem}
  .match-playing .hand .card:hover,.match-playing .hand .card:focus-visible{transform:translateY(-10px);z-index:5}
  .match-playing .hand .cost{width:22px;height:22px;min-width:22px}
  .match-playing .priority-option{position:absolute;bottom:7px;right:12px;width:270px;padding:0;font-size:.75rem;line-height:18px;z-index:15}
  .match-playing .priority-option input{padding:0;vertical-align:middle}
  .match-playing .command-area{position:absolute;right:26px;bottom:34px;width:276px;max-width:none;max-height:none;margin:0;padding:8px 10px;z-index:15;border-radius:10px;background:#f7fafcf5;box-shadow:0 4px 20px #17354420;overflow:visible}
  .match-playing .phase-bar{flex-wrap:nowrap;justify-content:space-between;gap:1px;margin:0 0 4px;padding:0}
  .match-playing .phase{padding:3px 4px;font-size:.75rem;white-space:nowrap}
  .match-playing .action-bar{display:flex;flex-direction:column;gap:6px;margin:0;min-height:0;align-items:stretch}
  .match-playing .action-bar .hint{font-size:.75rem;line-height:1.35;flex:auto;min-height:0;max-height:33px;overflow:auto}
  .match-playing .action-bar .primary{min-width:0;width:100%;min-height:36px;padding:7px 10px;font-size:.875rem}
  .match-playing .tutorial-step{position:absolute;top:44px;left:24px;width:300px;max-width:calc(100% - 48px);margin:0;padding:14px;z-index:28;background:#f7fcff;box-shadow:0 8px 25px #17354435;align-items:flex-start;font-size:.875rem}
  .match-playing .effect-stack{position:absolute;right:28px;top:80px;width:238px;max-height:calc(100% - var(--hand-height) - 110px);overflow:auto;margin:0;padding:10px;z-index:18;box-shadow:0 8px 24px #17354428;background:#fff8edf5}
  .match-playing .effect-stack .eyebrow{font-size:.75rem;letter-spacing:.05em}
  .match-playing .effect-stack .stack-item{display:block;margin:0 0 5px;padding:8px;font-size:.8125rem}
  .match-playing .sidebar{position:absolute;right:14px;top:44px;width:300px;max-width:calc(100% - 28px);height:auto;bottom:calc(clamp(150px,23dvh,218px) + 8px);max-height:none;overflow:auto;z-index:24;padding:15px;border:1px solid #a9c0cd;border-radius:12px;box-shadow:0 12px 40px #17354440;background:#f7fafcf7}
  .match-playing .sidebar .eyebrow{margin-bottom:10px}
  .match-playing .sidebar .inspect .art{height:130px}
}
@media (min-width:900px) and (min-height:560px) and (max-height:680px){
  .match-playing .table{--hand-height:150px;grid-template-rows:28px 50px minmax(0,1fr) 14px minmax(0,1fr) 50px var(--hand-height);gap:2px;padding-top:3px}
  .match-playing .player-bar{height:48px;padding-block:2px}
  .match-playing .player-bar .avatar{height:40px;width:40px}
  .match-playing .pile{height:38px;min-height:38px}
  .match-playing .player-info small,.match-playing .hp small{display:none}
  .match-playing .board-row{padding-block:5px}
  .match-playing .board-row .card{grid-template-rows:24px minmax(12px,1fr) 20px}
  .match-playing .hand .card{grid-template-rows:28px minmax(20px,1fr) 20px}
  .match-playing .hand .card-title{font-size:.9375rem}
  .match-playing .combat-divider{font-size:.75rem}
}
/* Phones retain a readable scrolling layout; the desktop lock never hides content. */
@media (max-width:899px), (max-height:559px){
  .battle-lane .board-row{justify-content:safe center}
}

/* Opaque HUD surfaces keep text readable over every part of the artwork. */
.table .battlefield-heading{opacity:1;text-shadow:none;align-items:center;line-height:1.2}
.lane-label,.deployed-counter{display:inline-flex;align-items:center;gap:8px;background:#f7fafc;color:#203b4c;border:1px solid #8da4b4;box-shadow:0 2px 5px #17354426;border-radius:7px;min-height:28px;padding:4px 9px;font-size:.75rem;font-weight:700;letter-spacing:.025em}
.lane-label svg,.deployed-counter svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}
.deployed-counter{gap:7px;min-width:54px;justify-content:center;background:#203b4c;color:#fff;border-color:#203b4c}
.deployed-counter strong{font-size:1rem;line-height:1;font-variant-numeric:tabular-nums}
.table .empty-zone{color:#203b4c}
.empty-zone>span{background:#f7fafc;border:1px solid #a6bac7;border-radius:8px;padding:9px 14px;line-height:1.4;box-shadow:0 2px 8px #17354414}
.table .combat-divider>span{background:#203b4c;color:#fff;border-radius:20px;padding:2px 12px;font-weight:600;text-shadow:none}
.table .hand-dock{background:#edf3f7}
.table .hand-dock>.zone-head{color:#203b4c;text-shadow:none;font-weight:600}
.table .priority-option{color:#344f60;background:#edf3f7;border-radius:4px}
.table .match-top h2{background:#f7fafc;border:1px solid #a6bac7;border-radius:6px;padding:3px 9px;color:#203b4c;text-shadow:none}
.table .match-top h2 .muted{color:#344f60}
@media (min-width:900px) and (min-height:560px){
 .match-playing .battle-lane{grid-template-rows:28px minmax(0,1fr)}
 .match-playing .battle-lane>.zone-head{opacity:1;line-height:1.2}
 .match-playing .combat-divider>span{font-size:.6875rem;line-height:14px}
 .match-playing .hand-dock{background:#edf3f7}
}
.table .resources{background:#f7fafc;color:#203b4c;border:1px solid #a6bac7;border-radius:7px;padding:5px 8px}.table .resources .muted{color:#344f60}

/* Infrastructure pile: available / total stays readable above the card art. */
.table .resources.compute-pile{width:94px;height:48px;min-height:48px;max-height:none;padding:0;border:0;background:none;overflow:visible;display:block;isolation:isolate;cursor:help}
.compute-stack{position:absolute;inset:0;--pile-art:url('art/blue-infrastructure.png')}
.compute-stack.red{--pile-art:url('art/red-infrastructure.png')}
.compute-pile .stack-layer{display:block;position:absolute;left:calc(4px + var(--offset,0px));top:0;width:37px;height:46px;min-width:0;border:2px solid #f7fafc;border-radius:4px;background:#203b4c var(--pile-art) center/cover;box-shadow:0 1px 3px #102c3b80;transform:rotate(-5deg);margin:0}
.compute-pile .back-layer{left:0;top:2px;transform:rotate(-13deg)}
.compute-pile .middle-layer{left:7px;top:1px;transform:rotate(5deg)}
.compute-pile .front-layer{left:13px;transform:rotate(8deg)}
.compute-pile .resource.used{filter:grayscale(.85) brightness(.7);background-color:#203b4c}
.compute-stack.empty .stack-layer{background:#dce6ed;border-color:#7d96a7;box-shadow:none}
.compute-pile .compute-count{position:absolute;z-index:3;top:8px;left:30px;min-width:56px;height:31px;display:flex;justify-content:center;align-items:center;background:#203b4c;color:#fff;border:2px solid #f7fafc;border-radius:16px;padding:2px 8px;box-shadow:0 2px 5px #17354450;font-size:1.125rem;line-height:1;font-variant-numeric:tabular-nums}
.compute-count>span{font-size:.8125rem;margin-left:2px;color:#fff}
.compute-pile:focus-visible{outline:3px solid #96610b;outline-offset:3px;border-radius:6px}

/* One visible layer per real infrastructure; tapped layers show faction backs. */
.table .resources.compute-pile{width:var(--pile-width);max-width:100%;height:48px}
.compute-stack{--pile-back:url('art/blue-card-back.png');overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
.compute-stack.red{--pile-back:url('art/red-card-back.png')}
.compute-pile .stack-layer{left:var(--offset);transform:none;top:1px;height:43px}
.compute-pile .resource.used{filter:none;background-image:var(--pile-back);background-size:100% 100%;border-color:#8299aa}
.compute-pile .compute-count{left:auto;right:-4px;top:-10px;height:26px;min-width:49px;font-size:1rem}
.compute-stack.empty{border:1px dashed #8299aa;border-radius:6px;background:#edf3f7;width:37px;height:43px}
@media (min-width:900px) and (min-height:560px){.table .resources.compute-pile{max-width:calc((100% - clamp(410px,45vw,600px))/2 - 14px)}}
