/* cat-game.css */

.cat-workspace {
  width: min(100%, 1040px);
  padding: 24px;
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  width: 100%;
}

@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
}

/* 舞台区 */
.game-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-header h2 {
  font-size: 20px;
  margin: 0;
  color: var(--ink);
}

.grid-wrapper {
  background: var(--glass);
  border: 2px solid rgba(255, 253, 248, 0.4);
  border-radius: 12px;
  padding: 12px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.grid-container {
  display: grid;
  aspect-ratio: 1;
  width: 100%;
  position: relative;
}

.grid-cell {
  background: #EFECE6; /* 浅柔米灰 */
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(24px, 5vw, 40px);
  transition: all 0.2s ease;
  position: relative;
}

.grid-cell[data-type="1"] {
  background: #C4B9B1; /* 墙壁: 暖灰褐 */
}

.grid-cell[data-type="4"] {
  background: #9FA19F; /* 坑洞: 冷灰 */
  box-shadow: inset 0 6px 12px rgba(0,0,0,0.15);
}

/* 实体叠加 */
.entity-layer {
  position: absolute;
  top: 0; left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(24px, 5vw, 40px);
  z-index: 10;
  transition: left 0.3s ease-out, top 0.3s ease-out, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#dogEntity {
  z-index: 11;
}

.stage-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.stage-footer span {
  font-weight: 600;
  color: var(--muted);
}

/* 控制区 */
.game-controls {
  background: rgba(255, 253, 248, 0.6);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100%;
}

.panel-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 12px;
}

.toolbox {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cmd-block {
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmd-block:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.cmd-block:active {
  transform: translateY(1px);
}

.cmd-forward { background: #96A8A1; } /* 莫兰迪绿 */
.cmd-turnleft { background: #C2A297; } /* 莫兰迪粉 */
.cmd-turnright { background: #A7B2C4; } /* 莫兰迪蓝 */
.cmd-jump { background: #D4B572; } /* 莫兰迪黄 */

.sequence-section {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.sequence-area {
  flex-grow: 1;
  min-height: 200px;
  background: rgba(239, 236, 230, 0.5);
  border: 1px dashed var(--soft-line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.seq-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  animation: slideIn 0.2s ease-out;
}

.seq-item:hover {
  opacity: 0.9;
}

.seq-item::after {
  content: '×';
  font-size: 16px;
  opacity: 0.6;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.action-bar {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.action-bar button {
  flex: 1;
}

/* 编辑器浮层 */
.editor-panel {
  background: var(--glass);
  padding: 20px;
  border-radius: 16px;
  border: 1px solid var(--soft-line);
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
  margin-top: 16px;
}

.editor-panel.hidden {
  display: none;
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.editor-tool {
  background: #fff;
  border: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.editor-tool.selected {
  border-color: #A7B2C4;
  background: #F4F6F9;
}

.editor-hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 253, 248, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s;
}

.modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-content {
  background: #fff;
  padding: 40px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 24px 80px rgba(59, 54, 46, 0.15);
  max-width: 400px;
  transform: translateY(0);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal.hidden .modal-content {
  transform: translateY(20px);
}

.modal h2 {
  margin-top: 0;
  font-size: 28px;
  color: var(--ink);
}

.modal p {
  color: var(--muted);
  margin-bottom: 24px;
}

/* 关卡总览面板 */
#summaryModal .modal-content {
  max-width: 600px;
  width: 90%;
  padding: 32px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.summary-header h2 {
  margin: 0;
  font-size: 24px;
}

.summary-close {
  background: transparent;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted);
}

.summary-tabs {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 8px;
}

.summary-tab {
  background: none;
  border: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}

.summary-tab.active {
  color: var(--ink);
  border-bottom: 2px solid var(--ink);
}

.summary-body {
  overflow-y: auto;
  flex-grow: 1;
}

.summary-body.hidden {
  display: none;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
  gap: 12px;
}

.level-btn {
  background: var(--glass);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  padding: 12px 0;
  text-align: center;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.level-btn:hover {
  background: #fff;
  border-color: #A7B2C4;
}

.level-btn.locked {
  opacity: 0.5;
  cursor: not-allowed;
  background: #f0f0f0;
}

.level-btn.completed {
  background: #e6f4ea;
  border-color: #96A8A1;
  color: #1e8e3e;
}

.level-btn.skipped {
  background: #fef7e0;
  border-color: #D4B572;
  color: #b06000;
}

.diy-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.diy-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--glass);
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  cursor: pointer;
}

.diy-item:hover {
  background: #fff;
}

.diy-item h4 {
  margin: 0;
  font-size: 16px;
}
