/**
 * style.css - 尺规作图游戏样式
 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* 布局容器 */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===== 左侧工具栏（垂直） ===== */
.toolbar-left {
  position: fixed;
  left: 0;
  top: 0;
  width: 48px;
  height: 100vh;
  background: #f8f8f8;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  z-index: 100;
  overflow-y: auto;
}

.toolbar-left .tool-btn,
.toolbar-left .draw-btn {
  width: 40px;
  height: 40px;
  font-size: 20px;
  margin: 2px 0;
  border-radius: 6px;
  flex-shrink: 0;
}

.toolbar-left .style-btn {
  width: 40px;
  height: 32px;
  font-size: 12px;
  margin: 2px 0;
  border-radius: 6px;
  flex-shrink: 0;
}

.toolbar-left .toolbar-sep {
  width: 28px;
  height: 1px;
  background: #ddd;
  margin: 4px 0;
  flex-shrink: 0;
}

/* ===== 顶部栏（关卡信息 + 计时器 + 关卡选择） ===== */
.toolbar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
  z-index: 10;
  flex-shrink: 0;
  margin-left: 48px;
  overflow-x: auto;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-group + .toolbar-group {
  margin-left: 16px;
  padding-left: 16px;
  border-left: 1px solid #e0e0e0;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #f8f8f8;
  cursor: pointer;
  font-size: 20px;
  transition: all 0.15s;
  user-select: none;
}

.tool-btn:hover {
  background: #e8e8e8;
  border-color: #ddd;
}

.tool-btn.active {
  background: #333;
  border-color: #333;
  color: #fff;
}

.tool-btn:active {
  transform: scale(0.95);
}

.tool-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-info {
  flex: 1;
  text-align: center;
}

.level-info h2 {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.level-info p {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

.tool-tip {
  font-size: 12px;
  color: #888;
  margin-left: 8px;
}

/* 主内容区 */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  margin-left: 48px;
}

/* Canvas区域 */
.canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  border: 1px solid #ddd;
  cursor: crosshair;
}

/* 右侧面板 */
.side-panel {
  width: 250px;
  background: #fff;
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.panel-section {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.panel-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin-bottom: 12px;
}

/* 条件列表 */
#conditions-list {
  max-height: 200px;
  overflow-y: auto;
}

.condition-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.4;
}

.condition-icon {
  flex-shrink: 0;
  font-size: 14px;
}

.condition-text {
  color: #555;
}

.condition-item.passed .condition-text {
  color: #27ae60;
}

.condition-item.failed .condition-text {
  color: #c0392b;
}

#conditions-count {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
  text-align: center;
}

.final-hint {
  font-size: 11px;
  color: #e67e22;
  margin-top: 6px;
  padding: 6px 8px;
  background: #fef9e7;
  border-radius: 4px;
  border-left: 3px solid #f39c12;
  line-height: 1.4;
}

.final-hint .bold {
  font-weight: bold;
  color: #e74c3c;
}

/* 提示面板 */
#hint-panel {
  display: none;
  padding: 12px;
  background: #fff3cd;
  border-radius: 6px;
  font-size: 13px;
  color: #856404;
  line-height: 1.5;
  margin-top: 8px;
}

/* 提示按钮 */
.hint-btn {
  display: block;
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: #666;
  transition: all 0.15s;
}

.hint-btn:hover {
  background: #f8f8f8;
  border-color: #bbb;
}

/* 底部状态栏 */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 6px 16px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
  color: #888;
  flex-shrink: 0;
  margin-left: 48px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 工具栏计时器 */
.toolbar-timer {
  font-size: 22px;
  font-weight: 700;
  color: #27ae60;
  background: #e8f8f0;
  padding: 4px 16px;
  border-radius: 8px;
  border: 2px solid #27ae60;
  white-space: nowrap;
  flex-shrink: 0;
}

.toolbar-timer.warning {
  color: #f39c12;
  background: #fef3e2;
  border-color: #f39c12;
}

.toolbar-timer.danger {
  color: #e74c3c;
  background: #fde8e8;
  border-color: #e74c3c;
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 得分显示样式 */
#score-display {
  font-size: 28px;
  font-weight: 700;
  color: #2196F3;
  margin: 8px 0;
}

#percentile-display {
  font-size: 16px;
  color: #666;
  margin-bottom: 12px;
}

/* 过关弹窗 */
#overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 100;
}

#complete-dialog {
  background: #fff;
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 400px;
  width: 90%;
}

#complete-dialog h2 {
  font-size: 24px;
  margin-bottom: 16px;
  color: #333;
}

#stars-display {
  font-size: 48px;
  margin: 16px 0;
  letter-spacing: 8px;
}

.dialog-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}

.dialog-btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.dialog-btn.primary {
  background: #2196F3;
  color: #fff;
}

.dialog-btn.primary:hover {
  background: #1976D2;
}

