/* K13 Design & Code (js/duo13.js): the two-player co-op platformer on the workbench. Tokens come from css/site.css.
   The card, head, reset pill, status line and footnote reuse the .wb rules in css/workbench.css and the bench subgrid;
   this file only adds the stage (HUD strip on top, board in the middle, controls underneath) and the panel.
   The canvas lives only inside .d13-view, and every button lives below it, so nothing can cover a button. */
.d13-stage{display:flex;flex-direction:column;padding:0;background:var(--paper-2);-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}

/* HUD: plain text chips above the board; the right side leaves room for the Restart pill */
.d13-top{display:flex;flex-wrap:wrap;align-items:center;gap:6px;min-height:54px;padding:10px 120px 10px 10px;background:var(--paper-2);border-bottom:1px solid var(--line)}
.d13-chip{font-family:var(--mono);font-size:11px;letter-spacing:.04em;line-height:1.4;color:var(--ink);background:var(--paper-3);border:1px solid var(--line-2);border-radius:100px;padding:3px 10px}
.d13-deaths{color:var(--blue);border-color:var(--blue)}

/* the board keeps the level's own shape, 20 by 12 tiles */
.d13-view{position:relative;width:100%;aspect-ratio:20/12;max-height:68vh;background:var(--paper-3)}
.d13-cv{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none;cursor:pointer;-webkit-tap-highlight-color:transparent}
.d13-cv:focus-visible{outline:3px solid var(--blue);outline-offset:-4px}

/* controls: Left, Right, Jump, Switch (44px and up, several at once) and the level picker, all under the board */
.d13-bar{display:flex;flex-direction:column;gap:10px;padding:10px 12px 12px;background:var(--paper-2);border-top:1px solid var(--line)}
.d13-pad{display:flex;flex-wrap:wrap;justify-content:center;gap:8px}
.d13-btn{flex:1 1 76px;max-width:170px;min-height:48px;padding:0 14px;display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  font-family:var(--body);font-weight:600;font-size:15px;line-height:1.2;color:var(--ink);background:var(--paper-3);border:1.5px solid var(--line-3);border-radius:14px;
  touch-action:none;-webkit-tap-highlight-color:transparent;transition:color .25s var(--work,ease),border-color .25s var(--work,ease),background .25s var(--work,ease),transform .25s var(--pop)}
.d13-btn:hover{color:var(--blue);border-color:var(--blue)}
.d13-btn:active,.d13-btn.held{background:var(--blue);border-color:var(--blue);color:#fff;transform:scale(.97)}
.d13-sw{touch-action:manipulation}
.d13-swn{font-family:var(--mono);font-size:10.5px;font-weight:500;letter-spacing:.06em;text-transform:uppercase;color:var(--muted)}
.d13-stage[data-owner="design"] .d13-swn{color:var(--blue)}
.d13-stage[data-owner="code"] .d13-swn{color:var(--ink)}
.d13-btn:focus-visible,.d13-lv:focus-visible,.d13-obtn:focus-visible{outline:2px solid var(--blue);outline-offset:3px}
:root[data-theme="dark"] .d13-btn:active,:root[data-theme="dark"] .d13-btn.held{color:#1A1B1E}

.d13-lvs{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:6px}
.d13-lab{font-family:var(--mono);font-size:11px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);margin-right:4px}
.d13-lv{min-width:44px;height:44px;padding:0 6px;border-radius:100px;font-family:var(--mono);font-size:12px;color:var(--ink);background:var(--paper-3);border:1px solid var(--line-2);
  transition:color .3s var(--work,ease),border-color .3s var(--work,ease),background .3s var(--work,ease)}
.d13-lv:hover:not(:disabled){color:var(--blue);border-color:var(--blue)}
.d13-lv.done{background:var(--wash-mint)}
.d13-lv[aria-pressed="true"]{background:var(--ink);color:var(--paper-2);border-color:var(--ink)}
.d13-lv:disabled{opacity:.4;cursor:not-allowed}

/* the panel: level intro, paused, cleared, both shipped. It covers the board only, never the controls */
.d13-over{position:absolute;inset:0;z-index:5;display:grid;place-items:center;padding:12px;background:rgba(31,32,35,.42)}
.d13-over[hidden]{display:none}
.d13-panel{width:min(100%,400px);display:flex;flex-direction:column;align-items:center;gap:6px;text-align:center;padding:20px 20px 18px;border-radius:18px;
  background:var(--paper-2);color:var(--ink);border:1px solid var(--line);box-shadow:0 30px 70px -30px rgba(31,32,35,.6);max-height:100%;overflow:auto}
.d13-over-t{font-family:var(--disp);font-weight:600;font-size:24px;line-height:1.15;letter-spacing:-.01em;color:var(--ink)}
.d13-over-s{font-size:14.5px;line-height:1.5;color:var(--muted)}
.d13-over-row{display:flex;flex-wrap:wrap;gap:10px;justify-content:center;margin-top:8px}
.d13-obtn{font-family:var(--body);font-weight:600;font-size:15px;min-height:44px;padding:0 22px;border-radius:100px;color:#fff;background:var(--blue);border:1.5px solid var(--blue);transition:background .3s var(--work,ease),transform .3s var(--pop)}
.d13-obtn:hover{background:var(--ink);border-color:var(--ink)}
.d13-obtn.ghost{color:var(--ink);background:transparent;border-color:var(--line-3)}
.d13-obtn.ghost:hover{color:var(--blue);background:transparent;border-color:var(--blue)}
:root[data-theme="dark"] .d13-obtn:not(.ghost){color:#1A1B1E}
:root[data-theme="dark"] .d13-obtn:not(.ghost):hover{background:var(--blue-2);border-color:var(--blue-2)}
:root[data-theme="dark"] .d13-over{background:rgba(10,10,12,.55)}

@media(prefers-reduced-motion:no-preference){
  .d13-panel{animation:d13-rise .45s var(--ease) both}
}
@keyframes d13-rise{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:reduce){
  .d13-btn,.d13-lv,.d13-obtn{transition:none}
  .d13-btn:active,.d13-btn.held{transform:none}
}

/* on a phone the board is small: the panel tucks its copy in, the HUD tightens, the four controls stay 48px tall for a thumb */
@media(max-width:560px){
  .d13-top{padding:8px 104px 8px 8px;gap:4px;min-height:50px}
  .d13-chip{padding:2px 8px;font-size:10.5px}
  .d13-view{min-height:190px}
  .d13-panel{padding:12px 12px 10px;gap:3px}
  .d13-over-t{font-size:18px}
  .d13-over-s{font-size:12.5px;line-height:1.4}
  .d13-obtn{min-height:44px;font-size:14px;padding:0 18px}
  .d13-over-row{margin-top:4px}
  .d13-bar{padding:8px;gap:8px}
  .d13-pad{gap:6px}
  .d13-btn{flex:1 1 70px;padding:0 8px;font-size:14px}
}
