/* LC-083: touch surfaces also work on tablets with a connected mouse. */
.hand-card[data-source]{touch-action:pan-x; -webkit-touch-callout:none}
.formation-slot .unit-card[data-source]{touch-action:none;-webkit-touch-callout:none;user-select:none}
.touch-drag-ghost{
  position:fixed!important;left:0!important;top:0!important;margin:0!important;
  z-index:1000;pointer-events:none!important;opacity:.94;
  transform-origin:center;transition:none!important;animation:none!important;
  box-shadow:0 10px 26px #0009,0 0 0 2px #efd39d;
}
.touch-dragging .is-dragging{opacity:.35}
.touch-dragging .is-drop-valid{outline:2px dashed #dcc28b;outline-offset:-2px}
.touch-dragging .is-dragover{outline:3px solid #ffe3a0;outline-offset:-3px;background:#ae9b4f44}
.touch-dragging .is-drop-invalid{outline:3px solid #cf796a;outline-offset:-3px}

@media(max-width:999px){
  :root{--type-caption:14px;--type-body:16px;--type-heading:24px}
  body{min-width:0}
  .shell{width:100%;min-width:0;padding:8px max(8px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
  button,select,input,.info-trigger{min-height:48px;min-width:48px}
  button{touch-action:manipulation}
  .topbar{height:auto;min-height:0;gap:8px;flex-wrap:wrap;padding-top:env(safe-area-inset-top)}
  .topbar .brand{min-width:0;max-width:100%}
  .topbar .brand h1{white-space:normal}
  .topbar .header-right{width:100%;flex:1 1 100%;gap:6px 12px;flex-wrap:wrap;justify-content:space-between}
  .topbar .header-stat{gap:4px;min-width:0}
  .topbar .header-stat strong{font-size:var(--type-caption)}
  .topbar .header-stat small{font-size:var(--type-caption);letter-spacing:0}
  .topbar .toolbar{display:flex;flex:1 1 100%;width:100%;padding:4px 0;gap:4px;flex-wrap:wrap;justify-content:flex-end;border:0}
  .topbar .toolbar>[data-collection-action]{flex:1 1 82px;min-width:0;padding-inline:4px;font-size:var(--type-caption);line-height:1.2}
  .topbar .toolbar .language-select{width:70px;height:48px;min-height:48px;padding:4px;font-size:var(--type-caption)}
  .topbar .icon-button{flex:0 0 48px;width:48px;height:48px}
  .resource-plus,.energy-label .resource-plus{width:48px;min-width:48px;height:48px;padding:12px;background-clip:content-box;border-color:transparent;position:relative}
  .resource-plus::before{content:'';position:absolute;inset:12px;border:1px solid currentColor;border-radius:50%;opacity:.6;pointer-events:none}
  .info-trigger{width:48px;height:48px;min-width:48px;min-height:48px;border:0;position:relative}
  .info-trigger::before{content:'';position:absolute;inset:10px;border:1px solid currentColor;border-radius:50%;pointer-events:none}
  .shop-close,.pass-close,.collection-modal .collection-close,.modal-close,.shop-detail-header button{width:48px;height:48px;min-width:48px;min-height:48px;flex-shrink:0}
  .collection-modal :is(button,select,input),.shop-tabs button,.pass-button{min-height:48px}
  main.shell:has(>.run-layout){display:grid;grid-template-columns:minmax(0,1fr);gap:10px;max-width:720px}
  main.shell>.topbar{grid-row:1}
  main.shell>.topbar>.brand{display:none}
  main.shell>.run-heading{grid-row:2;margin:0;padding:2px 0}
  .run-heading h2{font-size:var(--type-body);line-height:1.3}
  .run-heading>.journey{margin-top:6px;max-width:100%;gap:0}
  .journey-node{width:24px;height:24px;flex:0 0 24px}
  .journey-line{width:auto;min-width:2px;flex:1 1 12px;max-width:24px}
  .run-layout{display:contents}
  .run-layout>.battlefield{grid-row:3;min-width:0;min-height:0;padding-bottom:4px}
  main.shell>.hand-panel{grid-row:4;min-width:0;margin:0;padding:8px}
  main.shell>.command-bar{grid-row:5;display:grid;grid-template-columns:minmax(0,1fr);gap:8px;margin:0;padding:8px 0;background:var(--bg);position:sticky;bottom:env(safe-area-inset-bottom);z-index:8}
  .run-layout>.sidebar{grid-row:6;min-width:0;gap:10px}
  main.shell>.run-footer{grid-row:7;gap:8px;margin:0;flex-wrap:wrap;letter-spacing:0}
  main.shell:not(:has(>.hand-panel))>.command-bar{grid-row:4}
  main.shell:has(>.hand-panel)>.command-bar>.spells-panel{display:none}
  .battlefield .field-topline{padding:6px;gap:4px;letter-spacing:0;flex-wrap:wrap}
  .battlefield .field-state{letter-spacing:0;padding:4px}
  .battlefield .enemy-row{height:auto;min-height:0;padding:6px;gap:6px;align-items:stretch}
  .battlefield .unit-card.enemy-card{width:auto;flex:1 1 0;min-width:0;padding:3px;gap:3px}
  .battlefield .enemy-card .enemy-figure{width:min(100%,72px);height:auto;aspect-ratio:1;align-self:center}
  .battlefield .enemy-card .enemy-intent{font-size:var(--type-caption);padding:4px 2px;line-height:1.25;overflow:visible;white-space:normal}
  .battlefield .enemy-card .unit-body{padding:5px 3px}
  .battlefield .enemy-card .unit-name{font-size:var(--type-caption);overflow-wrap:anywhere}
  .battlefield .arena-midline{height:20px;margin:0;font-size:var(--type-caption)}
  .battlefield .field-bottom{font-size:var(--type-caption);padding:4px 6px;margin:0;line-height:1.3}
  .battlefield .formation-board,.battlefield .ally-row.formation-board{--formation-card-width:100%;width:100%;height:auto;min-height:0;overflow:visible;padding:6px;gap:6px;align-items:stretch}
  .battlefield .formation-board{scroll-margin-bottom:96px}
  .battlefield .formation-board[data-capacity="3"]{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .battlefield .formation-board[data-capacity="4"]{grid-template-columns:repeat(4,minmax(0,1fr))!important}
  .battlefield .formation-board .formation-slot{width:100%;max-width:none;min-width:0;min-height:0;padding:3px;gap:3px}
  .battlefield .formation-label{font-size:var(--type-caption);line-height:1.2;overflow-wrap:anywhere;margin:0;letter-spacing:0}
  .battlefield .formation-content{align-items:stretch}
  .battlefield .formation-slot .unit-card{display:flex;flex-direction:column;width:100%;min-width:0;max-width:none;height:auto;min-height:0;padding:0;overflow:visible}
  .battlefield .formation-slot .unit-card .portrait{position:relative;inset:auto;flex:none;width:100%;height:auto;aspect-ratio:1;border-radius:4px 4px 0 0}
  .battlefield .formation-slot .unit-body{position:static;inset:auto;width:100%;min-width:0;flex:1;padding:5px 3px;background:#e4d4aa;color:#382d1d;text-shadow:none}
  .battlefield .formation-slot .unit-name{display:block;font-size:var(--type-caption);line-height:1.25;white-space:normal;overflow:visible;overflow-wrap:anywhere;-webkit-line-clamp:unset;color:#382d1d;text-shadow:none}
  .battlefield .formation-slot .unit-role{display:none}
  .battlefield .formation-empty{height:100%;min-height:140px;max-height:none;padding:3px;gap:5px;font-size:var(--type-caption);overflow-wrap:anywhere}
  .battlefield .unit-stats{display:flex;flex-wrap:wrap;gap:3px 6px;font-size:var(--type-caption);line-height:1.2}
  .battlefield .hp-text{white-space:normal;overflow-wrap:anywhere}
  .battlefield .formation-slot .rank{top:1px;right:1px;padding:2px;gap:2px}
  .battlefield .formation-slot .ranksteps{display:none}
  .battlefield .formation-slot .faction-icon{width:20px;height:20px;top:1px;left:1px}
  .battlefield .formation-slot .shield-pill{position:static;align-self:stretch;margin:0;font-size:var(--type-caption);text-align:center}
  .hand-heading{gap:5px;align-items:center;margin:0}
  .hand-heading h3{font-size:var(--type-body)}
  .hand-count{display:flex;align-items:center;font-size:var(--type-caption)}
  .hand-heading .hand-auto{min-height:48px;padding:6px 10px}
  .hand-strip{padding:8px 2px;gap:10px;overscroll-behavior-x:contain;touch-action:pan-x}
  .hand-strip{align-items:stretch}
  .hand-strip .hand-card{width:112px;min-width:112px;flex-basis:112px;height:auto;min-height:164px}
  .hand-card{display:flex;flex-direction:column;padding:0}
  .hand-card .portrait{position:relative;inset:auto;width:100%;height:80px;flex:none}
  .hand-card .unit-body{position:static;inset:auto;width:100%;flex:1;padding:6px;background:#e4d4aa;color:#382d1d;font-size:var(--type-caption)}
  .hand-card .unit-name{display:block;font-size:var(--type-caption);white-space:normal;overflow:visible;-webkit-line-clamp:unset;color:#382d1d;text-shadow:none}
  .hand-card .unit-role{display:none}
  .command-bar .spells-panel{display:block;padding:8px;min-width:0}
  .command-bar .energy-panel{display:flex;align-items:center;justify-content:space-between;width:100%;padding:0 0 6px;border:0;gap:6px}
  .command-bar .energy-value{font-size:var(--type-body)}
  .command-bar .energy-label{display:flex;align-items:center;gap:4px;margin:0}
  .command-bar .energy-pips{display:none}
  .command-bar .spells{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  .command-bar .spell{padding:30px 5px 7px;min-width:0;min-height:76px}
  .command-bar .spell .spell-glyph{display:none}
  .command-bar .spell strong{font-size:var(--type-caption);white-space:normal;overflow-wrap:anywhere;line-height:1.2}
  .command-bar .spell small{font-size:var(--type-caption);white-space:normal;overflow-wrap:anywhere;line-height:1.25}
  .command-bar .spell .spell-key{display:none}
  .command-bar .action-panel{gap:4px}
  .command-bar .action-panel .primary,.battle-controls .secondary{min-height:48px;padding:10px}
  .command-bar .action-caption{font-size:var(--type-caption);line-height:1.3}
  .title-screen{height:auto;min-height:100dvh}
  .title-screen>.shell{height:auto;display:block;padding:8px max(8px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
  .title-screen .title-body{position:static;display:block;padding:12px 0;pointer-events:auto}
  .title-screen .draft-panel{display:block;width:100%;max-width:600px;max-height:none;overflow:visible;padding:16px;margin:auto}
  .title-screen .starter-options,.title-screen .title-actions,.title-screen .meta-panel{margin-top:12px}
  .title-screen .title-actions>.primary,.title-screen .title-actions>.secondary{min-height:48px}
  .modal-backdrop,.shop-backdrop,.pass-backdrop,.collection-backdrop{padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))}
  #toast{bottom:max(12px,env(safe-area-inset-bottom));font-size:var(--type-body)}
}
@media(max-width:480px){
  .battlefield .formation-board,.battlefield .ally-row.formation-board{padding:4px;gap:4px}
  .battlefield .formation-board .formation-slot{padding:1px}
  .battlefield .formation-slot .unit-body{padding:5px 2px}
}
@media(max-width:999px) and (max-height:500px){
  .battlefield .formation-slot .unit-card .portrait{width:64px;max-width:100%;align-self:center}
  .battlefield .formation-empty{min-height:116px}
  .command-bar:has(.battle-controls) .action-caption{display:none}
}
