/* =================== Режиссёр =================== */
#stage { left:0; transform:none; }
html, body { touch-action:auto; }
#panel { position:fixed; top:0; right:0; bottom:0; left:50%; display:flex; flex-direction:column; padding:14px 16px; gap:12px;
  background: radial-gradient(ellipse at 30% 0%, #2a2050, #140f24 70%); color:#fff1c4; box-sizing:border-box; min-width:0; }
#panel .ptop { display:flex; align-items:center; justify-content:space-between; }
#panel h1 { margin:0; font-size:22px; color:#ffe6a8; text-shadow:0 3px 0 #7a2a20, 0 0 20px rgba(255,190,90,.35); }
#panel .cols { flex:1; display:grid; grid-template-columns: 1fr 1.15fr; gap:14px; min-height:0; }
#panel .col { display:flex; flex-direction:column; min-height:0; padding:12px; }
#panel h2 { margin:2px 0 10px; font-size:13px; font-family:'Press Start 2P', monospace; font-weight:400; color:#a8322c; text-shadow:0 2px 0 #f0c9a0; }
#panel .btn.small { font-size:20px; padding:4px 10px; }
.ctrl { display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; }
.ctrl .btn { font-size:20px; padding:8px 14px; }
#playBtn { flex:1; font-size:22px; }
#stopBtn { flex:1; }
#clearBtn.arm { background:#c8473d; border-color:#5a1a16; font-size:16px; }
[hidden] { display:none !important; }

#cards { list-style:none; margin:0; padding:2px; overflow-y:auto; flex:1; min-height:0; }
#emptyHint { color:#7a3a24; font-size:18px; padding:16px 6px; text-align:center; }
.card { display:flex; align-items:center; gap:8px; background:#fffaf0; border:2px solid #c9965c; border-radius:8px; padding:5px 6px; margin-bottom:6px;
  color:var(--ink); font-size:17px; transition: transform .2s, background .2s, box-shadow .2s; }
.card .num { font-family:'Press Start 2P', monospace; font-size:12px; color:#9a6a40; min-width:24px; text-align:right; }
.card .pic, .card .scenePic { width:40px; height:40px; image-rendering:pixelated; flex:none; border-radius:6px; background:#f0dcb4; }
.card .scenePic { display:flex; align-items:center; justify-content:center; font-size:24px; }
.card .txt { flex:1; line-height:1.3; }
.card .txt b { color:#7a3a24; }
.card .arg { display:inline-flex; align-items:center; gap:3px; background:#f0dcb4; border-radius:6px; padding:0 6px; }
.card .argpic { width:26px; height:26px; image-rendering:pixelated; vertical-align:middle; }
.card .tools { display:flex; gap:3px; }
.card .tools button { width:30px; height:30px; border:2px solid #c9965c; background:#f7e8c8; color:#7a3a24; border-radius:6px; font-size:14px; cursor:pointer; padding:0; }
.card .tools button:hover { background:#ffe6a8; }
.card.new { animation: pop .35s ease-out; }
.card.run { background:#fff3a0; border-color:#e8a820; box-shadow:0 0 0 3px #ffd23a, 0 0 18px rgba(255,210,58,.7); transform:scale(1.03); }
.card.done { opacity:.55; }
.card.err { background:#ffd0c8; border-color:#c8473d; box-shadow:0 0 0 3px #e8574e; animation: shake .45s; }
#panel.running .tools, #panel.running #who, #panel.running #what { opacity:.4; pointer-events:none; }
@keyframes pop { 0% { transform:scale(.6); opacity:0 } 70% { transform:scale(1.05) } 100% { transform:scale(1); opacity:1 } }
@keyframes shake { 0%,100% { transform:translateX(0) } 20% { transform:translateX(-8px) } 40% { transform:translateX(8px) } 60% { transform:translateX(-5px) } 80% { transform:translateX(5px) } }

#who { display:grid; grid-template-columns: repeat(5, 1fr); gap:8px; margin-bottom:14px; }
.who { display:flex; flex-direction:column; align-items:center; gap:4px; padding:6px 2px; border:3px solid #c9965c; border-radius:10px; background:#fffaf0;
  font-family:inherit; font-weight:800; font-size:15px; color:#7a3a24; cursor:pointer; }
.who .pic, .who .scenePic { width:56px; height:56px; image-rendering:pixelated; }
.who .scenePic { display:flex; align-items:center; justify-content:center; font-size:36px; }
.who.sel { border-color:#e8a820; background:#fff3a0; box-shadow:0 0 0 3px #ffd23a; }
#what { display:grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap:8px; overflow-y:auto; align-content:start; min-height:0; flex:1; padding:2px; }
.tile { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px; min-height:72px; padding:6px 4px; border:3px solid #c9965c; border-radius:10px;
  background:#fffaf0; font-family:inherit; font-weight:800; font-size:15px; color:#4a2a18; cursor:pointer; text-align:center; line-height:1.2; }
.tile:hover, .who:hover { background:#fff3c8; }
.tile:active, .who:active { transform:translateY(2px); }
.tile .ic { font-size:28px; line-height:1; }
.tile.back { background:#e8d4b0; }
.tile .toypic { width:44px; height:44px; image-rendering:pixelated; }
.tile.toy { min-height:72px; }

.bubble { position:absolute; z-index:6; transform:translate(-50%, -100%) scale(.5); opacity:0; pointer-events:none; white-space:nowrap;
  background:#fffdf5; color:#3a2418; border:3px solid #3b2213; border-radius:12px; padding:5px 11px; font-size:18px; font-weight:800;
  transition: opacity .2s, transform .25s cubic-bezier(.3,1.6,.5,1); }
.bubble::after { content:''; position:absolute; left:50%; bottom:-10px; margin-left:-7px; border:7px solid transparent; border-top-color:#3b2213; border-bottom:0; }
.bubble.show { opacity:1; transform:translate(-50%, -100%) scale(1); }
.bubble.err { background:#ffe0d8; border-color:#c8473d; font-size:28px; padding:2px 12px; }
@media (max-width: 1100px) { #panel .cols { grid-template-columns: 1fr; overflow-y:auto; } }
#panel .ptools { display:flex; gap:8px; }
#panel a.btn { text-decoration:none; }
#panel .ptop { flex-wrap:wrap; gap:6px; min-width:0; }   /* на узком экране кнопки 👕 🏠 🔊 переносятся, а не уезжают за край */

/* 🎥 Снять (js/record.js) */
#recBtn { background:#c8473d; border-color:#5a1a16; font-size:18px; }
#recBtn.rec { animation: recBlink 1s steps(2) infinite; }
@keyframes recBlink { 50% { opacity:.55 } }
#recModal { z-index:30; }
#recModal .box { width:92%; max-width:520px; max-height:92%; }
#recVideo { width:100%; max-height:62vh; border-radius:10px; background:#000; }
#recSave { text-decoration:none; }

/* перетаскивание карточек */
.card { cursor:grab; touch-action:pan-y; user-select:none; -webkit-user-select:none; }
#panel.running .card { cursor:default; }
.card.dragging { position:relative; z-index:5; cursor:grabbing; transition:none; box-shadow:0 8px 22px rgba(0,0,0,.35), 0 0 0 3px #ffd23a; background:#fff8d8; }
