/* ===== レイアウト ===== */
.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.lead {
  text-align: center;
  color: var(--muted-color);
  font-size: 1rem;
  margin: -8px 0 24px;
}

/* ===== セクションヘッダー ===== */
.sec-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sec-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: #1a202c;
  letter-spacing: 0;
  text-shadow: none;
  text-align: left;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.var-badge  { background: #fff3e0; color: #c2410c; }
.list-badge { background: #eff6ff; color: #1d4ed8; }

/* ===== 説明文 ===== */
.concept-desc {
  color: #374151;
  line-height: 1.75;
  margin-bottom: 4px;
}

/* ===== デモエリア ===== */
.demo-area {
  display: flex;
  align-items: center;
  gap: 32px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.demo-area.column {
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

/* ===== 変数ビジュアル ===== */
.var-visual { flex: 0 0 auto; padding-top: 18px; padding-right: 26px; }

/* ── cardboard box ──────────────────────────── */
.var-box {
  --box-dx: 22px;
  --box-dy: 14px;
  position: relative;
  width: 162px;
  border-radius: 3px 3px 4px 4px;
  overflow: visible;
  flex-shrink: 0;
  background: #C8935A;
  background-image:
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.07) 0px,  rgba(255,255,255,0.07) 1px,
      rgba(0,0,0,0.04)       1px,  rgba(0,0,0,0.04)       2px,
      transparent            2px,  transparent            6px
    );
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
}

.var-box.pop {
  animation: varPop .35s ease;
}

@keyframes varPop {
  0%   { transform: scale(1) translateY(0); }
  35%  { transform: scale(1.07) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

/* ── 3-D faces: two top flaps + right side ──── */
.box-flap-l,
.box-flap-r {
  position: absolute;
  top: calc(-1 * var(--box-dy));
  left: 0;
  width: calc(100% + var(--box-dx));
  height: var(--box-dy);
  background-image:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.07) 0px, rgba(255,255,255,0.07) 1px,
      transparent            1px, transparent            6px
    );
  /* pivot at fold line (bottom = top edge of box front face) */
  transform-origin: center bottom;
  transition: transform 0.42s ease, opacity 0.36s;
}

/* left flap: left half of the top parallelogram */
.box-flap-l {
  background-color: #E8CA90;
  clip-path: polygon(
    0px var(--box-dy),
    calc(50% - var(--box-dx) / 2) var(--box-dy),
    calc(50% + var(--box-dx) / 2) 0px,
    var(--box-dx) 0px
  );
}

/* right flap: right half of the top parallelogram */
.box-flap-r {
  background-color: #D9B57A;
  clip-path: polygon(
    calc(50% - var(--box-dx) / 2) var(--box-dy),
    calc(100% - var(--box-dx)) var(--box-dy),
    100% 0px,
    calc(50% + var(--box-dx) / 2) 0px
  );
}

.box-face-right {
  position: absolute;
  top: calc(-1 * var(--box-dy));
  left: 100%;
  width: var(--box-dx);
  bottom: 0;
  background: #8B5224;
  background-image:
    repeating-linear-gradient(
      180deg,
      rgba(0,0,0,0.08) 0px, rgba(0,0,0,0.08) 1px,
      transparent      1px, transparent      6px
    );
  clip-path: polygon(0 var(--box-dy), 100% 0, 100% 100%, 0 100%);
}

/* box opening: flaps fold backward (rotateX around fold line) */
.var-box.box-open .box-flap-l {
  transform: perspective(320px) rotateX(-115deg);
  opacity: 0.5;
}

.var-box.box-open .box-flap-r {
  transform: perspective(320px) rotateX(-115deg);
  opacity: 0.5;
}

/* ── shipping label (variable name) ─────────── */
.var-name-label {
  margin: 10px 10px 0;
  background: #FFFEF0;
  border: 1px solid #DDD0B0;
  border-radius: 3px;
  padding: 6px 9px;
  display: flex;
  align-items: baseline;
  gap: 5px;
  /* label shadow = sticker lifted slightly */
  box-shadow: 0 1px 3px rgba(0,0,0,0.18), 0 0 0 1px rgba(255,255,255,0.5) inset;
  position: relative;
}

/* tape strip across top of label */
.var-name-label::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 22%;
  right: 22%;
  height: 7px;
  background: rgba(210,190,100,0.55);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* tiny zone tags */
.var-zone-tag {
  font-size: 0.58rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.var-zone-inner {
  color: rgba(255,255,255,0.45);
}

/* the variable name on the label */
.var-label {
  color: #2D1A08;
  font-size: 0.95rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

/* ── interior (value) ───────────────────────── */
.var-value-area {
  position: relative;
  margin: 8px 10px 10px;
  background: #A86A32;
  background-image:
    repeating-linear-gradient(
      180deg,
      rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 1px,
      transparent            1px, transparent            5px
    );
  border-radius: 3px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  /* deep inner shadow = looking into box */
  box-shadow: inset 0 5px 16px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(0,0,0,0.1);
}

.var-val {
  font-size: 1.8rem;
  font-weight: 800;
  color: #FFF8F0;
  word-break: break-all;
  max-width: 130px;
  text-align: center;
  font-family: 'Courier New', monospace;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.var-type {
  font-size: 0.65rem;
  font-weight: 700;
  color: #FFDFA0;
  background: rgba(0,0,0,0.2);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ── mini (compare section) ─────────────────── */
.var-box.mini {
  --box-dx: 14px;
  --box-dy: 9px;
  width: 104px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}

.var-box.mini .var-name-label {
  margin: 7px 7px 0;
  padding: 4px 7px;
}

.var-box.mini .var-label {
  font-size: 0.78rem;
}

.var-box.mini .var-value-area {
  margin: 6px 7px 7px;
  padding: 7px 8px 8px;
}

.var-box.mini .var-val {
  font-size: 1.2rem;
}

/* ===== 操作コントロール ===== */
.demo-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted-color);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.demo-input {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .95rem;
  width: 130px;
  transition: border-color .2s;
  background: #fff;
  color: #1a202c;
}

.demo-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,120,215,.12);
}

.mono { font-family: 'Courier New', monospace; }

.eq-sign {
  font-size: 1.4rem;
  font-weight: 700;
  color: #9ca3af;
  margin-bottom: 6px;
  line-height: 1;
}

/* ===== コードブロック ===== */
.code-block {
  background: #1e293b;
  border-radius: 10px;
  padding: 10px 16px 14px;
  margin: 16px 0;
}

.code-label {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

.code-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.code-block code {
  font-family: 'Courier New', 'Consolas', monospace;
  font-size: .92rem;
  color: #e2e8f0;
  background: none;
  padding: 0;
  line-height: 1.6;
}

/* ===== ノート ===== */
.concept-note {
  background: #f0f9ff;
  border-left: 4px solid var(--brand);
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: .88rem;
  line-height: 1.75;
  margin-top: 16px;
  color: #0c4a6e;
}

.concept-note code {
  background: #dbeafe;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: .85em;
  color: #1d4ed8;
}

/* ===== マンションイラスト ===== */
.list-wrapper { width: 100%; overflow-x: auto; padding-bottom: 4px; }

/* 建物全体 */
.mansion-building {
  display: inline-block;
  min-width: 100%;
  overflow: hidden;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* 三角屋根（clip-pathで幅に追従） */
.mansion-roof-peak {
  height: 52px;
  background: #c0392b;
  clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
  margin-bottom: -1px;
}

/* 屋根帯（建物名） */
.mansion-roof-band {
  background: #c0392b;
  border-bottom: 4px solid #922b21;
  padding: 6px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: .9rem;
  color: #fff;
}

.mansion-roof-band code {
  font-family: 'Courier New', monospace;
  font-weight: 800;
  color: #fff;
  font-size: .9rem;
  background: none;
  padding: 0;
}

.mansion-name-sub {
  font-size: .65rem;
  color: rgba(255,255,255,0.75);
  font-weight: 600;
}

/* 外壁（クリーム） */
.mansion-wall {
  background: #f0ede4;
  border-left: 5px solid #d4c5a9;
  border-right: 5px solid #d4c5a9;
  padding: 20px 16px 18px;
}

/* 基礎 */
.mansion-ground {
  height: 12px;
  background: #6d5a2a;
  border-left: 5px solid #4a3a18;
  border-right: 5px solid #4a3a18;
  border-radius: 0 0 3px 3px;
}

/* ===== 部屋（ドアイラスト） ===== */
.list-visual {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  padding: 0 4px 4px;
  flex-wrap: nowrap;
}

.list-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: transform .15s;
}

.list-item:hover { transform: translateY(-3px); }

/* ドア本体（木製） */
.list-box {
  width: 58px;
  height: 88px;
  background: linear-gradient(170deg, #a87040 0%, #8b5228 60%, #7a4220 100%);
  border: 3px solid #5a3010;
  border-radius: 4px 4px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 8px 4px 4px;
  gap: 6px;
  position: relative;
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,0.18),
    inset -1px 0 0 rgba(0,0,0,0.15),
    2px 3px 8px rgba(0,0,0,0.28);
  transition: all .2s;
}

/* ドアの小窓 */
.door-win {
  width: 32px;
  height: 20px;
  background: #cce5f5;
  border: 2px solid #5a3010;
  border-radius: 2px;
  flex-shrink: 0;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* ドアに書いたラベル */
.door-label {
  font-size: .72rem;
  font-weight: 700;
  color: #fff0d8;
  text-align: center;
  line-height: 1.2;
  word-break: break-all;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  max-width: 52px;
}

/* ドアノブ（真鍮） */
.door-knob {
  position: absolute;
  right: 7px;
  bottom: 18px;
  width: 8px;
  height: 8px;
  background: radial-gradient(circle at 35% 30%, #f8e090, #c89a28);
  border-radius: 50%;
  border: 1px solid #8b6010;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

/* ドアの段差（step） */
.list-box::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: -5px;
  right: -5px;
  height: 6px;
  background: #b8a890;
  border-radius: 0 0 3px 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* 部屋番号プレート */
.list-index {
  margin-top: 13px;
  background: #5a4a3a;
  color: #f5dfa0;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  font-family: monospace;
  white-space: nowrap;
}

/* 選択時：ドアが明るくなる */
.list-item.selected .list-box {
  background: linear-gradient(170deg, #d49050 0%, #b87038 60%, #a06028 100%);
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,0.25),
    0 0 16px rgba(255,200,80,0.5),
    2px 3px 8px rgba(0,0,0,0.28);
}

.list-item.selected .door-win {
  background: #fff9c4;
  box-shadow: inset 0 0 8px rgba(255,220,0,0.4), 0 0 6px rgba(255,220,0,0.3);
}

.list-item.selected .list-index {
  background: #7a5a10;
  color: #ffd54f;
}

@keyframes itemIn {
  from { opacity: 0; transform: scale(.6) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.list-item.new-item { animation: itemIn .28s ease; }

.list-hint {
  font-size: .8rem;
  color: var(--muted-color);
  margin-top: 10px;
  min-height: 1.2em;
}

/* リスト操作バー */
.list-action-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.list-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
}

.list-btn:active { transform: scale(.96); }

.add-btn    { background: var(--brand); color: #fff; }
.add-btn:hover  { background: var(--brand-dark); }
.add-btn:disabled { background: #cbd5e1; cursor: not-allowed; }

.remove-btn { background: #fff; color: #6b7280; border: 1.5px solid var(--border); }
.remove-btn:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }
.remove-btn:disabled { color: #d1d5db; border-color: #e5e7eb; cursor: not-allowed; }

.list-count { font-size: .82rem; color: var(--muted-color); margin-left: 4px; }

/* ===== 比較カード ===== */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.compare-card {
  border-radius: 12px;
  padding: 20px;
  border: 2px solid transparent;
}

.var-theme  { background: #fff7ed; border-color: #fed7aa; }
.list-theme { background: #eff6ff; border-color: #bfdbfe; }

.compare-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.var-theme  .compare-title { color: #c2410c; }
.list-theme .compare-title { color: #1d4ed8; }

.compare-visual {
  margin: 12px 0 16px;
  display: flex;
  justify-content: center;
  padding-top: 12px;
  padding-right: 18px;
}

/* ===== ミニマンション（比較カード用） ===== */
.mini-mansion {
  display: inline-flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 0 0 3px 3px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.mini-roof-peak {
  height: 28px;
  background: #c0392b;
  clip-path: polygon(0% 100%, 50% 0%, 100% 100%);
  margin-bottom: -1px;
}

.mini-roof-band {
  background: #c0392b;
  border-bottom: 3px solid #922b21;
  padding: 3px 10px 4px;
  font-size: .62rem;
  font-weight: 700;
  color: #fff;
  text-align: center;
  font-family: 'Courier New', monospace;
}

.mini-wall {
  background: #f0ede4;
  border-left: 3px solid #d4c5a9;
  border-right: 3px solid #d4c5a9;
  padding: 8px 6px 4px;
}

.mini-ground {
  height: 7px;
  background: #6d5a2a;
  border-left: 3px solid #4a3a18;
  border-right: 3px solid #4a3a18;
  border-radius: 0 0 2px 2px;
}

.mini-list {
  display: flex;
  gap: 5px;
}

.mini-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 42px;
}

.mini-val {
  width: 38px;
  height: 48px;
  border: 2px solid #5a3010;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(170deg, #a87040, #7a4220);
  box-shadow: inset 1px 0 0 rgba(255,255,255,0.15), 1px 2px 5px rgba(0,0,0,0.25);
  font-size: .6rem;
  font-weight: 700;
  color: #fff0d8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 5px;
  gap: 3px;
  text-align: center;
  line-height: 1.2;
  word-break: break-all;
  position: relative;
}

/* ミニ小窓 */
.mini-val::before {
  content: '';
  width: 20px;
  height: 12px;
  background: #cce5f5;
  border: 1.5px solid #5a3010;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ミニノブ */
.mini-val::after {
  content: '';
  position: absolute;
  right: 4px;
  bottom: 8px;
  width: 5px;
  height: 5px;
  background: radial-gradient(circle at 35% 30%, #f8e090, #c89a28);
  border-radius: 50%;
  border: 1px solid #8b6010;
}

.mini-idx {
  margin-top: 4px;
  background: #5a4a3a;
  color: #f5dfa0;
  font-size: .5rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 2px;
  font-family: monospace;
  white-space: nowrap;
}

.compare-list {
  font-size: .85rem;
  padding-left: 18px;
  line-height: 1.9;
  color: #374151;
  margin: 0;
}

.compare-list code {
  font-family: 'Courier New', monospace;
  font-size: .8em;
  background: rgba(0,0,0,.07);
  padding: 1px 4px;
  border-radius: 4px;
}

/* ===== 代入デモ ===== */
.assign-badge { background: #f0fdf4; color: #166534; }
.incr-badge   { background: #fdf4ff; color: #7e22ce; }

.assign-demo {
  position: relative;           /* anchor for flying token */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 20px 0;
  flex-wrap: wrap;
}

.assign-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 18px;
  padding-right: 26px;
}

.assign-sublabel {
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted-color);
  letter-spacing: .5px;
}

/* ── assign box theme (green tint on label) ─── */
.assign-var-box .var-name-label {
  background: #F0FFF8;
  border-color: #A8D8C0;
}

.assign-var-box .var-name-label::before {
  background: rgba(100,200,160,0.5);
}

.assign-var-box .var-label {
  color: #064E3B;
}

/* box thud when value lands */
@keyframes boxReceive {
  0%   { transform: scale(1)    translateY(0);  }
  18%  { transform: scale(1.06) translateY(-6px); }
  44%  { transform: scale(0.97) translateY(3px); }
  66%  { transform: scale(1.02) translateY(-2px); }
  100% { transform: scale(1)    translateY(0);  }
}

.assign-var-box.box-receive {
  animation: boxReceive 0.45s ease;
}

/* val drops into interior */
@keyframes valDrop {
  0%   { transform: scale(0.4) translateY(-20px); opacity: 0; }
  60%  { transform: scale(1.15) translateY(4px);  opacity: 1; }
  100% { transform: scale(1)   translateY(0);     opacity: 1; }
}

.assign-var-box.box-receive .var-val {
  animation: valDrop 0.38s ease forwards;
}

/* ── RHS value box ───────────────────────────── */
.assign-rhs {
  width: 110px;
  height: 80px;
  border: 2.5px solid #6ee7b7;
  border-radius: 12px;
  background: #f0fdf4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: #065f46;
  font-family: 'Courier New', monospace;
  transition: background .15s, border-color .15s, transform .15s;
}

.assign-rhs.flash {
  animation: rhsFlash .22s ease;
}

@keyframes rhsFlash {
  0%   { background: #bbf7d0; border-color: #10b981; transform: scale(1.06); }
  100% { background: #f0fdf4; border-color: #6ee7b7; transform: scale(1); }
}

/* ── center = sign ───────────────────────────── */
.assign-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 24px;
}

.assign-eq {
  font-size: 2rem;
  font-weight: 800;
  color: #10b981;
  line-height: 1;
  transition: transform .2s;
}

.assign-eq.eq-pulse {
  animation: eqPulse .4s ease;
}

@keyframes eqPulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.5); color: #059669; }
  100% { transform: scale(1); }
}

.assign-dir-label {
  font-size: .72rem;
  font-weight: 700;
  color: #10b981;
  white-space: nowrap;
  letter-spacing: .3px;
}

/* ── flying value token ──────────────────────── */
.fly-token {
  position: absolute;
  background: #10b981;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 800;
  font-family: 'Courier New', monospace;
  padding: 7px 16px;
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(16,185,129,0.55);
  z-index: 50;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  will-change: transform, opacity;
}

/* ── status message ──────────────────────────── */
.assign-status {
  text-align: center;
  font-size: .88rem;
  font-weight: 700;
  min-height: 1.4em;
  margin: -4px 0 8px;
  color: #10b981;
  transition: opacity .3s;
}

.assign-controls {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* 共通アクションボタン */
.action-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}

.action-btn:active { transform: scale(.96); }
.action-btn:disabled { opacity: .5; cursor: not-allowed; }

.assign-btn     { background: #10b981; color: #fff; }
.assign-btn:hover:not(:disabled) { filter: brightness(.9); }

/* ===== score = score + 1 ステップデモ ===== */
.step-demo {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin: 20px 0;
  flex-wrap: wrap;
}

.step-var-area {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding-top: 18px;
  padding-right: 26px;
}

/* ── step box theme (purple tint on label) ──── */
.step-var-box .var-name-label {
  background: #FAF5FF;
  border-color: #D8B4FE;
}

.step-var-box .var-name-label::before {
  background: rgba(168,85,247,0.35);
}

.step-var-box .var-label {
  color: #3B0764;
}

.step-cards {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-card {
  border: 2px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
  opacity: .4;
  transition: opacity .3s, border-color .3s, background .3s, box-shadow .3s;
}

.step-card.active {
  opacity: 1;
  border-color: #a855f7;
  background: #fdf4ff;
  box-shadow: 0 0 0 3px rgba(168,85,247,.15);
}

.step-card.done {
  opacity: .75;
  border-color: #d8b4fe;
  background: #f5f3ff;
}

.step-num {
  font-size: .62rem;
  font-weight: 800;
  color: #a855f7;
  letter-spacing: 1px;
  margin-bottom: 3px;
}

.step-title {
  font-size: .88rem;
  font-weight: 700;
  color: #1a202c;
  margin-bottom: 6px;
}

.step-code {
  font-family: 'Courier New', monospace;
  font-size: .88rem;
  background: #1e293b;
  color: #e2e8f0;
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.step-desc {
  font-size: .82rem;
  color: #4b5563;
  line-height: 1.5;
}

/* ステップ内ハイライト */
mark.hl-read  { background: #fef9c3; color: #854d0e; padding: 1px 3px; border-radius: 3px; font-style: normal; }
mark.hl-calc  { background: #dcfce7; color: #166534; padding: 1px 3px; border-radius: 3px; font-style: normal; }
mark.hl-store { background: #ede9fe; color: #6d28d9; padding: 1px 3px; border-radius: 3px; font-style: normal; }

.step-controls {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.step-run-btn   { background: #a855f7; color: #fff; }
.step-run-btn:hover:not(:disabled) { filter: brightness(.9); }

.step-reset-btn { background: #fff; color: #6b7280; border: 1.5px solid var(--border); }
.step-reset-btn:hover { background: #f9fafb; }

/* ===== リスト名ラベル ===== */
.list-name-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.list-var-code {
  font-family: 'Courier New', monospace;
  font-size: .95rem;
  font-weight: 700;
  color: #1d4ed8;
  background: #dbeafe;
  padding: 3px 10px;
  border-radius: 6px;
}

.list-name-desc {
  font-size: .75rem;
  color: #6b7280;
}

/* ===== 二次元リスト ===== */
.matrix-badge { background: #f0fdf4; color: #166534; }

.matrix-area { margin: 16px 0; }

.matrix-mansion { display: block; }

.matrix-mansion .mansion-wall {
  overflow-x: auto;
  padding: 16px 14px 12px;
}

.matrix-container {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 4px;
}

.matrix-col-labels {
  display: flex;
  gap: 8px;
}

.matrix-corner { width: 46px; flex-shrink: 0; }

.matrix-col-label {
  width: 64px;
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  color: #f5dfa0;
  background: linear-gradient(135deg, #3a4a6b, #2a3a5a);
  border-radius: 4px;
  padding: 4px 0;
  font-family: monospace;
  flex-shrink: 0;
  border: 1px solid #2d1f14;
}

.matrix-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.matrix-row-label {
  width: 46px;
  text-align: center;
  font-size: .68rem;
  font-weight: 700;
  color: #a8e6a3;
  background: linear-gradient(135deg, #2d4a28, #1e3318);
  border-radius: 4px;
  padding: 4px 0;
  font-family: monospace;
  flex-shrink: 0;
  border: 1px solid #1a1209;
}

.matrix-cell {
  width: 64px;
  height: 64px;
  border: 3px solid #4a6d8c;
  border-radius: 4px 4px 2px 2px;
  background: #cce5f5;
  box-shadow:
    inset 0 3px 8px rgba(0,0,0,0.08),
    0 2px 5px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: #1a3a52;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  flex-shrink: 0;
  transition: all .2s;
  user-select: none;
}

.matrix-cell:hover { transform: translateY(-3px); }

.matrix-cell.selected {
  background: #fff9c4;
  border-color: #8b7320;
  box-shadow:
    0 0 14px rgba(255,215,0,0.55),
    0 2px 5px rgba(0,0,0,0.15);
}

/* ===== レスポンシブ ===== */
@media (max-width: 600px) {
  .demo-area {
    flex-direction: column;
    align-items: flex-start;
  }

  .compare-grid {
    grid-template-columns: 1fr;
  }

  .list-box {
    width: 60px;
    height: 60px;
    font-size: .75rem;
  }
}
