* {
  margin: 0; padding: 0; box-sizing: border-box;
}
body {
  font-family: "Microsoft YaHei", sans-serif;
  background: #f5f0e8;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 10px;
}
.container {
  text-align: center;
  max-width: 900px;
  width: 100%;
}
h1 {
  font-size: 24px; color: #333; margin-bottom: 10px;
}

.main-area {
  display: flex;
  justify-content: center;
  gap: 16px;
  position: relative;
}

/* ============ 游戏主区域 ============ */
.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* 状态栏 */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  width: 100%; max-width: 600px;
}
.status-bar .timer {
  font-size: 26px; font-weight: bold; color: #e74c3c; min-width: 36px;
}
.status-bar .status-text {
  font-size: 14px; color: #888; flex: 1; text-align: left;
}
.status-bar .score {
  font-size: 15px; color: #27ae60; font-weight: bold; white-space: nowrap;
}

/* 画布 */
.canvas-wrapper {
  position: relative;
  width: 600px; height: 600px;
  border: 1px solid #ddd;
  background: #fff;
}
#gameCanvas {
  display: block; cursor: crosshair;
}
.overlay {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; justify-content: center; align-items: center;
  background: rgba(255,255,255,0.7);
  font-size: 36px; font-weight: bold; pointer-events: none;
}
.overlay.hidden { display: none; }
.overlay.success { color: #2ecc71; }
.overlay.fail { color: #e74c3c; }

/* 按钮区 */
.buttons {
  display: flex;
  gap: 10px;
  width: 100%; max-width: 600px;
}
.btn {
  flex: 1;
  padding: 12px 0;
  font-size: 16px;
  border: none; border-radius: 8px;
  cursor: pointer; font-weight: bold; transition: all 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-start { background: #27ae60; color: #fff; }
.btn-start:hover:not(:disabled) { background: #2ecc71; }
.btn-undo { background: #f39c12; color: #fff; }
.btn-undo:hover:not(:disabled) { background: #f1c40f; }
.btn-confirm { background: #2980b9; color: #fff; }
.btn-confirm:hover:not(:disabled) { background: #3498db; }

/* ============ 设置面板（PC右下角） ============ */
.settings-panel {
  position: absolute;
  right: -240px; top: 0;
  width: 220px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.settings-toggle {
  display: none;
  padding: 10px; font-size: 15px; cursor: pointer;
  border-radius: 10px; background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  text-align: center; color: #555;
}
.settings-body {
  padding: 14px;
}
.settings-body label {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: 13px; color: #666;
}
.settings-body label span:first-child { flex: 1; text-align: left; }
.settings-body input[type="range"] { width: 70px; margin: 0 6px; }
.settings-body .val {
  width: 22px; text-align: center; font-weight: bold; color: #e74c3c;
}

/* 难度按钮 */
.diff-row { display: flex; gap: 4px; }
.diff-btn {
  padding: 3px 10px; font-size: 12px;
  border: 2px solid #ddd; border-radius: 6px;
  background: #fff; color: #666; cursor: pointer; transition: all 0.2s;
}
.diff-btn:hover { border-color: #3498db; color: #3498db; }
.diff-btn.active { background: #3498db; border-color: #3498db; color: #fff; }

/* 汉字控制 */
.char-controls { display: flex; gap: 4px; }
.char-input {
  width: 50px; padding: 3px 6px; font-size: 15px;
  text-align: center; border: 2px solid #ddd;
  border-radius: 6px; outline: none;
}
.char-input:focus { border-color: #3498db; }
.char-mode-btn {
  padding: 3px 0; width: 44px; font-size: 12px;
  border: 2px solid #ddd; border-radius: 6px;
  background: #fff; color: #666; cursor: pointer; transition: all 0.2s;
}
.char-mode-btn:hover { border-color: #e74c3c; color: #e74c3c; }
.char-mode-btn.fixed { background: #e74c3c; border-color: #e74c3c; color: #fff; }
.char-mode-btn.manual { background: #8e44ad; border-color: #8e44ad; color: #fff; }

/* 人工面板 */
.manual-panel { margin-top: 4px; }
.manual-panel.hidden { display: none; }
.manual-panel label { margin-bottom: 6px; }
.manual-select { flex: 1; padding: 3px; font-size: 12px;
  border: 2px solid #ddd; border-radius: 6px; outline: none; }
.manual-btns { display: flex; gap: 4px; }
.btn-small {
  flex: 1; padding: 5px 0; font-size: 12px;
  border: none; border-radius: 6px;
  background: #3498db; color: #fff; cursor: pointer;
}
.btn-small:hover { opacity: 0.85; }
.btn-small.recording { background: #e74c3c; }
.btn-del { background: #c0392b; }

/* ============ 移动端 ============ */
@media (max-width: 700px) {
  .main-area { flex-direction: column; align-items: center; }

  .canvas-wrapper {
    width: 100vw; height: 100vw;
    max-width: 600px; max-height: 600px;
  }
  #gameCanvas { width: 100%; height: 100%; }

  .settings-panel {
    position: static;
    width: 100%; max-width: 600px;
  }
  .settings-toggle { display: block; }
  .settings-body { display: none; }
  .settings-body.open { display: block; }
  .settings-body label { font-size: 14px; }
}
