/* SYUBEA coding center - full screen play page */

:root {
  --coding-font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  --coding-brand: #0E9F8E;
  --coding-ink: #12262E;
}

html, body.coding-play {
  height: 100%;
  margin: 0;
}

body.coding-play {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: #e8f1f8;
  font-family: var(--coding-font);
}

.coding-topbar {
  flex: 0 0 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  background: #0b2b27;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
  position: relative;
  z-index: 100;
  box-sizing: border-box;
}

.coding-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.coding-back {
  color: #8FE8DA;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.coding-back:hover { color: #52E0C8; }

.coding-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coding-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(82,224,200,.12);
  border: 1px solid rgba(82,224,200,.3);
  color: #52E0C8;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
}

.coding-topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.coding-member {
  font-size: 12px;
  color: rgba(255,255,255,.72);
  white-space: nowrap;
}

.coding-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.coding-btn:hover { background: rgba(255,255,255,.15); color: #fff; }
.coding-btn-primary { background: #2f9b73; border-color: #2f9b73; }
.coding-btn-primary:hover { background: #278a65; border-color: #278a65; }
.coding-btn-ghost { background: transparent; border-color: transparent; color: rgba(255,255,255,.78); }
.coding-btn-ghost:hover { background: rgba(255,255,255,.1); }

#coding-shell {
  flex: 1 1 auto;
  min-height: 0;
  height: calc(100vh - 48px);
  position: relative;
  overflow: hidden;
}

#app { height: 100%; }

#run-lock-overlay {
  position: absolute !important;
  inset: 0 !important;
}

#sim-panel {
  /* Coding : simulator = 3 : 2 on desktop. */
  flex: 0 0 40%;
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #0b1d2a;
  color: #fff;
  border-left: 1px solid rgba(255,255,255,.12);
  position: relative;
  z-index: 2;
}

/* Desktop simulator toggle: hide the panel and let the editor reclaim
   the full width (demo-bridge re-measures Blockly after toggling). */
#sim-panel.collapsed { display: none; }

.sim-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  font-size: 13px;
  font-weight: 800;
}

.sim-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background: #071a22;
  overflow: hidden;
}

#sim3d-canvas,
#sim2d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
#sim3d-canvas[hidden],
#sim2d-canvas[hidden] { display: none; }

.sim-hud {
  position: absolute;
  inset: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.sim-hud-top {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}

.sim-stat {
  min-width: 58px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(4,20,30,.72);
  border: 1px solid rgba(255,255,255,.12);
  color: rgba(255,255,255,.65);
  font-size: 10px;
  line-height: 1.3;
}
.sim-stat span { display: block; font-size: 10px; }
.sim-stat strong {
  display: block;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}
.sim-stat small {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255,255,255,.65);
  margin-left: 2px;
}

.sim-hud-bottom {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}

.sim-status {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(4,20,30,.72);
  color: #52E0C8;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.sim-block {
  max-width: 60%;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(4,20,30,.72);
  color: rgba(255,255,255,.82);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sim-crosshair {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 50%;
  pointer-events: none;
}
#sim-panel[data-camera="fpv"] .sim-crosshair { display: block; }

.sim-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease;
}
.sim-flash.on { opacity: .75; }

.sim-rec {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  padding: 3px 9px;
  border-radius: 999px;
  background: #b00020;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
}
.sim-rec.on { display: block; }

.sim-emergency {
  position: absolute;
  inset: 0;
  display: none;
  border: 3px solid #ff5252;
  box-shadow: inset 0 0 40px rgba(255,82,82,.45);
  pointer-events: none;
}
.sim-emergency.on { display: block; }

.sim-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(4,20,30,.72);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.sim-loading.hide { display: none; }

.sim-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.12);
  background: #0b1d2a;
}
.sim-controls button,
.sim-controls select {
  height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}
.sim-controls button:hover { background: rgba(255,255,255,.15); }
.sim-controls button.primary { background: #2f9b73; border-color: #2f9b73; }
.sim-controls button.primary:hover { background: #278a65; }
.sim-controls button:disabled { opacity: .45; cursor: default; }
.sim-controls select { padding-right: 6px; }

.sim-example-row {
  align-items: center;
  gap: 6px;
}
.sim-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.65);
}
#sim-example {
  flex: 1 1 auto;
  min-width: 0;
}

.sim-member-note {
  padding: 0 12px 10px;
  font-size: 10.5px;
  line-height: 1.5;
  color: rgba(255,255,255,.6);
}

.coding-modal {
  position: fixed;
  inset: 0;
  z-index: 4000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(4,18,32,.55);
}
.coding-modal.show { display: flex; }

.coding-modal-card {
  width: min(92vw, 520px);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  background: #0b2740;
  color: #fff;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,.4);
  overflow: hidden;
}

.coding-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  font-size: 14px;
  font-weight: 800;
}
.coding-modal-head button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.coding-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px;
}

.coding-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.12);
}

.coding-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,.72);
}
.coding-field input {
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(0,0,0,.2);
  color: #fff;
  padding: 0 10px;
  font: inherit;
  font-size: 12px;
  outline: none;
}
.coding-field input:focus { border-color: #2fe0c8; }

.coding-modal-msg {
  min-height: 17px;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #ffcc00;
}
.coding-modal-msg.error { color: #ff8a8a; }
.coding-modal-msg.ok { color: #52E0C8; }

.coding-program-list { margin-top: 10px; }
.coding-program-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  margin-bottom: 7px;
  border-radius: 8px;
  background: rgba(255,255,255,.06);
}
.coding-program-meta { min-width: 0; flex: 1 1 auto; }
.coding-program-name {
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coding-program-date {
  font-size: 10px;
  color: rgba(255,255,255,.55);
  margin-top: 2px;
}
.coding-program-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.coding-program-actions button {
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.08);
  color: #fff;
  font: inherit;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
}
.coding-program-actions button.load {
  background: #2f9b73;
  border-color: #2f9b73;
}

.coding-empty {
  padding: 22px 10px;
  text-align: center;
  font-size: 11.5px;
  color: rgba(255,255,255,.6);
}

@media (max-width: 1024px) {
  #sim-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    flex-basis: auto;
    transform: translateX(100%);
    transition: transform .2s ease;
    box-shadow: -10px 0 30px rgba(0,0,0,.35);
  }
  #sim-panel.open { transform: none; }
}

@media (max-width: 820px) {
  .coding-topbar { padding: 0 10px; }
  .coding-title { font-size: 0; gap: 0; }
  .coding-title .coding-badge { font-size: 10px; }
  .coding-member { display: none; }
  .coding-topbar-actions { gap: 5px; }
  .coding-btn { padding: 0 8px; font-size: 11px; }
}

@media (max-width: 560px) {
  .coding-back { font-size: 12px; }
  .coding-topbar-actions .coding-btn { height: 28px; }
  .coding-modal { padding: 10px; }
  .coding-modal-card { width: 100%; max-height: 90vh; }
}
