/* ============================================================
 * 꽃길 로봇 — style.css  (자기완결형, 외부 셸 의존 없음)
 * robot-coding 의 검증된 패턴 재사용:
 *   [hidden]!important · 데스크탑 3컬럼 밀착 클러스터 · 모바일 세로 스택
 * ============================================================ */
:root {
  --color-primary: #2563eb;
  --color-secondary: #16a34a;
  --color-xp: #f59e0b;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f2f6ee;
  --card: #ffffff;

  /* 명령 카테고리 색 */
  --gc-move: #2563eb;   /* 이동 — 파랑 */
  --gc-jump: #f59e0b;   /* 점프 — 골드 */
  --gc-bloom: #ec4899;  /* 피우기 — 분홍 */
  --gc-call: #16a34a;   /* 내 블록 — 초록 */

  --stage-wc: #ec4899;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont,
               system-ui, 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; cursor: pointer; }
h1 { margin: 0; }

/* hidden 이 저자 CSS 에 눌리지 않게 — robot-coding 실수 1의 교훈 */
[hidden] { display: none !important; }

/* ══════════════ 메뉴 화면 ══════════════ */
#screen-menu {
  min-height: 100dvh;
  background: linear-gradient(180deg, #f8fcf4 0%, #eef6e8 100%);
}
.menu-inner { max-width: 940px; margin: 0 auto; padding: 4.2rem 1.1rem 4rem; position: relative; }
.exit-pill {
  position: absolute; top: 1rem; left: 1.1rem;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .42rem .85rem; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  color: var(--muted); font-weight: 700; font-size: .84rem;
  text-decoration: none; box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: background .15s, color .15s;
}
.exit-pill:hover { color: var(--color-primary); background: #f1f5ff; }

.menu-head { text-align: center; margin-bottom: 2rem; }
.menu-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; }
.menu-head .gr-bot { font-size: 1.7rem; }
.menu-sub { color: var(--muted); margin: .7rem auto 0; max-width: 560px; line-height: 1.6; font-size: .98rem; }
.menu-sub b { color: var(--gc-bloom); }

.menu-list { display: flex; flex-direction: column; gap: 2rem; }
.world-head {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: .5rem .7rem;
  padding: 0 0 .7rem; margin-bottom: 1rem;
  border-bottom: 2px solid var(--wc, var(--gc-bloom));
}
.world-name { font-size: 1.25rem; font-weight: 800; color: var(--wc); }
.world-tag {
  font-size: .74rem; font-weight: 700; color: #fff; background: var(--wc);
  padding: .12rem .5rem; border-radius: 999px;
}
.world-desc { color: var(--muted); font-size: .9rem; }

