/* ── PixelDev-only: the Controls keybinding editor (controls-ui.js) ──────
   Separate file on purpose: style.css comes down from upstream and every edit
   there is a recurring merge conflict. Player colors: P1 rides the app accent
   blue, P2 the control-brick orange — the same pair everywhere in the UI. */

:root {
  --ctl-p1: #41a6f6;
  --ctl-p2: #ff8c1a;
  --ctl-hat: #7ddba1;   /* "when () key pressed" bricks — the project's own keys */
}

/* ═══ the panel summary (under "code lives on…") ═══ */
#ctl-summary { display: flex; flex-direction: column; gap: 4px; margin: 2px 0 10px; }
.ctl-sum-row {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 8px; cursor: pointer; min-width: 0;
}
.ctl-sum-row:hover { border-color: var(--accent); }
.ctl-sum-ico { flex: 0 0 auto; }
.ctl-sum-nm { font-weight: 600; flex: 0 0 auto; }
.ctl-sum-info {
  color: var(--dim); font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; min-width: 0;
}

/* ═══ modal shell ═══ */
#ctl-modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(10, 11, 18, .72);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.ctl-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  width: min(1020px, 100%); max-height: 94vh; display: flex; flex-direction: column;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
}
.ctl-head {
  display: flex; gap: 8px; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.ctl-head-space { flex: 1; }
.ctl-tab { border-radius: 8px; padding: 6px 14px; font-weight: 600; }
.ctl-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.ctl-close { padding: 4px 10px; }
.ctl-body { padding: 14px; overflow: auto; }
.ctl-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-top: 1px solid var(--line);
}
.ctl-msg { flex: 1; color: var(--dim); font-size: 12px; opacity: 0; transition: opacity .25s; min-height: 1em; }
.ctl-msg.show { opacity: 1; }
.ctl-note { color: var(--dim); font-size: 11.5px; margin: 12px 2px 0; }