.dialog-btn.secondary {
  background: #e0e0e0;
  color: #333;
}

.dialog-btn.secondary:hover {
  background: #d0d0d0;
}

.quote-box {
  background: #f5f5f5;
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  position: relative;
  text-align: center;
}

.quote-mark {
  font-size: 36px;
  font-weight: bold;
  color: #f0c040;
  line-height: 1;
}

.quote-mark.left {
  margin-right: 4px;
}

.quote-mark.right {
  margin-left: 4px;
}

.quote-text {
  font-size: 14px;
  color: #666;
  margin: 4px 0;
  display: inline;
  line-height: 1.6;
}

.quote-author {
  font-size: 12px;
  color: #999;
  margin-top: 8px;
  margin-bottom: 0;
}

/* 关卡选择 */
.level-selector {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.level-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  transition: all 0.15s;
}

.level-btn:hover {
  background: #f0f0f0;
  border-color: #bbb;
}

.level-btn.active {
  background: #2196F3;
  color: #fff;
  border-color: #2196F3;
}

.level-btn.locked {
  background: #f0f0f0;
  color: #888;
  border-color: #ccc;
  cursor: not-allowed;
  font-size: 11px;
}

/* 绘图工具按钮 */
.draw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: #f8f8f8;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.15s;
  user-select: none;
}

.draw-btn:hover {
  background: #e8e8e8;
  border-color: #ddd;
}

.draw-btn.active {
  background: #333;
  border-color: #333;
  color: #fff;
}

.style-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 2px solid transparent;
  border-radius: 6px;
  background: #f8f8f8;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #666;
  transition: all 0.15s;
  user-select: none;
}

.style-btn:hover {
  background: #e8e8e8;
  border-color: #ddd;
}

.style-btn.active {
  background: #e74c3c;
  border-color: #e74c3c;
  color: #fff;
}

.toolbar-sep {
  color: #ddd;
  font-size: 20px;
  margin: 0 4px;
  user-select: none;
}

/* ===== 技能解锁样式 ===== */
.draw-btn.skill-unlocked {
  border-color: #f39c12;
  background: #fef9e7;
}

.skill-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.skill-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 2px solid #f39c12;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  z-index: 201;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  max-width: 320px;
}

.skill-popup h3 {
  color: #f39c12;
  margin-bottom: 12px;
}

.skill-popup p {
  color: #666;
  margin-bottom: 16px;
}

.skill-popup button {
  background: #f39c12;
  color: #fff;
  border: none;
  padding: 8px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.skill-popup button:hover {
  background: #e67e22;
}

/* ===== Panel toggle button (hidden on desktop) ===== */
.panel-toggle {
  display: none;
  position: fixed;
  right: 8px;
  top: 54px;
  z-index: 91;
  width: 32px;
  height: 32px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 16px;
}

/* ===== Mobile responsive ===== */
@media (max-width: 768px) {
  .panel-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Left sidebar → Bottom toolbar */
  .toolbar-left {
    position: fixed;
    left: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px 8px;
    border-right: none;
    border-top: 1px solid #ddd;
    z-index: 100;
    background: #f8f8f8;
    justify-content: flex-start;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .toolbar-left .toolbar-sep {
    width: 1px;
    height: 28px;
    margin: 0 4px;
    flex-shrink: 0;
  }

  .toolbar-left .tool-btn,
  .toolbar-left .draw-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
    flex-shrink: 0;
  }

  .toolbar-left .style-btn {
    width: 44px;
    height: 36px;
    font-size: 13px;
    flex-shrink: 0;
  }

  /* Top bar adjustments */
  .toolbar {
    margin-left: 0;
    padding: 4px 8px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .level-info h2 {
    font-size: 14px;
  }

  .level-info p {
    font-size: 11px;
  }

  .level-selector {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .level-btn {
    width: 32px;
    height: 32px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .toolbar-timer {
    font-size: 16px;
    padding: 2px 10px;
  }

  .tool-tip {
    font-size: 11px;
    margin-left: 4px;
  }

  /* Main content */
  .main-content {
    margin-left: 0;
    padding-bottom: 60px; /* space for bottom toolbar */
    height: calc(100vh - 50px - 52px); /* viewport - topbar - bottombar */
  }

  /* Canvas */
  #game-canvas {
    touch-action: none;
  }

  /* Side panel - collapsible overlay */
  .side-panel {
    position: fixed;
    right: -260px;
    top: 50px;
    width: 260px;
    height: calc(100vh - 50px - 52px);
    z-index: 90;
    transition: right 0.3s;
    background: #fff;
    border-left: 1px solid #ddd;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
  }

  .side-panel.open {
    right: 0;
  }

  /* Status bar */
  .status-bar {
    margin-left: 0;
    padding: 4px 12px;
  }

  /* Level info layout for narrow screens */
  .level-info {
    min-width: 0;
    flex: 1;
    text-align: left;
  }
}