.stage-grid { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stage-card {
  position: relative; text-align: left;
  display: flex; flex-direction: column; gap: .35rem;
  padding: .85rem .9rem; min-height: 92px;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--card);
  box-shadow: 0 2px 6px rgba(15,23,42,.05);
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.stage-card:not(.locked):hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(15,23,42,.12); border-color: var(--wc); }
.stage-card.locked { opacity: .55; cursor: not-allowed; background: #f8fafc; }
.stage-card.done { border-color: var(--wc); }
.sc-num {
  font-size: .72rem; font-weight: 800; color: #fff; background: var(--wc);
  width: 1.5rem; height: 1.5rem; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.sc-title { font-weight: 700; font-size: 1rem; }
.sc-stars { color: var(--color-xp); font-size: 1.05rem; letter-spacing: 1px; margin-top: auto; }
.sc-lock { position: absolute; top: .8rem; right: .8rem; font-size: 1.05rem; }

/* ══════════════ 플레이 화면 (풀스크린 셸 · 3컬럼 밀착 클러스터) ══════════════ */
#screen-play {
  position: fixed; inset: 0; height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(1100px 600px at 18% 8%, rgba(190,242,190,.55), rgba(190,242,190,0) 60%),
    radial-gradient(900px 560px at 86% 92%, rgba(251,207,232,.5), rgba(251,207,232,0) 60%),
    linear-gradient(165deg, #f2fcf1 0%, #eef7ff 55%, #fdf4fa 100%);
  overflow: hidden;
}
.play-top {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: .8rem;
  padding: .6rem .9rem; background: #fff; border-bottom: 1px solid var(--line);
}
.play-titles { flex: 1; min-width: 0; text-align: center; line-height: 1.15; }
.play-world { display: block; font-size: .74rem; font-weight: 700; color: var(--stage-wc); }
.play-stage-title { font-size: 1.1rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.play-count { font-size: .8rem; color: var(--muted); font-weight: 700; white-space: nowrap; }

.mini-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: .42rem .8rem; font-weight: 700; font-size: .82rem;
  transition: background .15s;
}
.mini-btn:hover { background: #f1f5f9; }
.mini-btn.primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.play-hint {
  flex: 0 0 auto; margin: 0; padding: .55rem .95rem;
  font-size: .86rem; color: #64435a; font-weight: 600;
  background: linear-gradient(90deg, #fff0f7, #fff7ee);
  border-bottom: 1px solid #fbd9ea;
}

/* 세 열은 밀착 덩어리 + 덩어리째 중앙 (robot-coding 시선 교훈) */
.play-main {
  flex: 1 1 auto; min-height: 0;
  display: flex; gap: .8rem; padding: .8rem;
  justify-content: center;
}
.play-left {
  flex: 0 1 640px; min-width: 280px;
  display: flex; flex-direction: column; gap: .6rem;
}
.maze-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
.iso-canvas { display: block; }
/* 컨트롤 묶음 — 오른쪽 편집 열의 슬롯 바로 아래 (편집하던 손 그대로 실행) */
.play-side-bottom { flex: 0 0 auto; display: flex; flex-direction: column; align-items: stretch; gap: .45rem; margin-top: .3rem; }

.play-palette-col {
  flex: 0 0 172px;
  display: flex; flex-direction: column; gap: .55rem;
  min-height: 0; overflow-y: auto;
}
.play-right {
  flex: 0 0 clamp(380px, 34vw, 520px);
  display: flex; flex-direction: column; min-height: 0; gap: .45rem;
}
.ws-label { font-size: .76rem; font-weight: 800; color: var(--muted); letter-spacing: .02em; }

/* 팔레트 (세로 스택) — 카테고리 그라데이션 + 살짝 떠오르는 호버 */
.palette { display: flex; flex-direction: column; gap: .55rem; }
.pal-btn {
  display: flex; align-items: center; gap: .55rem;
  border: none; border-radius: 999px; color: #fff; font-weight: 800;
  padding: .68rem .85rem; font-size: .92rem; line-height: 1;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 3px 8px var(--cs, rgba(15,23,42,.2)), inset 0 1px 0 rgba(255,255,255,.35);
  cursor: grab;
  transition: transform .12s, box-shadow .12s, filter .12s;
}
.pal-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 14px var(--cs, rgba(15,23,42,.28)), inset 0 1px 0 rgba(255,255,255,.35); }
.pal-btn:active { transform: scale(.95); }
.pal-btn:disabled { opacity: .5; cursor: default; box-shadow: none; transform: none; }
.pal-btn.dragging { opacity: .5; }
.pb-icon {
  flex: 0 0 auto; width: 1.6rem; height: 1.6rem; border-radius: 9px;
  background: rgba(255,255,255,.28); font-size: .95rem; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
.cat-move  { --c1: #5b8cf8; --c2: #2563eb; --cs: rgba(37,99,235,.35); }
.cat-jump  { --c1: #fbbf3f; --c2: #f59e0b; --cs: rgba(245,158,11,.35); }
.cat-bloom { --c1: #f472b6; --c2: #e0518c; --cs: rgba(236,72,153,.35); }
.cat-call  { --c1: #34c465; --c2: #16a34a; --cs: rgba(22,163,74,.35); }

/* 슬롯 에디터 — 카드형 줄 + 그라데이션 칩 */
.slot-wrap { flex: 1 1 auto; overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: .75rem; }
.slot-wrap.locked .pal-btn, .slot-wrap.locked .slot.filled { cursor: default; }
.slot-row {
  border: 2px solid transparent; border-radius: 18px;
  padding: .7rem .8rem; background: rgba(255,255,255,.85); cursor: pointer;
  box-shadow: 0 4px 14px rgba(23,55,95,.08);
  transition: border-color .15s, box-shadow .15s;
}
.slot-row:hover { border-color: #e3ebf5; }
.slot-row.active { border-color: var(--stage-wc); box-shadow: 0 4px 16px rgba(236,72,153,.16); background: #fff; }
.slot-row.drag-over { border-color: var(--stage-wc); background: #fff7fb; }
.slot-label { font-size: .78rem; font-weight: 800; color: var(--muted); margin-bottom: .5rem; letter-spacing: .02em; }
.slot-row.active .slot-label { color: var(--stage-wc); }
.slot-label.proc { color: var(--gc-call); }
.slot-cells { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.slot {
  width: 50px; height: 50px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.28rem; font-weight: 800; color: #fff;
  user-select: none;
}
.slot.empty {
  border: 2px dashed #d4deea;
  background: rgba(244,248,252,.8);
  box-shadow: inset 0 2px 4px rgba(23,55,95,.05);
}
.slot.filled {
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 3px 7px var(--cs, rgba(15,23,42,.2)), inset 0 1px 0 rgba(255,255,255,.35);
  cursor: grab;
  transition: transform .1s, filter .1s;
}
.slot.filled:hover { filter: brightness(1.07); transform: translateY(-1px); }
.slot.filled.dragging { opacity: .35; }
/* 실행 중: 지금 도는 블록만 밝게 펄스, 나머지는 살짝 가라앉힘 */
.slot-wrap.locked .slot.filled:not(.running) { opacity: .45; filter: saturate(.75); }
.slot.running {
  opacity: 1 !important;
  animation: gr-running .55s ease-in-out infinite alternate;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--color-xp), 0 4px 12px rgba(245,158,11,.45);
}
@keyframes gr-running {
  from { transform: scale(1.04); }
  to { transform: scale(1.14); }
}
/* 드롭 위치 표시선 */
.slot-drop-line {
  width: 5px; height: 50px; border-radius: 3px;
  background: var(--stage-wc);
  box-shadow: 0 0 0 1px rgba(255,255,255,.8);
}

/* 컨트롤/피드백 — 오른쪽 편집 열, 슬롯 아래 */
.play-controls { flex: 0 0 auto; display: flex; gap: .5rem; width: 100%; }
.ctrl-btn {
  flex: 1; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 12px; padding: .7rem; font-weight: 800; font-size: .95rem;
  transition: background .15s, transform .1s;
}
.ctrl-btn:hover { background: #f1f5f9; }
.ctrl-btn:active { transform: scale(.97); }
.ctrl-btn.run {
  flex: 2; color: #fff; border: none;
  background: linear-gradient(180deg, #5b8cf8, #2563eb);
  box-shadow: 0 4px 12px rgba(37,99,235,.35), inset 0 1px 0 rgba(255,255,255,.3);
}
.ctrl-btn.run:hover { background: linear-gradient(180deg, #4a7ef2, #1d4ed8); }
.ctrl-btn.stop {
  color: #fff; border: none;
  background: linear-gradient(180deg, #f87171, #dc2626);
  box-shadow: 0 4px 12px rgba(220,38,38,.30), inset 0 1px 0 rgba(255,255,255,.3);
}
.ctrl-btn.stop:hover:not(:disabled) { background: linear-gradient(180deg, #ef4444, #b91c1c); }
.ctrl-btn:disabled { opacity: .55; cursor: default; box-shadow: none; }

.play-msg {
  flex: 0 0 auto; min-height: 1.4rem;
  font-size: .88rem; color: var(--muted); padding: .1rem;
  text-align: center;
}
.play-msg.ok { color: var(--color-secondary); font-weight: 700; }
.play-msg.no { color: #dc2626; font-weight: 700; }
.play-msg.hint { color: var(--color-xp); font-weight: 700; }
.succ { display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.succ-stars { font-size: 1.6rem; color: var(--color-xp); letter-spacing: 3px; }
.succ-line { color: var(--ink); font-weight: 700; font-size: .9rem; }
.succ-btns { display: flex; gap: .5rem; margin-top: .2rem; }

/* ══════════════ 반응형 (모바일: 세로 스택) ══════════════ */
@media (max-width: 820px) {
  .play-main { flex-direction: column; gap: .5rem; padding: .5rem; }
  .play-left { flex: 0 0 auto; }
  .maze-wrap { flex: 0 0 auto; height: 38vh; }
  .play-palette-col { flex: 0 0 auto; overflow-y: visible; }
  .play-palette-col .palette { flex-direction: row; flex-wrap: wrap; gap: .4rem; }
  .play-palette-col .pal-btn { width: auto; padding: .5rem .7rem; font-size: .85rem; }
  .play-right { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .menu-inner { padding-top: 3.6rem; }
  .menu-head h1 { font-size: 1.6rem; }
  .maze-wrap { height: 32vh; }
  .slot { width: 42px; height: 42px; }
}