/* ═══ action rows (shared by both panes) ═══ */
.ctl-actions { display: flex; flex-direction: column; gap: 3px; margin-bottom: 14px; }
.ctl-arow { display: flex; gap: 6px; align-items: stretch; }
.ctl-ahead { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .8px; }
.ctl-acell { flex: 1 1 0; min-width: 0; display: flex; align-items: center; padding: 3px 8px; }
.ctl-aname { flex: 0 0 168px; color: var(--txt); font-size: 12px; }
button.ctl-bind {
  justify-content: center; font: inherit; font-size: 12px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px;
  padding: 5px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
button.ctl-bind.ctl-p1 { border-left: 3px solid var(--ctl-p1); }
button.ctl-bind.ctl-p2 { border-left: 3px solid var(--ctl-p2); }
button.ctl-bind.ctl-pd { border-left: 3px solid var(--accent); }
button.ctl-bind:hover { border-color: var(--accent); }
button.ctl-bind.listening {
  color: #fff; border-color: var(--accent);
  animation: ctl-pulse 1s ease-in-out infinite;
}
@keyframes ctl-pulse {
  0%, 100% { background: var(--panel2); }
  50% { background: var(--accent); }
}
.ctl-ahead .ctl-p1 { color: var(--ctl-p1); font-weight: 700; }
.ctl-ahead .ctl-p2 { color: var(--ctl-p2); font-weight: 700; }
.ctl-fixed-row { color: var(--dim); font-size: 12px; }

button.ctl-bind.ctl-hat { border-left: 3px solid var(--ctl-hat); }

/* keyboard pane: actions left, keyboard right on wide screens */
.ctl-kb-pane .ctl-actions { max-width: 560px; }

/* the Platformer / Fight view toggle */
.ctl-modes { display: flex; gap: 6px; margin-bottom: 12px; }
.ctl-mode { border-radius: 8px; padding: 5px 12px; font-weight: 600; }
.ctl-mode.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ═══ the keyboard picture ═══ */
.ctl-keyboard {
  display: flex; gap: 14px; align-items: flex-start; justify-content: center;
  background: var(--ws-bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; overflow-x: auto;
  --u: 30px;
}
.ctl-kb-main { display: flex; flex-direction: column; gap: 4px; }
.ctl-krow { display: flex; gap: 4px; }
.ctl-key {
  position: relative; width: calc(var(--u) * var(--w, 1) + 4px * (var(--w, 1) - 1));
  height: calc(var(--u) + 6px);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--txt); user-select: none; flex: 0 0 auto;
}
.ctl-key:not(.dead) { cursor: pointer; }
.ctl-key:not(.dead):hover { border-color: var(--accent); }
.ctl-key.dead { color: var(--dim); opacity: .45; }
.ctl-key .cap { pointer-events: none; }
.ctl-key .own {
  position: absolute; left: 2px; right: 2px; bottom: 1px;
  display: flex; gap: 2px; justify-content: center; pointer-events: none;
}
.ctl-key .oc { font-size: 7.5px; line-height: 1; border-radius: 3px; padding: 1px 2px; }
.ctl-key .oc.ctl-p1 { background: var(--ctl-p1); }
.ctl-key .oc.ctl-p2 { background: var(--ctl-p2); }
.ctl-key .oc.ctl-hat { background: var(--ctl-hat); color: #10241a; }
.ctl-key.is-p1 { border-color: var(--ctl-p1); box-shadow: inset 0 0 0 1px var(--ctl-p1); }
.ctl-key.is-p2 { border-color: var(--ctl-p2); box-shadow: inset 0 0 0 1px var(--ctl-p2); }
.ctl-key.is-hat { border-color: var(--ctl-hat); box-shadow: inset 0 0 0 1px var(--ctl-hat); }
.ctl-key.both {
  border-color: var(--ctl-p2);
  box-shadow: inset 0 0 0 1px var(--ctl-p1), 0 0 0 1px var(--ctl-p2);
}
.ctl-key.flash { animation: ctl-flash .5s ease-out; }
@keyframes ctl-flash {
  0% { background: var(--accent); color: #fff; }
  100% { background: var(--panel2); }
}
.ctl-kb-side { display: flex; flex-direction: column; gap: 10px; }
.ctl-kb-arrows {
  display: grid; grid-template-columns: repeat(3, calc(var(--u) + 4px)); gap: 4px;
  justify-content: center; margin-top: calc((var(--u) + 10px) * 2);
}
.ctl-kgap { width: calc(var(--u) + 4px); }
.ctl-kb-numpad {
  display: grid; grid-template-columns: repeat(4, calc(var(--u) + 4px));
  grid-auto-rows: calc(var(--u) + 6px); gap: 4px;
}
.ctl-kb-numpad .ctl-key { width: auto; height: auto; }
.ctl-kb-numpad .np-plus { grid-row: span 2; }
.ctl-kb-numpad .np-ent { grid-row: span 2; }
.ctl-kb-numpad .np-zero { grid-column: span 2; }

/* legend */
.ctl-legend { display: flex; align-items: center; gap: 6px; margin-top: 10px; color: var(--txt); font-size: 12px; }
.ctl-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.ctl-dot.ctl-p1 { background: var(--ctl-p1); }
.ctl-dot.ctl-p2 { background: var(--ctl-p2); }
.ctl-dot.ctl-hat { background: var(--ctl-hat); }
.ctl-legend-hint { color: var(--dim); font-size: 11px; }

/* ═══ the controller picture ═══ */
.ctl-pad-status { color: var(--dim); font-size: 12px; margin-bottom: 8px; }
.ctl-pad-status.on { color: #7ddba1; }
.ctl-padpic {
  position: relative; height: 250px; max-width: 560px; margin: 0 auto 16px;
  background: var(--ws-bg); border: 1px solid var(--line); border-radius: 90px 90px 70px 70px;
}
.ctl-pbtn {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 38px; height: 38px; border-radius: 50%;
  background: var(--panel2); border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  font-size: 10px; font-weight: 700; color: var(--txt); cursor: pointer; user-select: none;
  padding: 0 4px;
}
.ctl-pbtn:hover { border-color: var(--accent); }
.ctl-pbtn.fixed { cursor: default; opacity: .55; }
.ctl-pbtn.fixed:hover { border-color: var(--line); }
.ctl-pbtn.bound { border-color: var(--accent); }
.ctl-pbtn.down { background: var(--accent); color: #fff; }
.ctl-pbtn .own { font-size: 9px; line-height: 1; pointer-events: none; }
.ctl-pbtn .cap { pointer-events: none; }
/* shoulders — rectangles riding the top edge */
.p-lt, .p-rt, .p-lb, .p-rb { border-radius: 9px; height: 24px; min-width: 52px; }
.p-lt { left: 16%; top: 4%; }  .p-rt { right: 16%; top: 4%; transform: translate(50%, -50%); }
.p-lb { left: 16%; top: 15%; } .p-rb { right: 16%; top: 15%; transform: translate(50%, -50%); }
/* d-pad cluster */
.p-du { left: 17%; top: 38%; } .p-dd { left: 17%; top: 68%; }
.p-dl { left: 9%;  top: 53%; } .p-dr { left: 25%; top: 53%; }
/* face cluster (diamond) */
.p-fy { right: 17%; top: 38%; transform: translate(50%, -50%); }
.p-fa { right: 17%; top: 68%; transform: translate(50%, -50%); }
.p-fx { right: 25%; top: 53%; transform: translate(50%, -50%); }
.p-fb { right: 9%;  top: 53%; transform: translate(50%, -50%); }
/* middle buttons + decorative sticks */
.p-sel { left: 42%; top: 40%; } .p-start { left: 58%; top: 40%; }
.ctl-stick {
  position: absolute; transform: translate(-50%, -50%);
  width: 52px; height: 52px; border-radius: 50%;
  background: radial-gradient(circle at 45% 40%, var(--panel2), var(--bg));
  border: 2px solid var(--line); opacity: .6;
}
.p-stl { left: 36%; top: 78%; } .p-str { left: 64%; top: 78%; }

.ctl-pad-actions { max-width: 560px; margin: 0 auto; }
